#!/bin/sh
### BEGIN INIT INFO
# Provides: AirVideoServerHD
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start AirVideoServer HD
### END INIT INFO
USERID=kindtito
USERGID=kindtito
AIRVIDEO_DIR=/etc/airvideoHD/AirVideoServerHD
SERVER=$AIRVIDEO_DIR/AirVideoServerHD
OPTIONS=”–config=Server.properties”
PIDFILE=/var/run/airvideoserverhd.pid
DBUS_SOCKET=/var/run/dbus/system_bus_socket
# See if the server is there
test -x $SERVER || exit 0
. /lib/lsb/init-functions
case $1 in
start)
if init_is_upstart; then
exit 1
fi
echo “Starting AirVideo” AirVideoServerHD
export DBUS_SYSTEM_BUS_ADDRESS=unix:path=$DBUS_SOCKET
if ! start-stop-daemon -d $AIRVIDEO_DIR -m -b –chuid $USERID:$USERGID –start –quiet –oknodo –pidfile $PIDFILE –exec $SERVER — $OPTIONS
then
log_end_msg 1
exit 1
fi
log_end_msg 0
;;
stop)
if init_is_upstart; then
exit 0
fi
echo “Stopping AirVideo name server” AirVideoServerHD
start-stop-daemon –stop –quiet –user $USERID –pidfile $PIDFILE –exec $SERVER
rm -f $PIDFILE
log_end_msg 0
;;
restart|force-reload)
if init_is_upstart; then
exit 1
fi
$0 stop
sleep 1
$0 start
;;
status)
status_of_proc -p $PIDFILE $SERVER AirVideoServer
exit $?
;;
*)
echo “Usage: /etc/init.d/airvideo {start|stop|restart|force-reload|status}”
exit 1
;;
esac
////////////////////////////////////////////////////////////
우분투에서는 아래처럼
#!/bin/sh
### BEGIN INIT INFO
# Provides: AirVideoServerHD
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start AirVideoServer HD
### END INIT INFO
USERID=kindtito
USERGID=kindtito
AIRVIDEO_DIR=/usr/local/share/AirVideoServerHD
SERVER=$AIRVIDEO_DIR/AirVideoServerHD
OPTIONS=”–config=Server.properties”
PIDFILE=/var/run/airvideoserverhd.pid
DBUS_SOCKET=/var/run/dbus/system_bus_socket
# See if the server is there
test -x $SERVER || exit 0
. /lib/lsb/init-functions
case $1 in
start)
if init_is_upstart; then
exit 1
fi
echo “Starting AirVideo” AirVideoServerHD
export DBUS_SYSTEM_BUS_ADDRESS=unix:path=$DBUS_SOCKET
if ! start-stop-daemon -d $AIRVIDEO_DIR -m -b –chuid $USERID:$USERGID –start –quiet –oknodo –pidfile $PIDFILE –exec $SERVER — $OPTI$
then
log_end_msg 1
exit 1
fi
log_end_msg 0
;;
stop)
if init_is_upstart; then
exit 0
fi
echo “Stopping AirVideo name server” AirVideoServerHD
start-stop-daemon –stop –quiet –user $USERID –pidfile $PIDFILE –exec $SERVER
rm -f $PIDFILE
log_end_msg 0
;;
restart|force-reload)
if init_is_upstart; then
exit 1
fi
$0 stop
sleep 1
$0 start
;;
status)
status_of_proc -p $PIDFILE $SERVER AirVideoServer
status_of_proc -p $PIDFILE $SERVER AirVideoServer
exit $?
;;
*)
echo “Usage: /etc/init.d/airvideo {start|stop|restart|force-reload|status}”
exit 1
;;
esac
그다음
chmod +x airvideo
sudo chmod 755 /etc/init.d/airvideo
sudo chown root: /etc/init.d/airvideo
sudo update-rc.d airvideo defaults
sudo /etc/init.d/airvideo start
아래처럼 되면 완성
[ ok ] Starting airvideo (via systemctl): airvideo.service.
그럼 끝