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:
parent
93d11754b0
commit
56e98c3128
@ -1,12 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
#set -x
|
|
||||||
|
|
||||||
|
user_exists=$(id -u fhem > /dev/null 2>&1; echo $?)
|
||||||
|
if [ "$user_exists" -eq "1" ]; then
|
||||||
if ! getent passwd fhem >/dev/null; then
|
echo "creating user fhem"
|
||||||
useradd --system --home /opt/fhem --gid dialout --shell /bin/false fhem
|
useradd --system --home /opt/fhem --gid dialout --shell /bin/false fhem
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -16,14 +14,27 @@ chown -R fhem:dialout /opt/fhem
|
|||||||
sed -i /debian.fhem.de/d /etc/apt/sources.list
|
sed -i /debian.fhem.de/d /etc/apt/sources.list
|
||||||
|
|
||||||
# set up of autostart
|
# set up of autostart
|
||||||
# Sysvinit; upstart no longer supported
|
# systemd: supported
|
||||||
|
# sysvinit: supported
|
||||||
|
# upstart: not supported
|
||||||
|
|
||||||
#mkdir -p /etc/init.d
|
# detect init system
|
||||||
cp /opt/fhem/contrib/init-scripts/fhem.3 /etc/init.d/fhem
|
test=$(stat /sbin/init |grep "File")
|
||||||
chmod ugo+x /etc/init.d/fhem
|
re="systemd$"
|
||||||
update-rc.d fhem defaults
|
|
||||||
|
|
||||||
if test -f /etc/init.d/fhem; then
|
if [[ $test =~ $re ]];
|
||||||
/etc/init.d/fhem start noaptmark
|
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
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# $Id:$
|
||||||
|
|
||||||
#set -x
|
set -e
|
||||||
set -e # required by lintian
|
|
||||||
set +e # Don't know how to check presence of fhem in passwd with -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
|
userdel fhem
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -15,3 +16,7 @@ fi
|
|||||||
if test -f /etc/init.d/fhem; then
|
if test -f /etc/init.d/fhem; then
|
||||||
rm /etc/init.d/fhem
|
rm /etc/init.d/fhem
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test -f /etc/systemd/system/fhem.service; then
|
||||||
|
rm /etc/systemd/system/fhem.service
|
||||||
|
fi
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
# $Id:$
|
||||||
|
|
||||||
#set -x
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
apt-mark unhold fhem
|
# detect init system
|
||||||
|
test=$(stat /sbin/init |grep "File")
|
||||||
|
re="systemd$"
|
||||||
|
|
||||||
# stop fhem if running
|
if [[ $test =~ $re ]]; then
|
||||||
if test -f /etc/init.d/fhem; then
|
systemctl stop fhem.service
|
||||||
/etc/init.d/fhem stop noaptmark
|
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
|
fi
|
||||||
|
|
||||||
# remove fhem autostart
|
|
||||||
update-rc.d -f fhem remove
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user