Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (3.76 KB)

1
#!/bin/sh
2

    
3
#
4
#  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
#
24

    
25
args=`getopt i $*`
26
if [ $? != 0 ]
27
then
28
	echo "Usage: $0 [-i]"
29
	exit 1
30
fi
31

    
32
eval set -- "$args"
33
moreargs=true
34
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
# we assume this is in the adm directory
53
cd `dirname $0`/..
54
GDP_SRC_ROOT=`pwd`
55
TMP=/tmp
56
. adm/common-support.sh
57

    
58
## compile code and utilities, possibly not as root
59
info "Compiling GDP code and utilities"
60
make
61
(cd util && make)
62

    
63
## 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
. adm/gdp-version.sh
70
: ${GDP_VER=$GDP_VERSION_MAJOR}
71
: ${GDPLOGD_LOG:=$GDP_LOG_DIR/gdplogd.log}
72
: ${GDPLOGD_BIN:=$GDP_ROOT/sbin/gdplogd$GDP_VER}
73
: ${GDP_REST_INSTALL:=false}
74
export GDP_VER
75

    
76
echo "Installing gdplogd:"
77
(cd $GDP_SRC_ROOT/gdplogd && make install)
78

    
79
echo "Making server-specific directories"
80
mkdir_gdp $GDP_LOG_DIR
81
mkdir_gdp $GDP_VAR
82
mkdir_gdp $GDPLOGD_DATADIR 0750
83
mkdir_gdp /var/swarm
84
mkdir_gdp /var/swarm/gdp
85
mkdir_gdp /var/swarm/gdp/glogs
86

    
87
mkfile_gdp $GDPLOGD_LOG
88
mkfile_gdp $GDP_REST_LOG
89

    
90
info "Creating $EP_PARAMS/gdplogd"
91
{
92
	echo "swarm.gdplogd.gdpname=edu.berkeley.eecs.$hostname.gdplogd.physical"
93
	echo "swarm.gdplogd.runasuser=gdp"
94
} > $TMP/gdplogd.params
95
if [ ! -f $EP_PARAMS/gdplogd ]
96
then
97
	cp $TMP/gdplogd.params $EP_PARAMS/gdplogd
98
	chown ${GDP_USER}:${GDP_GROUP} $EP_PARAMS/gdplogd
99
	cat $EP_PARAMS/gdplogd
100
elif cmp -s $TMP/gdplogd.params $EP_PARAMS/gdplogd
101
then
102
	rm $TMP/gdplogd.params
103
else
104
	warn "$EP_PARAMS/gdplogd already exists; check consistency" 1>&2
105
	diff -u $TMP/gdplogd.params $EP_PARAMS/gdplogd
106
fi
107

    
108
info "Installing utility programs"
109
cd $GDP_SRC_ROOT
110
(cd util && make install)
111

    
112
info "Installing gdplogd wrapper script"
113
install -o ${GDP_USER} adm/gdplogd-wrapper.sh \
114
	$GDP_ROOT/sbin/gdplogd${GDP_VER}-wrapper.sh
115

    
116
if $GDP_REST_INSTALL
117
then
118
	info "Installing gdp-rest wrapper script"
119
	install -o ${GDP_USER} adm/gdp-rest-wrapper.sh $GDP_ROOT/sbin/gdp-rest${GDP_VER}-wrapper.sh
120
fi
121

    
122
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
if [ -d /etc/logrotate.d ]
130
then
131
	info "Installing logrotate configuration"
132
	cp adm/gdp-logrotate.conf /etc/logrotate.d/gdp
133
fi
134

    
135
if [ "$INITSYS" = "systemd" ]
136
then
137
	info "Installing and enabling systemd service files"
138
	info "gdplogd.service ..."
139
	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
	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
	systemctl daemon-reload
148
	systemctl enable gdplogd$GDP_VER
149
	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
else
157
	warn "No system initialization configured"
158
fi