summaryrefslogtreecommitdiff
path: root/iiod/init/iiod.init.cmakein
blob: 27999256ddab6de2ec5380df863d238bbd7580e0 (plain)
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
#!/bin/sh
#
### BEGIN INIT INFO
# Provides:          iiod
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: IIO Daemon
### END INIT INFO
# Debian init.d script for the IIO Daemon
# Copyright (C) 2016 Analog Devices Inc.

. /lib/lsb/init-functions

# Server-side demuxing by default
IIOD_OPTS=-D

if test -f /etc/default/iiod; then
    . /etc/default/iiod
fi

case "$1" in
	start)
		log_daemon_msg "Starting IIO Daemon" "iiod" || true
		if start-stop-daemon -S -b -q -m -p /var/run/iiod.pid -x @CMAKE_INSTALL_FULL_SBINDIR@/iiod -- $IIOD_OPTS; then
			log_end_msg 0 || true
		else
			log_end_msg 1 || true
		fi
		;;

	stop)
		log_daemon_msg "Stopping IIO Daemon" "iiod" || true
		if start-stop-daemon -K -q -p /var/run/iiod.pid; then
			log_end_msg 0 || true
		else
			log_end_msg 1 || true
		fi
		;;

	restart|force-reload)
		$0 stop
		$0 start
		;;

	status)
		if [ -f /var/run/iiod.pid ] ; then
			status_of_proc -p /var/run/iiod.pid @CMAKE_INSTALL_FULL_SBINDIR@/iiod iiod && exit 0 || exit $?
		else
			status_of_proc @CMAKE_INSTALL_FULL_SBINDIR@/iiod iiod && exit 0 || exit $?
		fi
		;;

	*)
		log_action_msg "Usage: /etc/init.d/iiod.sh {start|stop|restart|status}" || true
		exit 1
esac

exit 0