Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

gdp / adm / customize.sh @ master

History | View | Annotate | Download (2.33 KB)

1
#!/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
if [ $# -lt 1 -o $# -gt 2 ]
12
then
13
	echo 1>&2 "Usage: $0 source-file [target-dir]"
14
	exit 1
15
fi
16

    
17
source_file=$1
18
target_dir=${2:-}
19

    
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
# 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
: ${GDP_ROOT:=/usr}
34
if [ "$GDP_ROOT" = "/usr" ]
35
then
36
	: ${GDP_ETC:=/etc/gdp}
37
else
38
	: ${GDP_ETC:=$GDP_ROOT/etc}
39
fi
40
: ${GDP_LOG_DIR:=/var/log/gdp}
41
: ${GDP_SYSLOG_FACILITY:=local4}
42
: ${GDP_SYSLOG_LEVEL:=notice}
43
: ${GDP_USER:=gdp}
44
: ${GDP_VAR:=/var/swarm/gdp}
45
: ${GDP_VAR_RUN:=/var/run}
46
: ${GDP_KEYS_DIR:=$GDP_ETC/keys}
47
: ${GDPLOGD_BIN:=$GDP_ROOT/sbin/gdplogd$GDP_VER}
48
: ${GDPLOGD_ARGS:=}
49
: ${GDPLOGD_DATADIR:=}
50
: ${GDPLOGD_PIDFILE:=$GDP_VAR_RUN/gdplogd.pid}
51
: ${GDP_ROUTER_CONF:=$GDP_VAR_RUN/gdp-router-click.conf}
52
: ${SCGI_DEBUG:=1}
53
: ${SCGI_PORT:=8001}
54

    
55
if [ -z "$target_dir" ]
56
then
57
	target=/dev/stdout
58
else
59
	target=$target_dir/$source_root
60
fi
61

    
62
(
63
	echo "# Generated" `date +"%F %T %z"` from $source_file
64
	sed \
65
		-e "s;@GDP_VER@;$GDP_VER;g" \
66
		-e "s;@GDP_ROOT@;$GDP_ROOT;g" \
67
		-e "s;@GDP_ETC@;$GDP_ETC;g" \
68
		-e "s;@GDP_LOG_DIR@;$GDP_LOG_DIR;g" \
69
		-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
		-e "s;@GDP_VAR@;$GDP_VAR;g" \
73
		-e "s;@GDP_VAR_RUN@;$GDP_VAR_RUN;g" \
74
		-e "s;@GDP_KEYS_DIR@;$GDP_KEYS_DIR;g" \
75
		-e "s;@GDPLOGD_BIN@;$GDPLOGD_BIN;g" \
76
		-e "s;@GDPLOGD_ARGS@;$GDPLOGD_ARGS;g" \
77
		-e "s;@GDPLOGD_DATADIR@;$GDPLOGD_DATADIR;g" \
78
		-e "s;@GDPLOGD_PIDFILE@;$GDPLOGD_PIDFILE;g" \
79
		-e "s;@GDP_ROUTER_CONF@;$GDP_ROUTER_CONF;g" \
80
		-e "s;@SCGI_DEBUG@;$SCGI_DEBUG;g" \
81
		-e "s;@SCGI_PORT@;$SCGI_PORT;g" \
82

    
83
	echo "# End of generated text" $1
84
) < $source_file > $target