2014-10-10 15:52:47 +00:00
|
|
|
#!/bin/bash
|
2017-02-27 20:44:26 +00:00
|
|
|
# $Id$
|
2010-09-30 13:12:28 +00:00
|
|
|
set -e
|
2017-02-27 20:44:26 +00:00
|
|
|
|
2017-12-26 20:36:30 +00:00
|
|
|
user_exists=$(id -u fhem > /dev/null 2>&1; echo $?)
|
|
|
|
if [ "$user_exists" -eq "1" ]; then
|
|
|
|
echo "creating user fhem"
|
2012-12-29 07:57:52 +00:00
|
|
|
useradd --system --home /opt/fhem --gid dialout --shell /bin/false fhem
|
2010-08-02 12:47:55 +00:00
|
|
|
fi
|
2010-09-30 13:12:28 +00:00
|
|
|
|
2015-01-20 13:49:15 +00:00
|
|
|
chown -R fhem:dialout /opt/fhem
|
2010-09-30 13:12:28 +00:00
|
|
|
|
2017-02-27 20:44:26 +00:00
|
|
|
# remove repository entry after first installation
|
|
|
|
sed -i /debian.fhem.de/d /etc/apt/sources.list
|
|
|
|
|
2017-12-25 18:47:43 +00:00
|
|
|
# set up of autostart
|
2017-12-26 20:36:30 +00:00
|
|
|
# systemd: supported
|
|
|
|
# sysvinit: supported
|
|
|
|
# upstart: not supported
|
|
|
|
|
|
|
|
# detect init system
|
2018-01-05 11:29:16 +00:00
|
|
|
test=$(stat /sbin/init |grep "/sbin/init")
|
2017-12-26 20:36:30 +00:00
|
|
|
re="systemd$"
|
|
|
|
|
|
|
|
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
|
2017-12-25 18:47:43 +00:00
|
|
|
fi
|
2017-12-26 20:36:30 +00:00
|
|
|
|
2014-11-09 13:19:57 +00:00
|
|
|
exit 0
|