inst-resources/apacheconfig.nsh
changeset 3 0cce88c7cf7c
parent 0 67e1cc6cd929
equal deleted inserted replaced
2:0c0d5dadfca3 3:0cce88c7cf7c
     1 /**
     1 /**
     2  * Search the Apache configuration for the Include line for this package's Apache settings.
     2  * Search the Apache configuration for the Include line for Apache settings.
     3  * @return int 0 if successful (found line); 1 if not found
     3  * @return int 0 if successful (found line); 1 if not found
     4  */
     4  */
     5 
     5 
     6 Function search_apache_config
     6 Function search_apache_config
     7   FileOpen $0 "$INSTDIR\apache2\conf\httpd.conf" "r"
     7   FileOpen $0 "$INSTDIR\apache2\conf\httpd.conf" "r"
    42     Call ks_error
    42     Call ks_error
    43     Return
    43     Return
    44     
    44     
    45   FileSeek $0 0 END
    45   FileSeek $0 0 END
    46   FileWrite $0 "$\r$\nInclude $\"../apps/${PRODUCT_SHORTNAME}/conf/httpd.conf$\"$\r$\n"
    46   FileWrite $0 "$\r$\nInclude $\"../apps/${PRODUCT_SHORTNAME}/conf/httpd.conf$\"$\r$\n"
    47   FileClose $0
    47 FileClose $0
    48   
    48   
    49   WriteLocalConfig:
    49   WriteLocalConfig:
    50   
    50   
    51   ClearErrors
    51   ClearErrors
    52   CreateDirectory "$INSTDIR\apps\${PRODUCT_SHORTNAME}\conf"
    52   CreateDirectory "$INSTDIR\apps\${PRODUCT_SHORTNAME}\conf"
    70   FileWrite $0 "  Allow from all$\r$\n"
    70   FileWrite $0 "  Allow from all$\r$\n"
    71   FileWrite $0 "</Directory>$\r$\n"
    71   FileWrite $0 "</Directory>$\r$\n"
    72   FileClose $0
    72   FileClose $0
    73 
    73 
    74 FunctionEnd
    74 FunctionEnd
       
    75 
       
    76 ; Remove from Apache config upon uninstall
       
    77 Function un.disable_in_apache_config
       
    78   StrCpy $0 "$stack_instdir\apache2\conf\httpd.conf"
       
    79   ClearErrors
       
    80   FileOpen $1 $0 "r"
       
    81   
       
    82   ; input file
       
    83   IfErrors 0 +3
       
    84     Push 1
       
    85     Return
       
    86   
       
    87   ; output file
       
    88   FileOpen $2 $0.tmp "w"
       
    89   IfErrors 0 +3
       
    90     Push 1
       
    91     Return
       
    92   
       
    93   ; read each line, if nothing to do with enano, pass through
       
    94   loop:
       
    95     ClearErrors
       
    96     FileRead $1 $3 1024
       
    97     IfErrors done
       
    98     Push $3
       
    99     Push "/apps/${PRODUCT_SHORTNAME}/"
       
   100     Call un.StrStr
       
   101     Pop $4
       
   102     StrCmp $4 "" 0 loop
       
   103       ; no mention of Enano, ok to write it
       
   104       FileWrite $2 $3
       
   105       Goto loop
       
   106     
       
   107   done:
       
   108     
       
   109   FileClose $1
       
   110   FileClose $2
       
   111   Delete "$0"
       
   112   Rename "$0.tmp" "$0"
       
   113   
       
   114   Push 0
       
   115 FunctionEnd
       
   116 
       
   117 ; Remove from applications.html upon uninstall
       
   118 Function un.disable_in_applications_html
       
   119   StrCpy $0 "$stack_instdir\apache2\htdocs\applications.html"
       
   120   ClearErrors
       
   121   FileOpen $1 $0 "r"
       
   122   
       
   123   ; State variable: are we in the Enano section or not?
       
   124   StrCpy $5 0
       
   125   
       
   126   ; input file
       
   127   IfErrors 0 +3
       
   128     Push 1
       
   129     Return
       
   130   
       
   131   ; output file
       
   132   FileOpen $2 $0.tmp "w"
       
   133   IfErrors 0 +3
       
   134     Push 1
       
   135     Return
       
   136   
       
   137   ; read each line, if nothing to do with enano, pass through
       
   138   loop:
       
   139     ClearErrors
       
   140     FileRead $1 $3 1024
       
   141     IfErrors done
       
   142     Push $3
       
   143     StrCmp $5 1 0 outsideblock
       
   144       ; inside of the block - don't write
       
   145       StrCpy $6 0
       
   146       Push "END BitNami ${PRODUCT_NAME} Module ${PRODUCT_SHORTNAME}"
       
   147       Call un.StrStr
       
   148       Pop $4
       
   149       StrCmp $4 "" +2
       
   150         ; found it - don't write this line, but set $5 to 0 so we write the next one
       
   151         StrCpy $5 0
       
   152       Goto loop
       
   153       outsideblock:
       
   154       Push "START BitNami ${PRODUCT_NAME} Module ${PRODUCT_SHORTNAME}"
       
   155       Call un.StrStr
       
   156       Pop $4
       
   157       StrCmp $4 "" +3
       
   158         ; found the start of the block - disable writes
       
   159         StrCpy $5 1
       
   160         Goto loop
       
   161         
       
   162       FileWrite $2 $3
       
   163       Goto loop
       
   164       
       
   165   done:
       
   166     
       
   167   FileClose $1
       
   168   FileClose $2
       
   169   Delete "$0"
       
   170   Rename "$0.tmp" "$0"
       
   171   
       
   172   Delete "$stack_instdir\apache2\htdocs\img\${PRODUCT_SHORTNAME}-module.png"
       
   173   
       
   174   Push 0
       
   175 FunctionEnd