Browse Source

version 0.3.5

- Remove remove hook script
- Add Upgrade to hook

This reverts commit 06f24805f4.
nohooks-patch 0.3.5
M. Herdiansyah 4 years ago
parent
commit
9a105f2d7f
  1. 2
      Makefile
  2. 52
      initswitch
  3. 1
      initswitch-hook
  4. 2
      initswitch-hook-script
  5. 10
      initswitch-remove-hook-script

2
Makefile

@ -11,10 +11,8 @@ install:
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 -m644 initswitch-hook $(DESTDIR)$(PREFIX)/share/libalpm/hooks/initswitch.hook
install -m755 initswitch-hook-script $(DESTDIR)$(PREFIX)/share/libalpm/scripts/initswitch
install -m755 initswitch-remove-hook-script $(DESTDIR)$(PREFIX)/share/libalpm/scripts/initswitch-remove
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

52
initswitch

@ -1,52 +0,0 @@
#!/bin/sh
# This file is part of the halt program.
# To see the licensing terms, see the COPYING file.
check_current_init()
{
if [ "$(ps -o comm= 1)" = "runit" ]; then
selected2="*"
selected1=" "
elif [ "$(ps -o comm= 1)" = "init" ]; then
selected1="*"
selected2=" "
else
printf "\\033[1;31mError:\\033[m Current init is not supported!\\n"
exit 1
fi
}
available_init()
{
printf "Currently available init system(s): \\n"
[ -x "/sbin/openrc-init" ] && printf " - [\\033[1;32m%s\\033[0m] openrc\\n" "$selected1"
[ -x "/sbin/runit-init" ] && printf " - [\\033[1;32m%s\\033[0m] runit\\n" "$selected2"
}
select_init()
{
printf "Select your chosen init: "
read -r NEXTINIT
case $NEXTINIT in
"openrc") ln -sf "openrc-init" "/usr/bin/init" ;;
"runit") ln -sf "runit-init" "/usr/bin/init" ;;
*) printf "Init does not exist/is not supported!\\n"; exit 1 ;;
esac
}
main()
{
if [ "$(id -u)" != "0" ]; then
printf "\\033[1;31mError:\\033[m User must be root to run this program!\\n"
exit 1
fi
check_current_init
available_init
if [ -x "/usr/bin/openrc-init" ] && [ -x "/usr/bin/runit-init" ]; then
select_init
fi
}
main "$@"

1
initswitch-hook

@ -1,6 +1,7 @@
[Trigger]
Type = File
Operation = Install
Operation = Upgrade
Operation = Remove
Target = usr/bin/openrc-init
Target = etc/runit/1

2
initswitch-hook-script

@ -1,7 +1,7 @@
#!/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."
echo " This should not be possible."
elif [ -x "/usr/bin/openrc-init" ]; then
ln -sf "openrc-init" "/usr/bin/init"
echo " Activated OpenRC as your init system."

10
initswitch-remove-hook-script

@ -1,10 +0,0 @@
#!/bin/sh
case $1 in
"openrc") [ "$(cat /proc/1/comm)" == "init" ] && initrunning=1 ;;
"runit") [ "$(cat /proc/1/comm)" == "runit" ] && initrunning=1 ;;
esac
if [ $initrunning = 1 ]; then
echo " $1 is currently running as your init system. You cannot remove it."
exit 1
fi