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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#!/bin/sh
### BEGIN INIT INFO
# Provides: landscape-client
# Required-Start: $local_fs $remote_fs hal dbus
# Required-Stop: $local_fs $remote_fs hal dbus
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Landscape client daemons
# Description: The Landscape client daemons are needed so the
# Landscape server can manage a computer.
### END INIT INFO
LANDSCAPE_DEFAULTS=/etc/default/landscape-client
NAME=landscape-client
DAEMON=/usr/bin/$NAME
PIDDIR=/var/run/landscape
PIDFILE=$PIDDIR/$NAME.pid
RUN=0 # overridden in /etc/default/landscape-client
CLOUD=0 # overridden in /etc/default/landscape-client
DAEMON_GROUP=landscape
[ -f $DAEMON ] || exit 0
. /lib/lsb/init-functions
[ -f $LANDSCAPE_DEFAULTS ] && . $LANDSCAPE_DEFAULTS
check_config () {
# This $RUN check should match the semantics of
# l.sysvconfig.SysVConfig.is_configured_to_run.
if [ $RUN -eq 0 ]; then
if [ $CLOUD -eq 1 ]; then
if landscape-is-cloud-managed; then
# Install the cloud default configuration file
cp /usr/share/landscape/cloud-default.conf /etc/landscape/client.conf
# Override default file for not going in this conditional again at
# next startup
sed -i "s/^RUN=.*/RUN=1/" $LANDSCAPE_DEFAULTS
if ! grep -q "^RUN=" $LANDSCAPE_DEFAULTS; then
echo "RUN=1" >> $LANDSCAPE_DEFAULTS
fi
else
echo "$NAME is not configured, please run landscape-config."
exit 0
fi
else
echo "$NAME is not configured, please run landscape-config."
exit 0
fi
fi
}
case "$1" in
start)
check_config
log_daemon_msg "Starting the $NAME daemon"
if [ ! -e $PIDDIR ]; then
mkdir $PIDDIR
chown landscape $PIDDIR
fi
FULL_COMMAND="start-stop-daemon --start --quiet --oknodo --startas $DAEMON --pidfile $PIDFILE -g $DAEMON_GROUP -- --daemon --pid-file $PIDFILE"
if [ x"$DAEMON_USER" != x ]; then
sudo -u $DAEMON_USER $FULL_COMMAND
else
$FULL_COMMAND
fi
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping $NAME daemon"
start-stop-daemon --retry 30 --stop --quiet --pidfile $PIDFILE
log_end_msg $?
;;
status)
# We want to maintain backward compatibility with Dapper,
# so we're not going to use status_of_proc()
pidofproc -p $PIDFILE $DAEMON >/dev/null
status=$?
if [ $status -eq 0 ]; then
log_success_msg "$NAME is running"
else
log_failure_msg "$NAME is not running"
fi
exit $status
;;
restart|force-reload)
$0 stop && $0 start
;;
*)
echo "Usage: $0 {start|stop|status|restart|force-reload}"
exit 1
;;
esac
exit 0
|