Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

gdp / adm / customize.sh @ master

History | View | Annotate | Download (2.33 KB)

1 90cd4faa Eric Allman
#!/bin/sh
2
3
#
4
#  Customize scripts for various pathnames and other parameters.
5
#
6
#	Defaults are defined here.
7
#
8
#	Usage: adm/customize.sh source-file target-dir
9
#
10
11 c2844648 Eric Allman
if [ $# -lt 1 -o $# -gt 2 ]
12 5913a5c3 Eric Allman
then
13 c2844648 Eric Allman
	echo 1>&2 "Usage: $0 source-file [target-dir]"
14 5913a5c3 Eric Allman
	exit 1
15
fi
16
17 90cd4faa Eric Allman
source_file=$1
18 c2844648 Eric Allman
target_dir=${2:-}
19 90cd4faa Eric Allman
20
source_dir=`dirname $source_file`
21
source_root=`basename $source_file .template`
22
source_file="$source_dir/$source_root.template"
23
#echo source_file=$source_file, source_dir=$source_dir, source_root=$source_root, target_dir=$target_dir
24
25 d17c1801 Eric Allman
# allow environment to give us a different configuration; local overrides
26
: ${GDP_VER=}
27
{ test -r /etc/gdp.conf.sh && . /etc/gdp.conf.sh; }
28
{ test -r /usr/local/etc/gdp.conf.sh && . /usr/local/etc/gdp.conf.sh; }
29
{ test -r /etc/gdp${GDP_VER}.conf.sh && . /etc/gdp${GDP_VER}.conf.sh; }
30
{ test -r /usr/local/etc/gdp${GDP_VER}.conf.sh && . /usr/local/etc/gdp${GDP_VER}.conf.sh; }
31
32
# default configuration
33 90cd4faa Eric Allman
: ${GDP_ROOT:=/usr}
34 ebd10406 Eric Allman
if [ "$GDP_ROOT" = "/usr" ]
35
then
36 0dc3d148 Eric Allman
	: ${GDP_ETC:=/etc/gdp}
37 ebd10406 Eric Allman
else
38
	: ${GDP_ETC:=$GDP_ROOT/etc}
39
fi
40 0dc3d148 Eric Allman
: ${GDP_LOG_DIR:=/var/log/gdp}
41 90cd4faa Eric Allman
: ${GDP_SYSLOG_FACILITY:=local4}
42
: ${GDP_SYSLOG_LEVEL:=notice}
43
: ${GDP_USER:=gdp}
44 ebd10406 Eric Allman
: ${GDP_VAR:=/var/swarm/gdp}
45 2e0d7aab Eric Allman
: ${GDP_VAR_RUN:=/var/run}
46 0dc3d148 Eric Allman
: ${GDP_KEYS_DIR:=$GDP_ETC/keys}
47 d17c1801 Eric Allman
: ${GDPLOGD_BIN:=$GDP_ROOT/sbin/gdplogd$GDP_VER}
48 90cd4faa Eric Allman
: ${GDPLOGD_ARGS:=}
49 cdc61088 Eric Allman
: ${GDPLOGD_DATADIR:=}
50 2e0d7aab Eric Allman
: ${GDPLOGD_PIDFILE:=$GDP_VAR_RUN/gdplogd.pid}
51
: ${GDP_ROUTER_CONF:=$GDP_VAR_RUN/gdp-router-click.conf}
52 5913a5c3 Eric Allman
: ${SCGI_DEBUG:=1}
53
: ${SCGI_PORT:=8001}
54 90cd4faa Eric Allman
55 c2844648 Eric Allman
if [ -z "$target_dir" ]
56
then
57
	target=/dev/stdout
58
else
59
	target=$target_dir/$source_root
60
fi
61
62 90cd4faa Eric Allman
(
63
	echo "# Generated" `date +"%F %T %z"` from $source_file
64
	sed \
65 d17c1801 Eric Allman
		-e "s;@GDP_VER@;$GDP_VER;g" \
66 90cd4faa Eric Allman
		-e "s;@GDP_ROOT@;$GDP_ROOT;g" \
67 ebd10406 Eric Allman
		-e "s;@GDP_ETC@;$GDP_ETC;g" \
68 2e0d7aab Eric Allman
		-e "s;@GDP_LOG_DIR@;$GDP_LOG_DIR;g" \
69 90cd4faa Eric Allman
		-e "s;@GDP_SYSLOG_FACILITY@;$GDP_SYSLOG_FACILITY;g" \
70
		-e "s;@GDP_SYSLOG_LEVEL@;$GDP_SYSLOG_LEVEL;g" \
71
		-e "s;@GDP_USER@;$GDP_USER;g" \
72 ebd10406 Eric Allman
		-e "s;@GDP_VAR@;$GDP_VAR;g" \
73 2e0d7aab Eric Allman
		-e "s;@GDP_VAR_RUN@;$GDP_VAR_RUN;g" \
74 d17c1801 Eric Allman
		-e "s;@GDP_KEYS_DIR@;$GDP_KEYS_DIR;g" \
75
		-e "s;@GDPLOGD_BIN@;$GDPLOGD_BIN;g" \
76 90cd4faa Eric Allman
		-e "s;@GDPLOGD_ARGS@;$GDPLOGD_ARGS;g" \
77 cdc61088 Eric Allman
		-e "s;@GDPLOGD_DATADIR@;$GDPLOGD_DATADIR;g" \
78 2e0d7aab Eric Allman
		-e "s;@GDPLOGD_PIDFILE@;$GDPLOGD_PIDFILE;g" \
79
		-e "s;@GDP_ROUTER_CONF@;$GDP_ROUTER_CONF;g" \
80 5913a5c3 Eric Allman
		-e "s;@SCGI_DEBUG@;$SCGI_DEBUG;g" \
81
		-e "s;@SCGI_PORT@;$SCGI_PORT;g" \
82 90cd4faa Eric Allman
83 ebd10406 Eric Allman
	echo "# End of generated text" $1
84 c2844648 Eric Allman
) < $source_file > $target