summaryrefslogtreecommitdiff
path: root/databases/slony1v2/files/slon-mkservice.sh.in
blob: ea77e07c067786253bee0f2281bc24a152fea830 (plain) (blame)
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
#!/bin/sh

# create a slon service directory for use with svscan from deamontools

echo -n 'specify directory for "slon" service like "/var/slon-master": '
read DIR
if [ -z "$DIR" ]; then
 echo "Directory must be non-empty"
 exit 1;
fi

echo -n 'System user name for programs to run under (default pgsql): '
read sysuser
if [ -z "$sysuser" ]; then
 echo "User name pgsql being used."
 sysuser='pgsql'
fi

mkdir -p ${DIR}/env ${DIR}/supervise || exit 1
mkdir -p ${DIR}/log/main ${DIR}/log/supervise || exit 1

cat > ${DIR}/run  <<EOF
#!/bin/sh
exec 2>&1

exec envdir ./env sh -c 'exec setuidgid ${sysuser} slon -f \${CONFIGFILE}'
EOF
chmod +x ${DIR}/run

cat >${DIR}/log/run <<EOF
#!/bin/sh
exec setuidgid ${sysuser} multilog t ./main
EOF
chmod +x ${DIR}/log/run

echo "%%PREFIX%%/etc/slon.conf" > ${DIR}/env/CONFIGFILE

chown -R ${sysuser} ${DIR}