Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

gdp / adm / init-gdp-server.sh @ master

History | View | Annotate | Download (3.76 KB)

1 874dd6e4 Eric Allman
#!/bin/sh
2
3
#
4 ebd10406 Eric Allman
#  Initialize GDP server hosts
5
#
6
#	This script should not be needed for ordinary clients.
7
#
8
#	This should be portable to all environments.  In particular,
9
#	it is not dependent on a particular version of Linux (or
10
#	for that matter, Linux at all).
11
#
12
#	XXX  This assumes the Berkeley-based routers.  If you have
13
#	XXX  your own router you'll need to modify $EP_PARAMS/gdp
14
#	XXX  after this completes.
15
#
16
#	XXX  It also assumes you are in the eecs.berkeley.edu domain.
17
#	XXX  If you aren't you'll need to modify $EP_PARAMS/gdplogd
18
#	XXX  after this completes.
19
#
20
#	This script does not install a router or router
21
#	startup scripts.  The router is a separate package
22
#	and must be installed separately.
23 874dd6e4 Eric Allman
#
24
25 2786071d Eric Allman
args=`getopt i $*`
26
if [ $? != 0 ]
27
then
28
	echo "Usage: $0 [-i]"
29
	exit 1
30
fi
31
32
eval set -- "$args"
33 ac3fec0e Eric Allman
moreargs=true
34 2786071d Eric Allman
do_install=true
35
while $moreargs
36
do
37
	case "$1"
38
	in
39
	  -i)
40
		do_install=false;
41
		;;
42
43
	  --)
44
		moreargs=false
45
		shift
46
		break
47
		;;
48
	esac
49
	shift
50
done
51
52 ebd10406 Eric Allman
# we assume this is in the adm directory
53
cd `dirname $0`/..
54 3756d4ac Eric Allman
GDP_SRC_ROOT=`pwd`
55 d17c1801 Eric Allman
TMP=/tmp
56 3756d4ac Eric Allman
. adm/common-support.sh
57 ebd10406 Eric Allman
58 d17c1801 Eric Allman
## compile code and utilities, possibly not as root
59 1a1a88c7 Eric Allman
info "Compiling GDP code and utilities"
60 d17c1801 Eric Allman
make
61 f4794b37 Eric Allman
(cd util && make)
62
63 2786071d Eric Allman
## be sure we're running as root
64
test `whoami` = "root" || exec sudo GDP_REST_INSTALL=$GDP_REST_INSTALL $0 "$@"
65
66
# setup GDP user, basic directories, etc.
67
. adm/gdp-bin-setup.sh
68
69 d17c1801 Eric Allman
. adm/gdp-version.sh
70
: ${GDP_VER=$GDP_VERSION_MAJOR}
71 3756d4ac Eric Allman
: ${GDPLOGD_LOG:=$GDP_LOG_DIR/gdplogd.log}
72 d17c1801 Eric Allman
: ${GDPLOGD_BIN:=$GDP_ROOT/sbin/gdplogd$GDP_VER}
73 34200e7f Eric Allman
: ${GDP_REST_INSTALL:=false}
74 d17c1801 Eric Allman
export GDP_VER
75 874dd6e4 Eric Allman
76 1a1a88c7 Eric Allman
echo "Installing gdplogd:"
77
(cd $GDP_SRC_ROOT/gdplogd && make install)
78 f83aaeb5 Eric Allman
79 2786071d Eric Allman
echo "Making server-specific directories"
80 ebd10406 Eric Allman
mkdir_gdp $GDP_LOG_DIR
81
mkdir_gdp $GDP_VAR
82 cdc61088 Eric Allman
mkdir_gdp $GDPLOGD_DATADIR 0750
83 1a1a88c7 Eric Allman
mkdir_gdp /var/swarm
84
mkdir_gdp /var/swarm/gdp
85
mkdir_gdp /var/swarm/gdp/glogs
86 874dd6e4 Eric Allman
87 45121ec5 Eric Allman
mkfile_gdp $GDPLOGD_LOG
88
mkfile_gdp $GDP_REST_LOG
89 3756d4ac Eric Allman
90 d17c1801 Eric Allman
info "Creating $EP_PARAMS/gdplogd"
91
{
92 3b0b4cd7 Eric Allman
	echo "swarm.gdplogd.gdpname=edu.berkeley.eecs.$hostname.gdplogd.physical"
93 d17c1801 Eric Allman
	echo "swarm.gdplogd.runasuser=gdp"
94
} > $TMP/gdplogd.params
95 cdc61088 Eric Allman
if [ ! -f $EP_PARAMS/gdplogd ]
96
then
97 d17c1801 Eric Allman
	cp $TMP/gdplogd.params $EP_PARAMS/gdplogd
