forked from artix/alpm-hooks
		
	Compare commits
	
		
			74 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1729205a54 | |||
| bd83fd645d | |||
| c9518dae35 | |||
| 51cf1104bd | |||
| 89b170310d | |||
| 4937e1ee11 | |||
| b6e6922998 | |||
| 48b9a2a9ec | |||
| e14878b49c | |||
| 31f3dda786 | |||
| 09ef3fc619 | |||
| 9442565f14 | |||
| c17eb2ad37 | |||
| 70445d2177 | |||
| 5d3cd01ffe | |||
| fccd8fcdd9 | |||
| 0126b86bf7 | |||
| 1487bf4089 | |||
| cf66dd76c5 | |||
| d68ed909c4 | |||
|   | 3ada9e391e | ||
| 3d142ebda7 | |||
| 7a5877342a | |||
| 6a1c2c55d9 | |||
| 09bc2d021b | |||
| 8396101929 | |||
| 1344532759 | |||
| 4ace40eddd | |||
| 6a9ac65e53 | |||
| c36cea5240 | |||
| 57bcc7fee2 | |||
|   | da1975c606 | ||
| 8ee6788925 | |||
| fda8182527 | |||
| ca121a8621 | |||
| c375c45283 | |||
| 7ba882813a | |||
| f97c7d3041 | |||
| 5090413f28 | |||
| 315cb334f1 | |||
| b9d94c232e | |||
| d0f03bc2c7 | |||
| a71fa724f6 | |||
| 0bf78e4885 | |||
| c9a6659ec8 | |||
| 3d909a640a | |||
| 42a9f1a5ba | |||
| 2b823adf5c | |||
| 0d93c640ec | |||
| 48aee2b67d | |||
| f47aa4a061 | |||
| 8f970e6b6a | |||
| 10f0b56b79 | |||
| a8a445f2e6 | |||
| bc2867b1cd | |||
| 29cd296aa4 | |||
| 185c4b2e51 | |||
| d2362e98e5 | |||
| 4e4451be73 | |||
| 948388bb18 | |||
| a2164ac051 | |||
| 32cfa84a93 | |||
| 27263a58e8 | |||
| 09bcac3bbb | |||
| c7db8b46ab | |||
| 54b6a8d842 | |||
| 41274292e4 | |||
| 10c5644890 | |||
| 022c5887a5 | |||
|   | b74274ec84 | ||
| 9142373219 | |||
|   | 88147c78b3 | ||
| a88c0c6036 | |||
| 720d72ac7d | 
							
								
								
									
										53
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								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/*) | ||||||
| @@ -16,18 +17,16 @@ RUNITHOOKS = $(wildcard runit/hooks/*) | |||||||
| S6SCRIPTS = $(wildcard s6/scripts/*) | S6SCRIPTS = $(wildcard s6/scripts/*) | ||||||
| S6HOOKS = $(wildcard s6/hooks/*) | S6HOOKS = $(wildcard s6/hooks/*) | ||||||
|  |  | ||||||
| S6EXTRA = s6/s6-rc-bundle-update |  | ||||||
|  |  | ||||||
| S6CRONIEHOOKS = $(wildcard s6/cronie-hooks/*) | S6CRONIEHOOKS = $(wildcard s6/cronie-hooks/*) | ||||||
| S6DBUSHOOKS = $(wildcard s6/dbus-hooks/*) | S6DBUSHOOKS = $(wildcard s6/dbus-hooks/*) | ||||||
| S6ATDHOOKS = $(wildcard s6/atd-hooks/*) | S6ATDHOOKS = $(wildcard s6/atd-hooks/*) | ||||||
|  |  | ||||||
| SUITE66SCRIPTS = $(wildcard suite66/scripts/*) | DINITSCRIPTS = $(wildcard dinit/scripts/*) | ||||||
| SUITE66HOOKS = $(wildcard suite66/hooks/*) | DINITHOOKS = $(wildcard dinit/hooks/*) | ||||||
|  |  | ||||||
| SUITE66CRONIEHOOKS = $(wildcard suite66/cronie-hooks/*) | DINITCRONIEHOOKS = $(wildcard dinit/cronie-hooks/*) | ||||||
| SUITE66DBUSHOOKS = $(wildcard suite66/dbus-hooks/*) | DINITDBUSHOOKS = $(wildcard dinit/dbus-hooks/*) | ||||||
| SUITE66ATDHOOKS = $(wildcard suite66/atd-hooks/*) | DINITATDHOOKS = $(wildcard dinit/atd-hooks/*) | ||||||
|  |  | ||||||
| UDEVSCRIPTS = $(wildcard udev/scripts/*) | UDEVSCRIPTS = $(wildcard udev/scripts/*) | ||||||
| UDEVHOOKS = $(wildcard udev/hooks/*) | UDEVHOOKS = $(wildcard udev/hooks/*) | ||||||
| @@ -35,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 | ||||||
| @@ -50,10 +51,6 @@ install_common: | |||||||
| install_hook_common: | install_hook_common: | ||||||
| 	install $(DMODE) $(DESTDIR)$(HOOKSDIR) | 	install $(DMODE) $(DESTDIR)$(HOOKSDIR) | ||||||
|  |  | ||||||
| install_s6_extra: |  | ||||||
| 	install $(DMODE) $(DESTDIR)$(PREFIX)/bin |  | ||||||
| 	install $(EMODE) $(S6EXTRA) $(DESTDIR)$(PREFIX)/bin |  | ||||||
|  |  | ||||||
| install_base: install_common | install_base: install_common | ||||||
| 	install $(EMODE) $(BASESCRIPTS) $(DESTDIR)$(SCRIPTSDIR) | 	install $(EMODE) $(BASESCRIPTS) $(DESTDIR)$(SCRIPTSDIR) | ||||||
| 	install $(MODE) $(BASEHOOKS) $(DESTDIR)$(HOOKSDIR) | 	install $(MODE) $(BASEHOOKS) $(DESTDIR)$(HOOKSDIR) | ||||||
| @@ -62,10 +59,10 @@ install_udev: install_common | |||||||
| 	install $(EMODE) $(UDEVSCRIPTS) $(DESTDIR)$(SCRIPTSDIR) | 	install $(EMODE) $(UDEVSCRIPTS) $(DESTDIR)$(SCRIPTSDIR) | ||||||
| 	install $(MODE) $(UDEVHOOKS) $(DESTDIR)$(HOOKSDIR) | 	install $(MODE) $(UDEVHOOKS) $(DESTDIR)$(HOOKSDIR) | ||||||
|  |  | ||||||
| install_tmpfiles: install_common | install_tmpfiles: install_hook_common | ||||||
| 	install $(MODE) $(TMPFILESHOOKS) $(DESTDIR)$(HOOKSDIR) | 	install $(MODE) $(TMPFILESHOOKS) $(DESTDIR)$(HOOKSDIR) | ||||||
|  |  | ||||||
| install_sysusers: install_common | install_sysusers: install_hook_common | ||||||
| 	install $(MODE) $(SYSUSERSHOOKS) $(DESTDIR)$(HOOKSDIR) | 	install $(MODE) $(SYSUSERSHOOKS) $(DESTDIR)$(HOOKSDIR) | ||||||
|  |  | ||||||
| install_openrc: install_common | install_openrc: install_common | ||||||
| @@ -76,13 +73,13 @@ install_runit: install_common | |||||||
| 	install $(EMODE) $(RUNITSCRIPTS) $(DESTDIR)$(SCRIPTSDIR) | 	install $(EMODE) $(RUNITSCRIPTS) $(DESTDIR)$(SCRIPTSDIR) | ||||||
| 	install $(MODE) $(RUNITHOOKS) $(DESTDIR)$(HOOKSDIR) | 	install $(MODE) $(RUNITHOOKS) $(DESTDIR)$(HOOKSDIR) | ||||||
|  |  | ||||||
| install_s6: install_common install_s6_extra | install_s6: install_common | ||||||
| 	install $(EMODE) $(S6SCRIPTS) $(DESTDIR)$(SCRIPTSDIR) | 	install $(EMODE) $(S6SCRIPTS) $(DESTDIR)$(SCRIPTSDIR) | ||||||
| 	install $(MODE) $(S6HOOKS) $(DESTDIR)$(HOOKSDIR) | 	install $(MODE) $(S6HOOKS) $(DESTDIR)$(HOOKSDIR) | ||||||
|  |  | ||||||
| install_suite66: install_common | install_dinit: install_common | ||||||
| 	install $(EMODE) $(SUITE66SCRIPTS) $(DESTDIR)$(SCRIPTSDIR) | 	install $(EMODE) $(DINITSCRIPTS) $(DESTDIR)$(SCRIPTSDIR) | ||||||
| 	install $(MODE) $(SUITE66HOOKS) $(DESTDIR)$(HOOKSDIR) | 	install $(MODE) $(DINITHOOKS) $(DESTDIR)$(HOOKSDIR) | ||||||
|  |  | ||||||
| install_openrc_cronie: install_hook_common | install_openrc_cronie: install_hook_common | ||||||
| 	install $(MODE) $(OPENRCCRONIEHOOKS) $(DESTDIR)$(HOOKSDIR) | 	install $(MODE) $(OPENRCCRONIEHOOKS) $(DESTDIR)$(HOOKSDIR) | ||||||
| @@ -102,13 +99,17 @@ install_s6_at: install_hook_common | |||||||
| install_s6_dbus: install_hook_common | install_s6_dbus: install_hook_common | ||||||
| 	install $(MODE) $(S6DBUSHOOKS) $(DESTDIR)$(HOOKSDIR) | 	install $(MODE) $(S6DBUSHOOKS) $(DESTDIR)$(HOOKSDIR) | ||||||
|  |  | ||||||
| install_suite66_cronie: install_hook_common | install_dinit_cronie: install_hook_common | ||||||
| 	install $(MODE) $(SUITE66CRONIEHOOKS) $(DESTDIR)$(HOOKSDIR) | 	install $(MODE) $(DINITCRONIEHOOKS) $(DESTDIR)$(HOOKSDIR) | ||||||
|  |  | ||||||
| install_suite66_dbus: install_hook_common | install_dinit_at: install_hook_common | ||||||
| 	install $(MODE) $(SUITE66DBUSHOOKS) $(DESTDIR)$(HOOKSDIR) | 	install $(MODE) $(DINITATDHOOKS) $(DESTDIR)$(HOOKSDIR) | ||||||
|  |  | ||||||
| install_suite66_at: install_hook_common | install_dinit_dbus: install_hook_common | ||||||
| 	install $(MODE) $(SUITE66ATDHOOKS) $(DESTDIR)$(HOOKSDIR) | 	install $(MODE) $(DINITDBUSHOOKS) $(DESTDIR)$(HOOKSDIR) | ||||||
|  |  | ||||||
| .PHONY: install install_base install_s6 install_openrc install_runit install_suite66 | 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 | ||||||
|   | |||||||
| @@ -7,5 +7,5 @@ Target = usr/lib/binfmt.d/*.conf | |||||||
| [Action] | [Action] | ||||||
| Description = Registering binary formats... | Description = Registering binary formats... | ||||||
| When = PostTransaction | When = PostTransaction | ||||||
| Exec = /usr/share/libalpm/scripts/66-hook binfmt | Exec = /usr/lib/artix/binfmt.sh | ||||||
| NeedsTargets | NeedsTargets | ||||||
| @@ -5,7 +5,7 @@ Type = Path | |||||||
| Target = usr/bin/openrc-init | Target = usr/bin/openrc-init | ||||||
| Target = usr/bin/runit-init | Target = usr/bin/runit-init | ||||||
| Target = usr/bin/s6-init | Target = usr/bin/s6-init | ||||||
| Target = usr/bin/suite66-init | Target = usr/bin/dinit-init | ||||||
|  |  | ||||||
| [Action] | [Action] | ||||||
| Description = Setting init symlink ... | Description = Setting init symlink ... | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ init_conf(){ | |||||||
| } | } | ||||||
|  |  | ||||||
| init_detect(){ | init_detect(){ | ||||||
|     artix_inits="openrc-init runit-init s6-init suite66-init" |     artix_inits="openrc-init runit-init s6-init dinit-init" | ||||||
|     for supported in ${artix_inits}; do |     for supported in ${artix_inits}; do | ||||||
|         bin=/usr/bin/"$supported" |         bin=/usr/bin/"$supported" | ||||||
|         if [ -f "$bin" ];then |         if [ -f "$bin" ];then | ||||||
| @@ -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} | ||||||
|   | |||||||
| @@ -6,4 +6,4 @@ Target = glibc | |||||||
| [Action] | [Action] | ||||||
| Description = Restarting atd for libc upgrade... | Description = Restarting atd for libc upgrade... | ||||||
| When = PostTransaction | When = PostTransaction | ||||||
| Exec = /usr/share/libalpm/scripts/66-hook longrun_restart atd | Exec = /usr/share/libalpm/scripts/dinit-hook restart atd | ||||||
| @@ -6,4 +6,4 @@ Target = glibc | |||||||
| [Action] | [Action] | ||||||
| Description = Restarting cronie for libc upgrade... | Description = Restarting cronie for libc upgrade... | ||||||
| When = PostTransaction | When = PostTransaction | ||||||
| Exec = /usr/share/libalpm/scripts/66-hook longrun_restart cronie | Exec = /usr/share/libalpm/scripts/dinit-hook restart cronie | ||||||
| @@ -10,4 +10,4 @@ Target = usr/share/dbus-1/system-services/*.service | |||||||
| [Action] | [Action] | ||||||
| Description = Reloading system bus configuration... | Description = Reloading system bus configuration... | ||||||
| When = PostTransaction | When = PostTransaction | ||||||
| Exec = /usr/share/libalpm/scripts/66-hook dbus_reload | Exec = /usr/share/libalpm/scripts/dinit-hook dbus_reload | ||||||
| @@ -8,5 +8,5 @@ Target = usr/lib/sysctl.d/*.conf | |||||||
| [Action] | [Action] | ||||||
| Description = Applying kernel sysctl settings... | Description = Applying kernel sysctl settings... | ||||||
| When = PostTransaction | When = PostTransaction | ||||||
| Exec = /usr/share/libalpm/scripts/66-hook sysctl | Exec = /usr/share/libalpm/scripts/dinit-hook sysctl | ||||||
| NeedsTargets | NeedsTargets | ||||||
							
								
								
									
										11
									
								
								dinit/hooks/dinit-install.hook
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								dinit/hooks/dinit-install.hook
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | [Trigger] | ||||||
|  | Type = Path | ||||||
|  | Operation = Install | ||||||
|  | Operation = Upgrade | ||||||
|  | Target = etc/dinit.d/* | ||||||
|  |  | ||||||
|  | [Action] | ||||||
|  | Description = Displaying dinit service help ... | ||||||
|  | When = PostTransaction | ||||||
|  | Exec = /usr/share/libalpm/scripts/dinit-hook add | ||||||
|  | NeedsTargets | ||||||
							
								
								
									
										10
									
								
								dinit/hooks/dinit-remove.hook
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								dinit/hooks/dinit-remove.hook
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | [Trigger] | ||||||
|  | Type = Path | ||||||
|  | Operation = Remove | ||||||
|  | Target = etc/dunit.d/* | ||||||
|  |  | ||||||
|  | [Action] | ||||||
|  | Description = Displaying dinit service help ... | ||||||
|  | When = PostTransaction | ||||||
|  | Exec = /usr/share/libalpm/scripts/dinit-hook del | ||||||
|  | NeedsTargets | ||||||
							
								
								
									
										11
									
								
								dinit/hooks/dinit-user-install.hook
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								dinit/hooks/dinit-user-install.hook
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | [Trigger] | ||||||
|  | Type = Path | ||||||
|  | Operation = Install | ||||||
|  | Operation = Upgrade | ||||||
|  | Target = etc/dinit.d/user/* | ||||||
|  |  | ||||||
|  | [Action] | ||||||
|  | Description = Displaying dinit user service help ... | ||||||
|  | When = PostTransaction | ||||||
|  | Exec = /usr/share/libalpm/scripts/dinit-hook addU | ||||||
|  | NeedsTargets | ||||||
							
								
								
									
										10
									
								
								dinit/hooks/dinit-user-remove.hook
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								dinit/hooks/dinit-user-remove.hook
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | [Trigger] | ||||||
|  | Type = Path | ||||||
|  | Operation = Remove | ||||||
|  | Target = etc/dinit.d/user/* | ||||||
|  |  | ||||||
|  | [Action] | ||||||
|  | Description = Displaying dinit user service help ... | ||||||
|  | When = PostTransaction | ||||||
|  | Exec = /usr/share/libalpm/scripts/dinit-hook delU | ||||||
|  | NeedsTargets | ||||||
							
								
								
									
										72
									
								
								dinit/scripts/dinit-hook
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								dinit/scripts/dinit-hook
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,72 @@ | |||||||
|  | #!/bin/sh -e | ||||||
|  |  | ||||||
|  | dinit_live() { | ||||||
|  |   if [ ! -S /run/dinitctl ]; then | ||||||
|  |     echo >&2 "  Skipped: Current root is not booted." | ||||||
|  |     exit 0 | ||||||
|  |   fi | ||||||
|  | } | ||||||
|  |  | ||||||
|  | svc_help(){ | ||||||
|  |     echo "	==> Start/stop/restart a service:" | ||||||
|  |     echo "	dinitctl <start/stop/restart> <service>" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | svc_add_help(){ | ||||||
|  |     echo "	==> Add a service:" | ||||||
|  |     echo "	# dinitctl enable <service>" | ||||||
|  |     svc_help | ||||||
|  | } | ||||||
|  |  | ||||||
|  | svc_del_help(){ | ||||||
|  |     echo "	==> Remove a service:" | ||||||
|  |     echo "	# dinitctl disable <service>" | ||||||
|  |     svc_help | ||||||
|  | } | ||||||
|  |  | ||||||
|  | svc_user_add_help(){ | ||||||
|  |     echo "	==> Add a user service:" | ||||||
|  |     echo "	$ dinitctl enable <service>" | ||||||
|  |     svc_help | ||||||
|  | } | ||||||
|  |  | ||||||
|  | svc_user_del_help(){ | ||||||
|  |     echo "	==> Remove a user service:" | ||||||
|  |     echo "	$ dinitctl disable <service>" | ||||||
|  |     svc_help | ||||||
|  | } | ||||||
|  |  | ||||||
|  | each_conf() { | ||||||
|  |   while read -r f; do | ||||||
|  |     "$@" "/$f" | ||||||
|  |   done | ||||||
|  | } | ||||||
|  |  | ||||||
|  | reload_dbus() { | ||||||
|  |     dbus-send --print-reply --system --type=method_call \ | ||||||
|  |             --dest=org.freedesktop.DBus \ | ||||||
|  |             / org.freedesktop.DBus.ReloadConfig > /dev/null | ||||||
|  | } | ||||||
|  |  | ||||||
|  | restart_service() { | ||||||
|  |     if dinitctl list | grep -qF "[[+]     ] $1"; then | ||||||
|  |         dinitctl restart "$1" | ||||||
|  |     fi | ||||||
|  | } | ||||||
|  |  | ||||||
|  | op="$1"; shift | ||||||
|  |  | ||||||
|  | case $op in | ||||||
|  |   sysctl)   dinit_live; each_conf /usr/bin/sysctl -q -p ;; | ||||||
|  |   dbus_reload) dinit_live; reload_dbus ;; | ||||||
|  |     # For use by other packages | ||||||
|  |   reload)   dinit_live; /usr/bin/dinitctl reload "$@"; /usr/bin/dinitctl restart "$@" ;; | ||||||
|  |   restart)  dinit_live; restart_service "$1" ;; | ||||||
|  |   add)      svc_add_help ;; | ||||||
|  |   del)      svc_del_help ;; | ||||||
|  |   addU)      svc_user_add_help ;; | ||||||
|  |   delU)      svc_user_del_help ;; | ||||||
|  |   *) echo >&2 "  Invalid operation '$op'"; exit 1 ;; | ||||||
|  | esac | ||||||
|  |  | ||||||
|  | exit 0 | ||||||
| @@ -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 | ||||||
| @@ -4,6 +4,6 @@ Operation = Upgrade | |||||||
| Target = openrc | Target = openrc | ||||||
|  |  | ||||||
| [Action] | [Action] | ||||||
| Description = Reexecuting init ... | Description = Configuring user service & reexecuting init ... | ||||||
| When = PostTransaction | When = PostTransaction | ||||||
| Exec = /usr/share/libalpm/scripts/openrc-hook reexec | Exec = /usr/share/libalpm/scripts/openrc-hook reexec | ||||||
|   | |||||||
							
								
								
									
										11
									
								
								openrc/hooks/openrc-user-install.hook
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								openrc/hooks/openrc-user-install.hook
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | [Trigger] | ||||||
|  | Type = Path | ||||||
|  | Operation = Install | ||||||
|  | Operation = Upgrade | ||||||
|  | Target = etc/user/init.d/* | ||||||
|  |  | ||||||
|  | [Action] | ||||||
|  | Description = Displaying openrc user service help ... | ||||||
|  | When = PostTransaction | ||||||
|  | Exec = /usr/share/libalpm/scripts/openrc-hook uadd | ||||||
|  | NeedsTargets | ||||||
							
								
								
									
										10
									
								
								openrc/hooks/openrc-user-remove.hook
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								openrc/hooks/openrc-user-remove.hook
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | [Trigger] | ||||||
|  | Type = Path | ||||||
|  | Operation = Remove | ||||||
|  | Target = etc/user/init.d/* | ||||||
|  |  | ||||||
|  | [Action] | ||||||
|  | Description = Displaying openrc user service help ... | ||||||
|  | When = PostTransaction | ||||||
|  | Exec = /usr/share/libalpm/scripts/openrc-hook udel | ||||||
|  | NeedsTargets | ||||||
| @@ -1,46 +1,80 @@ | |||||||
| #!/bin/sh -e | #!/bin/sh -e | ||||||
|  |  | ||||||
| openrc_live() { | openrc_live() { | ||||||
|   if [ ! -f /run/openrc/softlevel ]; then |     if [ ! -f /run/openrc/softlevel ]; then | ||||||
|     echo >&2 "  Skipped: Current root is not booted." |         echo >&2 "  Skipped: Current root is not booted." | ||||||
|     exit 0 |         exit 0 | ||||||
|   fi |     fi | ||||||
| } |  | ||||||
|  |  | ||||||
| svc_help(){ |  | ||||||
|     echo "	==> Start/stop/restart a service:" |  | ||||||
|     echo "	rc-service <service> <start/stop/restart>" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| svc_add_help(){ |  | ||||||
|     echo "	==> Add a service to runlevel:" |  | ||||||
|     echo "	rc-update add <service> <runlevel>" |  | ||||||
|     svc_help |  | ||||||
| } |  | ||||||
|  |  | ||||||
| svc_del_help(){ |  | ||||||
|     echo "	==> Remove a service from runlevel:" |  | ||||||
|     echo "	rc-update del <service> <runlevel>" |  | ||||||
|     svc_help |  | ||||||
| } | } | ||||||
|  |  | ||||||
| each_conf() { | each_conf() { | ||||||
|   while read -r f; do |     while read -r f; do | ||||||
|     "$@" "/$f" |         "$@" "/$f" | ||||||
|   done |     done | ||||||
|  | } | ||||||
|  |  | ||||||
|  | svc_help(){ | ||||||
|  |     arg="${1:-}" | ||||||
|  |     str="${arg#--*}" | ||||||
|  |     if [ -n "$str" ]; then | ||||||
|  |         echo "	==> Start/stop/restart a $str service:" | ||||||
|  |     else | ||||||
|  |         echo "	==> Start/stop/restart a service:" | ||||||
|  |     fi | ||||||
|  |     echo "	rc-service <service> <start/stop/restart>" "$arg" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | svc_add_help(){ | ||||||
|  |     arg="${1:-}" | ||||||
|  |     str="${arg#--*}" | ||||||
|  |     if [ -n "$str" ]; then | ||||||
|  |         echo "	==> Add a $str service to runlevel:" | ||||||
|  |     else | ||||||
|  |         echo "	==> Add a service to runlevel:" | ||||||
|  |     fi | ||||||
|  |     echo "	rc-update add <service> <runlevel>" "$arg" | ||||||
|  |     svc_help "$arg" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | svc_del_help(){ | ||||||
|  |     arg="${1:-}" | ||||||
|  |     str="${arg#--*}" | ||||||
|  |     if [ -n "$str" ]; then | ||||||
|  |         echo "	==> Remove a $str service from runlevel:" | ||||||
|  |     else | ||||||
|  |         echo "	==> Remove a service from runlevel:" | ||||||
|  |     fi | ||||||
|  |     echo "	rc-update del <service> <runlevel>" "$arg" | ||||||
|  |     svc_help "$arg" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | svc_user_ln() { | ||||||
|  |     umin=$(grep "^UID_MIN" /etc/login.defs) | ||||||
|  |     umax=$(grep "^UID_MAX" /etc/login.defs) | ||||||
|  |     users=$(awk -F':' -v "min=${umin##UID_MIN}" -v "max=${umax##UID_MAX}" \ | ||||||
|  |         '{ if ( $3 >= min && $3 <= max ) print $0 }' /etc/passwd \ | ||||||
|  |             | cut -d: -f1) | ||||||
|  |  | ||||||
|  |     for u in $users; do | ||||||
|  |         if [ ! -e /etc/init.d/user.$u ]; then | ||||||
|  |             ln -sv /etc/init.d/user /etc/init.d/user.$u | ||||||
|  |         fi | ||||||
|  |     done | ||||||
| } | } | ||||||
|  |  | ||||||
| op="$1"; shift | op="$1"; shift | ||||||
|  |  | ||||||
| case $op in | case $op in | ||||||
|   sysctl)   openrc_live; each_conf /usr/bin/sysctl -q -p ;; |     sysctl) openrc_live; each_conf /usr/bin/sysctl -q -p ;; | ||||||
|   binfmt)   openrc_live; each_conf /usr/lib/openrc/sh/binfmt.sh ;; |     binfmt) openrc_live; each_conf /usr/lib/openrc/sh/binfmt.sh ;; | ||||||
|   reexec) openrc_live; /usr/bin/openrc-shutdown -R ;; |     reexec) svc_user_ln; openrc_live; /usr/bin/openrc-shutdown -R ;; | ||||||
|     # For use by other packages |     # For use by other packages | ||||||
|   reload)        openrc_live; /usr/bin/rc-service "$@" reload ;; |     reload) openrc_live; /usr/bin/rc-service "$@" reload ;; | ||||||
|   add) svc_add_help ;; |     add) svc_add_help ;; | ||||||
|   del) svc_del_help ;; |     del) svc_del_help ;; | ||||||
|   *) echo >&2 "  Invalid operation '$op'"; exit 1 ;; |     uadd) svc_add_help "--user" ;; | ||||||
|  |     udel) svc_del_help "--user" ;; | ||||||
|  |     *) echo >&2 "  Invalid operation '$op'"; exit 1 ;; | ||||||
| esac | esac | ||||||
|  |  | ||||||
| exit 0 | exit 0 | ||||||
|   | |||||||
| @@ -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 |  | ||||||
| @@ -1,7 +1,6 @@ | |||||||
| [Trigger] | [Trigger] | ||||||
| Type = Path | Type = Path | ||||||
| Operation = Install | Operation = Install | ||||||
| Operation = Upgrade |  | ||||||
| Target = etc/runit/sv/* | Target = etc/runit/sv/* | ||||||
|  |  | ||||||
| [Action] | [Action] | ||||||
|   | |||||||
| @@ -14,13 +14,13 @@ svc_help(){ | |||||||
|  |  | ||||||
| svc_add_help(){ | svc_add_help(){ | ||||||
|     echo "	==> Add a service:" |     echo "	==> Add a service:" | ||||||
|     echo "	ln -s /etc/runit/sv/<service> /run/runit/service/" |     echo "	ln -s ../../sv/<service> /run/runit/service/" | ||||||
|     svc_help |     svc_help | ||||||
| } | } | ||||||
|  |  | ||||||
| svc_del_help(){ | svc_del_help(){ | ||||||
|     echo "	==> Remove a service:" |     echo "	==> Remove a service:" | ||||||
|     echo "	rm /run/runit/service/<service>" |     echo "	unlink /run/runit/service/<service>" | ||||||
|     svc_help |     svc_help | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -34,7 +34,6 @@ op="$1"; shift | |||||||
|  |  | ||||||
| case $op in | case $op in | ||||||
|   sysctl)   runit_live; each_conf /usr/bin/sysctl -q -p ;; |   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 |     # For use by other packages | ||||||
|   reload)   runit_live; /usr/bin/sv "$@" reload ;; |   reload)   runit_live; /usr/bin/sv "$@" reload ;; | ||||||
|   add)      svc_add_help ;; |   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 |  | ||||||
| @@ -1,10 +0,0 @@ | |||||||
| [Trigger] |  | ||||||
| Type = Path |  | ||||||
| Operation = Remove |  | ||||||
| Target = etc/s6/sv/* |  | ||||||
|  |  | ||||||
| [Action] |  | ||||||
| Description = Shutting down services ... |  | ||||||
| When = PreTransaction |  | ||||||
| Exec = /usr/share/libalpm/scripts/s6-rc-hook shutdown_sv |  | ||||||
| NeedsTargets |  | ||||||
| @@ -8,4 +8,4 @@ Target = etc/s6/sv/* | |||||||
| [Action] | [Action] | ||||||
| Description = Updating s6-rc database... | Description = Updating s6-rc database... | ||||||
| When = PostTransaction | When = PostTransaction | ||||||
| Exec = /usr/share/libalpm/scripts/s6-rc-db-update-hook | Exec = /usr/bin/s6-db-reload | ||||||
|   | |||||||
| @@ -1,166 +0,0 @@ | |||||||
| #!/bin/sh |  | ||||||
|  |  | ||||||
| # {{{ functions |  | ||||||
|  |  | ||||||
| db_action() { |  | ||||||
|     s6-rc-db -c "${DATABASE}" "$@" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| bundle_action() { |  | ||||||
|     s6-rc-bundle -c "${DATABASE}" "$@" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| db_err_msg() { |  | ||||||
|     echo "${CMD_UPD}: fatal: unable to take lock on ${DATABASE} Permission denied" |  | ||||||
|     exit 1 |  | ||||||
| } |  | ||||||
|  |  | ||||||
| bundle_err_msg() { |  | ||||||
|     echo "${BUNDLE} is not an existing bundle. Create it with ${CMD}." |  | ||||||
|     exit 1 |  | ||||||
| } |  | ||||||
|  |  | ||||||
| bundle_entry_err_msg() { |  | ||||||
|     name="$1" |  | ||||||
|     echo "$name does not exist in bundle ${BUNDLE}!" |  | ||||||
|     exit 1 |  | ||||||
| } |  | ||||||
|  |  | ||||||
| bundle_add_err_msg() { |  | ||||||
|     echo "Error when trying to add ${CONTENTS}!" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| cmd_help() { |  | ||||||
|     echo "${CMD_UPD} help" |  | ||||||
|     echo "${CMD_UPD} add bundlename contents..." |  | ||||||
|     echo "${CMD_UPD} delete bundlename contents..." |  | ||||||
|     echo "${CMD_UPD} list bundlename" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| bundle_action_check() { |  | ||||||
|     pos="$1" |  | ||||||
|     num="$2" |  | ||||||
|  |  | ||||||
|     if [ "$pos" -lt "$num" ]; then |  | ||||||
|         echo "${HELP_MSG}" |  | ||||||
|         exit 1 |  | ||||||
|     fi |  | ||||||
|  |  | ||||||
|     isbundle=$(db_action type "${BUNDLE}" 2> /dev/null) |  | ||||||
|  |  | ||||||
|     if [ "$?" = 111 ]; then |  | ||||||
|         db_err_msg |  | ||||||
|     fi |  | ||||||
|  |  | ||||||
|     if [ "$isbundle" != "bundle" ]; then |  | ||||||
|         bundle_err_msg |  | ||||||
|     fi |  | ||||||
| } |  | ||||||
|  |  | ||||||
| bundle_to_backup() { |  | ||||||
|     backup=$(db_action contents "${BUNDLE}") |  | ||||||
|  |  | ||||||
|     for entry in ${CONTENTS}; do |  | ||||||
|  |  | ||||||
|         isbundle=$(db_action type "$entry" 2> /dev/null) |  | ||||||
|  |  | ||||||
|         entrycontents=$entry |  | ||||||
|         if [ "$isbundle" = "bundle" ]; then |  | ||||||
|             entrycontents=$(db_action contents "$entry") |  | ||||||
|         fi |  | ||||||
|  |  | ||||||
|         for srv in $entrycontents; do |  | ||||||
|             if ! echo $backup | grep -w "$srv" > /dev/null; then |  | ||||||
|                 bundle_entry_err_msg "$entry" |  | ||||||
|             else |  | ||||||
|                 oldupdated="" |  | ||||||
|                 for oldsrv in $backup; do |  | ||||||
|                     if [ "$oldsrv" != "$srv" ]; then |  | ||||||
|                         oldupdated="${oldupdated} $oldsrv" |  | ||||||
|                     fi |  | ||||||
|                 done |  | ||||||
|                 backup=$oldupdated |  | ||||||
|             fi |  | ||||||
|         done |  | ||||||
|  |  | ||||||
|     done |  | ||||||
|  |  | ||||||
|     echo "$backup" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| cmd_add() { |  | ||||||
|     pos="$1" |  | ||||||
|     bundle_action_check "$pos" 3 |  | ||||||
|  |  | ||||||
|     old="$(db_action contents "${BUNDLE}")" |  | ||||||
|  |  | ||||||
|     bundle_action delete "${BUNDLE}" |  | ||||||
|  |  | ||||||
|     if ! bundle_action add "${BUNDLE}" $old ${CONTENTS}; then |  | ||||||
|         bundle_add_err_msg |  | ||||||
|         bundle_action add "${BUNDLE}" $old |  | ||||||
|     fi |  | ||||||
| } |  | ||||||
|  |  | ||||||
| cmd_delete() { |  | ||||||
|     pos="$1" |  | ||||||
|     bundle_action_check "$pos" 3 |  | ||||||
|  |  | ||||||
|     old="$(bundle_to_backup)" |  | ||||||
|     if [ "$?" = 1 ]; then |  | ||||||
|         echo $old |  | ||||||
|         exit 1 |  | ||||||
|     fi |  | ||||||
|  |  | ||||||
|     bundle_action delete "${BUNDLE}" |  | ||||||
|     bundle_action add "${BUNDLE}" $old |  | ||||||
| } |  | ||||||
|  |  | ||||||
| cmd_list() { |  | ||||||
|     pos="$1" |  | ||||||
|     bundle_action_check "$pos" 2 |  | ||||||
|  |  | ||||||
|     db_action contents "${BUNDLE}" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| # }}} |  | ||||||
|  |  | ||||||
| BUNDLE="" |  | ||||||
| COMMAND="" |  | ||||||
| CONTENTS="" |  | ||||||
| DATABASE="/run/s6-rc/compiled" |  | ||||||
|  |  | ||||||
| CMD="s6-rc-bundle" |  | ||||||
| CMD_UPD="${CMD}-update" |  | ||||||
| HELP_MSG="${CMD_UPD}: usage: ${CMD_UPD} [ -c compiled ] command... (use ${CMD_UPD} help for more information)" |  | ||||||
|  |  | ||||||
| c_arg=false |  | ||||||
|  |  | ||||||
| for arg in "$@"; do |  | ||||||
|     if [ "$c_arg" = true ]; then |  | ||||||
|         DATABASE=$arg |  | ||||||
|         c_arg=false |  | ||||||
|         continue |  | ||||||
|     fi |  | ||||||
|     if [ "$arg" = "-c" ]; then |  | ||||||
|         c_arg=true |  | ||||||
|         continue |  | ||||||
|     fi |  | ||||||
|     if [ "${COMMAND}" = "" ]; then |  | ||||||
|         COMMAND=$arg |  | ||||||
|         continue |  | ||||||
|     fi |  | ||||||
|     if [ "${BUNDLE}" = "" ]; then |  | ||||||
|         BUNDLE=$arg |  | ||||||
|         continue |  | ||||||
|     fi |  | ||||||
|     CONTENTS="${CONTENTS} $arg" |  | ||||||
| done |  | ||||||
|  |  | ||||||
| case "${COMMAND}" in |  | ||||||
|     help) cmd_help ;; |  | ||||||
|     add) cmd_add "$#" ;; |  | ||||||
|     delete) cmd_delete "$#" ;; |  | ||||||
|     list) cmd_list "$#" ;; |  | ||||||
|     *) echo "${HELP_MSG}" ;; |  | ||||||
| esac |  | ||||||
| @@ -1,122 +0,0 @@ | |||||||
| #!/bin/bash |  | ||||||
|  |  | ||||||
| # {{{ functions |  | ||||||
|  |  | ||||||
| db_action() { |  | ||||||
|     s6-rc-db -c "${DBPATH}" "$@" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| a_newbundle() { |  | ||||||
|     for j in $new_bundles; do |  | ||||||
|         if [ "$j" = "$1" ]; then |  | ||||||
|             return 0 |  | ||||||
|         fi |  | ||||||
|     done |  | ||||||
|     return 1 |  | ||||||
| } |  | ||||||
|  |  | ||||||
| service_exists() { |  | ||||||
|     for k in $all_services; do |  | ||||||
|         if [ "$k" = "$1" ]; then |  | ||||||
|             return 0 |  | ||||||
|         fi |  | ||||||
|     done |  | ||||||
|     return 1 |  | ||||||
| } |  | ||||||
|  |  | ||||||
| in_newbundle() { |  | ||||||
|     bundle_contents=$(db_action contents "$1") |  | ||||||
|     for l in $bundle_contents; do |  | ||||||
|         if [ "$l" = "$2" ]; then |  | ||||||
|             return 0 |  | ||||||
|         fi |  | ||||||
|     done |  | ||||||
|     return 1 |  | ||||||
| } |  | ||||||
|  |  | ||||||
| # }}} |  | ||||||
|  |  | ||||||
|  |  | ||||||
| # main |  | ||||||
|  |  | ||||||
| RCPATH='/etc/s6/rc' |  | ||||||
| DBPATH="${RCPATH}/compiled" |  | ||||||
| SVPATH='/etc/s6/sv' |  | ||||||
| SVDIRS='/run/s6-rc/servicedirs' |  | ||||||
| TIMESTAMP=$(date +%s) |  | ||||||
|  |  | ||||||
| if [ -e "${DBPATH}" ]; then |  | ||||||
|     old_bundles="$(db_action list bundles)" |  | ||||||
|     len=0 |  | ||||||
|     for bundle in $old_bundles; do |  | ||||||
|         contents[$len]=$(db_action contents "$bundle") |  | ||||||
|         len=$(( len + 1 )) |  | ||||||
|     done |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| if ! s6-rc-compile "${DBPATH}"-"${TIMESTAMP}" "${SVPATH}"; then |  | ||||||
|     echo "Error compiling database." |  | ||||||
|     echo "Please double check the ${SVPATH} directories. Exiting." |  | ||||||
|     exit 1 |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| if [ -e "/run/s6-rc" ]; then |  | ||||||
|     for dir in ${SVDIRS}/*; do |  | ||||||
|         if [ -e "${dir}/down" ]; then |  | ||||||
|             s6-svc -x "${dir}" |  | ||||||
|         fi |  | ||||||
|     done |  | ||||||
|     s6-rc-update "${DBPATH}"-"${TIMESTAMP}" |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| if [ -d "${DBPATH}" ]; then |  | ||||||
|     ln -sf "${DBPATH}"-"${TIMESTAMP}" "${DBPATH}"/compiled |  | ||||||
|     mv -f "${DBPATH}"/compiled "${RCPATH}" |  | ||||||
| else |  | ||||||
|     ln -sf "${DBPATH}"-"${TIMESTAMP}" "${DBPATH}" |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| new_bundles=$(db_action list bundles) |  | ||||||
| all_services=$(db_action list all) |  | ||||||
|  |  | ||||||
|  |  | ||||||
| if [ -n "$old_bundles" ]; then |  | ||||||
|     len=0 |  | ||||||
|     for m in $old_bundles; do |  | ||||||
|         old_contents=${contents[$len]} |  | ||||||
|         a_newbundle "$m" |  | ||||||
|         ret=$? |  | ||||||
|  |  | ||||||
|         for n in $old_contents; do |  | ||||||
|             service_exists "$n" |  | ||||||
|             ret2=$? |  | ||||||
|  |  | ||||||
|             if [ $ret -eq 1 ]; then |  | ||||||
|                 if [ $ret2 -eq 0 ]; then |  | ||||||
|                     new_contents="$new_contents $n" |  | ||||||
|                 fi |  | ||||||
|             else |  | ||||||
|                 if [ $ret2 -eq 0 ]; then |  | ||||||
|                     in_newbundle "$m" "$n" |  | ||||||
|                     ret3=$? |  | ||||||
|  |  | ||||||
|                     if [ $ret3 -eq 1 ]; then |  | ||||||
|                         s6-rc-bundle-update -c "${DBPATH}" add "$m" "$n" |  | ||||||
|                     fi |  | ||||||
|  |  | ||||||
|                 fi |  | ||||||
|             fi |  | ||||||
|  |  | ||||||
|         done |  | ||||||
|  |  | ||||||
|         if [ -n "$new_contents" ]; then |  | ||||||
|             s6-rc-bundle -c "${DBPATH}" add "$m" $new_contents |  | ||||||
|         fi |  | ||||||
|  |  | ||||||
|         new_contents="" |  | ||||||
|         len=$(( len + 1 )) |  | ||||||
|     done |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| echo "==> Switched to a new database." |  | ||||||
| echo "    Remove any old unwanted/unneeded database directories in ${RCPATH}." |  | ||||||
| @@ -10,17 +10,19 @@ s6_live() { | |||||||
| svc_help(){ | svc_help(){ | ||||||
|     echo "	==> Start/stop a service:" |     echo "	==> Start/stop a service:" | ||||||
|     echo "  s6-rc -u/-d change <service>" |     echo "  s6-rc -u/-d change <service>" | ||||||
|  |     echo "	==> Recompile the service database:" | ||||||
|  |     echo "  s6-db-reload <args>" | ||||||
| } | } | ||||||
|  |  | ||||||
| svc_add_help(){ | svc_add_help(){ | ||||||
|     echo "	==> Add a service:" |     echo "	==> Add a service:" | ||||||
|     echo "  s6-rc-bundle-update add default <service>" |     echo "  s6-service add default <service>" | ||||||
|     svc_help |     svc_help | ||||||
| } | } | ||||||
|  |  | ||||||
| svc_del_help(){ | svc_del_help(){ | ||||||
|     echo "	==> Remove a service:" |     echo "	==> Remove a service:" | ||||||
|     echo "  s6-rc-bundle-update delete default <service>" |     echo "  s6-service delete default <service>" | ||||||
|     svc_help |     svc_help | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -30,18 +32,6 @@ reload_dbus() { | |||||||
|             / org.freedesktop.DBus.ReloadConfig > /dev/null |             / org.freedesktop.DBus.ReloadConfig > /dev/null | ||||||
| } | } | ||||||
|  |  | ||||||
| shutdown_service() { |  | ||||||
|   while read -r dir; do |  | ||||||
|     if [ -d "$dir" ] && [ "$dir" != "etc/s6/sv/" ]; then |  | ||||||
|       sv=$(basename "$dir") |  | ||||||
|       active=$(s6-rc -a list | grep -Fx "$sv" || true) |  | ||||||
|       if [ -n $active ]; then |  | ||||||
|         s6-rc -d change "$sv" |  | ||||||
|       fi |  | ||||||
|     fi |  | ||||||
|   done |  | ||||||
| } |  | ||||||
|  |  | ||||||
| restart_service() { | restart_service() { | ||||||
|   if [ -e /run/s6-rc/servicedirs/"$1" ]; then |   if [ -e /run/s6-rc/servicedirs/"$1" ]; then | ||||||
|     s6-svc -r /run/s6-rc/servicedirs/"$1" |     s6-svc -r /run/s6-rc/servicedirs/"$1" | ||||||
| @@ -61,13 +51,11 @@ op="$1"; shift | |||||||
|  |  | ||||||
| case $op in | case $op in | ||||||
|   sysctl)   s6_live; each_conf /usr/bin/sysctl -q -p ;; |   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 ;; |   dbus_reload) s6_live; reload_dbus ;; | ||||||
|     # For use by other packages |     # For use by other packages | ||||||
|   add)      svc_add_help ;; |   add)      svc_add_help ;; | ||||||
|   del)      svc_del_help ;; |   del)      svc_del_help ;; | ||||||
|   longrun_restart) s6_live; restart_service "$1" ;; |   longrun_restart) s6_live; restart_service "$1" ;; | ||||||
|   shutdown_sv) s6_live; shutdown_service ;; |  | ||||||
|   *) echo >&2 "  Invalid operation '$op'"; exit 1 ;; |   *) echo >&2 "  Invalid operation '$op'"; exit 1 ;; | ||||||
| esac | esac | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,10 +0,0 @@ | |||||||
| [Trigger] |  | ||||||
| Operation = Upgrade |  | ||||||
| Type = Package |  | ||||||
| Target = suite66-scripts |  | ||||||
| Target = 66 |  | ||||||
|  |  | ||||||
| [Action] |  | ||||||
| Description = Updating boot tree module  |  | ||||||
| When = PostTransaction |  | ||||||
| Exec = /usr/share/libalpm/scripts/66-bootmodule |  | ||||||
| @@ -1,11 +0,0 @@ | |||||||
| [Trigger] |  | ||||||
| Type = Path |  | ||||||
| Operation = Install |  | ||||||
| Operation = Upgrade |  | ||||||
| Target = etc/66/service/* |  | ||||||
|  |  | ||||||
| [Action] |  | ||||||
| Description = Displaying 66 service help ... |  | ||||||
| When = PostTransaction |  | ||||||
| Exec = /usr/share/libalpm/scripts/66-hook add |  | ||||||
| NeedsTargets |  | ||||||
| @@ -1,10 +0,0 @@ | |||||||
| [Trigger] |  | ||||||
| Operation = Install  |  | ||||||
| Type = Package |  | ||||||
| Target = suite66-base |  | ||||||
| Target = 66 |  | ||||||
|  |  | ||||||
| [Action] |  | ||||||
| Description = Creating initial boot and default tree  |  | ||||||
| When = PostTransaction |  | ||||||
| Exec = /usr/share/libalpm/scripts/66-postinstall |  | ||||||
| @@ -1,10 +0,0 @@ | |||||||
| [Trigger] |  | ||||||
| Type = Path |  | ||||||
| Operation = Remove |  | ||||||
| Target = etc/66/service/* |  | ||||||
|  |  | ||||||
| [Action] |  | ||||||
| Description = Displaying 66 service help ... |  | ||||||
| When = PostTransaction |  | ||||||
| Exec = /usr/share/libalpm/scripts/66-hook del |  | ||||||
| NeedsTargets |  | ||||||
| @@ -1,2 +0,0 @@ | |||||||
| #!/usr/bin/sh |  | ||||||
| 66-enable -t boot -F boot@system |  | ||||||
| @@ -1,54 +0,0 @@ | |||||||
| #!/bin/sh -e |  | ||||||
|  |  | ||||||
| suite66_live() { |  | ||||||
|   if [ ! -d /run/dbus ]; then |  | ||||||
|     echo >&2 "  Skipped: 66 is not running." |  | ||||||
|     exit 0 |  | ||||||
|   fi |  | ||||||
| } |  | ||||||
|  |  | ||||||
| svc_help(){ |  | ||||||
|     echo "	==> Start/stop a service:" |  | ||||||
|     echo "  66-start <service>" |  | ||||||
|     echo "  66-stop <service>" |  | ||||||
| } |  | ||||||
|  |  | ||||||
| svc_add_help(){ |  | ||||||
|     echo "	==> Add a service:" |  | ||||||
|     echo "  66-enable <service>" |  | ||||||
|     svc_help |  | ||||||
| } |  | ||||||
|  |  | ||||||
| svc_del_help(){ |  | ||||||
|     echo "	==> Remove a service:" |  | ||||||
|     echo "  66-disable <service>" |  | ||||||
|     svc_help |  | ||||||
| } |  | ||||||
|  |  | ||||||
| reload_dbus() { |  | ||||||
|   dbus-send --print-reply --system --type=method_call \ |  | ||||||
|             --dest=org.freedesktop.DBus \ |  | ||||||
|             / org.freedesktop.DBus.ReloadConfig > /dev/null |  | ||||||
| } |  | ||||||
|  |  | ||||||
| each_conf() { |  | ||||||
|   while read -r f; do |  | ||||||
|     "$@" "/$f" |  | ||||||
|   done |  | ||||||
| } |  | ||||||
|  |  | ||||||
| op="$1"; shift |  | ||||||
| sv="$2" |  | ||||||
|  |  | ||||||
| case $op in |  | ||||||
|   sysctl)   suite66_live; each_conf /usr/bin/sysctl -q -p ;; |  | ||||||
|   binfmt)   suite66_live; /etc/66/script/binfmt.sh ;; |  | ||||||
|   dbus_reload)  suite66_live; reload_dbus ;; |  | ||||||
|     # For use by other packages |  | ||||||
|   add)      svc_add_help ;; |  | ||||||
|   del)      svc_del_help ;; |  | ||||||
|   longrun_restart) suite66_live; 66-svctl -r "$1" ;; |  | ||||||
|   *) echo >&2 "  Invalid operation '$op'"; exit 1 ;; |  | ||||||
| esac |  | ||||||
|  |  | ||||||
| exit 0 |  | ||||||
| @@ -1,9 +0,0 @@ | |||||||
| #!/usr/bin/sh |  | ||||||
| if [ ! -d /var/lib/66/system/boot ]; then |  | ||||||
|   66-tree -n boot |  | ||||||
|   66-enable -t boot -F boot@system |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| if [ ! -d /var/lib/66/system/default ]; then |  | ||||||
|   66-tree -ncE default |  | ||||||
| fi |  | ||||||
| @@ -1,19 +1,28 @@ | |||||||
| #!/bin/sh -e | #!/bin/sh -e | ||||||
|  |  | ||||||
| udevd_live() { | udevd_live() { | ||||||
|   if [ ! -d /run/udev ]; then |     if [ ! -d /run/udev ]; then | ||||||
|     echo >&2 "  Skipped: Device manager is not running." |         echo >&2 "  Skipped: Device manager is not running." | ||||||
|     exit 0 |         exit 0 | ||||||
|   fi |     fi | ||||||
| } | } | ||||||
|  |  | ||||||
| op="$1"; shift | op="$1"; shift | ||||||
|  |  | ||||||
| case "$op" in | case "$op" in | ||||||
|   #hwdb)     /usr/bin/udev-hwdb --usr update ;; |     hwdb) | ||||||
|   hwdb)     /usr/bin/udevadm hwdb --update ;; |         /usr/bin/udev-hwdb --usr update | ||||||
|   udev-reload)   udevd_live;   /usr/bin/udevadm control --reload ;; |     ;; | ||||||
|   *) echo >&2 "  Invalid operation '$op'"; exit 1 ;; |     udev-reload) | ||||||
|  |         udevd_live | ||||||
|  |         /usr/bin/udevadm control --reload | ||||||
|  |         /usr/bin/udevadm trigger -c change | ||||||
|  |         /usr/bin/udevadm settle | ||||||
|  |     ;; | ||||||
|  |     *) | ||||||
|  |         echo >&2 "  Invalid operation '$op'" | ||||||
|  |         exit 1 | ||||||
|  |     ;; | ||||||
| esac | esac | ||||||
|  |  | ||||||
| exit 0 | exit 0 | ||||||
|   | |||||||
							
								
								
									
										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]="dinitctl -o enable ${SV}" | ||||||
|  |     COMMANDS[disable]="dinitctl -o disable ${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