add systemd unit file and update install to use it

This commit is contained in:
Sispheor 2015-06-24 20:28:38 +02:00
parent 01c35b4745
commit 13913709d4
2 changed files with 29 additions and 7 deletions

25
tools/install.sh Normal file → Executable file
View File

@ -9,14 +9,22 @@ if [ ! -z "$1" ]; then
# Copy arkdaemon to /etc/init.d ,set permissions and add it to boot # Copy arkdaemon to /etc/init.d ,set permissions and add it to boot
if [ -f /lib/lsb/init-functions ]; then if [ -f /lib/lsb/init-functions ]; then
cp lsb/arkdaemon "${INSTALL_ROOT}/etc/init.d/arkmanager" # on debian 8, sysvinit and systemd are present. If systemd is available we use it instead of sysvinit
chmod +x "${INSTALL_ROOT}/etc/init.d/arkmanager" if [[ -f /etc/systemd/system.conf ]]; then # used by systemd
sed -i "s|^DAEMON=\"/usr|DAEMON=\"${EXECPREFIX}|" "${INSTALL_ROOT}/etc/init.d/arkmanager" cp systemd/arkdeamon.service /etc/systemd/system/arkdaemon.service
# add to startup if the system use sysinit systemctl enable arkdeamon.service
if [ -x /usr/sbin/update-rc.d -a -z "${INSTALL_ROOT}" ]; then
update-rc.d arkmanager defaults
echo "Ark server will now start on boot, if you want to remove this feature run the following line" echo "Ark server will now start on boot, if you want to remove this feature run the following line"
echo "update-rc.d -f arkmanager remove" echo "systemctl disable unit"
else # systemd not present, so use sysvinit
cp lsb/arkdaemon "${INSTALL_ROOT}/etc/init.d/arkmanager"
chmod +x "${INSTALL_ROOT}/etc/init.d/arkmanager"
sed -i "s|^DAEMON=\"/usr|DAEMON=\"${EXECPREFIX}|" "${INSTALL_ROOT}/etc/init.d/arkmanager"
# add to startup if the system use sysinit
if [ -x /usr/sbin/update-rc.d -a -z "${INSTALL_ROOT}" ]; then
update-rc.d arkmanager defaults
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
echo "update-rc.d -f arkmanager remove"
fi
fi fi
elif [ -f /etc/rc.d/init.d/functions ]; then elif [ -f /etc/rc.d/init.d/functions ]; then
cp redhat/arkdaemon "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager" cp redhat/arkdaemon "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager"
@ -36,6 +44,9 @@ if [ ! -z "$1" ]; then
echo "Ark server will now start on boot, if you want to remove this feature run the following line" echo "Ark server will now start on boot, if you want to remove this feature run the following line"
echo "rc-update del arkmanager default" echo "rc-update del arkmanager default"
fi fi
elif [[ /etc/systemd/system.conf ]]; then # used by systemd
cp systemd/arkdeamon.service /etc/systemd/system/arkdaemon.service
systemctl enable arkdeamon.service
fi fi
# Create a folder in /var/log to let Ark tools write its own log files # Create a folder in /var/log to let Ark tools write its own log files

View File

@ -0,0 +1,11 @@
[Unit]
Description=Daemon to start ark server
After=network.target
[Service]
ExecStart=/etc/init.d/arkdaemon start
ExecStop=/etc/init.d/arkdaemon stop
Type=forking
[Install]
WantedBy=multi-user.target