98 9f800e1d Eric Allman
	chown ${GDP_USER}:${GDP_GROUP} $EP_PARAMS/gdplogd
99 cdc61088 Eric Allman
	cat $EP_PARAMS/gdplogd
100 1a1a88c7 Eric Allman
elif cmp -s $TMP/gdplogd.params $EP_PARAMS/gdplogd
101 d17c1801 Eric Allman
then
102
	rm $TMP/gdplogd.params
103 cdc61088 Eric Allman
else
104
	warn "$EP_PARAMS/gdplogd already exists; check consistency" 1>&2
105 d17c1801 Eric Allman
	diff -u $TMP/gdplogd.params $EP_PARAMS/gdplogd
106 cdc61088 Eric Allman
fi
107 3756d4ac Eric Allman
108 f4794b37 Eric Allman
info "Installing utility programs"
109 417743d7 Eric Allman
cd $GDP_SRC_ROOT
110 f4794b37 Eric Allman
(cd util && make install)
111
112
info "Installing gdplogd wrapper script"
113 2786071d Eric Allman
install -o ${GDP_USER} adm/gdplogd-wrapper.sh \
114
	$GDP_ROOT/sbin/gdplogd${GDP_VER}-wrapper.sh
115 5000cc4a Eric Allman
116 34200e7f Eric Allman
if $GDP_REST_INSTALL
117
then
118
	info "Installing gdp-rest wrapper script"
119 1220cf5e Eric Allman
	install -o ${GDP_USER} adm/gdp-rest-wrapper.sh $GDP_ROOT/sbin/gdp-rest${GDP_VER}-wrapper.sh
120 34200e7f Eric Allman
fi
121 45121ec5 Eric Allman
122 c6f2f27f Eric Allman
if [ -d /etc/rsyslog.d ]
123
then
124
	info "Installing rsyslog configuration"
125
	sh adm/customize.sh adm/60-gdp.conf.template /etc/rsyslog.d
126
	chown ${GDP_USER}:${GDP_GROUP} /etc/rsyslog.d/60-gdp.conf
127
fi
128
129 966ea205 Eric Allman
if [ -d /etc/logrotate.d ]
130
then
131
	info "Installing logrotate configuration"
132 18bc89b5 Eric Allman
	cp adm/gdp-logrotate.conf /etc/logrotate.d/gdp
133 966ea205 Eric Allman
fi
134
135 3756d4ac Eric Allman
if [ "$INITSYS" = "systemd" ]
136
then
137 5913a5c3 Eric Allman
	info "Installing and enabling systemd service files"
138
	info "gdplogd.service ..."
139 d17c1801 Eric Allman
	adm/customize.sh adm/gdplogd.service.template $TMP
140
	cp $TMP/gdplogd.service /etc/systemd/system/gdplogd$GDP_VER.service
141
	rm $TMP/gdplogd.service
142 34200e7f Eric Allman
	if $GDP_REST_INSTALL
143
	then
144
		info "gdp-rest.service ..."
145
		adm/customize.sh adm/gdp-rest.service.template /etc/systemd/system
146
	fi
147 45121ec5 Eric Allman
	systemctl daemon-reload
148 d17c1801 Eric Allman
	systemctl enable gdplogd$GDP_VER
149 34200e7f Eric Allman
	if $GDP_REST_INSTALL
150
	then
151
		systemctl enable gdp-rest
152
		warn "Startup scripts for gdp-rest are installed, but you will"
153
		warn "need to configure a web server to use the SCGI interface."
154
		warn "See README-CAAPI.md for advice."
155
	fi
156 3756d4ac Eric Allman
else
157
	warn "No system initialization configured"
158
fi