Merge branch 'template' of ssh://matthijs@git.stderr.nl/matthijs/servers/drsnuggles...
[matthijs/servers/drsnuggles.git] / usr / local / bin / update-php.ini
1 #!/bin/sh
2
3 # This script will merge the main php.ini with local and site specific
4 # additions into a site specific php.ini.
5
6 BASE=/etc/php5/cgi/php.ini
7 LOCAL=/etc/php5/cgi/php.ini.local
8 SITES=/data/www/*
9 CONFIN=conf/php.ini.override
10 CONFOUT=conf/php.ini
11
12 for SITE in $SITES; do
13         IN=$SITE/$CONFIN
14         OUT=$SITE/$CONFOUT
15         if [ \! -r $IN ]; then
16                 continue;
17         fi
18         echo "Updating $OUT"
19
20         cat > $OUT <<EOF
21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22 ;
23 ; This file is autogenerated by $0
24
25 ; Do NOT edit this file directly.
26 ;
27 ; You should instead edit $IN (for site-specific config) or $LOCAL (for global
28 ; config) and run $0 afterwards.
29 ;
30 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
31
32
33 ;;; Begin included $BASE (this is the default config from php) ;;;
34
35 EOF
36         
37         cat $BASE >> $OUT
38         echo -e "\n;;; End included $BASE ;;;\n" >> $OUT
39         echo -e "\n;;; Begin included $LOCAL (these are global config changes) ;;;\n" >> $OUT
40         cat $LOCAL >> $OUT
41         echo -e "\n;;; End included $LOCAL ;;;\n" >> $OUT
42         echo -e "\n;;; Begin included $IN (these are config changes specific to this site) ;;;\n" >> $OUT
43         cat $IN >> $OUT
44         echo -e "\n;;; End included $IN ;;;\n" >> $OUT
45 done