4
# Provides: landscape-client
5
# Required-Start: $local_fs $remote_fs
6
# Required-Stop: $local_fs $remote_fs
7
# Default-Start: 2 3 4 5
9
# Short-Description: Landscape client daemons
10
# Description: The Landscape client daemons are needed so the
11
# Landscape server can manage a computer.
14
LANDSCAPE_DEFAULTS=/etc/default/landscape-client
17
PIDDIR=/var/run/landscape
18
SOCKETDIR=/var/lib/landscape/client/sockets
19
PIDFILE=$PIDDIR/$NAME.pid
20
RUN=0 # overridden in /etc/default/landscape-client
21
CLOUD=0 # overridden in /etc/default/landscape-client
22
DAEMON_GROUP=landscape
23
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
25
[ -f $DAEMON ] || exit 0
27
. /lib/lsb/init-functions
28
[ -f $LANDSCAPE_DEFAULTS ] && . $LANDSCAPE_DEFAULTS
31
# This $RUN check should match the semantics of
32
# l.sysvconfig.SysVConfig.is_configured_to_run.
33
if [ $RUN -eq 0 ]; then
34
echo "$NAME is not configured, please run landscape-config."
42
log_daemon_msg "Starting the $NAME daemon"
43
if [ ! -e $PIDDIR ]; then
45
chown landscape $PIDDIR
47
# Cleanup leftover sockets if there's no other landscape process
48
# running. This shouldn't be usually necessary, but it can
49
# happen in case the client crashed badly and the socket points
50
# to a process with the same PID.
51
if [ -d "${SOCKETDIR:?}" ]; then
52
if ! pidofproc -p "$PIDFILE" "$DAEMON" > /dev/null; then
53
find "${SOCKETDIR:?}" -maxdepth 1 -type s -print0 | xargs -r0 rm -f
54
find "${SOCKETDIR:?}" -maxdepth 1 -type l -print0 | xargs -r0 rm -f
58
FULL_COMMAND="start-stop-daemon --start --quiet --oknodo --startas $DAEMON --pidfile $PIDFILE -g $DAEMON_GROUP -- --daemon --pid-file $PIDFILE"
59
if [ x"$DAEMON_USER" != x ]; then
60
sudo -u $DAEMON_USER $FULL_COMMAND
68
log_daemon_msg "Stopping $NAME daemon"
69
start-stop-daemon --retry 30 --stop --quiet --pidfile $PIDFILE
74
# We want to maintain backward compatibility with Dapper,
75
# so we're not going to use status_of_proc()
76
pidofproc -p $PIDFILE $DAEMON >/dev/null
78
if [ $status -eq 0 ]; then
79
log_success_msg "$NAME is running"
81
log_failure_msg "$NAME is not running"
91
echo "Usage: $0 {start|stop|status|restart|force-reload}"