From 9649ae208248fc14b44dde67d6bc7301127d9f4c Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Sat, 5 Apr 2014 22:30:31 +0000
Subject: runit-scripts: fix frontend respawn by shutting down all services in
 3. refs #961

add pause utility from ignite project

remove power script stuff as it is done in poweroff-scripts
---
 abs/core/runit-scripts/PKGBUILD                    | 18 +++++++++++---
 abs/core/runit-scripts/runit.install               | 21 +++-------------
 abs/core/runit-scripts/runitscripts/1              | 29 ++++++++++++++--------
 abs/core/runit-scripts/runitscripts/3              | 16 +++++++++---
 .../runitscripts/services/alsa-utils/finish        |  4 +--
 .../runitscripts/services/alsa-utils/run           |  5 ++--
 6 files changed, 53 insertions(+), 40 deletions(-)

diff --git a/abs/core/runit-scripts/PKGBUILD b/abs/core/runit-scripts/PKGBUILD
index 9b32d76..ed76902 100755
--- a/abs/core/runit-scripts/PKGBUILD
+++ b/abs/core/runit-scripts/PKGBUILD
@@ -1,20 +1,26 @@
 pkgname=runit-scripts
 pkgver=8.1
-pkgrel=10
+pkgrel=11
 pkgdesc="collection of startup scripts for runit"
 url="http://smarden.org/runit/"
 license="BSD"
 depends=('glibc' 'util-linux' 'initscripts' 'runit' )
-makedepends=('rsync')
+makedepends=('gcc' 'make' 'rsync')
 conflicts=()
 replaces=()
 backup=('etc/runit/1.local' 'etc/runit/3.local')
 install=runit.install
