2018-08-10 Fred Gleason <fredg@paravelsystems.com>

* Modified the boot system to use SystemD.
This commit is contained in:
Fred Gleason 2018-08-10 07:16:15 -04:00
parent 223bdc2f84
commit e39a0e4d00
9 changed files with 83 additions and 338 deletions

1
.gitignore vendored
View File

@ -85,6 +85,7 @@ rivendell
rivendell-suse
rivendell.spec
slack-desc
systemd/rivendell.service
tests/audio_convert_test
tests/audio_export_test
tests/audio_import_test

View File

@ -17354,3 +17354,5 @@
* Removed code to start service daemons automatically from
user modules.
* Added rdservice(8).
2018-08-10 Fred Gleason <fredg@paravelsystems.com>
* Modified the boot system to use SystemD.

View File

@ -56,6 +56,7 @@ SUBDIRS = icons\
rdservice\
rdvairplayd\
ripcd\
systemd\
tests\
utils\
web
@ -125,7 +126,6 @@ EXTRA_DIST = autogen.sh\
rivendell.ism\
rivendell.pro\
rivendell.spec.in\
rivendell-suse.in\
rivendell.sys\
slack-desc.in\
slack_doinst.sh\
@ -161,5 +161,4 @@ MAINTAINERCLEANFILES = *~\
ltmain.sh\
missing\
mkinstalldirs\
rivendell.spec\
rivendell-suse
rivendell.spec

View File

