File: 4store.init

package info (click to toggle)
4store 1.1.6+20151109-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 82,388 kB
  • sloc: ansic: 65,689; sh: 2,916; perl: 2,245; makefile: 281; python: 213
file content (94 lines) | stat: -rw-r--r-- 2,617 bytes parent folder | download
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
#!/bin/bash
#
### BEGIN INIT INFO
# Provides:          4store
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Should-Start:      $network $syslog avahi-daemon
# Should-Stop:       $network $syslog avahi-daemon
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start and stop the 4store database server daemon
# Description:       Controls the 4store database server daemon "4s-httpd"
### END INIT INFO
#
set -e
set -u
${DEBIAN_SCRIPT_DEBUG:+ set -v -x}

DAEMON1=/usr/bin/4s-backend
DAEMON2=/usr/bin/4s-httpd

test -x $DAEMON1 || exit 5
test -x $DAEMON2 || exit 5

# Default knowledge base
KB="default"
# Default port
PORT="9000"
# Default user
USER=fourstore

if [ -r /etc/default/4store ]; then
        . /etc/default/4store
fi

. /lib/lsb/init-functions

# Safeguard (relative paths, core dumps..)
cd /
umask 077


case "$1" in
	start)
		mkdir -p -m 0755 /var/lib/4store /var/log/4store
		# Refresh ownership, avoiding "chown -R" hardlink attacks
		find /var/lib/4store /var/log/4store \( \( -type d -links 2 \) -o \( -type f -links 1 \) \) -execdir chown "$USER": {} +

		if [ ! -d "/var/lib/4store/$KB" ]; then
			log_warning_msg "Creating missing default knowledge base"
			su - fourstore -s /bin/sh -c "4s-backend-setup '$KB'" &>/dev/null \
				|| log_failure_msg "Failed creating default knowledge base \"$KB\""
		fi

		log_daemon_msg "Starting 4s-backend" "4s-backend"
		start-stop-daemon --start --chuid $USER --quiet --oknodo --name 4s-backend --startas $DAEMON1 -- $KB
		status=$?
		log_end_msg $status
		log_daemon_msg "Starting 4s-httpd" "4s-httpd"
		start-stop-daemon --start --chuid $USER --quiet --oknodo --name 4s-httpd --startas $DAEMON2 -- -p $PORT $KB
		status=$?
		log_end_msg $status
		;;
	stop)
		log_daemon_msg "Stopping 4s-httpd" "4s-httpd"
		start-stop-daemon --stop --quiet --oknodo --name 4s-backend
		log_end_msg $?
		log_daemon_msg "Stopping 4s-backend" "4s-backend"
		start-stop-daemon --stop --quiet --oknodo --name 4s-httpd
		log_end_msg $?
		;;
        restart|force-reload)
                $0 stop && sleep 2 && $0 start
                ;;
        try-restart)
                if $0 status >/dev/null; then
                        $0 restart
                else
                        exit 0
                fi
                ;;
        reload)
                exit 3
                ;;
        status)
                status_of_proc $DAEMON1 "4s-backend server"
                ;;
        *)
                echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
                exit 2
                ;;
esac

exit 0