Compare commits
	
		
			13 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| fdff324081 | |||
| e14878b49c | |||
| 31f3dda786 | |||
| 09ef3fc619 | |||
| 9442565f14 | |||
| c17eb2ad37 | |||
| 70445d2177 | |||
| 5d3cd01ffe | |||
| fccd8fcdd9 | |||
| 0126b86bf7 | |||
| 1487bf4089 | |||
| cf66dd76c5 | |||
| d68ed909c4 | 
							
								
								
									
										7
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								Makefile
									
									
									
									
									
								
							@@ -2,6 +2,7 @@ PREFIX ?= /usr
 | 
			
		||||
ALPMDIR = $(PREFIX)/share/libalpm
 | 
			
		||||
SCRIPTSDIR = $(ALPMDIR)/scripts
 | 
			
		||||
HOOKSDIR = $(ALPMDIR)/hooks
 | 
			
		||||
BINDIR = $(PREFIX)/bin
 | 
			
		||||
 | 
			
		||||
OPENRCSCRIPTS = $(wildcard openrc/scripts/*)
 | 
			
		||||
OPENRCHOOKS = $(wildcard openrc/hooks/*)
 | 
			
		||||
@@ -39,8 +40,6 @@ SYSUSERSHOOKS = $(wildcard esysusers/hooks/*)
 | 
			
		||||
 | 
			
		||||
WRAPPER = $(wildcard wrapper/*)
 | 
			
		||||
 | 
			
		||||
WRAPPERDIR = $(PREFIX)/share/artix
 | 
			
		||||
 | 
			
		||||
DMODE = -dm0755
 | 
			
		||||
MODE = -m0644
 | 
			
		||||
EMODE = -m0755
 | 
			
		||||
@@ -110,7 +109,7 @@ install_dinit_dbus: install_hook_common
 | 
			
		||||
	install $(MODE) $(DINITDBUSHOOKS) $(DESTDIR)$(HOOKSDIR)
 | 
			
		||||
 | 
			
		||||
install_wrapper:
 | 
			
		||||
	install $(DMODE) $(DESTDIR)$(WRAPPERDIR)
 | 
			
		||||
	install $(EMODE) $(WRAPPER) $(DESTDIR)$(WRAPPERDIR)
 | 
			
		||||
	install $(DMODE) $(DESTDIR)$(BINDIR)
 | 
			
		||||
	install $(EMODE) $(WRAPPER) $(DESTDIR)$(BINDIR)
 | 
			
		||||
 | 
			
		||||
.PHONY: install install_base install_s6 install_openrc install_runit install_dinit install_wrapper
 | 
			
		||||
 
 | 
			
		||||
@@ -7,5 +7,5 @@ Target = usr/lib/binfmt.d/*.conf
 | 
			
		||||
[Action]
 | 
			
		||||
Description = Registering binary formats...
 | 
			
		||||
When = PostTransaction
 | 
			
		||||
Exec = /usr/share/libalpm/scripts/dinit-hook binfmt
 | 
			
		||||
Exec = /usr/lib/artix/binfmt.sh
 | 
			
		||||
NeedsTargets
 | 
			
		||||
@@ -46,7 +46,6 @@ op="$1"; shift
 | 
			
		||||
 | 
			
		||||
case $op in
 | 
			
		||||
  sysctl)   dinit_live; each_conf /usr/bin/sysctl -q -p ;;
 | 
			
		||||
  binfmt)   dinit_live; /usr/bin/dinitctl restart binfmt ;;
 | 
			
		||||
  dbus_reload) dinit_live; reload_dbus ;;
 | 
			
		||||
    # For use by other packages
 | 
			
		||||
  reload)   dinit_live; /usr/bin/dinitctl reload "$@"; /usr/bin/dinitctl restart "$@" ;;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +0,0 @@
 | 
			
		||||
[Trigger]
 | 
			
		||||
Type = Path
 | 
			
		||||
Operation = Install
 | 
			
		||||
Operation = Upgrade
 | 
			
		||||
Target = usr/lib/binfmt.d/*.conf
 | 
			
		||||
 | 
			
		||||
[Action]
 | 
			
		||||
Description = Registering binary formats...
 | 
			
		||||
When = PostTransaction
 | 
			
		||||
Exec = /usr/share/libalpm/scripts/runit-hook binfmt
 | 
			
		||||
NeedsTargets
 | 
			
		||||
@@ -34,7 +34,6 @@ op="$1"; shift
 | 
			
		||||
 | 
			
		||||
case $op in
 | 
			
		||||
  sysctl)   runit_live; each_conf /usr/bin/sysctl -q -p ;;
 | 
			
		||||
  binfmt)   runit_live; each_conf /usr/lib/rc/sv.d/binfmt once ;;
 | 
			
		||||
    # For use by other packages
 | 
			
		||||
  reload)   runit_live; /usr/bin/sv "$@" reload ;;
 | 
			
		||||
  add)      svc_add_help ;;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +0,0 @@
 | 
			
		||||
[Trigger]
 | 
			
		||||
Type = Path
 | 
			
		||||
Operation = Install
 | 
			
		||||
Operation = Upgrade
 | 
			
		||||
Target = usr/lib/binfmt.d/*.conf
 | 
			
		||||
 | 
			
		||||
[Action]
 | 
			
		||||
Description = Registering binary formats...
 | 
			
		||||
When = PostTransaction
 | 
			
		||||
Exec = /usr/share/libalpm/scripts/s6-rc-hook binfmt
 | 
			
		||||
NeedsTargets
 | 
			
		||||
@@ -51,7 +51,6 @@ op="$1"; shift
 | 
			
		||||
 | 
			
		||||
case $op in
 | 
			
		||||
  sysctl)   s6_live; each_conf /usr/bin/sysctl -q -p ;;
 | 
			
		||||
  binfmt)   s6_live; sh /etc/s6/sv/binfmt/shell_up ;;
 | 
			
		||||
  dbus_reload) s6_live; reload_dbus ;;
 | 
			
		||||
    # For use by other packages
 | 
			
		||||
  add)      svc_add_help ;;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										90
									
								
								wrapper/artix-service
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								wrapper/artix-service
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,90 @@
 | 
			
		||||
#!/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]="dinitctl -o enable ${SV}"
 | 
			
		||||
    COMMANDS[disable]="dinitctl -o disable ${SV}"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cmds_runit() {
 | 
			
		||||
    mkdir -p /run/runit
 | 
			
		||||
    ln -s /etc/runit/runsvdir/current /run/runit/service 2>/dev/null
 | 
			
		||||
    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
 | 
			
		||||
 | 
			
		||||
[ ${INIT} == s6 ] && s6-db-reload
 | 
			
		||||
@@ -1,55 +0,0 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
sv_start() {
 | 
			
		||||
	case "$init" in
 | 
			
		||||
		openrc) exec /usr/bin/rc-service "$1" start ;;
 | 
			
		||||
		runit) exec /usr/bin/sv start /run/runit/service/"$1" ;;
 | 
			
		||||
		s6) exec /usr/bin/s6-rc -u change "$1" ;;
 | 
			
		||||
		dinit) exec /usr/bin/dinitctl start "$1" ;;
 | 
			
		||||
	esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sv_stop() {
 | 
			
		||||
	case "$init" in
 | 
			
		||||
		openrc) exec /usr/bin/rc-service "$1" stop ;;
 | 
			
		||||
		runit) exec /usr/bin/sv stop /run/runit/service/"$1" ;;
 | 
			
		||||
		s6) exec /usr/bin/s6-rc -d change "$1" ;;
 | 
			
		||||
		dinit) exec /usr/bin/dinitctl stop "$1" ;;
 | 
			
		||||
	esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sv_enable() {
 | 
			
		||||
	case "$init" in
 | 
			
		||||
		openrc) exec /usr/bin/rc-update add "$1" default ;;
 | 
			
		||||
		runit) exec unlink /run/runit/service/"$1"/down ;;
 | 
			
		||||
		s6) exec /usr/bin/s6-service add default "$1" ;;
 | 
			
		||||
		dinit) exec /usr/bin/dinitctl enable "$1" ;;
 | 
			
		||||
	esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sv_disable() {
 | 
			
		||||
	case "$init" in
 | 
			
		||||
		openrc) exec /usr/bin/rc-update del "$1" default ;;
 | 
			
		||||
		runit)  exec touch /run/runit/service/"$1"/down ;;
 | 
			
		||||
		s6) exec /usr/bin/s6-service delete default "$1" ;;
 | 
			
		||||
		dinit) exec /usr/bin/dinitctl disable "$1" ;;
 | 
			
		||||
	esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if [ -d /run/openrc ]; then
 | 
			
		||||
	init=openrc
 | 
			
		||||
elif [-d /run/runit ]; then
 | 
			
		||||
	init=runit
 | 
			
		||||
elif [ -d /run/s6-rc ]; then
 | 
			
		||||
	init=s6
 | 
			
		||||
elif [ -S /run/dinitctl ]; then
 | 
			
		||||
	init=dinit
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
case "$1" in
 | 
			
		||||
	start)   shift; sv_start   "$@" ;;
 | 
			
		||||
	stop)    shift; sv_stop    "$@" ;;
 | 
			
		||||
	enable)  shift; sv_enable  "$@" ;;
 | 
			
		||||
	disable) shift; sv_disable "$@" ;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user