forked from styxit/HTPC-Manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
initd.fedora
78 lines (71 loc) · 2.18 KB
/
initd.fedora
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
#! /bin/sh
### BEGIN INIT INFO
# Provides: HTPC-Manager application instance
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts instance of HTPC-Manager
# Description: starts instance of HTPC-Manager
### END INIT INFO
# Source function library.
. /etc/init.d/functions
############### How to ##################
#Copy this file to your /etc/init.d/htpc or whatever you would like to name it.
#Ensure file is executable "chmod +x htpc".
#Edit the fields in the EDIT ME section below for your preferences.
#Enable services at startup by "chkconfig htpc on" or "systemctl enable htpc"
############### EDIT ME ##################
# PID & Lock. Change if you would like your lock/pid elsewhere.
PID_FILE=/var/run/htpcmanager.pid
LOCK_FILE=/var/lock/subsys/${NAME}
# path to app
APP_PATH=APPPATH_GOES_HERE
# path to python bin (must be changed to python, use which python to find path)
DAEMON=PATH_TO_PYTHON
# startup args
# Script that will be ran, doesn't need to be changed
DAEMON_OPTS="Htpc.py"
# Options you wish to use, OK to change these items however PID is needed for stopping and restarting. Leave the space at the beginning.
OPTIONS=" --daemon --pid=$PID_FILE"
# script name (doesn't need to be changed)
NAME=htpc
# app name
DESC=HTPC-Manager
# User you want to run service as
RUN_AS=RUNAS_USER
############### END EDIT ME ##################
start() {
echo "Starting $DESC: "
touch ${PID_FILE}
daemon --user=${RUN_AS} --pidfile=${PID_FILE} python ${APP_PATH}/${DAEMON_OPTS}${OPTIONS}
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch ${LOCK_FILE}
return $RETVAL
}
stop() {
echo "Stopping $DESC: "
killproc -p ${PID_FILE} python
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f ${LOCK_FILE}
return $RETVAL
}
# How we will call the options
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|force-reload}"
exit 2
esac
exit 0