summarylogtreecommitdiffstats
path: root/plptools.rcd
blob: 1f9be6cc1557157ea75e2751a205228611ca6a03 (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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
#
# plptools        Starts ncpd/plpfuse.
#
# chkconfig: 2345 45 10
# description: This facility enables connectivity to an EPOC PDA.

. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/plptools

NCPD_PIDFILE=/var/run/plptools/ncpd.pid
NCPD_PID=$(cat $NCPD_PIDFILE 2>/dev/null)
if ! readlink -q /proc/$NCPD_PID/exe | grep -q '^/usr/sbin/ncpd'; then
	NCPD_PID=
	rm $NCPD_PIDFILE 2>/dev/null
fi

PLPFUSE_PIDFILE=/var/run/plptools/plpfuse.pid
PLPFUSE_PID=$(cat $PLPFUSE_PIDFILE 2>/dev/null)
if ! readlink -q /proc/$PLPFUSE_PID/exe | grep -q '^/usr/sbin/plpfuse'; then
	PLPFUSE_PID=
	rm $PLPFUSE_PIDFILE 2>/dev/null
fi

PLPPRINTD_PIDFILE=/var/run/plptools/plpprintd.pid
PLPPRINTD_PID=$(cat $PLPPRINTD_PIDFILE 2>/dev/null)
if ! readlink -q /proc/$PLPPRINTD_PID/exe | grep -q '^/usr/sbin/plpprintd'; then
	PLPPRINTD_PID=
	rm $PLPPRINTD_PIDFILE 2>/dev/null
fi

start() {
	echo "Starting EPOC support ..."
	RETVAL=0
	if [ ! -x /var/run/plptools ] ; then
		install -m755 -d /var/run/plptools
	fi
	if test "$START_NCPD" = "yes" ; then
		stat_busy "  ncpd: "
		[[ -z $NCPD_PID ]] && /usr/sbin/ncpd $NCPD_ARGS
		if [[ $? -gt 0 ]]; then
			RETVAL=1
			stat_fail
		else
			PID=`pidof -o %PPID /usr/sbin/ncpd`
			echo $PID > $NCPD_PIDFILE 2>/dev/null
			add_daemon ncpd
			stat_done
		fi
	fi
        if [ $RETVAL -eq 0 ] ; then
		if test "$START_PLPFUSE" = "yes" ; then
			stat_busy "  plpfuse: "
			[[ -z $PLPFUSE_PID ]] && /usr/sbin/plpfuse $PLPFUSE_ARGS $PLPFUSE_MOUNTPOINT
			if [[ $? -gt 0 ]]; then
				RETVAL=1
				stat_fail
			else
				PID=`pidof -o %PPID /usr/sbin/plpfuse`
				echo $PID > $PLPFUSE_PIDFILE 2>/dev/null
				add_daemon plpfuse
				stat_done
			fi
		fi
	fi
	if [ $RETVAL -eq 0 ] ; then
		if test "$START_PLPPRINTD" = "yes" ; then
			stat_busy "  plpprintd: "
			[[ -z $PLPPRINTD_PID ]] && /usr/sbin/plpprintd $PLPPRINTD_ARGS
			if [[ $? -gt 0 ]]; then
				RETVAL=1
				stat_fail
			else
				PID=`pidof -o %PPID /usr/sbin/plpprintd`
				echo $PID > $PLPPRINTD_PIDFILE 2>/dev/null
				add_daemon plpprintd
				stat_done
			fi
		fi
	fi
	[ $RETVAL -eq 0 ] && touch /var/lock/plptools
}

stop() {
	echo "Stopping EPOC support ..."
	RETVAL=0
	if test "$START_PLPPRINTD" = "yes" ; then
		stat_busy "  plpprintd: "
		[[ ! -z $PLPPRINTD_PID ]] && kill $PLPPRINTD_PID &> /dev/null
		if [[ $? -gt 0 ]]; then
			stat_fail
		else
			rm $PLPPRINTD_PIDFILE &>/dev/null
			rm_daemon plpprintd
			stat_done
		fi
	fi
	if test "$START_PLPFUSE" = "yes" ; then
		stat_busy "  plpfuse: "
		[[ ! -z $PLPFUSE_PID ]] && fusermount -u $PLPFUSE_MOUNTPOINT &> /dev/null
		if [[ $? -gt 0 ]]; then
			stat_fail
		else
			rm $PLPFUSE_PIDFILE &>/dev/null
			rm_daemon plpfuse
			stat_done
		fi
	fi
	if test "$START_NCPD" = "yes" ; then
		stat_busy "  ncpd: "
		[[ ! -z $NCPD_PID ]] && kill $NCPD_PID &> /dev/null
		if [[ $? -gt 0 ]]; then
			RETVAL=1
			stat_fail
		else
			rm $NCPD_PIDFILE &>/dev/null
			rm_daemon ncpd
			stat_done
		fi
		echo
	fi
	[ $RETVAL -eq 0 ] && rm -f /var/lock/plptools
}

restart() {
	stop
	start
}

# See how we were called.
case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  status)
	status ncpd
	status plpprintd
	;;
  restart|reload)
  	restart
	;;
  condrestart)
  	test -f /var/lock/plptools && restart || :
	;;
  *)
	echo "Usage: plptools {start|stop|status|restart|reload|condrestart}"
esac
exit 0