File: setup-instance

package info (click to toggle)
apache2 2.2.22-13%2Bdeb7u6
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 47,900 kB
  • sloc: ansic: 233,662; sh: 15,591; perl: 2,223; awk: 1,172; makefile: 1,081; lex: 191; python: 142; yacc: 100; xml: 36
file content (39 lines) | stat: -rw-r--r-- 1,141 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh

set -eu

if [ $# != 1 ] ; then
	echo usage: $0 '<suffix>'
	exit 1
fi

# the SUFFIX must not contain spaces or shell meta characters
SUFFIX=$1

if [ -e /etc/apache2-$SUFFIX ] ; then
	echo ERROR: /etc/apache2-$SUFFIX already exists
	exit 2
fi

echo Setting up /etc/apache2-$SUFFIX ...
cp -a /etc/apache2 /etc/apache2-$SUFFIX

echo Setting up /etc/init.d/apache2-$SUFFIX ...
cp /usr/share/doc/apache2.2-common/examples/secondary-init-script /etc/init.d/apache2-$SUFFIX
# adjust service name (this prevents us from using a simple symlink)
perl -p -i -e s,XXX,$SUFFIX, /etc/init.d/apache2-$SUFFIX
chmod 755 /etc/init.d/apache2-$SUFFIX

echo -n Setting up symlinks: 
for a in a2enmod a2dismod a2ensite a2dissite apache2ctl ; do
	echo -n " $a-$SUFFIX"
	ln -s /usr/sbin/$a /usr/local/sbin/$a-$SUFFIX
done
echo

echo Setting up /etc/logrotate.d/apache2-$SUFFIX and /var/log/apache2-$SUFFIX ...
cp -a /etc/logrotate.d/apache2 /etc/logrotate.d/apache2-$SUFFIX
perl -p -i -e s,apache2,apache2-$SUFFIX,g /etc/logrotate.d/apache2-$SUFFIX
mkdir /var/log/apache2-$SUFFIX
chmod 750 /var/log/apache2-$SUFFIX
chown root:adm /var/log/apache2-$SUFFIX