-source=('fbsplash-runit.sh')
+source=('fbsplash-runit.sh'
+        'http://chneukirchen.org/releases/ignite-0.9.0.tar.gz')
 arch=('i686' 'x86_64')
 
 build() {
   rsync -a --exclude=.svn --exclude=*~ $startdir/runitscripts $srcdir
+
+  #build pause util from ignite
+  cd $srcdir/ignite-0.9.0/util
+  sed -i 's/musl-gcc/gcc/g' ./Makefile
+  make
 }
 
 package() {
@@ -34,5 +40,9 @@ package() {
   rsync -a --exclude=.svn services/* $pkgdir/etc/sv
   chmod -R  755 $pkgdir/etc/sv
   chown -R root:root $pkgdir/etc/sv
+
+  install -D -m0755 $srcdir/ignite-0.9.0/util/pause $pkgdir/usr/bin/pause
+  install -D -m0644 $srcdir/ignite-0.9.0/util/pause.1 $pkgdir/usr/share/man/man1/pause.1
 }
-md5sums=('30b944b91aa1f57c5469c8bd210cb497')
+md5sums=('30b944b91aa1f57c5469c8bd210cb497'
+         '1d88cf79d810e7d371e713f724fa2e85')
diff --git a/abs/core/runit-scripts/runit.install b/abs/core/runit-scripts/runit.install
index d77c9aa..4ec6a9f 100755
--- a/abs/core/runit-scripts/runit.install
+++ b/abs/core/runit-scripts/runit.install
@@ -8,27 +8,12 @@ post_install () {
   do
    ln -s /etc/sv/$i /service/$i
   done
-
-  [ -e /sbin/halt ] || ln -s /sbin/halt.script /sbin/halt
-  [ -e /sbin/reboot ] || ln -s /sbin/reboot.script /sbin/reboot
-  [ -e /sbin/poweroff ] ||  ln -s /sbin/poweroff.script /sbin/poweroff
-  [ -e /sbin/reboot.init ] || ln -s /sbin/halt-init /sbin/reboot.init
-  [ -e /sbin/poweroff.init ] || ln -s /sbin/halt-init /sbin/poweroff.init
-
-
 }
 
 # arg 1:  the new package version
 # arg 2:  the old package version
 
 post_upgrade(){
-
-  [ -e /sbin/halt ] || ln -s /sbin/halt.script /sbin/halt
-  [ -e /sbin/reboot ] || ln -s /sbin/reboot.script /sbin/reboot
-  [ -e /sbin/poweroff ] ||  ln -s /sbin/poweroff.script /sbin/poweroff
-  [ -e /sbin/reboot.init ] || ln -s /sbin/halt-init /sbin/reboot.init
-  [ -e /sbin/poweroff.init ] || ln -s /sbin/halt-init /sbin/poweroff.init
-
   if [ -e /var/service ]
   then
 	  if [ ! -e /service ]
@@ -45,9 +30,9 @@ post_upgrade(){
 
   if [ -e /service/lircd ]
   then
-      /sbin/sv stop lircd
-      /sbin/remove_service.sh lircd
-      /sbin/add_service.sh remotes
+      sv stop lircd
+      remove_service.sh lircd
+      add_service.sh remotes
   fi
 
   if [ -e /etc/sv/lircd ]
diff --git a/abs/core/runit-scripts/runitscripts/1 b/abs/core/runit-scripts/runitscripts/1
index 9463e60..9f92530 100755
--- a/abs/core/runit-scripts/runitscripts/1
+++ b/abs/core/runit-scripts/runitscripts/1
@@ -1,28 +1,33 @@
 #!/bin/bash
+
+PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
 /etc/rc.sysinit
 . /etc/rc.conf
 . /etc/rc.d/functions
-#no longer needed rc.sysinit takes care of the hostname
-#hostname `cat /etc/hostname`
-/sbin/sysctl -p 2>/dev/null >/dev/null
+
+sysctl -p 2>/dev/null >/dev/null
+
 #make sure permissions are right for /etc/systemconfig
 chown root:mythtv /etc/systemconfig
 chmod 774 /etc/systemconfig
-/usr/bin/setfacl -m u:mythtv:rw- /etc/systemconfig 2>/dev/null >/dev/null
+setfacl -m u:mythtv:rw- /etc/systemconfig 2>/dev/null >/dev/null
 
-#yes it's needed the 2nd time
 /usr/LH/bin/load-modules-mythvantage.sh >/dev/null
 rm /etc/dhcpc/dhcpcd*.pid  2>/dev/null
 rm -f /service/frontend/.runtime/* 2>/dev/null
 rm -f /etc/runit/reboot 2>/dev/null
-/sbin/agetty -8 38400 tty10 linux &
+agetty -8 38400 tty10 linux &
+
 stat_busy "Starting network"
-/bin/mkdir -p /var/lock/subsys
+mkdir -p /var/lock/subsys
 /etc/net/scripts/network.init start 2>/var/log/network.init.error >/var/log/network.init
 stat_done
-/usr/sbin/ethtool -s  eth0 wol g 2>/dev/null
-/usr/sbin/ethtool -s  eth1 wol g 2>/dev/null
-/usr/sbin/ethtool -s  eth2 wol g 2>/dev/null
+
+ethtool -s  eth0 wol g 2>/dev/null
+ethtool -s  eth1 wol g 2>/dev/null
+ethtool -s  eth2 wol g 2>/dev/null
+
 #cleanup of log files
 if [ -f /etc/cron.daily/log_care ]
 then
@@ -39,13 +44,15 @@ then
     /etc/runit/1.local
     stat_done
 fi
+
 #some stuff from rc.multi
 run_hook multi_start
+
 # Load sysctl config files
 /usr/lib/systemd/systemd-sysctl
+
 # Load additional binary formats
 mountpoint -q /proc/sys/fs/binfmt_misc || mount /proc/sys/fs/binfmt_misc &>/dev/null || mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc
 /usr/lib/systemd/systemd-binfmt
-bootlogd_stop
 
 rm -f /run/nologin
diff --git a/abs/core/runit-scripts/runitscripts/3 b/abs/core/runit-scripts/runitscripts/3
index 1a4b384..91617e5 100755
--- a/abs/core/runit-scripts/runitscripts/3
+++ b/abs/core/runit-scripts/runitscripts/3
@@ -1,7 +1,16 @@
 #!/bin/sh
+
+PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
 clear
 . /etc/rc.conf
 . /etc/rc.d/functions
+
+stat_busy "Waiting for services to stop..."
+sv -w196 force-stop /service/*
+sv exit /service/*
+stat_done
+
 for i in `seq 3`
 do
 echo " " > /dev/tty1
@@ -18,8 +27,9 @@ then
     /etc/runit/3.local
     stat_done
 fi
-/usr/sbin/ethtool -s  eth0 wol g 2>/dev/null
-/usr/sbin/ethtool -s  eth1 wol g 2>/dev/null
-/usr/sbin/ethtool -s  eth2 wol g 2>/dev/null
+
+ethtool -s  eth0 wol g 2>/dev/null
+ethtool -s  eth1 wol g 2>/dev/null
+ethtool -s  eth2 wol g 2>/dev/null
 
 /etc/rc.shutdown
diff --git a/abs/core/runit-scripts/runitscripts/services/alsa-utils/finish b/abs/core/runit-scripts/runitscripts/services/alsa-utils/finish
index d6f3897..84e3f81 100755
--- a/abs/core/runit-scripts/runitscripts/services/alsa-utils/finish
+++ b/abs/core/runit-scripts/runitscripts/services/alsa-utils/finish
@@ -1,3 +1,3 @@
 #!/bin/sh
-exec 2>&1
-sv down alsa-utils
+set -e
+exec /usr/bin/alsactl store
diff --git a/abs/core/runit-scripts/runitscripts/services/alsa-utils/run b/abs/core/runit-scripts/runitscripts/services/alsa-utils/run
index 17f5f99..a376059 100755
--- a/abs/core/runit-scripts/runitscripts/services/alsa-utils/run
+++ b/abs/core/runit-scripts/runitscripts/services/alsa-utils/run
@@ -1,3 +1,4 @@
 #!/bin/sh
-exec 2>&1
-exec /etc/rc.d/alsa start
+set -e
+/usr/bin/alsactl restore
+exec chpst -b alsa pause
-- 
cgit v0.12

