From: Kyle J. McKay Date: Fri, 18 Apr 2014 04:31:03 +0000 (-0700) Subject: apache.conf: replace with apache.conf.in and make-apache-conf.sh X-Git-Url: https://repo.or.cz/w/girocco.git/commitdiff_plain/5e718fbcb9ac95528c94c748874466f3ec865720 apache.conf: replace with apache.conf.in and make-apache-conf.sh There are too many places in the sample configuration file where values from Config.pm need to be substituted. Doing this by hand is extremely error prone. Instead, replace apache.conf with apache.conf.in and add a new make-apache-conf.sh script that creates apache.conf by automatically using the current values from Config.pm. Also make sure that apache.conf is updated before installing it. --- diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8359151 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +.gitattributes export-ignore +.gitignore export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c23e334 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/apache.conf diff --git a/Girocco/Config.pm b/Girocco/Config.pm index bd93958..0a8de7c 100644 --- a/Girocco/Config.pm +++ b/Girocco/Config.pm @@ -493,6 +493,7 @@ our $mobpushurl = $pushurl; $mobpushurl =~ s,^ssh://,ssh://mob@,i if $mobpushurl; $disable_dsa = 1 unless $pushurl; $disable_dsa = $disable_dsa ? 1 : ''; +our $httpdnsname = ($gitweburl =~ m,https?://([A-Za-z0-9.-]+),i) ? lc($1) : undef if $gitweburl; our $httpsdnsname = ($httpspushurl =~ m,https://([A-Za-z0-9.-]+),i) ? lc($1) : undef if $httpspushurl; ($mirror or $push) or die "Girocco::Config: neither \$mirror nor \$push is set?!"; (not $push or ($pushurl or $httpspushurl or $gitpullurl or $httppullurl)) or die "Girocco::Config: no pull URL is set"; diff --git a/Makefile b/Makefile index f158b7a..04d1094 100644 --- a/Makefile +++ b/Makefile @@ -13,11 +13,14 @@ all:: # This should be fatal in non-GNU make export MAKE -all:: +all:: apache.conf "$(MAKE)" -C git.git --quiet gitweb "$(MAKE)" -C src --quiet -install:: +install:: all @./install.sh clean:: + +apache.conf: apache.conf.in + ./make-apache-conf.sh diff --git a/apache.conf b/apache.conf.in similarity index 82% rename from apache.conf rename to apache.conf.in index eee64ae..4a9ae86 100644 --- a/apache.conf +++ b/apache.conf.in @@ -1,19 +1,22 @@ -# This is example configuration of a virtualhost running Girocco, as set up +## To convert this file to apache.conf using the current Girocco::Config values +## either do "make" or "make apache.conf" or ./make-apache-conf.sh +## +# This is an example configuration of a virtualhost running Girocco, as set up # at repo.or.cz; unfortunately, completely independent from Girocco::Config. # It is not essential for Girocco to use a special virtualhost, however. - ServerName repo.or.cz - ServerAlias www.repo.or.cz - ServerAdmin admin@repo.or.cz + ServerName @@httpdnsname@@ + ServerAlias www.@@httpdnsname@@ + ServerAdmin @@admin@@ ErrorLog /var/log/apache2/repo-error.log CustomLog /var/log/apache2/repo-access.log combined AddHandler cgi-script .cgi - DocumentRoot /home/repo/WWW - + DocumentRoot @@webroot@@ + # Add MultiViews only if pages are truly # offered in more than a single language Options Indexes FollowSymLinks ExecCGI @@ -24,21 +27,21 @@ Satisfy all - ScriptAlias /w /home/repo/WWW/gitweb.cgi - ScriptAlias /h /home/repo/WWW/html.cgi + ScriptAlias /w @@cgiroot@@/gitweb.cgi + ScriptAlias /h @@cgiroot@@/html.cgi # Make the leading /w optional if the rest names an existing repo RewriteEngine On RewriteCond %{HTTP_USER_AGENT} !git/ [NC] - RewriteCond /srv/git/$1/HEAD -f + RewriteCond @@reporoot@@/$1/HEAD -f # Might want to use [NC,L,R] instead of [NC,PT] maybe even [NC,L,R=301] RewriteRule \ ^/(?!w/)((?:[a-z0-9+._-]+(? - + Options FollowSymLinks AllowOverride None Order allow,deny @@ -56,7 +59,7 @@ - + Options None AllowOverride None Order deny,allow @@ -68,7 +71,7 @@ Satisfy all - SetEnv GIT_PROJECT_ROOT /srv/git + SetEnv GIT_PROJECT_ROOT @@reporoot@@ SetEnv GIT_HTTP_EXPORT_ALL 1 # By default non-smart HTTP fetch access will be allowed, however @@ -77,8 +80,8 @@ # These accelerate non-smart HTTP access to loose objects and packs with the /r/ prefix - AliasMatch ^/r/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /srv/git/$1 - AliasMatch ^/r/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /srv/git/$1 + AliasMatch ^/r/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ @@reporoot@@/$1 + AliasMatch ^/r/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ @@reporoot@@/$1 # These accelerate non-smart HTTP access for Git user agents without the /r/ prefix @@ -87,7 +90,7 @@ RewriteRule "(?x) ^/((?!r/).*/objects/(?: \ (?:[0-9a-f]{2}/[0-9a-f]{38}) | \ (?:pack/pack-[0-9a-f]{40}.(?:pack|idx)) ))$" \ - /srv/git/$1 [L] + @@reporoot@@/$1 [L] @@ -107,14 +110,14 @@ # SetEnv GIT_HTTP_BACKEND_BIN to override Config.pm $git_http_backend_bin - ScriptAlias /r/ /home/repo/repomgr/bin/git-http-backend-verify/ + ScriptAlias /r/ @@basedir@@/bin/git-http-backend-verify/ # This allows HTTP access for Git user agents without the /r/ prefix RewriteEngine On RewriteCond %{HTTP_USER_AGENT} git/ [NC] RewriteRule ^/(?!r/)(.*)$ \ - /home/repo/repomgr/bin/git-http-backend-verify/$1 \ + @@basedir@@/bin/git-http-backend-verify/$1 \ [L,H=cgi-script] @@ -124,7 +127,7 @@ -# This is example configuration of an https virtualhost running Girocco, as set +# This is an example configuration of an https virtualhost running Girocco, as set # up at repo.or.cz; unfortunately, completely independent from Girocco::Config. # It is not essential for Girocco to use a special virtualhost, however. # The Config.pm $httpspushurl variable needs to be defined to properly enable @@ -135,14 +138,14 @@ # paths here may need to be corrected to match the paths # (especially $certsdir) from Config.pm - SSLCertificateFile /home/repo/certs/girocco_www_crt.pem - SSLCertificateKeyFile /home/repo/certs/girocco_www_key.pem - SSLCertificateChainFile /home/repo/certs/girocco_www_chain.pem + SSLCertificateFile @@certsdir@@/girocco_www_crt.pem + SSLCertificateKeyFile @@certsdir@@/girocco_www_key.pem + SSLCertificateChainFile @@certsdir@@/girocco_www_chain.pem # when using a paid www server cert, only the above three lines should # be changed. Changing any of the below two lines (other than updating # the paths to match $certsdir) will likely break https client auth - SSLCACertificateFile /home/repo/certs/girocco_root_crt.pem - SSLCADNRequestFile /home/repo/certs/girocco_client_crt.pem + SSLCACertificateFile @@certsdir@@/girocco_root_crt.pem + SSLCADNRequestFile @@certsdir@@/girocco_client_crt.pem SSLVerifyDepth 3 SSLOptions +FakeBasicAuth +StrictRequire diff --git a/install.sh b/install.sh index 4d71d08..ec6ad18 100755 --- a/install.sh +++ b/install.sh @@ -74,6 +74,8 @@ esac echo "*** Setting up basedir..." +"$MAKE" --quiet apache.conf +"$MAKE" --quiet -C src rm -fr "$cfg_basedir" mkdir -p "$cfg_basedir" cp -pR Girocco jobd taskd gitweb html jobs toolbox hooks apache.conf shlib.sh bin screen "$cfg_basedir" diff --git a/make-apache-conf.sh b/make-apache-conf.sh new file mode 100755 index 0000000..748b57e --- /dev/null +++ b/make-apache-conf.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# This script uses the current values of Girocco::Config to +# convert apache.conf.in into apache.conf. +# +# It is run automatically by "make" or "make apache.conf" but +# may be run separately if desired. + +set -e + +. ./shlib.sh + +config_options='admin basedir certsdir cgiroot httpdnsname reporoot webroot' + +cmd="sed < apache.conf.in > apache.conf -e '/^##/d'" +for option in $config_options; do + cmd="$cmd -e \"s#@@$option@@#\$cfg_$option#g\"" +done +eval "$cmd"