Commit 7b6da276 authored by Milan's avatar Milan
Browse files

add systemd support

parent 99afece0
#!/bin/sh
while true
do
pkill -f "/usr/bin/scheduler.pl"
[ -d /var/run/stream-schedule ] || mkdir /var/run/stream-schedule
chmod 775 /var/run/stream-schedule
chown audiostream /var/run/stream-schedule
[ -f /var/run/stream-schedule/stream-schedule.pid ] && rm /var/run/stream-schedule/stream-schedule.pid
[ -d /var/log/stream-schedule/ ] || mkdir /var/log/stream-schedule/
chmod 755 /var/log/stream-schedule
chown audiostream:www-data /var/log/stream-schedule/
[ -f /var/log/stream-schedule/scheduler.log ] && chmod 664 /var/log/stream-schedule/scheduler.log
[ -f /var/log/stream-schedule/scheduler.log ] && chown audiostream:www-data /var/log/stream-schedule/scheduler.log
su -s /bin/sh -c 'exec "$0" "$@" >> /var/log/stream-schedule/scheduler.log 2>&1' audiostream -- /usr/bin/scheduler.pl --daemon
done
stream-schedule (0.01.0051) xenial; urgency=low
* fix systemd service location
-- Milan Chrobok <mc@radiopiloten.de> Thu, 21 Apr 2018 16:54:09 +0200
stream-schedule (0.01.0042) xenial; urgency=low
* move to xenial
-- Milan Chrobok <mc@radiopiloten.de> Thu, 21 Apr 2018 16:04:09 +0200
stream-schedule (0.01.0041) trusty; urgency=low
* fix systemd/upstart handling
-- Milan Chrobok <mc@radiopiloten.de> Thu, 16 Nov 2017 23:04:09 +0200
......
......@@ -3,4 +3,5 @@ bin/scheduler-monitor.pl /usr/bin
etc/init/stream-schedule.conf /etc/init
etc/logrotate.d/stream-schedule /etc/logrotate.d
etc/stream-schedule/stream-schedule.conf /etc/stream-schedule
etc/systemd/system/stream-schedule.service /etc/system.d/system
etc/systemd/system/stream-schedule.service /etc/systemd/system
bin/start-stream-schedule.sh
#! /bin/sh
isUpstart() {
/sbin/init --version 2>/dev/null | grep -q 'upstart' || return 1
echo "upstart" found
return 0
/sbin/init --version 2>/dev/null | grep -q 'upstart'
#echo "result=$?"
if [ "$?" = "0" ]; then
return 0
else
return 1
fi
}
isSystemd() {
/bin/systemctl 2>/dev/null | grep -q '\-\.mount' || return 1
echo "systemd found"
return 0
/bin/systemctl 2>/dev/null | grep -q '\-\.mount'
#echo "result=$?"
if [ "$?" = "0" ]; then
return 0
else
return 1
fi
}
if ! getent group audiostream >/dev/null; then
......@@ -58,6 +66,8 @@ if [ -d /var/log/stream-schedule/plot/ ]; then
chown -R audiostream:www-data /var/log/stream-schedule/plot/
chmod 0755 /var/log/stream-schedule/plot/
fi
chmod 0755 /bin/start-stream-schedule.sh
[ -f /etc/stream-schedule/stream-schedule.conf ] && chgrp audiostream /etc/stream-schedule/stream-schedule.conf
[ -f /etc/init/stream-schedule.conf ] && chgrp audiostream /etc/init/stream-schedule.conf
......@@ -65,12 +75,13 @@ fi
[ -f /etc/logrotate.d/stream-schedule ] && chmod 644 /etc/logrotate.d/stream-schedule
if isUpstart; then
echo "stop stream-schedule upstart service"
echo "restart stream-schedule upstart service"
initctl reload-configuration
status stream-schedule && stop stream-schedule || echo "could not stop service"
start stream-schedule
elif isSystemd; then
echo "stop stream-schedule systemd service"
echo "restart stream-schedule systemd service"
systemctl daemon-reload
systemctl enable stream-schedule
systemctl start stream-schedule
fi
......
#! /bin/sh
isUpstart() {
/sbin/init --version 2>/dev/null | grep -q 'upstart' || return 1
echo "upstart" found
return 0
/sbin/init --version 2>/dev/null | grep -q 'upstart'
#echo "result=$?"
if [ "$?" = "0" ]; then
return 0
else
return 1
fi
}
isSystemd() {
/bin/systemctl 2>/dev/null | grep -q '\-\.mount' || return 1
echo "systemd found"
return 0
/bin/systemctl 2>/dev/null | grep -q '\-\.mount'
#echo "result=$?"
if [ "$?" = "0" ]; then
return 0
else
return 1
fi
}
if [ "$1" = "purge" ] ; then
......@@ -22,4 +30,9 @@ if [ "$1" = "purge" ] ; then
fi
fi
if isSystemd; then
echo "reload systemd services"
systemctl daemon-reload
fi
exit 0;
#! /bin/sh -e
isUpstart() {
/sbin/init --version 2>/dev/null | grep -q 'upstart' || return 1
echo "upstart" found
return 0
/sbin/init --version 2>/dev/null | grep -q 'upstart'
#echo "result=$?"
if [ "$?" = "0" ]; then
return 0
else
return 1
fi
}
isSystemd() {
/bin/systemctl 2>/dev/null | grep -q '\-\.mount' || return 1
echo "systemd found"
return 0
/bin/systemctl 2>/dev/null | grep -q '\-\.mount'
#echo "result=$?"
if [ "$?" = "0" ]; then
return 0
else
return 1
fi
}
if [ "$1" = "remove" ]; then
......
#! /bin/sh
isUpstart() {
/sbin/init --version 2>/dev/null | grep -q 'upstart' || return 1
echo "upstart" found
return 0
/sbin/init --version 2>/dev/null | grep -q 'upstart'
#echo "result=$?"
if [ "$?" = "0" ]; then
return 0
else
return 1
fi
}
isSystemd() {
/bin/systemctl 2>/dev/null | grep -q '\-\.mount' || return 1
echo "systemd found"
return 0
/bin/systemctl 2>/dev/null | grep -q '\-\.mount'
#echo "result=$?"
if [ "$?" = "0" ]; then
return 0
else
return 1
fi
}
if [ "$1" = "remove" ]; then
......@@ -21,6 +29,7 @@ if [ "$1" = "remove" ]; then
echo "stop stream-schedule service"
systemctl stop stream-schedule
systemctl disable stream-schedule
systemctl daemon-reload
fi
fi
......
......@@ -4,19 +4,12 @@ Description=audio stream schedule
After=network.target
[Service]
Restart=always
User=audiostream
PIDFile=/var/run/stream-schedule/stream-schedule.pid
ExecStartPre= [ -d /var/run/stream-schedule ] || mkdir /var/run/stream-schedule
ExecStartPre= chmod 775 /var/run/stream-schedule
ExecStartPre= chown audiostream /var/run/stream-schedule
ExecStartPre= [ -f /var/run/stream-schedule/stream-schedule.pid ] && rm /var/run/stream-schedule/stream-schedule.pid
ExecStartPre= [ -d /var/log/stream-schedule/ ] || mkdir /var/log/stream-schedule/
ExecStartPre= chmod 755 /var/log/stream-schedule
ExecStartPre= chown audiostream:www-data /var/log/stream-schedule/
ExecStartPre= [ -f /var/log/stream-schedule/scheduler.log ] && chmod 664 /var/log/stream-schedule/scheduler.log
ExecStartPre= [ -f /var/log/stream-schedule/scheduler.log ] && chown audiostream:www-data /var/log/stream-schedule/scheduler.log
ExecStart=/usr/bin/scheduler.pl --daemon >>/var/log/stream-schedule/scheduler.log 2>&1
Type=simple
Restart=on-failure
RestartSec=3
Group=audiostream
ExecStart=/bin/start-stream-schedule.sh
ExecReload=/bin/kill -HUP $(cat /var/run/stream-schedule/stream-schedule.pid)
[Install]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment