inst-resources/apacheconfig.nsh
changeset 3 0cce88c7cf7c
parent 0 67e1cc6cd929
--- a/inst-resources/apacheconfig.nsh	Wed May 27 01:17:11 2009 -0400
+++ b/inst-resources/apacheconfig.nsh	Sat Jul 11 10:07:32 2009 -0400
@@ -1,5 +1,5 @@
 /**
- * Search the Apache configuration for the Include line for this package's Apache settings.
+ * Search the Apache configuration for the Include line for Apache settings.
  * @return int 0 if successful (found line); 1 if not found
  */
 
@@ -44,7 +44,7 @@
     
   FileSeek $0 0 END
   FileWrite $0 "$\r$\nInclude $\"../apps/${PRODUCT_SHORTNAME}/conf/httpd.conf$\"$\r$\n"
-  FileClose $0
+FileClose $0
   
   WriteLocalConfig:
   
@@ -71,4 +71,105 @@
   FileWrite $0 "</Directory>$\r$\n"
   FileClose $0
 
+FunctionEnd
+
+; Remove from Apache config upon uninstall
+Function un.disable_in_apache_config
+  StrCpy $0 "$stack_instdir\apache2\conf\httpd.conf"
+  ClearErrors
+  FileOpen $1 $0 "r"
+  
+  ; input file
+  IfErrors 0 +3
+    Push 1
+    Return
+  
+  ; output file
+  FileOpen $2 $0.tmp "w"
+  IfErrors 0 +3
+    Push 1
+    Return
+  
+  ; read each line, if nothing to do with enano, pass through
+  loop:
+    ClearErrors
+    FileRead $1 $3 1024
+    IfErrors done
+    Push $3
+    Push "/apps/${PRODUCT_SHORTNAME}/"
+    Call un.StrStr
+    Pop $4
+    StrCmp $4 "" 0 loop
+      ; no mention of Enano, ok to write it
+      FileWrite $2 $3
+      Goto loop
+    
+  done:
+    
+  FileClose $1
+  FileClose $2
+  Delete "$0"
+  Rename "$0.tmp" "$0"
+  
+  Push 0
+FunctionEnd
+
+; Remove from applications.html upon uninstall
+Function un.disable_in_applications_html
+  StrCpy $0 "$stack_instdir\apache2\htdocs\applications.html"
+  ClearErrors
+  FileOpen $1 $0 "r"
+  
+  ; State variable: are we in the Enano section or not?
+  StrCpy $5 0
+  
+  ; input file
+  IfErrors 0 +3
+    Push 1
+    Return
+  
+  ; output file
+  FileOpen $2 $0.tmp "w"
+  IfErrors 0 +3
+    Push 1
+    Return
+  
+  ; read each line, if nothing to do with enano, pass through
+  loop:
+    ClearErrors
+    FileRead $1 $3 1024
+    IfErrors done
+    Push $3
+    StrCmp $5 1 0 outsideblock
+      ; inside of the block - don't write
+      StrCpy $6 0
+      Push "END BitNami ${PRODUCT_NAME} Module ${PRODUCT_SHORTNAME}"
+      Call un.StrStr
+      Pop $4
+      StrCmp $4 "" +2
+        ; found it - don't write this line, but set $5 to 0 so we write the next one
+        StrCpy $5 0
+      Goto loop
+      outsideblock:
+      Push "START BitNami ${PRODUCT_NAME} Module ${PRODUCT_SHORTNAME}"
+      Call un.StrStr
+      Pop $4
+      StrCmp $4 "" +3
+        ; found the start of the block - disable writes
+        StrCpy $5 1
+        Goto loop
+        
+      FileWrite $2 $3
+      Goto loop
+      
+  done:
+    
+  FileClose $1
+  FileClose $2
+  Delete "$0"
+  Rename "$0.tmp" "$0"
+  
+  Delete "$stack_instdir\apache2\htdocs\img\${PRODUCT_SHORTNAME}-module.png"
+  
+  Push 0
 FunctionEnd
\ No newline at end of file