@ -408,19 +408,6 @@ else
AC_DEFINE(HAVE_FLAC_METADATA,yes)
fi
#
# Distro-Specific Stuff
#
if test -f /etc/gentoo-release ; then
rm -f rivendell
ln -s rivendell-gentoo rivendell
AC_MSG_NOTICE([Configured to install Gentoo-specific init script])
else
rm -f rivendell
ln -s rivendell-suse rivendell
AC_MSG_NOTICE([Configured to install generic init script])
fi
#
# Configure RPM Build
#
@ -483,7 +470,6 @@ AC_CONFIG_FILES([rivendell.spec \
Makefile \
make_slack \
slack-desc \
rivendell-suse \
rdrepld-suse \
conf/rd-bin.conf \
icons/Makefile \
@ -559,12 +545,13 @@ AC_CONFIG_FILES([rivendell.spec \
rdservice/Makefile \
rdvairplayd/Makefile \
scripts/Makefile \
systemd/Makefile \
systemd/rivendell.service \
tests/Makefile \
xdg/Makefile \
])
AC_OUTPUT()
chmod 755 make_slack
chmod 755 rivendell-suse
chmod 755 rdrepld-suse
#

View File

@ -1,67 +0,0 @@
#!/sbin/runscript
##
## A Rivendell init script for Gentoo Linux.
##
## (C) Copyright 2005,2016 Fred Gleason <fredg@paravelsystems.com>
##
## Adapted from the Gentoo init script for Rivendell
## by Andres Toomsalu <andres@active.ee>
##
## Modified 2011 by Emery Hemingway <emery@icmlf.net>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of version 2 of the GNU General Public License as
## published by the Free Software Foundation;
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330,
## Boston, MA 02111-1307 USA
##
description="Rivendell system daemons"
user="rivendell"
group="rivendell"
pid_dir="/var/run/rivendell"
daemons="caed ripcd rdcatchd"
depend() {
use alsasound apache2 jackd mysql
}
start() {
ebegin "Starting Rivendell"
checkpath --directory --mode 0775 --owner $user:$group /var/snd
checkpath --file --mode 0664 --owner $user:$group /var/snd/*
ipcrm -M 0x5005 2> /dev/null
for daemon in $daemons
do
veinfo "Starting $daemon"
start-stop-daemon --start --pidfile $pid_dir/$daemon.pid \
--user $user:$group --umask 0113 \
--exec /usr/bin/$daemon
done
eend $?
}
stop() {
ebegin "Stopping Rivendell"
killall rdimport > /dev/null 2> /dev/null
for daemon in $daemons
do
start-stop-daemon --stop --pidfile $pid_dir/$daemon.pid
done
eend $?
}

View File

@ -1,253 +0,0 @@
#! /bin/bash
##
## Rivendell init script for LSB and chkconfig(8) compliant Linux systems.
##
## (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of version 2 of the GNU General Public License as
## published by the Free Software Foundation;
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330,
## Boston, MA 02111-1307 USA
##
# chkconfig: 35 65 35
# description: Rivendell system daemons
# config: /etc/rc.conf
### BEGIN INIT INFO
# Provides: rivendell
# Required-Start: $remote_fs alsasound
# Required-Stop: $remote_fs alsasound
# Should-Start: @MYSQL_PKG@
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Description: Start the Rivendell system daemons
### END INIT INFO
function StartDaemons {
rdcleandirs
if test $GPIO_START = yes ; then
if test -x /etc/init.d/gpio ; then
/etc/init.d/gpio status > /dev/null
if test $? -eq 3 ; then
/etc/init.d/gpio start
fi
fi
fi
if test $HPI_START = yes ; then
if test -x /etc/init.d/asihpi ; then
/etc/init.d/asihpi status > /dev/null
if test $? -eq 3 ; then
/etc/init.d/asihpi start
sleep 2
fi
fi
fi
if test $LIVEWIRE_START = yes ; then
if test -x /etc/init.d/axiad ; then
/etc/init.d/axiad status > /dev/null
if test $? -eq 3 ; then
/etc/init.d/axiad start
fi
fi
fi
$JACK_COMMAND > /dev/null 2> /dev/null &
echo -n $! > /var/run/rivendell/jackd.pid
ipcrm -M 0x5005 2> /dev/null
@LOCAL_PREFIX@/bin/caed 2> /dev/null
sleep 1
if test -x @LOCAL_PREFIX@/bin/ripcd ; then
@LOCAL_PREFIX@/bin/ripcd 2> /dev/null
sleep 1
fi
if test -x @LOCAL_PREFIX@/bin/rdcatchd ; then
@LOCAL_PREFIX@/bin/rdcatchd 2> /dev/null
fi
}
function StopDaemons {
killall rdimport > /dev/null 2> /dev/null
killall rdvairplayd > /dev/null 2> /dev/null
if [ -f /var/run/rivendell/rdcatchd.pid ] ; then
kill `cat /var/run/rivendell/rdcatchd.pid` > /dev/null 2> /dev/null
fi
if [ -f /var/run/rivendell/ripcd.pid ] ; then
kill `cat /var/run/rivendell/ripcd.pid` > /dev/null 2> /dev/null
fi
if [ -f /var/run/rivendell/caed.pid ] ; then
kill `cat /var/run/rivendell/caed.pid` > /dev/null 2> /dev/null
fi
if [ -n "$JACK_COMMAND" ] ; then
#
# FIXME
# Why are three kill(1) invocations necessary to stop jackd(1)?
#
if [ -f /var/run/rivendell/jackd.pid ] ; then
kill `cat /var/run/rivendell/jackd.pid` > /dev/null 2> /dev/null
kill `cat /var/run/rivendell/jackd.pid` > /dev/null 2> /dev/null
kill `cat /var/run/rivendell/jackd.pid` > /dev/null 2> /dev/null
rm -f /var/run/rivendell/jackd.pid
fi
fi
sleep 2
rdcleandirs
}
# Set path for script functions
export PATH=$PATH:/usr/local/bin:/usr/local/sbin
#
# If the LSB Init functions exist, use them, otherwise roll our own
#
if test -f /lib/lsb/init-functions ; then
. /lib/lsb/init-functions
else
function log_success_msg() {
echo "$1 ... done."
}
function log_failure_msg() {
echo "$1 ... done."
}
fi
# Default sysconfig values
GPIO_START="no"
HPI_START="no"
LIVEWIRE_START="no"
JACK_START="no"
JACK_SAMPLE_RATE="48000"
JACK_ALSA_DEVICE="hw:0"
JACK_USE_REALTIME="no"
# Override defaults, if we have the sysconfig file
test -f /etc/sysconfig/rivendell && . /etc/sysconfig/rivendell
# Build a jackd command line
if [ $JACK_START = yes ] ; then
if [ $JACK_USE_REALTIME = yes ] ; then
JACK_COMMAND="jackd -R"
else
JACK_COMMAND="jackd"
fi
JACK_COMMAND="$JACK_COMMAND -d alsa -d $JACK_ALSA_DEVICE -r $JACK_SAMPLE_RATE"
fi
# Check for missing binaries
if [ ! -x @LOCAL_PREFIX@/bin/caed ] ; then
echo "caed not installed"
exit 5
fi
#if [ ! -x @LOCAL_PREFIX@/bin/ripcd ] ; then
# echo "ripcd not installed"
# exit 5
#fi
#if [ ! -x @LOCAL_PREFIX@/bin/rdcatchd ] ; then
# echo "rdcatchd not installed"
# exit 5
#fi
# Check for existence of needed config file and read it
if [ ! -r /etc/rd.conf ] ; then
echo "Missing /etc/rd.conf"
exit 6
fi
# Check for existence of PID file directory and create it if necessary.
if [ ! -d /var/run/rivendell ] ; then
mkdir -p /var/run/rivendell
fi
if [ ! -d /var/run/rivendell ] ; then
echo "Missing /var/run/rivendell directory"
exit 6
fi
case "$1" in
start)
$0 silent-status
if test $? -eq 3 ; then
StartDaemons
fi
$0 silent-status
if test $? -eq 0 ; then
log_success_msg "Starting Rivendell system daemons"
exit 0
else
log_failure_msg "Starting Rivendell system daemons"
exit 1
fi
;;
stop)
StopDaemons
$0 silent-status
if test $? -eq 0 ; then
log_failure_msg "Stopping Rivendell system daemons"
exit 1
else
log_success_msg "Stopping Rivendell system daemons"
exit 0
fi
;;
restart)
$0 silent-status
if test $? -eq 0 ; then
$0 stop
fi
$0 silent-status
if test $? -eq 0 ; then
exit 1
fi
$0 start
$0 silent-status
if test $? -eq 0 ; then
exit 0
fi
exit 1
;;
force-reload)
$0 restart
;;
status)
$0 silent-status
EXIT_CODE=$?
if test $EXIT_CODE -eq 0 ; then
echo "Rivendell system daemons running."
else
echo "Rivendell system daemons stopped."
fi
exit $EXIT_CODE
;;
silent-status)
if test -f /var/run/rivendell/caed.pid ; then
if test -d /proc/`cat /var/run/rivendell/caed.pid` ; then
if test ! -x @LOCAL_PREFIX@/bin/ripcd ; then
exit 0
fi
if test -f /var/run/rivendell/ripcd.pid ; then
if test -d /proc/`cat /var/run/rivendell/ripcd.pid` ; then
if test -f /var/run/rivendell/rdcatchd.pid ; then
if test -d /proc/`cat /var/run/rivendell/rdcatchd.pid` ; then
exit 0
fi
fi
fi
fi
fi
fi
exit 3
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status}"
exit 1
;;
esac

38
systemd/Makefile.am Normal file
View File

@ -0,0 +1,38 @@
## Makefile.am
##
## Use automake to process this into a Makefile.in
##
## (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License version 2 as
## published by the Free Software Foundation.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
install-exec-local:
mkdir -p $(DESTDIR)/lib/systemd/system
cp rivendell.service $(DESTDIR)/lib/systemd/system/rivendell.service
./daemon-reload.sh
uninstall-local:
rm -f $(DESTDIR)/lib/systemd/system/rivendell.service
./daemon-reload.sh
EXTRA_DIST = daemon-reload.sh\
rivendell.service.in
CLEANFILES = *~
DISTCLEANFILES = Makefile.in\
*.service
MAINTAINERCLEANFILES = *~

25
systemd/daemon-reload.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
# daemon-reload.sh
#
# Do a daemon-reload for SystemD
#
# (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
if test $UID -eq 0 ; then
/bin/systemctl daemon-reload
fi

View File

@ -0,0 +1,13 @@
[Unit]
Description=Rivendell Radio Automation System
After=network.target remote-fs.target nss-lookup.target
#Documentation=man:drouterd(8) man:dmap(1) man:dlist(1)
[Service]
Type=simple
ExecStart=@prefix@/sbin/rdservice
PrivateTmp=true
Restart=always
[Install]
WantedBy=multi-user.target