File: plptools.init

package info (click to toggle)
plptools 1.0.13-2
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye
  • size: 4,476 kB
  • sloc: ansic: 17,622; sh: 12,838; cpp: 12,823; makefile: 650; yacc: 291; sed: 16
file content (108 lines) | stat: -rw-r--r-- 2,830 bytes parent folder | download | duplicates (5)
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
100
101
102
103
104
105
106
107
108
#!/bin/bash
### BEGIN INIT INFO
# Provides:          plptools
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start or stop the plptools daemons
# Description:       Enable EPOC communication, file system and printing services
### END INIT INFO


PATH=/sbin:/bin:/usr/sbin:/usr/bin
NCPD=/usr/sbin/ncpd
PLPFUSE=/usr/sbin/plpfuse
PLPPRINTD=/usr/sbin/plpprintd
NAME=plptools
DESC=plptools
CONFIG=/etc/default/plptools
MOUNTPOINT=/var/lib/plptools/mnt

test -x $NCPD || exit 0
test -x $PLPFUSE || exit 0
test -x $PLPPRINTD || exit 0
test -f $CONFIG && . $CONFIG || exit 0

. /lib/lsb/init-functions

set -e

plptools-run-daemon () {
    daemon=$1
    shift
    # Get rid of empty first argument caused by leading white space or empty arguments
    if test "$1" = ""; then shift; fi
    echo -n "Starting $DESC ($daemon): "
    start-stop-daemon --start --quiet \
	--exec "$daemon" -- "$@" && \
	echo -n "done" || echo -n "failed"
    echo "."
}

case "$1" in
    start)
	if test "$START_NCPD" = "yes" ; then
	    plptools-run-daemon "$NCPD" "${NCPD_ARGS[@]}"
	    sleep 1
	fi
	if test "$START_PLPFUSE" = "yes" ; then
	    plptools-run-daemon "$PLPFUSE" "${PLPFUSE_ARGS[@]}" "$MOUNTPOINT"
	fi
	if test "$START_PLPPRINTD" = "yes" ; then
	    plptools-run-daemon "$PLPPRINTD" "${PLPPRINTD_ARGS[@]}"
	fi
	;;
    stop)
	if test "$START_PLPFUSE" = "yes" ; then
	    echo -n "Stopping $DESC ($PLPFUSE): "
	    if [ "$(uname)" = Linux ]; then
		fusermount -z -u "$MOUNTPOINT" || true
	    elif [ "$(uname)" = GNU/kFreeBSD ]; then
		umount "$MOUNTPOINT" || true
	    else
		echo "I don't know how to unmount a FUSE filing system on this OS" >&2
		exit 1
	    fi
	    start-stop-daemon --stop --retry HUP/5/TERM/1 --quiet \
		--exec "$PLPFUSE" && \
		echo -n "done" || echo -n "already stopped"
	    echo "."
	fi
	if test "$START_PLPPRINTD" = "yes" ; then
	    echo -n "Stopping $DESC ($PLPPRINTD): "
	    start-stop-daemon --stop --quiet --exec "$PLPPRINTD" && \
		echo -n "done" || echo -n "already stopped"
	    echo "."
	fi
	if test "$START_NCPD" = "yes" ; then
	    echo -n "Stopping $DESC ($NCPD): "
	    start-stop-daemon --stop --quiet --exec "$NCPD" && \
		echo -n "done" || echo -n "already stopped"
	    echo "."
	    sleep 5 # in case we're restarted immediately afterwards
	fi
	;;
    restart|force-reload)
	$0 stop
	$0 start
	;;
    status)
	if "$START_NCPD" = "yes" ; then
	    status_of_proc "$NCPD" ncpd || exit $?
	fi
	if "$START_PLPFUSE" = "yes" ; then
	    status_of_proc "$PLPFUSE" plpfuse || exit $?
	fi
	if "$START_PLPPRINTD" = "yes" ; then
	    status_of_proc "$PLPPRINTD" plpprintd || exit $?
	fi
	;;
    *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0