0
|
1 |
/**
|
3
|
2 |
* Search the Apache configuration for the Include line for Apache settings.
|
0
|
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"
|
3
|
47 |
FileClose $0
|
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 |
|
3
|
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
|
0
|
175 |
FunctionEnd |