Browse Source

Simplify hook

A force push was used because I'm yet to push this to package to
[goblins].
nohooks-patch 0.3.1
M. Herdiansyah 4 years ago
parent
commit
9c56e33085
  1. 4
      Makefile
  2. 32
      initswitch-hook
  3. 14
      initswitch-hook-script

4
Makefile

@ -5,13 +5,15 @@ all:
install:
install -d $(DESTDIR)$(PREFIX)/bin
install -d $(DESTDIR)$(PREFIX)/share/libalpm/hook
install -d $(DESTDIR)$(PREFIX)/share/libalpm/scripts
install -m755 halt $(DESTDIR)$(PREFIX)/bin/halt
ln -sf halt $(DESTDIR)$(PREFIX)/bin/shutdown
ln -sf halt $(DESTDIR)$(PREFIX)/bin/poweroff
ln -sf halt $(DESTDIR)$(PREFIX)/bin/reboot
install -m755 initswitch $(DESTDIR)$(PREFIX)/bin/initswitch
install -m755 initswitch-hook $(DESTDIR)$(PREFIX)/share/libalpm/scripts/initswitch
install -m644 initswitch-hook $(DESTDIR)$(PREFIX)/share/libalpm/hook/initswitch.hook
install -m755 initswitch-hook-script $(DESTDIR)$(PREFIX)/share/libalpm/scripts/initswitch
install -d $(DESTDIR)$(PREFIX)/share/man/man8
install -m644 halt.8 $(DESTDIR)$(PREFIX)/share/man/man8/halt.8
ln -sf halt.8 $(DESTDIR)$(PREFIX)/share/man/man8/shutdown.8

32
initswitch-hook

@ -1,21 +1,11 @@
#!/bin/sh
if [ ! -L "/usr/bin/init" ]; then
case $1 in
"openrc") ln -sf "openrc-init" "/usr/bin/init" ;;
"runit") ln -sf "runit-init" "/usr/bin/init" ;;
esac
else
if [ -x "/usr/bin/openrc-init" ] && [ -x "/usr/bin/runit-init" ]; then
echo " We detected two init systems are installed in your system."
echo " Use 'initswitch' to choose your init."
elif [ -x "/usr/bin/openrc-init" ]; then
ln -sf "openrc-init" "/usr/bin/init"
echo " Activated OpenRC as your init system."
elif [ -x "/usr/bin/runit-init" ]; then
ln -sf "runit-init" "/usr/bin/init"
echo " Activated runit as your init system."
else
echo " You have no init systems installed."
echo " Install either openrc or runit-artix."
fi
fi
[Trigger]
Type = File
Operation = Install
Operation = Remove
Target = usr/bin/openrc-init
Target = etc/runit/1
[Action]
Description = Activating init switching system...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/initswitch

14
initswitch-hook-script

@ -0,0 +1,14 @@
#!/bin/sh
if [ -x "/usr/bin/openrc-init" ] && [ -x "/usr/bin/runit-init" ] && [ -r "/etc/runit/1" ]; then
echo " We detected two init systems are installed in your system."
echo " Use 'initswitch' to choose your init."
elif [ -x "/usr/bin/openrc-init" ]; then
ln -sf "openrc-init" "/usr/bin/init"
echo " Activated OpenRC as your init system."
elif [ -x "/usr/bin/runit-init" ] && [ -r "/etc/runit/1" ]; then
ln -sf "runit-init" "/usr/bin/init"
echo " Activated runit as your init system."
else
echo " You have no init systems installed."
echo " Install either openrc or runit-artix."
fi