summaryrefslogtreecommitdiff
path: root/www-apps/octoprint/files/octoprint.initd
blob: 6a4e648e29fc53e9d4ce590cce1d3baffce84916 (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
#!/sbin/openrc-run
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

PIDFILE="/run/octoprint/octoprint.pid"

depend() {
	need net
}

start() {
	ebegin "Starting OctoPrint"

	checkpath -q -d -o ${OCTOPRINT_USER}:${OCTOPRINT_GROUP} -m 0770 "$(dirname "${PIDFILE}")"

	start-stop-daemon \
		--quiet \
		--start \
		--user ${OCTOPRINT_USER} \
		--group ${OCTOPRINT_GROUP} \
		--background --make-pidfile \
		--pidfile "${PIDFILE}" \
		--wait 1000 \
		--nicelevel -2 \
		--ionice 1 \
		--exec /usr/bin/octoprint serve 

	eend $?
}

stop() {
	ebegin "Stopping OctoPrint"

	start-stop-daemon \
		--stop \
		--pidfile "${PIDFILE}" 

	eend $?
}