2 # InstallConf.awk Apache HTTP 2.2 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 2.0 server 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 = " serverport >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-manual.conf"] = "httpd-manual.conf.in";
64 filelist["httpd-mpm.conf"] = "httpd-mpm.conf.in";
65 filelist["httpd-multilang-errordoc.conf"] = "httpd-multilang-errordoc.conf.in";
66 filelist["httpd-ssl.conf"] = "httpd-ssl.conf.in";
67 filelist["httpd-userdir.conf"] = "httpd-userdir.conf.in";
68 filelist["httpd-vhosts.conf"] = "httpd-vhosts.conf.in";
70 for ( conffile in filelist ) {
72 if ( conffile == "httpd.conf" ) {
73 srcfl = sourceroot filelist[conffile];
74 dstfl = confdefault conffile;
77 srcfl = sourceroot "extra/" filelist[conffile];
78 dstfl = confdefault "extra/" conffile;
82 while ( ( getline < srcfl ) > 0 ) {
84 if ( bswarning && /^$/ ) {
86 print "# NOTE: Where filenames are specified, you must use forward slashes" > dstfl;
87 print "# instead of backslashes (e.g., \"c:/apache\" instead of \"c:\\apache\")." > dstfl;
88 print "# If a drive letter is omitted, the drive on which httpd.exe is located" > dstfl;
89 print "# will be used by default. It is recommended that you always supply" > dstfl;
90 print "# an explicit drive letter in absolute paths to avoid confusion." > dstfl;
93 if ( /@@LoadModule@@/ ) {
94 print "LoadModule access_compat_module modules/mod_access_compat.so" > dstfl;
95 print "LoadModule actions_module modules/mod_actions.so" > dstfl;
96 print "LoadModule alias_module modules/mod_alias.so" > dstfl;
97 print "LoadModule asis_module modules/mod_asis.so" > dstfl;
98 print "LoadModule auth_basic_module modules/mod_auth_basic.so" > dstfl;
99 print "#LoadModule auth_digest_module modules/mod_auth_digest.so" > dstfl;
100 print "#LoadModule authn_anon_module modules/mod_authn_anon.so" > dstfl;
101 print "LoadModule authn_core_module modules/mod_authn_core.so" > dstfl;
102 print "#LoadModule authn_dbd_module modules/mod_authn_dbd.so" > dstfl;
103 print "#LoadModule authn_dbm_module modules/mod_authn_dbm.so" > dstfl;
104 print "LoadModule authn_file_module modules/mod_authn_file.so" > dstfl;
105 print "#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so" > dstfl;
106 print "LoadModule authz_core_module modules/mod_authz_core.so" > dstfl;
107 print "#LoadModule authz_dbd_module modules/mod_authz_dbd.so" > dstfl;
108 print "#LoadModule authz_dbm_module modules/mod_authz_dbm.so" > dstfl;
109 print "LoadModule authz_groupfile_module modules/mod_authz_groupfile.so" > dstfl;
110 print "LoadModule authz_host_module modules/mod_authz_host.so" > dstfl;
111 print "#LoadModule authz_owner_module modules/mod_authz_owner.so" > dstfl;
112 print "LoadModule authz_user_module modules/mod_authz_user.so" > dstfl;
113 print "LoadModule autoindex_module modules/mod_autoindex.so" > dstfl;
114 print "#LoadModule cache_module modules/mod_cache.so" > dstfl;
115 print "#LoadModule cache_disk_module modules/mod_cache_disk.so" > dstfl;
116 print "#LoadModule cern_meta_module modules/mod_cern_meta.so" > dstfl;
117 print "LoadModule cgi_module modules/mod_cgi.so" > dstfl;
118 print "#LoadModule charset_lite_module modules/mod_charset_lite.so" > dstfl;
119 print "#LoadModule dav_module modules/mod_dav.so" > dstfl;
120 print "#LoadModule dav_fs_module modules/mod_dav_fs.so" > dstfl;
121 print "#LoadModule dav_lock_module modules/mod_dav_lock.so" > dstfl;
122 print "#LoadModule dbd_module modules/mod_dbd.so" > dstfl;
123 print "#LoadModule deflate_module modules/mod_deflate.so" > dstfl;
124 print "LoadModule dir_module modules/mod_dir.so" > dstfl;
125 print "#LoadModule dumpio_module modules/mod_dumpio.so" > dstfl;
126 print "LoadModule env_module modules/mod_env.so" > dstfl;
127 print "#LoadModule expires_module modules/mod_expires.so" > dstfl;
128 print "#LoadModule ext_filter_module modules/mod_ext_filter.so" > dstfl;
129 print "#LoadModule file_cache_module modules/mod_file_cache.so" > dstfl;
130 print "#LoadModule filter_module modules/mod_filter.so" > dstfl;
131 print "#LoadModule headers_module modules/mod_headers.so" > dstfl;
132 print "#LoadModule ident_module modules/mod_ident.so" > dstfl;
133 print "#LoadModule imagemap_module modules/mod_imagemap.so" > dstfl;
134 print "LoadModule include_module modules/mod_include.so" > dstfl;
135 print "#LoadModule info_module modules/mod_info.so" > dstfl;
136 print "LoadModule isapi_module modules/mod_isapi.so" > dstfl;
137 print "#LoadModule ldap_module modules/mod_ldap.so" > dstfl;
138 print "#LoadModule logio_module modules/mod_logio.so" > dstfl;
139 print "LoadModule log_config_module modules/mod_log_config.so" > dstfl;
140 print "#LoadModule log_forensic_module modules/mod_log_forensic.so" > dstfl;
141 print "LoadModule mime_module modules/mod_mime.so" > dstfl;
142 print "#LoadModule mime_magic_module modules/mod_mime_magic.so" > dstfl;
143 print "LoadModule negotiation_module modules/mod_negotiation.so" > dstfl;
144 print "#LoadModule proxy_module modules/mod_proxy.so" > dstfl;
145 print "#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so" > dstfl;
146 print "#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so" > dstfl;
147 print "#LoadModule proxy_connect_module modules/mod_proxy_connect.so" > dstfl;
148 print "#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so" > dstfl;
149 print "#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so" > dstfl;
150 print "#LoadModule proxy_http_module modules/mod_proxy_http.so" > dstfl;
151 print "#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so" > dstfl;
152 print "#LoadModule reqtimeout_module modules/mod_reqtimeout.so" > dstfl;
153 print "#LoadModule reflector_module modules/mod_reflector.so" > dstfl;
154 print "#LoadModule rewrite_module modules/mod_rewrite.so" > dstfl;
155 print "LoadModule setenvif_module modules/mod_setenvif.so" > dstfl;
156 print "#LoadModule speling_module modules/mod_speling.so" > dstfl;
157 print "#LoadModule ssl_module modules/mod_ssl.so" > dstfl;
158 print "#LoadModule status_module modules/mod_status.so" > dstfl;
159 print "#LoadModule substitute_module modules/mod_substitute.so" > dstfl;
160 print "#LoadModule unique_id_module modules/mod_unique_id.so" > dstfl;
161 print "#LoadModule userdir_module modules/mod_userdir.so" > dstfl;
162 print "#LoadModule usertrack_module modules/mod_usertrack.so" > dstfl;
163 print "#LoadModule version_module modules/mod_version.so" > dstfl;
164 print "#LoadModule vhost_alias_module modules/mod_vhost_alias.so" > dstfl;
167 gsub( /^SSLMutex.*/, "SSLMutex default" );
168 gsub( /@@ServerRoot@@/, serverroot );
169 gsub( /@exp_cgidir@/, serverroot "/cgi-bin" );
170 gsub( /@exp_sysconfdir@/, serverroot "/conf" );
171 gsub( /@exp_errordir@/, serverroot "/error" );
172 gsub( /@exp_htdocsdir@/, serverroot "/htdocs" );
173 gsub( /@exp_iconsdir@/, serverroot "/icons" );
174 gsub( /@exp_manualdir@/, serverroot "/manual" );
175 gsub( /@exp_runtimedir@/, serverroot "/logs" );
176 if ( gsub( /@exp_logfiledir@/, serverroot "/logs" ) ||
177 gsub( /@rel_logfiledir@/, "logs" ) ) {
178 gsub( /_log"/, ".log\"" )
180 gsub( /@rel_runtimedir@/, "logs" );
181 gsub( /@rel_sysconfdir@/, "conf" );
182 gsub( /\/home\/\*\/public_html/, \
183 usertree "/*/My Documents/My Website" );
184 gsub( /UserDir public_html/, "UserDir \"My Documents/My Website\"" );
185 gsub( /@@ServerName@@|www.example.com/, servername );
186 gsub( /@@ServerAdmin@@|you@example.com/, serveradmin );
187 gsub( /@@DomainName@@|example.com/, domainname );
188 gsub( /@@Port@@/, serverport );
189 gsub( /@@SSLPort@@|443/, serversslport );
194 if ( close(dstfl) >= 0 ) {
195 print "Rewrote " srcfl "\n to " dstfl > tstfl;
196 gsub(/\//, "\\", srcfl);
197 if ( sourceroot != "docs/conf/" ) {
198 if (system("del \"" srcfl "\"")) {
199 print "Failed to remove " srcfl > tstfl;
201 print "Successfully removed " srcfl > tstfl;
205 print "Failed to rewrite " srcfl "\n to " dstfl > tstfl;
207 filelist[conffile] = "extra/";
210 filelist["httpd.conf"] = "";
211 filelist["charset.conv"] = "";
212 filelist["magic"] = "";
213 filelist["mime.types"] = "";
215 for ( conffile in filelist ) {
216 srcfl = confdefault filelist[conffile] conffile;
217 dstfl = confroot filelist[conffile] conffile;
218 if ( ( getline < dstfl ) < 0 ) {
219 while ( ( getline < srcfl ) > 0 ) {
222 print "Duplicated " srcfl "\n to " dstfl > tstfl;
224 print "Existing file " dstfl " preserved" > tstfl;
230 if ( sourceroot != "docs/conf/" ) {
231 srcfl = confdefault "installwinconf.awk";
232 gsub(/\//, "\\", srcfl);
233 if (system("del \"" srcfl "\"")) {
234 print "Failed to remove " srcfl > tstfl;
236 print "Successfully removed " srcfl > tstfl;