Skip to content

Commit 0dd6bb0

Browse files
authored
Create hestia service file
1 parent 914a742 commit 0dd6bb0

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

src/deb/nginx/hestia

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/sh
2+
3+
### BEGIN INIT INFO
4+
# Provides: hestia
5+
# internal nginx
6+
# internal php-fpm
7+
# Required-Start: $local_fs $remote_fs $network $syslog
8+
# Required-Stop: $local_fs $remote_fs $network $syslog
9+
# Default-Start: 2 3 4 5
10+
# Default-Stop: 0 1 6
11+
# Short-Description: starts the hestia control panel
12+
# Description: starts nginx and php-fpm using start-stop-daemon
13+
### END INIT INFO
14+
15+
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
16+
NGINX_DAEMON=/usr/local/hestia/nginx/sbin/hestia-nginx
17+
NGINX_NAME=hestia-nginx
18+
NGINX_DESC=hestia-nginx
19+
NGINX_PID=/var/run/hestia-nginx.pid
20+
21+
PHP_DAEMON=/usr/local/hestia/php/sbin/hestia-php
22+
PHP_NAME=hestia-php
23+
PHP_DESC=hestia-php
24+
PHP_PID=/var/run/hestia-php.pid
25+
PHP_CONF=/usr/local/hestia/php/etc/php-fpm.conf
26+
27+
set -e
28+
29+
. /lib/lsb/init-functions
30+
31+
. /etc/profile.d/hestia.sh
32+
33+
start_nginx() {
34+
start-stop-daemon --start --quiet --pidfile $NGINX_PID \
35+
--retry 5 --exec $NGINX_DAEMON --oknodo
36+
}
37+
38+
start_php() {
39+
start-stop-daemon --start --quiet --pidfile $PHP_PID \
40+
--retry 5 --exec $PHP_DAEMON --oknodo
41+
}
42+
43+
stop_nginx() {
44+
start-stop-daemon --stop --quiet --pidfile $NGINX_PID \
45+
--retry 5 --oknodo --exec $NGINX_DAEMON
46+
}
47+
48+
stop_php() {
49+
start-stop-daemon --stop --quiet --pidfile $PHP_PID \
50+
--retry 5 --oknodo --exec $PHP_DAEMON
51+
}
52+
53+
case "$1" in
54+
start)
55+
log_daemon_msg "Starting $NGINX_DESC" "$NGINX_NAME"
56+
start_nginx
57+
log_end_msg $?
58+
log_daemon_msg "Starting $PHP_DESC" "$PHP_NAME"
59+
start_php
60+
log_end_msg $?
61+
;;
62+
63+
stop)
64+
log_daemon_msg "Stopping $NGINX_DESC" "$NGINX_NAME"
65+
stop_nginx
66+
log_end_msg $?
67+
log_daemon_msg "Stopping $PHP_DESC" "$PHP_NAME"
68+
stop_php
69+
log_end_msg $?
70+
;;
71+
72+
restart|force-reload|reload|configtest|testconfig)
73+
log_daemon_msg "Restarting $NGINX_DESC" "$NGINX_NAME"
74+
stop_nginx
75+
stop_php
76+
sleep 1
77+
start_nginx
78+
log_end_msg $?
79+
log_daemon_msg "Restarting $PHP_DESC" "$PHP_NAME"
80+
start_php
81+
log_end_msg $?
82+
;;
83+
84+
status)
85+
status_of_proc -p $NGINX_PID "$NGINX_DAEMON" hestia-nginx
86+
status_of_proc -p $PHP_PID "$PHP_DAEMON" hestia-php
87+
;;
88+
89+
*)
90+
echo "Usage: hestia {start|stop|restart|status}" >&2
91+
exit 1
92+
;;
93+
esac
94+
95+
exit 0

0 commit comments

Comments
 (0)