aboutsummaryrefslogtreecommitdiff
path: root/buildtools/debian-skeleton/rpki-ca.upstart
blob: 7b1b6611b4a1b7fd328d18e26f55efaaeb1f6f17 (plain) (blame)
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
# RPKI CA Service

description     "RPKI CA Servers"
author		"Rob Austein <sra@hactrn.net>"

# This is almost certainly wrong.  Suggestions on how to improve this
# welcome, but please first read the Python code to understand what it
# is doing.

# Our only real dependencies are on our SQL engine and our config file.
#
# Unfortunately, the switch to postgresql means we can't use a straightforward
# upstart dependency here, because postgresql uses an old-style init.d script.
# But everybody is moving to systemd, so we're going to have to rewrite this
# in any case.

# FWIW, "/etc/init.d/postgres status" returns a status line ending in "online"
# when the server is up, "down" when the server is down, and perhaps other values
# under stranger circumstances.

#start on started mysql
#stop on stopping mysql

start on runlevel [2345]
stop on runlevel [!2345]

pre-start script
    if  test -f /etc/rpki.conf &&
	test -f /usr/share/rpki/ca.cer &&
	test -f /usr/share/rpki/irbe.cer &&
	test -f /usr/share/rpki/irdbd.cer &&
	test -f /usr/share/rpki/rpkid.cer &&
	test -f /usr/share/rpki/rpkid.key
    then
        install -m 755 -o rpkid -g rpkid -d /var/run/rpki /usr/share/rpki/publication

	# This should be running as user rpkid, but I haven't got all
	# the pesky details worked out yet.  Most testing to date has
	# either been all under a single non-root user or everything
	# as root, so, eg, running "rpkic initialize" as root will not
	# leave things in a sane state for rpkid running as user
	# rpkid.
	#
	# In the interest of debugging the rest of this before trying
	# to break new ground, run daemons as root for the moment,
	# with the intention of coming back to fix this later.
	#
	#sudo -u rpkid /usr/sbin/rpki-start-servers
	/usr/sbin/rpki-start-servers

    else
	stop
	exit 0
    fi
end script

post-stop script
    for i in rpkid pubd irdbd rootd
    do
	if test -f /var/run/rpki/$i.pid
	then
	    kill `cat /var/run/rpki/$i.pid`
	fi
    done
end script