summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Schumacher2021-09-05 13:40:35 +0200
committerLeon Schumacher2021-09-05 13:40:35 +0200
commit3d882a9e5c2baca28d1139c12cd69a38a91f93c8 (patch)
tree7b12f69d4e15786f24ad6415759109e769412cad
downloadaur-3d882a9e5c2baca28d1139c12cd69a38a91f93c8.tar.gz
Create package for runit-conversion
-rw-r--r--.SRCINFO23
-rwxr-xr-x22
-rw-r--r--PKGBUILD28
-rwxr-xr-xpoweroff1
-rwxr-xr-xreboot1
-rwxr-xr-xshutdown62
6 files changed, 117 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 00000000000..3bac64eed19
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,23 @@
+pkgbase = runit-conversion
+ pkgdesc = Convert your system to use runit instead of systemd
+ pkgver = 1
+ pkgrel = 1
+ url = https://smarden.org/runit
+ arch = any
+ license = GPL
+ depends = base-init-agnostic
+ depends = kisslinux-init
+ depends = runit
+ depends = systemd-libs-fake
+ depends = eudev
+ optdepends = runit-services: many service definitions
+ source = 2
+ source = reboot
+ source = poweroff
+ source = shutdown
+ sha256sums = 8516f76f250e15c27c7713d45e75c5ddaa6cf9abc13f066b695fef94aded0418
+ sha256sums = aa2f3d56dd7f2c1e8810f7d0e3046129d7b1c2dc14c2c4d41c1a3ed466d34541
+ sha256sums = 9c4e8cba8ffc2e3b546401317ef6567acf71e07fe4b0ec0ac6c0f98457e08d1d
+ sha256sums = 0ff5be0b1124c7a8cbe06bd3968be51d4d96782cf96c3dddaa1661fa8f811e9a
+
+pkgname = runit-conversion
diff --git a/2 b/2
new file mode 100755
index 00000000000..590aba1d39e
--- /dev/null
+++ b/2
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec /usr/bin/runsvdir -P /var/service
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..53a9264ebee
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,28 @@
+# Maintainer: Leon Schumacher <leonsch@protonmail.com>
+# vim: ft=sh:
+pkgname=runit-conversion
+pkgver=1
+pkgrel=1
+pkgdesc="Convert your system to use runit instead of systemd"
+arch=('any')
+url="https://smarden.org/runit"
+license=('GPL')
+depends=('base-init-agnostic' 'kisslinux-init' 'runit' 'systemd-libs-fake' 'eudev')
+optdepends=('runit-services: many service definitions')
+source=('2' 'reboot' 'poweroff' 'shutdown')
+sha256sums=('8516f76f250e15c27c7713d45e75c5ddaa6cf9abc13f066b695fef94aded0418'
+ 'aa2f3d56dd7f2c1e8810f7d0e3046129d7b1c2dc14c2c4d41c1a3ed466d34541'
+ '9c4e8cba8ffc2e3b546401317ef6567acf71e07fe4b0ec0ac6c0f98457e08d1d'
+ '0ff5be0b1124c7a8cbe06bd3968be51d4d96782cf96c3dddaa1661fa8f811e9a')
+
+package() {
+ install -Dm755 "2" "$pkgdir/etc/runit/2"
+ ln -s "/usr/lib/init/rc.boot" "$pkgdir/etc/runit/1"
+ ln -s "/usr/lib/init/rc.shutdown" "$pkgdir/etc/runit/3"
+
+ install -d "$pkgdir/usr/bin"
+ install -Dm755 "reboot" "poweroff" "shutdown" "$pkgdir/usr/bin"
+ ln -s "poweroff" "$pkgdir/usr/bin/halt"
+
+ ln -s "runit-init" "$pkgdir/usr/bin/init"
+}
diff --git a/poweroff b/poweroff
new file mode 100755
index 00000000000..409dd991112
--- /dev/null
+++ b/poweroff
@@ -0,0 +1 @@
+#!/usr/bin/runit-init 0
diff --git a/reboot b/reboot
new file mode 100755
index 00000000000..bdb0af7c8c4
--- /dev/null
+++ b/reboot
@@ -0,0 +1 @@
+#!/usr/bin/runit-init 6
diff --git a/shutdown b/shutdown
new file mode 100755
index 00000000000..09151f5d9b3
--- /dev/null
+++ b/shutdown
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+
+PIDFILE="/run/shutdown.pid"
+NOLOGINFILE="/run/nologin"
+name="${0##*/}"
+
+abort() {
+ printf "%s\n" "$1" >&2
+ exit 1
+}
+
+usage() {
+ abort "$name [-hHPrkc] [time] [warning message]"
+}
+
+cancel() {
+ kill "$(< "$PIDFILE")"
+ rm -f "$PIDFILE" "$NOLOGINFILE"
+ echo "${*:-shutdown cancelled}" | wall
+ exit
+}
+
+action=poweroff
+mesg="${2:-The system is shutting down}"
+while getopts HPrhkc opt; do
+ case "$opt" in
+ h|H|P) action=poweroff;;
+ r) action=reboot; mesg="${2:-The system is rebooting}";;
+ k) action=true mesg="${2:-A shutdown test will happen}";;
+ c) cancel ;;
+ [?]) usage ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+time="${1:-+1}"
+
+[ -e "$PIDFILE" ] && abort "A shutdown is already pending"
+echo "$$" > "$PIDFILE" || abort "Not enough permissions to execute $name"
+
+case "$time" in
+ now) time=0 ;;
+ +*) time="$((${time#+} * 60))" ;;
+ *:*) time="$(($(date +%s -d "$time") - $(date +%s)))" ;;
+ *) abort "Invalid time" ;;
+esac
+
+((time < 0)) && abort "Absolute time must lie in the future"
+
+echo "$mesg at $(date +"%H:%M:%S" -d "@$(($(date +%s) + time))") (in $((time / 60)) minutes)" | wall
+
+if ((time > 300)); then
+ sleep "$((time - 300))"
+ touch "$NOLOGINFILE"
+ sleep 300
+else
+ touch "$NOLOGINFILE"
+ sleep "$time"
+fi
+
+echo "$mesg NOW!" | wall
+"$action"