inst-resources/apacheconfig.nsh
changeset 0 67e1cc6cd929
child 3 0cce88c7cf7c
equal deleted inserted replaced
-1:000000000000 0:67e1cc6cd929
       
     1 /**
       
     2  * Search the Apache configuration for the Include line for this package's Apache settings.
       
     3  * @return int 0 if successful (found line); 1 if not found
       
     4  */
       
     5 
       
     6 Function search_apache_config
       
     7   FileOpen $0 "$INSTDIR\apache2\conf\httpd.conf" "r"
       
     8   loop:
       
     9     ClearErrors
       
    10     FileRead $0 $1 1024
       
    11     IfErrors done
       
    12     Push $1
       
    13     Push "Include "
       
    14     Call StrStr
       
    15     Pop $2
       
    16     StrCmp $2 "" loop
       
    17       ; This is an include line
       
    18       Push $1
       
    19       Push "/apps/${PRODUCT_SHORTNAME}/"
       
    20       Call StrStr
       
    21       Pop $2
       
    22       StrCmp $2 "" loop
       
    23         ; We found it
       
    24         Push 0
       
    25         FileClose $0
       
    26         Return
       
    27   done:
       
    28   FileClose $0
       
    29   Push 1
       
    30 FunctionEnd
       
    31 
       
    32 Function write_apache_config
       
    33   Call search_apache_config
       
    34   Pop $0
       
    35   IntCmp $0 1 +2 0 0
       
    36     Goto WriteLocalConfig
       
    37     
       
    38   ClearErrors
       
    39   FileOpen $0 "$INSTDIR\apache2\conf\httpd.conf" "a"
       
    40   IfErrors 0 +4
       
    41     Push "write to the Apache configuration file"
       
    42     Call ks_error
       
    43     Return
       
    44     
       
    45   FileSeek $0 0 END
       
    46   FileWrite $0 "$\r$\nInclude $\"../apps/${PRODUCT_SHORTNAME}/conf/httpd.conf$\"$\r$\n"
       
    47   FileClose $0
       
    48   
       
    49   WriteLocalConfig:
       
    50   
       
    51   ClearErrors
       
    52   CreateDirectory "$INSTDIR\apps\${PRODUCT_SHORTNAME}\conf"
       
    53   IfErrors 0 +4
       
    54     Push "create the configuration directory"
       
    55     Call ks_error
       
    56     Return
       
    57     
       
    58   ClearErrors
       
    59   FileOpen $0 "$INSTDIR\apps\${PRODUCT_SHORTNAME}\conf\httpd.conf" "w"
       
    60   IfErrors 0 +4
       
    61     Push "write to the local configuration file"
       
    62     Call ks_error
       
    63     Return
       
    64 
       
    65   FileWrite $0 "Alias /${PRODUCT_SHORTNAME} $\"../apps/${PRODUCT_SHORTNAME}/htdocs$\"$\r$\n$\r$\n"
       
    66   FileWrite $0 "<Directory $\"../apps/${PRODUCT_SHORTNAME}/htdocs$\">$\r$\n"
       
    67   FileWrite $0 "  Options -Indexes MultiViews FollowSymLinks$\r$\n"
       
    68   FileWrite $0 "  AllowOverride All$\r$\n"
       
    69   FileWrite $0 "  Order allow,deny$\r$\n"
       
    70   FileWrite $0 "  Allow from all$\r$\n"
       
    71   FileWrite $0 "</Directory>$\r$\n"
       
    72   FileClose $0
       
    73 
       
    74 FunctionEnd