summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2011-08-20 15:26:26 (GMT)
committerJames Meyer <james.meyer@operamail.com>2011-08-20 15:26:26 (GMT)
commitc0121cf68b9f2a0329cb5bd40a65ecef4367fa65 (patch)
treee86b3c936e6498491abd78fabf04c376e39fb3ba
parentd66c33d9e436aa96c477991f89ebd85407bae0cb (diff)
downloadlinhes_pkgbuild-c0121cf68b9f2a0329cb5bd40a65ecef4367fa65.zip
linhes_pkgbuild-c0121cf68b9f2a0329cb5bd40a65ecef4367fa65.tar.gz
linhes_pkgbuild-c0121cf68b9f2a0329cb5bd40a65ecef4367fa65.tar.bz2
poweroff-scripts: This pkg contains the scripts used to determine which shutdown/poweroff procedure to use depending on the init system used. Both runit and init are supported and both pkg's depend on this one.
This pkg also creates two symlinks postinstall ln -sf /sbin/halt.init /sbin/reboot.init ln -sf /sbin/halt.init /sbin/poweroff.init These two are used by init, they are not part of the sysvsinit pkg because of two fileconflicts that are symlinks from a previous install. Instead of requiring a foce install to overwrite the links, they are created here post-install. If/when we move to x64 there will be no legacy files to worry about so reboot.init and poweroff.init should be moved back into the sysvinit pkg.
-rw-r--r--abs/core/poweroff-scripts/PKGBUILD27
-rw-r--r--abs/core/poweroff-scripts/halt.script16
-rw-r--r--abs/core/poweroff-scripts/poweroff-scripts.install28
-rw-r--r--abs/core/poweroff-scripts/poweroff.script11
-rw-r--r--abs/core/poweroff-scripts/reboot.script11
-rw-r--r--abs/core/poweroff-scripts/shutdown.script45
6 files changed, 138 insertions, 0 deletions
diff --git a/abs/core/poweroff-scripts/PKGBUILD b/abs/core/poweroff-scripts/PKGBUILD
new file mode 100644
index 0000000..af2fcd4
--- /dev/null
+++ b/abs/core/poweroff-scripts/PKGBUILD
@@ -0,0 +1,27 @@
+pkgname=poweroff-scripts
+pkgver=1.1
+pkgrel=2
+pkgdesc="replacement scripts to work with sysvinit and runit"
+license=('GPL')
+depends=('sysvinit>=2.88' 'runit>=2.1.1-6')
+makedepends=()
+conflicts=()
+replaces=()
+backup=()
+install=poweroff-scripts.install
+source=(halt.script reboot.script poweroff.script shutdown.script)
+arch=('i686')
+
+build() {
+ install -d $pkgdir/sbin/
+ install -m0755 $srcdir/reboot.script $pkgdir/sbin/reboot
+ install -m0755 $srcdir/halt.script $pkgdir/sbin/halt
+ install -m0755 $srcdir/poweroff.script $pkgdir/sbin/poweroff
+ install -m0755 $srcdir/shutdown.script $pkgdir/sbin/shutdown
+
+}
+
+md5sums=('e84d487ebd5c3cccd3477988efad3080'
+ '263198ec006b87891ea0f3ab1d103086'
+ '3ec5f3013dcbd60b6b957d17ba220585'
+ '953653da83f5188d51373abf4a42ba05')
diff --git a/abs/core/poweroff-scripts/halt.script b/abs/core/poweroff-scripts/halt.script
new file mode 100644
index 0000000..cfc05aa
--- /dev/null
+++ b/abs/core/poweroff-scripts/halt.script
@@ -0,0 +1,16 @@
+#!/bin/bash
+. /etc/profile
+INIT=`ps -p 1 -o comm=`
+if [ x$1 = x-w ]
+then
+ /sbin/halt.init -w
+ exit 0
+fi
+chvt 1
+if [ x$INIT = xrunit ]
+then
+ /sbin/halt-runit $@
+else
+ /sbin/halt.init $@
+fi
+
diff --git a/abs/core/poweroff-scripts/poweroff-scripts.install b/abs/core/poweroff-scripts/poweroff-scripts.install
new file mode 100644
index 0000000..b066f1d
--- /dev/null
+++ b/abs/core/poweroff-scripts/poweroff-scripts.install
@@ -0,0 +1,28 @@
+# arg 1: the new package version
+
+pre_install () {
+ echo ""
+}
+
+
+pre_upgrade () {
+ echo ""
+}
+
+post_install () {
+
+ [ -e /sbin/halt.init ] || ln -sf /sbin/halt.init /sbin/reboot.init
+ [ -e /sbin/halt.init ] || ln -sf /sbin/halt.init /sbin/poweroff.init
+}
+
+# arg 1: the new package version
+# arg 2: the old package version
+
+post_upgrade(){
+ post_install
+}
+
+op=$1
+shift
+
+$op $*
diff --git a/abs/core/poweroff-scripts/poweroff.script b/abs/core/poweroff-scripts/poweroff.script
new file mode 100644
index 0000000..99779eb
--- /dev/null
+++ b/abs/core/poweroff-scripts/poweroff.script
@@ -0,0 +1,11 @@
+#!/bin/bash
+. /etc/profile
+INIT=`ps -p 1 -o comm=`
+chvt 1
+if [ x$INIT = xrunit ]
+then
+ /sbin/halt-runit $@
+else
+ /sbin/poweroff.init $@
+fi
+
diff --git a/abs/core/poweroff-scripts/reboot.script b/abs/core/poweroff-scripts/reboot.script
new file mode 100644
index 0000000..fcce679
--- /dev/null
+++ b/abs/core/poweroff-scripts/reboot.script
@@ -0,0 +1,11 @@
+#!/bin/bash
+. /etc/profile
+INIT=`ps -p 1 -o comm=`
+chvt 1
+if [ x$INIT = xrunit ]
+then
+ /sbin/reboot-runit $@
+else
+ /sbin/reboot.init $@
+fi
+
diff --git a/abs/core/poweroff-scripts/shutdown.script b/abs/core/poweroff-scripts/shutdown.script
new file mode 100644
index 0000000..09245ef
--- /dev/null
+++ b/abs/core/poweroff-scripts/shutdown.script
@@ -0,0 +1,45 @@
+#!/bin/bash
+. /etc/profile
+INIT=`ps -p 1 -o comm=`
+if [ x$INIT = xrunit ]
+then
+ reboot=""
+ halt=""
+ delay=""
+ while getopts rht: name
+ do
+ case $name in
+ r) reboot=1 ;;
+ h) halt=1 ;;
+ t) delay="$OPTARG"
+ if [ x$delay = "xnow" ]
+ then
+ delay=0
+ fi
+ ;;
+ *)
+ exit 2;;
+ esac
+ done
+ if [ x$delay = x ]
+ then
+ delay=0
+ fi
+
+ if [ x$reboot = x1 ]
+ then
+ wall "System will reboot in $delay seconds"
+ sleep $delay
+ /sbin/runit-init 6
+ fi
+
+ if [ x$halt = x1 ]
+ then
+ wall "System will poweroff in $delay seconds"
+ sleep $delay
+ /sbin/runit-init 0
+ fi
+
+else
+ /sbin/shutdown.init $@
+fi