2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 19:04:20 +00:00

contrib/DEBIAN: use systemd or sysvinit for autostart

git-svn-id: https://svn.fhem.de/fhem/trunk@15697 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
betateilchen 2017-12-26 20:36:30 +00:00
parent 93d11754b0
commit 56e98c3128
3 changed files with 45 additions and 25 deletions

View File

@ -1,12 +1,10 @@
#!/bin/bash
# $Id$
set -e
#set -x
if ! getent passwd fhem >/dev/null; then
user_exists=$(id -u fhem > /dev/null 2>&1; echo $?)
if [ "$user_exists" -eq "1" ]; then
echo "creating user fhem"
useradd --system --home /opt/fhem --gid dialout --shell /bin/false fhem
fi
@ -16,14 +14,27 @@ chown -R fhem:dialout /opt/fhem
sed -i /debian.fhem.de/d /etc/apt/sources.list
# set up of autostart
# Sysvinit; upstart no longer supported
# systemd: supported
# sysvinit: supported
# upstart: not supported
#mkdir -p /etc/init.d
cp /opt/fhem/contrib/init-scripts/fhem.3 /etc/init.d/fhem
chmod ugo+x /etc/init.d/fhem
update-rc.d fhem defaults
# detect init system
test=$(stat /sbin/init |grep "File")
re="systemd$"
if test -f /etc/init.d/fhem; then
if [[ $test =~ $re ]];
then
cp /opt/fhem/contrib/init-scripts/fhem.service /etc/systemd/system
systemctl daemon-reload
systemctl enable fhem.service
systemctl start fhem.service
else
cp /opt/fhem/contrib/init-scripts/fhem.3 /etc/init.d/fhem
chmod ugo+x /etc/init.d/fhem
update-rc.d fhem defaults
if test -f /etc/init.d/fhem; then
/etc/init.d/fhem start noaptmark
fi
fi
exit 0

View File

@ -1,10 +1,11 @@
#!/bin/bash
# $Id:$
#set -x
set -e # required by lintian
set +e # Don't know how to check presence of fhem in passwd with -e
set -e
if grep -q fhem /etc/passwd; then
user_exists=$(id -u fhem > /dev/null 2>&1; echo $?)
if [ "$user_exists" -eq "0" ]; then
echo "deleting user fhem"
userdel fhem
fi
@ -15,3 +16,7 @@ fi
if test -f /etc/init.d/fhem; then
rm /etc/init.d/fhem
fi
if test -f /etc/systemd/system/fhem.service; then
rm /etc/systemd/system/fhem.service
fi

View File

@ -1,14 +1,18 @@
#!/bin/sh
#!/bin/bash
# $Id:$
#set -x
set -e
apt-mark unhold fhem
# detect init system
test=$(stat /sbin/init |grep "File")
re="systemd$"
# stop fhem if running
if test -f /etc/init.d/fhem; then
if [[ $test =~ $re ]]; then
systemctl stop fhem.service
systemctl disable fhem.service
else
if test -f /etc/init.d/fhem; then
/etc/init.d/fhem stop noaptmark
fi
update-rc.d fhem remove
fi
# remove fhem autostart
update-rc.d -f fhem remove