From c1371f42b90c38de227fe3531b60c9e34c001783 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Sat, 20 May 2017 14:43:29 -0700 Subject: [PATCH] Add service install for systemd --- debian/a2pi.default | 4 ++-- debian/init.d | 2 +- debian/postinst | 52 +++++---------------------------------------- share/a2pi.service | 3 ++- 4 files changed, 10 insertions(+), 51 deletions(-) diff --git a/debian/a2pi.default b/debian/a2pi.default index b0ea420..6f826f7 100755 --- a/debian/a2pi.default +++ b/debian/a2pi.default @@ -8,5 +8,5 @@ # Additional options that are passed to the Daemon. # If you are not using the default serial port /dev/ttyAMA0, enter it here. -# DAEMON_OPTS="/dev/ttyUSB0" -DAEMON_OPTS="" +# A2PID_OPTS="/dev/ttyUSB0" +A2PID_OPTS="" diff --git a/debian/init.d b/debian/init.d index b3a0ad4..87f242e 100755 --- a/debian/init.d +++ b/debian/init.d @@ -49,7 +49,7 @@ do_start() #start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 1 #start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ $DAEMON_ARGS \ || return 2 killall -HUP $NAMED - $DAEMON $DAEMON_ARGS $DAEMON_OPTS || return 2 + $DAEMON $DAEMON_ARGS $A2PID_OPTS || return 2 # Add code here, if necessary, that waits for the process to be ready # to handle requests from services started subsequently which depend # on this one. As a last resort, sleep for some time. diff --git a/debian/postinst b/debian/postinst index 55b8a97..c385e57 100755 --- a/debian/postinst +++ b/debian/postinst @@ -81,55 +81,13 @@ case "$1" in echo "deb http://schmenk.is-a-geek.com/raspbian jessie contrib" >> /etc/apt/sources.list fi # - # Remove old install + # Add a2pi service to systemd # if [ -f /usr/local/bin/a2pid ] ; then - rm /usr/local/bin/a2pid - fi - if [ -f /usr/local/bin/a2serclk ] ; then - rm /usr/local/bin/a2serclk - fi - if [ -f /usr/local/bin/a2mon ] ; then - rm /usr/local/bin/a2mon - fi - if [ -f /usr/local/bin/dskread ] ; then - rm /usr/local/bin/dskread - fi - if [ -f /usr/local/bin/dskwrite ] ; then - rm /usr/local/bin/dskwrite - fi - if [ -f /usr/local/bin/a2term ] ; then - rm /usr/local/bin/a2term - fi - if [ -f /usr/local/bin/fusea2pi ] ; then - rm /usr/local/bin/fusea2pi - fi - if [ -f /usr/local/bin/a2joy ] ; then - rm /usr/local/bin/a2joy - fi - if [ -f /usr/local/bin/a2joymou ] ; then - rm /usr/local/bin/a2joymou - fi - if [ -f /usr/local/bin/a2joypad ] ; then - rm /usr/local/bin/a2joypad - fi - if [ -f /usr/local/bin/a2mount ] ; then - rm /usr/local/bin/a2mount - fi - if [ -f /usr/local/bin/bload ] ; then - rm /usr/local/bin/bload - fi - if [ -f /usr/local/bin/brun ] ; then - rm /usr/local/bin/brun - fi - if [ -f /usr/local/sbin/a2pid ] ; then - rm /usr/local/sbin/a2pid - fi - if [ "$(grep a2pid /etc/rc.local)" != "" ] ; then - mv /etc/rc.local /etc/rc.local.old - sed -e '/^# Start Apple II Pi/d' -e '/a2pid/d' -e '/^wait 1/d' -e '/a2joy/'d /etc/rc.local.old > /etc/rc.local - rm /etc/rc.local.old - fi + cp /usr/share/a2pi/a2pi.service /lib/systemd/ + systemctl enable a2pi + systemctl reload a2pi + fi ;; abort-upgrade|abort-remove|abort-deconfigure) diff --git a/share/a2pi.service b/share/a2pi.service index b3b5963..59f454b 100644 --- a/share/a2pi.service +++ b/share/a2pi.service @@ -5,7 +5,8 @@ After=network.target [Service] Type=idle Environment="HOME=/root" -ExecStart=/sbin/a2pid +EnvironmentFile=-/etc/default/a2pi +ExecStart=/sbin/a2pid $A2PID_OPTS Restart=on-failure RestartSec=60