File: whereami.init

package info (click to toggle)
whereami 0.3.34-0.4
  • links: PTS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 424 kB
  • ctags: 33
  • sloc: sh: 1,103; perl: 524; makefile: 82
file content (60 lines) | stat: -rwxr-xr-x 1,638 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
#!/bin/sh
#
# Start or stop 'whereami'
#
### BEGIN INIT INFO
# Provides:          whereami
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Autoconfigure computer according to defined rules
# Description:       Using a variety of techniques this will ascertain
#                    the computer's location on the network, in the 
#                    docking station and so forth and configure things
#                    appropriately.
### END INIT INFO
#
# Andrew McMillan <Andrew@cat-it.co.nz>
#

test -x /usr/sbin/whereami || exit 0


case "$1" in
    start|restart|force-reload|reload)
        if [ ! -d /var/run/whereami ] ; then
            mkdir /var/run/whereami
        fi
    	echo -n "Where Am I: "
      # Find actual whereami
      ACTUAL_WHEREAMI=`readlink /usr/sbin/whereami`
      
      if [ "$ACTUAL_WHEREAMI" = "/usr/sbin/whereami.sh" ]; then
        # The old shell script took no parameters
        start-stop-daemon --start --quiet --exec /usr/sbin/whereami
      else
        # Use new format
        start-stop-daemon --start --quiet --exec /usr/sbin/whereami -- --run_from init --syslog --hint netstart
      fi
    ;;

    stop)
      if [ "$ACTUAL_WHEREAMI" != "/usr/sbin/whereami.sh" ]; then
        # Use new format
        start-stop-daemon --start --quiet --exec /usr/sbin/whereami -- --run_from init --syslog shutdown
      fi
    ;;

    status)
      cat /var/lib/whereami/iam
    ;;


    *)
	echo "Usage: /etc/init.d/whereami {start|stop|restart|force-reload}" >&2
	exit 1
    ;;
esac

exit 0