2 # InstallConf.awk Apache HTTP 2.x script to rewrite the @@ServerRoot@@
3 # tags in httpd.conf.in to original\httpd.conf - then duplicate the
4 # conf files to the 'live' configuration if they don't already exist.
6 # Note that we -don't- want the ARGV file list, so no additional {} blocks
7 # are coded. Use explicit args (more reliable on Win32) and use the fact
8 # that ARGV[] params are -not- '\' escaped to process the C:\Foo\Bar Win32
9 # path format. Note that awk var=path would not succeed, since it -does-
10 # escape backslashes in the assignment. Note also, a trailing space is
11 # required for paths, or the trailing quote following the backslash is
12 # escaped, rather than parsed.
17 serveradmin = ARGV[3];
19 serversslport = ARGV[5];
31 gsub( /\\/, "/", serverroot );
32 gsub( /[ \/]+$/, "", serverroot );
33 tstfl = serverroot "/logs/install.log"
34 confroot = serverroot "/conf/";
35 confdefault = confroot "original/";
37 if ( sourceroot != "docs/conf/" ) {
38 sourceroot = serverroot "/" sourceroot;
41 usertree = ENVIRON["USERPROFILE"]
42 if ( usertree > "" ) {
43 gsub( /\\/, "/", usertree );
44 gsub( /\/[^\/]+$/, "", usertree );
46 usertree = "C:/Documents and Settings";
49 print "Installing Apache HTTP Server 2.x with" >tstfl;
50 print " DomainName = " domainname >tstfl;
51 print " ServerName = " servername >tstfl;
52 print " ServerAdmin = " serveradmin >tstfl;
53 print " ServerPort = " serverport >tstfl;
54 print " ServerSslPort = " serversslport >tstfl;
55 print " ServerRoot = " serverroot >tstfl;
57 filelist["httpd.conf"] = "httpd.conf.in";
58 filelist["httpd-autoindex.conf"] = "httpd-autoindex.conf.in";
59 filelist["httpd-dav.conf"] = "httpd-dav.conf.in";
60 filelist["httpd-default.conf"] = "httpd-default.conf.in";
61 filelist["httpd-info.conf"] = "httpd-info.conf.in";
62 filelist["httpd-languages.conf"] = "httpd-languages.conf.in";
63 filelist["httpd-macro.conf"] = "httpd-macro.conf.in";
64 filelist["httpd-manual.conf"] = "httpd-manual.conf.in";
65 filelist["httpd-mpm.conf"] = "httpd-mpm.conf.in";
66 filelist["httpd-multilang-errordoc.conf"] = "httpd-multilang-errordoc.conf.in";
67 filelist["httpd-policy.conf"] = "httpd-policy.conf.in";
68 filelist["httpd-ssl.conf"] = "httpd-ssl.conf.in";
69 filelist["httpd-userdir.conf"] = "httpd-userdir.conf.in";
70 filelist["httpd-vhosts.conf"] = "httpd-vhosts.conf.in";
71 filelist["proxy-html.conf"] = "proxy-html.conf.in";
73 for ( conffile in filelist ) {
75 if ( conffile == "httpd.conf" ) {
76 srcfl = sourceroot filelist[conffile];
77 dstfl = confdefault conffile;
80 srcfl = sourceroot "extra/" filelist[conffile];
81 dstfl = confdefault "extra/" conffile;
85 while ( ( getline < srcfl ) > 0 ) {
87 if ( bswarning && /^$/ ) {
89 print "# NOTE: Where filenames are specified, you must use forward slashes" > dstfl;
90 print "# instead of backslashes (e.g., \"c:/apache\" instead of \"c:\\apache\")." > dstfl;
91 print "# If a drive letter is omitted, the drive on which httpd.exe is located" > dstfl;
92 print "# will be used by default. It is recommended that you always supply" > dstfl;
93 print "# an explicit drive letter in absolute paths to avoid confusion." > dstfl;
96 if ( /@@LoadModule@@/ ) {
97 print "LoadModule access_compat_module modules/mod_access_compat.so" > dstfl;
98 print "LoadModule actions_module modules/mod_actions.so" > dstfl;
99 print "LoadModule alias_module modules/mod_alias.so" > dstfl;
100 print "#LoadModule allowhandlers_module modules/mod_allowhandlers.so" > dstfl;
101 print "#LoadModule allowmethods_module modules/mod_allowmethods.so" > dstfl;
102 print "LoadModule asis_module modules/mod_asis.so" > dstfl;
103 print "LoadModule auth_basic_module modules/mod_auth_basic.so" > dstfl;
104 print "#LoadModule auth_digest_module modules/mod_auth_digest.so" > dstfl;
105 print "#LoadModule authn_anon_module modules/mod_authn_anon.so" > dstfl;
106 print "LoadModule authn_core_module modules/mod_authn_core.so" > dstfl;
107 print "#LoadModule authn_dbd_module modules/mod_authn_dbd.so" > dstfl;
108 print "#LoadModule authn_dbm_module modules/mod_authn_dbm.so" > dstfl;
109 print "LoadModule authn_file_module modules/mod_authn_file.so" > dstfl;
110 print "#LoadModule authn_socache_module modules/mod_authn_socache.so" > dstfl;
111 print "#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so" > dstfl;
112 print "LoadModule authz_core_module modules/mod_authz_core.so" > dstfl;
113 print "#LoadModule authz_dbd_module modules/mod_authz_dbd.so" > dstfl;
114 print "#LoadModule authz_dbm_module modules/mod_authz_dbm.so" > dstfl;
115 print "LoadModule authz_groupfile_module modules/mod_authz_groupfile.so" > dstfl;
116 print "LoadModule authz_host_module modules/mod_authz_host.so" > dstfl;
117 print "#LoadModule authz_owner_module modules/mod_authz_owner.so" > dstfl;
118 print "LoadModule authz_user_module modules/mod_authz_user.so" > dstfl;
119 print "LoadModule autoindex_module modules/mod_autoindex.so" > dstfl;
120 print "#LoadModule buffer_module modules/mod_buffer.so" > dstfl;
121 print "#LoadModule cache_module modules/mod_cache.so" > dstfl;
122 print "#LoadModule cache_disk_module modules/mod_cache_disk.so" > dstfl;
123 print "#LoadModule cache_socache_module modules/mod_cache_socache.so" > dstfl;
124 print "#LoadModule cern_meta_module modules/mod_cern_meta.so" > dstfl;
125 print "LoadModule cgi_module modules/mod_cgi.so" > dstfl;
126 print "#LoadModule charset_lite_module modules/mod_charset_lite.so" > dstfl;
127 print "#LoadModule data_module modules/mod_data.so" > dstfl;
128 print "#LoadModule dav_module modules/mod_dav.so" > dstfl;
129 print "#LoadModule dav_fs_module modules/mod_dav_fs.so" > dstfl;
130 print "#LoadModule dav_lock_module modules/mod_dav_lock.so" > dstfl;
131 print "#LoadModule dbd_module modules/mod_dbd.so" > dstfl;
132 print "#LoadModule deflate_module modules/mod_deflate.so" > dstfl;
133 print "LoadModule dir_module modules/mod_dir.so" > dstfl;
134 print "#LoadModule dumpio_module modules/mod_dumpio.so" > dstfl;
135 print "LoadModule env_module modules/mod_env.so" > dstfl;
136 print "#LoadModule expires_module modules/mod_expires.so" > dstfl;
137 print "#LoadModule ext_filter_module modules/mod_ext_filter.so" > dstfl;
138 print "#LoadModule file_cache_module modules/mod_file_cache.so" > dstfl;
139 print "#LoadModule filter_module modules/mod_filter.so" > dstfl;
140 print "#LoadModule headers_module modules/mod_headers.so" > dstfl;
141 print "#LoadModule heartbeat_module modules/mod_heartbeat.so" > dstfl;
142 print "#LoadModule heartmonitor_module modules/mod_heartmonitor.so" > dstfl;
143 print "#LoadModule ident_module modules/mod_ident.so" > dstfl;
144 print "#LoadModule imagemap_module modules/mod_imagemap.so" > dstfl;
145 print "LoadModule include_module modules/mod_include.so" > dstfl;
146 print "#LoadModule info_module modules/mod_info.so" > dstfl;
147 print "LoadModule isapi_module modules/mod_isapi.so" > dstfl;
148 print "#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so" > dstfl;
149 print "#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so" > dstfl;
150 print "#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so" > dstfl;
151 print "#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so" > dstfl;
152 print "#LoadModule ldap_module modules/mod_ldap.so" > dstfl;
153 print "#LoadModule logio_module modules/mod_logio.so" > dstfl;
154 print "LoadModule log_config_module modules/mod_log_config.so" > dstfl;
155 print "#LoadModule log_debug_module modules/mod_log_debug.so" > dstfl;
156 print "#LoadModule log_forensic_module modules/mod_log_forensic.so" > dstfl;
157 print "#LoadModule lua_module modules/mod_lua.so" > dstfl;
158 print "#LoadModule macro_module modules/mod_macro.so" > dstfl;
159 print "LoadModule mime_module modules/mod_mime.so" > dstfl;
160 print "#LoadModule mime_magic_module modules/mod_mime_magic.so" > dstfl;
161 print "LoadModule negotiation_module modules/mod_negotiation.so" > dstfl;
162 print "#LoadModule proxy_module modules/mod_proxy.so" > dstfl;
163 print "#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so" > dstfl;
164 print "#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so" > dstfl;
165 print "#LoadModule proxy_connect_module modules/mod_proxy_connect.so" > dstfl;
166 print "#LoadModule proxy_express_module modules/mod_proxy_express.so" > dstfl;
167 print "#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so" > dstfl;
168 print "#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so" > dstfl;
169 print "#LoadModule proxy_html_module modules/mod_proxy_html.so" > dstfl;
170 print "#LoadModule proxy_http_module modules/mod_proxy_http.so" > dstfl;
171 print "#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so" > dstfl;
172 print "#LoadModule ratelimit_module modules/mod_ratelimit.so" > dstfl;
173 print "#LoadModule reflector_module modules/mod_reflector.so" > dstfl;
174 print "#LoadModule remoteip_module modules/mod_remoteip.so" > dstfl;
175 print "#LoadModule request_module modules/mod_request.so" > dstfl;
176 print "#LoadModule reqtimeout_module modules/mod_reqtimeout.so" > dstfl;
177 print "#LoadModule rewrite_module modules/mod_rewrite.so" > dstfl;
178 print "#LoadModule sed_module modules/mod_sed.so" > dstfl;
179 print "#LoadModule session_module modules/mod_session.so" > dstfl;
180 print "#LoadModule session_cookie_module modules/mod_session_cookie.so" > dstfl;
181 print "#LoadModule session_crypto_module modules/mod_session_crypto.so" > dstfl;
182 print "#LoadModule session_dbd_module modules/mod_session_dbd.so" > dstfl;
183 print "LoadModule setenvif_module modules/mod_setenvif.so" > dstfl;
184 print "#LoadModule slotmem_plain_module modules/mod_slotmem_plain.so" > dstfl;
185 print "#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so" > dstfl;
186 print "#LoadModule socache_dbm_module modules/mod_socache_dbm.so" > dstfl;
187 print "#LoadModule socache_memcache_module modules/mod_socache_memcache.so" > dstfl;
188 print "#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so" > dstfl;
189 print "#LoadModule speling_module modules/mod_speling.so" > dstfl;
190 print "#LoadModule ssl_module modules/mod_ssl.so" > dstfl;
191 print "#LoadModule status_module modules/mod_status.so" > dstfl;
192 print "#LoadModule substitute_module modules/mod_substitute.so" > dstfl;
193 print "#LoadModule unique_id_module modules/mod_unique_id.so" > dstfl;
194 print "#LoadModule userdir_module modules/mod_userdir.so" > dstfl;
195 print "#LoadModule usertrack_module modules/mod_usertrack.so" > dstfl;
196 print "#LoadModule version_module modules/mod_version.so" > dstfl;
197 print "#LoadModule vhost_alias_module modules/mod_vhost_alias.so" > dstfl;
198 print "#LoadModule watchdog_module modules/mod_watchdog.so" > dstfl;
199 print "#LoadModule xml2enc_module modules/mod_xml2enc.so" > dstfl;
202 if ( /^ServerRoot / ) {
203 print "Define SRVROOT \"" serverroot "\"" > dstfl;
206 gsub( /@@ServerRoot@@/, "\${SRVROOT}" );
207 gsub( /@exp_cgidir@/, "\${SRVROOT}" "/cgi-bin" );
208 gsub( /@exp_sysconfdir@/, "\${SRVROOT}" "/conf" );
209 gsub( /@exp_errordir@/, "\${SRVROOT}" "/error" );
210 gsub( /@exp_htdocsdir@/, "\${SRVROOT}" "/htdocs" );
211 gsub( /@exp_iconsdir@/, "\${SRVROOT}" "/icons" );
212 gsub( /@exp_manualdir@/, "\${SRVROOT}" "/manual" );
213 gsub( /@exp_runtimedir@/, "\${SRVROOT}" "/logs" );
214 if ( gsub( /@exp_logfiledir@/, "\${SRVROOT}" "/logs" ) ||
215 gsub( /@rel_logfiledir@/, "logs" ) ) {
216 gsub( /_log"/, ".log\"" )
218 gsub( /@rel_runtimedir@/, "logs" );
219 gsub( /@rel_sysconfdir@/, "conf" );
220 gsub( /\/home\/\*\/public_html/, \
221 usertree "/*/My Documents/My Website" );
222 gsub( /UserDir public_html/, "UserDir \"My Documents/My Website\"" );
223 gsub( /@@ServerName@@|www.example.com/, servername );
224 gsub( /@@ServerAdmin@@|you@example.com/, serveradmin );
225 gsub( /@@DomainName@@|example.com/, domainname );
226 gsub( /@@Port@@/, serverport );
227 gsub( /@@SSLPort@@|443/, serversslport );
232 if ( close(dstfl) >= 0 ) {
233 print "Rewrote " srcfl "\n to " dstfl > tstfl;
234 if ( sourceroot != "docs/conf/" ) {
235 gsub(/\//, "\\", srcfl);
236 if (system("del 2>NUL \"" srcfl "\"")) {
237 print "Failed to remove " srcfl > tstfl;
239 print "Successfully removed " srcfl > tstfl;
243 print "Failed to rewrite " srcfl "\n to " dstfl > tstfl;
245 filelist[conffile] = "extra/";
248 filelist["httpd.conf"] = "";
249 filelist["charset.conv"] = "";
250 filelist["magic"] = "";
251 filelist["mime.types"] = "";
253 for ( conffile in filelist ) {
254 srcfl = confdefault filelist[conffile] conffile;
255 dstfl = confroot filelist[conffile] conffile;
256 if ( ( getline < dstfl ) < 0 ) {
257 while ( ( getline < srcfl ) > 0 ) {
260 print "Duplicated " srcfl "\n to " dstfl > tstfl;
262 print "Existing file " dstfl " preserved" > tstfl;
268 if ( sourceroot != "docs/conf/" ) {
269 srcfl = confdefault "installwinconf.awk";
270 gsub(/\//, "\\", srcfl);
271 if (system("del 2>NUL \"" srcfl "\"")) {
272 print "Failed to remove " srcfl > tstfl;
274 print "Successfully removed " srcfl > tstfl;