Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c17eb2ad37 | |||
| 70445d2177 | |||
| 5d3cd01ffe | |||
| fccd8fcdd9 | |||
| 0126b86bf7 | |||
| 1487bf4089 | |||
| cf66dd76c5 | |||
| d68ed909c4 | |||
|
|
3ada9e391e | ||
| 3d142ebda7 | |||
| 7a5877342a | |||
| 6a1c2c55d9 | |||
| 09bc2d021b | |||
| 8396101929 | |||
| 1344532759 |
13
Makefile
13
Makefile
@@ -2,6 +2,7 @@ PREFIX ?= /usr
|
|||||||
ALPMDIR = $(PREFIX)/share/libalpm
|
ALPMDIR = $(PREFIX)/share/libalpm
|
||||||
SCRIPTSDIR = $(ALPMDIR)/scripts
|
SCRIPTSDIR = $(ALPMDIR)/scripts
|
||||||
HOOKSDIR = $(ALPMDIR)/hooks
|
HOOKSDIR = $(ALPMDIR)/hooks
|
||||||
|
BINDIR = $(PREFIX)/bin
|
||||||
|
|
||||||
OPENRCSCRIPTS = $(wildcard openrc/scripts/*)
|
OPENRCSCRIPTS = $(wildcard openrc/scripts/*)
|
||||||
OPENRCHOOKS = $(wildcard openrc/hooks/*)
|
OPENRCHOOKS = $(wildcard openrc/hooks/*)
|
||||||
@@ -33,9 +34,11 @@ UDEVHOOKS = $(wildcard udev/hooks/*)
|
|||||||
BASESCRIPTS = $(wildcard base/scripts/*)
|
BASESCRIPTS = $(wildcard base/scripts/*)
|
||||||
BASEHOOKS = $(wildcard base/hooks/*)
|
BASEHOOKS = $(wildcard base/hooks/*)
|
||||||
|
|
||||||
TMPFILESHOOKS = $(wildcard tmpfiles/hooks/*)
|
TMPFILESHOOKS = $(wildcard etmpfiles/hooks/*)
|
||||||
|
|
||||||
SYSUSERSHOOKS = $(wildcard sysusers/hooks/*)
|
SYSUSERSHOOKS = $(wildcard esysusers/hooks/*)
|
||||||
|
|
||||||
|
WRAPPER = $(wildcard wrapper/*)
|
||||||
|
|
||||||
DMODE = -dm0755
|
DMODE = -dm0755
|
||||||
MODE = -m0644
|
MODE = -m0644
|
||||||
@@ -105,4 +108,8 @@ install_dinit_at: install_hook_common
|
|||||||
install_dinit_dbus: install_hook_common
|
install_dinit_dbus: install_hook_common
|
||||||
install $(MODE) $(DINITDBUSHOOKS) $(DESTDIR)$(HOOKSDIR)
|
install $(MODE) $(DINITDBUSHOOKS) $(DESTDIR)$(HOOKSDIR)
|
||||||
|
|
||||||
.PHONY: install install_base install_s6 install_openrc install_runit install_dinit
|
install_wrapper:
|
||||||
|
install $(DMODE) $(DESTDIR)$(BINDIR)
|
||||||
|
install $(EMODE) $(WRAPPER) $(DESTDIR)$(BINDIR)
|
||||||
|
|
||||||
|
.PHONY: install install_base install_s6 install_openrc install_runit install_dinit install_wrapper
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ init_detect(){
|
|||||||
s6_init_remake(){
|
s6_init_remake(){
|
||||||
# we need to ensure that s6-linux-init-maker is run on every machine
|
# we need to ensure that s6-linux-init-maker is run on every machine
|
||||||
rm -rf /tmp/current
|
rm -rf /tmp/current
|
||||||
s6-linux-init-maker -1 -G "/usr/bin/agetty -L -8 tty7 115200" -c /etc/s6/current /tmp/current
|
s6-linux-init-maker -1 -G "/usr/bin/agetty -L -8 tty12 115200" -c /etc/s6/current /tmp/current
|
||||||
mv /tmp/current/bin/init /tmp/current/bin/s6-init
|
mv /tmp/current/bin/init /tmp/current/bin/s6-init
|
||||||
cp -a /tmp/current/bin /usr
|
cp -a /tmp/current/bin /usr
|
||||||
rm -rf /tmp/current/{bin,scripts}
|
rm -rf /tmp/current/{bin,scripts}
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ Target = usr/lib/sysusers.d/*.conf
|
|||||||
[Action]
|
[Action]
|
||||||
Description = Creating system user accounts...
|
Description = Creating system user accounts...
|
||||||
When = PostTransaction
|
When = PostTransaction
|
||||||
Exec = /usr/bin/sysusers
|
Exec = /usr/bin/esysusers
|
||||||
@@ -7,4 +7,4 @@ Target = usr/lib/tmpfiles.d/*.conf
|
|||||||
[Action]
|
[Action]
|
||||||
Description = Creating temporary files...
|
Description = Creating temporary files...
|
||||||
When = PostTransaction
|
When = PostTransaction
|
||||||
Exec = /usr/bin/tmpfiles --create
|
Exec = /usr/bin/etmpfiles --create
|
||||||
@@ -16,7 +16,7 @@ case "$op" in
|
|||||||
udev-reload)
|
udev-reload)
|
||||||
udevd_live
|
udevd_live
|
||||||
/usr/bin/udevadm control --reload
|
/usr/bin/udevadm control --reload
|
||||||
/usr/bin/udevadm trigger
|
/usr/bin/udevadm trigger -c change
|
||||||
/usr/bin/udevadm settle
|
/usr/bin/udevadm settle
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|||||||
86
wrapper/artix-service
Normal file
86
wrapper/artix-service
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cmds_openrc() {
|
||||||
|
COMMANDS[enable]="rc-update add ${SV} default"
|
||||||
|
COMMANDS[disable]="rc-update del ${SV} default"
|
||||||
|
COMMANDS[start]="rc-service ${SV} start"
|
||||||
|
COMMANDS[stop]="rc-service ${SV} stop"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmds_s6() {
|
||||||
|
COMMANDS[start]="s6-rc -u change ${SV}"
|
||||||
|
COMMANDS[stop]="s6-rc -d change ${SV}"
|
||||||
|
COMMANDS[enable]="s6-service add default ${SV}"
|
||||||
|
COMMANDS[disable]="s6-service del default ${SV}"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmds_dinit() {
|
||||||
|
COMMANDS[start]="dinitctl start ${SV}"
|
||||||
|
COMMANDS[stop]="dinitctl stop ${SV}"
|
||||||
|
COMMANDS[enable]="ln -s /etc/dinit.d/${SV} /etc/dinit.d/boot.d/"
|
||||||
|
COMMANDS[disable]="rm /etc/dinit.d/boot.d/${SV}"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmds_runit() {
|
||||||
|
COMMANDS[start]="runsv /etc/runit/sv/${SV}"
|
||||||
|
COMMANDS[stop]="sv stop /etc/runit/sv/${SV}"
|
||||||
|
COMMANDS[enable]="ln -s /etc/runit/sv/${SV} /run/runit/service/"
|
||||||
|
COMMANDS[disable]="rm /run/runit/service/${SV}"
|
||||||
|
}
|
||||||
|
|
||||||
|
is_live() {
|
||||||
|
if [[ ! -d /run/openrc && "${INIT}" == "openrc" ]]; then
|
||||||
|
echo >&2 " Skipped: ${INIT} is not running."
|
||||||
|
exit 0
|
||||||
|
elif [[ ! -d /run/s6-rc && "${INIT}" == "s6" ]]; then
|
||||||
|
echo >&2 " Skipped: ${INIT} is not running."
|
||||||
|
exit 0
|
||||||
|
elif [[ ! -S /run/dinitctl && "${INIT}" == "dinit" ]]; then
|
||||||
|
echo >&2 " Skipped: ${INIT} is not running."
|
||||||
|
exit 0
|
||||||
|
elif [[ ! -d /run/runit && "${INIT}" == "runit" ]]; then
|
||||||
|
echo >&2 " Skipped: ${INIT} is not running."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
detect() {
|
||||||
|
for i in "${SUPPORTED[@]}"; do
|
||||||
|
if [[ -f /usr/bin/"$i"-init ]]; then
|
||||||
|
INIT="$i"
|
||||||
|
cmds_"${INIT}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<EOF
|
||||||
|
usage: ${0##*/} [action] [service]
|
||||||
|
|
||||||
|
actions:
|
||||||
|
enable
|
||||||
|
disable
|
||||||
|
start
|
||||||
|
stop
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly SUPPORTED=(openrc s6 dinit runit)
|
||||||
|
declare -A COMMANDS
|
||||||
|
|
||||||
|
INIT=
|
||||||
|
ACTION="$1"
|
||||||
|
SV="$2"
|
||||||
|
|
||||||
|
if [[ -z "${SV}" ]]; then
|
||||||
|
usage; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
detect
|
||||||
|
|
||||||
|
case "${ACTION}" in
|
||||||
|
start|stop) is_live; ${COMMANDS["${ACTION}"]} ;;
|
||||||
|
enable|disable) ${COMMANDS["${ACTION}"]} ;;
|
||||||
|
help) usage; exit 0 ;;
|
||||||
|
*) usage; exit 1 ;;
|
||||||
|
esac
|
||||||
Reference in New Issue
Block a user