File: martian

package info (click to toggle)
martian-modem 20080625-2
  • links: PTS
  • area: non-free
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 1,048 kB
  • ctags: 985
  • sloc: ansic: 6,095; sh: 298; makefile: 236
file content (84 lines) | stat: -rwxr-xr-x 1,525 bytes parent folder | download | duplicates (3)
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
#!/bin/bash
#
# Init file for martian_modem
#
# chkconfig: 2345 45 60
# description: martian_modem
#
# processname: martian_modem
#
### BEGIN INIT INFO
# Provides: martian_modem
# Default-Start: 2 3 4 5
# Short-Description: martian_modem
# Description: martian_modem
# Author: Stefan Puch
# Adjustments for 2006/11 release A. Chentsov
### END INIT INFO

#VPNCLIENT="/opt/cisco-vpnclient/bin/vpnclient"
NAME="martian_modem"
MARTIANMOD="martian_dev"
USER_DRIVER="/usr/sbin/martian_modem"

# edit to set other name
DEVICE="/dev/ttySM0"

if [ `/sbin/lsmod | grep -c ${MARTIANMOD}` -lt "1" ]; then
	echo "kernel module is not loaded!"
	exit 0
fi



# See how we were called.
case "$1" in
  start)
	echo -n "Starting ${NAME}: "
	if [ `ps -A | grep -c ${NAME}` -gt "0" ]; then
		echo "${NAME} is already running. Use restart instead."
		exit 1
	fi

	if [ ${DEVICE} != "/dev/ttySM0" ]; then
		ARGDEV=${DEVICE}
	else
		ARGDEV=
	fi
	/usr/sbin/martian_modem --daemon ${ARGDEV}
	echo "Done"
	;;
  stop)
	echo -n "Shutting down ${NAME}: "
	if [ `ps -A | grep -c "martian_modem"` -lt "1" ]; then
		echo "${NAME} is not running."
		exit 1
	fi
	PID=`/sbin/pidof ${NAME}`

	# cease now
	/bin/kill ${PID}

	if [ -L ${DEVICE} ]; then
		rm -f ${DEVICE}
	fi
	echo "Done"
	;;
  status)
	PID=`/sbin/pidof ${NAME}`
	if [ -n "${PID}" ] ; then
		echo ${NAME} "(PID ${PID}) is running..."
	else 
		echo ${NAME} "is stopped"
	fi
	;;
  restart|reload)
	$0 stop
	$0 start
	;;
  *)
	echo "Usage: $0 {start|stop|restart|reload|status}"
	exit 1
esac

exit 0