Compare commits
82 Commits
Author | SHA1 | Date | |
---|---|---|---|
0071bc2ce0 | |||
96a0aefa1d | |||
7aa0d2f443 | |||
bf99596e5e | |||
397b46ff3f | |||
ee63bf4a06 | |||
bcd456603b | |||
![]() |
c75de34303 | ||
![]() |
6453301c3b | ||
![]() |
454078d6a0 | ||
05801e2283 | |||
f84f50c4e9 | |||
10bdc1aa58 | |||
2b66059dbf | |||
8eec042261 | |||
8f195fc564 | |||
6278014c67 | |||
bdb730a244 | |||
![]() |
427bb5a772 | ||
![]() |
f9bf9fb275 | ||
![]() |
4882f52aba | ||
![]() |
ef17862551 | ||
![]() |
e148344dfa | ||
e8ad706b7b | |||
5d16b77bdb | |||
cea6a58cba | |||
d2ebd92f24 | |||
4908b26a2d | |||
fdb0488f1e | |||
1aeedd0019 | |||
0db3224e90 | |||
9527ccc8d0 | |||
fb122c1beb | |||
8b47e238b9 | |||
c9126a652a | |||
![]() |
89b99e475d | ||
![]() |
9befe99ed5 | ||
![]() |
d36f9e6952 | ||
7852ea0ee3 | |||
cf1c3912e7 | |||
![]() |
9cd7ec066b | ||
![]() |
0df2f865bb | ||
b3c76e6a59 | |||
8847aa38b4 | |||
161c96b8fa | |||
990661bfd9 | |||
bf732c4905 | |||
24306e68c1 | |||
9ae595db4f | |||
1eaaac7428 | |||
c9e84492fb | |||
9e4fd67db6 | |||
d47df45f50 | |||
0665f7630b | |||
9a9003b255 | |||
![]() |
a67af1e82b | ||
![]() |
b0238301c9 | ||
![]() |
c28ea35b41 | ||
7f0feca5b2 | |||
a47df21b08 | |||
989a323867 | |||
3139aa4609 | |||
7cad901c86 | |||
d145dce79a | |||
fd63fdca89 | |||
7d09c40c88 | |||
d3a6d855ca | |||
5c42be6143 | |||
90b1e1c301 | |||
![]() |
65768e39ea | ||
ed2bb8edd7 | |||
a44aab979b | |||
![]() |
1e6537cb5c | ||
![]() |
1250ac8e8f | ||
![]() |
9aed8d1e97 | ||
![]() |
46604a1cb9 | ||
![]() |
d8dfa64afc | ||
![]() |
0b464e9da9 | ||
![]() |
4dcecb7d45 | ||
20a1ca16bc | |||
82bf65d4fa | |||
f8a8bc673b |
34
1
34
1
@@ -1,34 +0,0 @@
|
||||
#!/bin/sh
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
PATH=/usr/bin:/usr/sbin
|
||||
|
||||
. /etc/runit/functions
|
||||
|
||||
[ -r /etc/runit/rc.conf ] && . /etc/runit/rc.conf
|
||||
|
||||
msg "Welcome to Artix Linux!"
|
||||
|
||||
if [ -x /usr/bin/openrc ] && [ "$SVMANAGER" = "openrc" ]; then
|
||||
# Start core services: we'll use OpenRC for this.
|
||||
msg "Initializing runlevel sysinit with OpenRC..."
|
||||
openrc sysinit || msg_error "Failed to start sysinit runlevel"
|
||||
else
|
||||
# Start core services: one-time system tasks.
|
||||
detect_virt
|
||||
for f in /etc/runit/core-services/*.sh; do
|
||||
[ -r $f ] && . $f
|
||||
done
|
||||
fi
|
||||
|
||||
dmesg >/var/log/dmesg.log
|
||||
if [ $(sysctl -n kernel.dmesg_restrict 2>/dev/null) -eq 1 ]; then
|
||||
chmod 0600 /var/log/dmesg.log
|
||||
else
|
||||
chmod 0644 /var/log/dmesg.log
|
||||
fi
|
||||
|
||||
mkdir -p /run/runit
|
||||
install -m100 /dev/null /run/runit/stopit
|
||||
|
||||
msg "Initialization complete, running stage 2..."
|
28
2
28
2
@@ -1,28 +0,0 @@
|
||||
#!/bin/sh
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
PATH=/usr/bin:/usr/sbin
|
||||
|
||||
runlevel=default
|
||||
for arg in $(cat /proc/cmdline); do
|
||||
if [ -d /etc/runit/runsvdir/"$arg" ]; then
|
||||
echo "Runlevel detected: '$arg' (via kernel cmdline)"
|
||||
runlevel="$arg"
|
||||
fi
|
||||
done
|
||||
|
||||
[ -x /etc/runit/rc.local ] && /etc/runit/rc.local
|
||||
|
||||
# The reason that boot is not in stage 1 is because if something hangs
|
||||
# we can still listen for signals, however stage 1 does NOT accept signals
|
||||
if [ -x /usr/bin/openrc ] && [ "$SVMANAGER" = "openrc" ]; then
|
||||
openrc boot
|
||||
openrc default
|
||||
fi
|
||||
|
||||
runsvchdir "${runlevel}"
|
||||
mkdir -p /run/runit/runsvdir
|
||||
ln -s /etc/runit/runsvdir/current /run/runit/service
|
||||
|
||||
exec env - PATH=$PATH \
|
||||
runsvdir -P /run/runit/service 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................'
|
59
3
59
3
@@ -1,59 +0,0 @@
|
||||
#!/bin/sh
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
PATH=/usr/bin:/usr/sbin
|
||||
|
||||
. /etc/runit/functions
|
||||
detect_virt
|
||||
[ -r /etc/runit/rc.conf ] && . /etc/runit/rc.conf
|
||||
|
||||
if [ -e /run/runit/reboot ]; then
|
||||
chmod 100 /run/runit/reboot
|
||||
fi
|
||||
|
||||
echo
|
||||
msg "Waiting for services to stop..."
|
||||
sv force-stop /run/runit/service/*
|
||||
sv exit /run/runit/service/*
|
||||
|
||||
[ -x /etc/runit/rc.shutdown ] && /etc/runit/rc.shutdown
|
||||
|
||||
msg "Saving random seed..."
|
||||
( umask 077; bytes=$(cat /proc/sys/kernel/random/poolsize) || bytes=512; dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=$bytes >/dev/null 2>&1 )
|
||||
|
||||
if [ -z "$VIRTUALIZATION" -a -n "$HARDWARECLOCK" ]; then
|
||||
hwclock --systohc ${HARDWARECLOCK:+--$(echo $HARDWARECLOCK |tr A-Z a-z)}
|
||||
fi
|
||||
|
||||
halt -w # for utmp
|
||||
|
||||
if [ -z "$VIRTUALIZATION" ]; then
|
||||
msg "Stopping udev..."
|
||||
udevadm control --exit
|
||||
fi
|
||||
|
||||
msg "Sending TERM signal to processes..."
|
||||
pkill --inverse -s0,1 -TERM
|
||||
sleep 1
|
||||
msg "Sending KILL signal to processes..."
|
||||
pkill --inverse -s0,1 -KILL
|
||||
|
||||
if [ -z "$VIRTUALIZATION" ]; then
|
||||
msg "Unmounting filesystems, disabling swap..."
|
||||
swapoff -a
|
||||
umount -r -a -t nosysfs,noproc,nodevtmpfs,notmpfs
|
||||
msg "Remounting rootfs read-only..."
|
||||
mount -o remount,ro /
|
||||
fi
|
||||
|
||||
sync
|
||||
|
||||
if [ -z "$VIRTUALIZATION" ]; then
|
||||
deactivate_vgs
|
||||
deactivate_crypt
|
||||
if [ -e /run/runit/reboot ] && command -v kexec >/dev/null; then
|
||||
msg "Triggering kexec..."
|
||||
kexec -e 2>/dev/null
|
||||
# not reached when kexec was successful.
|
||||
fi
|
||||
fi
|
24
COPYING
Normal file
24
COPYING
Normal file
@@ -0,0 +1,24 @@
|
||||
Copyright (C) 2018 Muhammad Herdiansyah
|
||||
Copyright (C) 2018 Artix Linux Developers
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
236
Makefile
236
Makefile
@@ -1,44 +1,200 @@
|
||||
PREFIX ?= /usr
|
||||
SCRIPTS= 1 2 3 ctrlaltdel
|
||||
SYSCONFDIR = /etc
|
||||
PREFIX ?= /usr
|
||||
BINDIR = $(PREFIX)/bin
|
||||
MANDIR = $(PREFIX)/share/man
|
||||
LIBDIR = $(PREFIX)/lib
|
||||
RCLIBDIR = $(LIBDIR)/rc
|
||||
|
||||
all:
|
||||
$(CC) $(CFLAGS) halt.c -o halt $(LDFLAGS)
|
||||
$(CC) $(CFLAGS) pause.c -o pause $(LDFLAGS)
|
||||
########### runit ###########
|
||||
|
||||
install:
|
||||
install -d ${DESTDIR}${PREFIX}/lib/runit-artix/bin
|
||||
install -m755 halt ${DESTDIR}${PREFIX}/lib/runit-artix/bin/halt
|
||||
install -m755 pause ${DESTDIR}${PREFIX}/lib/runit-artix/bin/pause
|
||||
install -m755 shutdown ${DESTDIR}${PREFIX}/lib/runit-artix/bin/shutdown
|
||||
install -m755 modules-load ${DESTDIR}${PREFIX}/lib/runit-artix/bin/modules-load
|
||||
install -m755 zzz ${DESTDIR}${PREFIX}/lib/runit-artix/bin/zzz
|
||||
ln -sf halt ${DESTDIR}${PREFIX}/lib/runit-artix/bin/poweroff
|
||||
ln -sf halt ${DESTDIR}${PREFIX}/lib/runit-artix/bin/reboot
|
||||
install -d ${DESTDIR}${PREFIX}/share/man/man1
|
||||
install -m644 pause.1 ${DESTDIR}${PREFIX}/share/man/man1
|
||||
install -d ${DESTDIR}${PREFIX}/share/man/man8
|
||||
install -m644 zzz.8 ${DESTDIR}${PREFIX}/share/man/man8/zzz-runit.8
|
||||
install -m644 shutdown.8 ${DESTDIR}${PREFIX}/share/man/man8/shutdown-runit.8
|
||||
install -m644 halt.8 ${DESTDIR}${PREFIX}/share/man/man8/halt-runit.8
|
||||
install -m644 modules-load.8 ${DESTDIR}${PREFIX}/share/man/man8
|
||||
ln -sf halt-runit.8 ${DESTDIR}${PREFIX}/share/man/man8/poweroff-runit.8
|
||||
ln -sf halt-runit.8 ${DESTDIR}${PREFIX}/share/man/man8/reboot-runit.8
|
||||
install -d ${DESTDIR}/etc/runit/sv
|
||||
install -d ${DESTDIR}/etc/runit/runsvdir
|
||||
install -d ${DESTDIR}/etc/runit/core-services
|
||||
install -m644 core-services/*.sh ${DESTDIR}/etc/runit/core-services
|
||||
install -m755 ${SCRIPTS} ${DESTDIR}/etc/runit
|
||||
install -m644 functions $(DESTDIR)/etc/runit
|
||||
install -m644 crypt.awk ${DESTDIR}/etc/runit
|
||||
install -m644 rc.conf ${DESTDIR}/etc/runit
|
||||
install -m755 rc.local ${DESTDIR}/etc/runit
|
||||
install -m755 rc.shutdown ${DESTDIR}/etc/runit
|
||||
ln -sf /run/runit/reboot ${DESTDIR}/etc/runit/
|
||||
ln -sf /run/runit/stopit ${DESTDIR}/etc/runit/
|
||||
cp -R --no-dereference --preserve=mode,links -v runsvdir/* ${DESTDIR}/etc/runit/runsvdir/
|
||||
cp -R --no-dereference --preserve=mode,links -v services/* ${DESTDIR}/etc/runit/sv/
|
||||
RCDIR = $(SYSCONFDIR)/rc
|
||||
RUNITDIR = $(SYSCONFDIR)/runit
|
||||
SVDIR = $(RUNITDIR)/sv
|
||||
RUNSVDIR = $(RUNITDIR)/runsvdir
|
||||
SERVICEDIR = /etc/service
|
||||
RUNDIR = /run/runit
|
||||
TMPFILESDIR = $(LIBDIR)/tmpfiles.d
|
||||
|
||||
clean:
|
||||
-rm -f halt pause
|
||||
|
||||
.PHONY: all install clean
|
||||
TMPFILES = misc/tmpfile.conf
|
||||
|
||||
BIN = script/zzz src/pause
|
||||
|
||||
STAGES = \
|
||||
script/1 \
|
||||
script/2 \
|
||||
script/3 \
|
||||
script/ctrlaltdel
|
||||
|
||||
RCLOCAL = script/rc.local.start script/rc.shutdown.stop
|
||||
|
||||
UDEV = $(wildcard sv/udevd/*)
|
||||
|
||||
AGETTY_CONSOLE = $(wildcard sv/agetty-console/*)
|
||||
AGETTY_CONSOLE_S = supervise.agetty-console
|
||||
|
||||
AGETTY_GENERIC = $(wildcard sv/agetty-generic/*)
|
||||
|
||||
AGETTY_SERIAL = $(wildcard sv/agetty-serial/*)
|
||||
|
||||
AGETTY_TTY1 = $(wildcard sv/agetty-tty1/*)
|
||||
AGETTY_TTY1_S = supervise.agetty-tty1
|
||||
|
||||
AGETTY_TTY2 = $(wildcard sv/agetty-tty2/*)
|
||||
AGETTY_TTY2_S = supervise.agetty-tty2
|
||||
|
||||
AGETTY_TTY3 = $(wildcard sv/agetty-tty3/*)
|
||||
AGETTY_TTY3_S = supervise.agetty-tty3
|
||||
|
||||
AGETTY_TTY4 = $(wildcard sv/agetty-tty4/*)
|
||||
AGETTY_TTY4_S = supervise.agetty-tty4
|
||||
|
||||
AGETTY_TTY5 = $(wildcard sv/agetty-tty5/*)
|
||||
AGETTY_TTY5_S = supervise.agetty-tty5
|
||||
|
||||
AGETTY_TTY6 = $(wildcard sv/agetty-tty6/*)
|
||||
AGETTY_TTY6_S = supervise.agetty-tty6
|
||||
|
||||
AGETTY_TTYAMA0 = $(wildcard sv/agetty-ttyAMA0/*)
|
||||
AGETTY_TTYAMA0_S = supervise.agetty-ttyAMA0
|
||||
|
||||
AGETTY_TTYS0 = $(wildcard sv/agetty-ttyS0/*)
|
||||
AGETTY_TTYS0_S = supervise.agetty-ttyS0
|
||||
|
||||
AGETTY_TTYUSB0 = $(wildcard sv/agetty-ttyUSB0/*)
|
||||
AGETTY_TTYUSB0_S = supervise.agetty-ttyUSB0
|
||||
|
||||
AGETTY_SULOGIN = $(wildcard sv/sulogin/*)
|
||||
AGETTY_SULOGIN_S = supervise.sulogin
|
||||
|
||||
AGETTY_SYMS = \
|
||||
agetty-tty1 \
|
||||
agetty-tty2 \
|
||||
agetty-tty3 \
|
||||
agetty-tty4 \
|
||||
agetty-tty5 \
|
||||
agetty-tty6
|
||||
|
||||
SULOGIN_SYM = sulogin
|
||||
|
||||
########### end ###########
|
||||
|
||||
LN = ln -sf
|
||||
CP = cp -R --no-dereference --preserve=mode,links -v
|
||||
RM = rm -f
|
||||
RMD = rm -fr --one-file-system
|
||||
M4 = m4 -P
|
||||
CHMODAW = chmod a-w
|
||||
CHMODX = chmod +x
|
||||
|
||||
EDIT = sed \
|
||||
-e "s|@RCDIR[@]|$(RCDIR)|g" \
|
||||
-e "s|@RUNITDIR[@]|$(RUNITDIR)|g" \
|
||||
-e "s|@SERVICEDIR[@]|$(SERVICEDIR)|g" \
|
||||
-e "s|@RUNSVDIR[@]|$(RUNSVDIR)|g" \
|
||||
-e "s|@RUNDIR[@]|$(RUNDIR)|g" \
|
||||
-e "s|@SYSCONFDIR[@]|$(SYSCONFDIR)|g" \
|
||||
-e "s|@RCLIBDIR[@]|$(RCLIBDIR)|g"
|
||||
|
||||
%: %.in Makefile
|
||||
@echo "GEN $@"
|
||||
@$(RM) "$@"
|
||||
@$(M4) $@.in | $(EDIT) >$@
|
||||
@$(CHMODAW) "$@"
|
||||
@$(CHMODX) "$@"
|
||||
|
||||
all: all-runit
|
||||
|
||||
all-runit: $(STAGES) $(RCLOCAL)
|
||||
$(CC) $(CFLAGS) src/pause.c -o src/pause $(LDFLAGS)
|
||||
|
||||
install-runit:
|
||||
install -d $(DESTDIR)$(RUNITDIR)
|
||||
install -m755 $(STAGES) $(DESTDIR)$(RUNITDIR)
|
||||
|
||||
install -d $(DESTDIR)$(RUNSVDIR)/single
|
||||
|
||||
install -d $(DESTDIR)$(RUNSVDIR)/default
|
||||
$(LN) default $(DESTDIR)$(RUNSVDIR)/current
|
||||
|
||||
$(LN) $(RUNDIR)/reboot $(DESTDIR)$(RUNITDIR)/
|
||||
$(LN) $(RUNDIR)/stopit $(DESTDIR)$(RUNITDIR)/
|
||||
|
||||
install -d $(DESTDIR)$(SYSCONFDIR)/local.d
|
||||
install -m755 $(RCLOCAL) $(DESTDIR)$(SYSCONFDIR)/local.d
|
||||
|
||||
install -d $(DESTDIR)$(BINDIR)
|
||||
install -m755 $(BIN) $(DESTDIR)$(BINDIR)
|
||||
|
||||
install -d $(DESTDIR)$(TMPFILESDIR)
|
||||
install -m755 $(TMPFILES) $(DESTDIR)$(TMPFILESDIR)/runit.conf
|
||||
|
||||
install -d $(DESTDIR)$(SVDIR)/udevd
|
||||
install -Dm755 $(UDEV) $(DESTDIR)$(SVDIR)/udevd
|
||||
|
||||
install -d $(DESTDIR)$(SVDIR)/agetty-console
|
||||
install -Dm755 $(AGETTY_CONSOLE) $(DESTDIR)$(SVDIR)/agetty-console
|
||||
$(LN) $(RUNDIR)/$(AGETTY_CONSOLE_S) $(DESTDIR)$(SVDIR)/agetty-console/supervise
|
||||
|
||||
install -d $(DESTDIR)$(SVDIR)/agetty-generic
|
||||
install -Dm755 $(AGETTY_GENERIC) $(DESTDIR)$(SVDIR)/agetty-generic
|
||||
|
||||
install -d $(DESTDIR)$(SVDIR)/agetty-serial
|
||||
install -Dm755 $(AGETTY_SERIAL) $(DESTDIR)$(SVDIR)/agetty-serial
|
||||
|
||||
install -d $(DESTDIR)$(SVDIR)/agetty-tty1
|
||||
install -Dm755 $(AGETTY_TTY1) $(DESTDIR)$(SVDIR)/agetty-tty1
|
||||
$(LN) $(RUNDIR)/$(AGETTY_TTY1_S) $(DESTDIR)$(SVDIR)/agetty-tty1/supervise
|
||||
#
|
||||
install -d $(DESTDIR)$(SVDIR)/agetty-tty2
|
||||
install -Dm755 $(AGETTY_TTY2) $(DESTDIR)$(SVDIR)/agetty-tty2
|
||||
$(LN) $(RUNDIR)/$(AGETTY_TTY2_S) $(DESTDIR)$(SVDIR)/agetty-tty2/supervise
|
||||
|
||||
install -d $(DESTDIR)$(SVDIR)/agetty-tty3
|
||||
install -Dm755 $(AGETTY_TTY3) $(DESTDIR)$(SVDIR)/agetty-tty3
|
||||
$(LN) $(RUNDIR)/$(AGETTY_TTY3_S) $(DESTDIR)$(SVDIR)/agetty-tty3/supervise
|
||||
|
||||
install -d $(DESTDIR)$(SVDIR)/agetty-tty4
|
||||
install -Dm755 $(AGETTY_TTY4) $(DESTDIR)$(SVDIR)/agetty-tty4
|
||||
$(LN) $(RUNDIR)/$(AGETTY_TTY4_S) $(DESTDIR)$(SVDIR)/agetty-tty4/supervise
|
||||
|
||||
install -d $(DESTDIR)$(SVDIR)/agetty-tty5
|
||||
install -Dm755 $(AGETTY_TTY5) $(DESTDIR)$(SVDIR)/agetty-tty5
|
||||
$(LN) $(RUNDIR)/$(AGETTY_TTY5_S) $(DESTDIR)$(SVDIR)/agetty-tty5/supervise
|
||||
|
||||
install -d $(DESTDIR)$(SVDIR)/agetty-tty6
|
||||
install -Dm755 $(AGETTY_TTY6) $(DESTDIR)$(SVDIR)/agetty-tty6
|
||||
$(LN) $(RUNDIR)/$(AGETTY_TTY6_S) $(DESTDIR)$(SVDIR)/agetty-tty6/supervise
|
||||
|
||||
install -d $(DESTDIR)$(SVDIR)/agetty-ttyAMA0
|
||||
install -Dm755 $(AGETTY_TTYAMA0) $(DESTDIR)$(SVDIR)/agetty-ttyAMA0
|
||||
$(LN) $(RUNDIR)/$(AGETTY_TTYAMA0_S) $(DESTDIR)$(SVDIR)/agetty-ttyAMA0/supervise
|
||||
|
||||
install -d $(DESTDIR)$(SVDIR)/agetty-ttyS0
|
||||
install -Dm755 $(AGETTY_TTYS0) $(DESTDIR)$(SVDIR)/agetty-ttyS0
|
||||
$(LN) $(RUNDIR)/$(AGETTY_TTYS0_S) $(DESTDIR)$(SVDIR)/agetty-ttyS0/supervise
|
||||
|
||||
install -d $(DESTDIR)$(SVDIR)/agetty-ttyUSB0
|
||||
install -Dm755 $(AGETTY_TTYUSB0) $(DESTDIR)$(SVDIR)/agetty-ttyUSB0
|
||||
$(LN) $(RUNDIR)/$(AGETTY_TTYUSB0_S) $(DESTDIR)$(SVDIR)/agetty-ttyUSB0/supervise
|
||||
|
||||
install -d $(DESTDIR)$(SVDIR)/sulogin
|
||||
install -Dm755 $(AGETTY_SULOGIN) $(DESTDIR)$(SVDIR)/sulogin
|
||||
$(LN) $(RUNDIR)/$(AGETTY_SULOGIN_S) $(DESTDIR)$(SVDIR)/sulogin/supervise
|
||||
|
||||
for g in $(AGETTY_SYMS); do $(LN) $(SVDIR)/$$g $(DESTDIR)$(RUNSVDIR)/default/$$g; done
|
||||
for g in $(SULOGIN_SYM); do $(LN) $(SVDIR)/$$g $(DESTDIR)$(RUNSVDIR)/single/$$g; done
|
||||
|
||||
install -d $(DESTDIR)$(MANDIR)/man1
|
||||
install -m644 man/pause.1 $(DESTDIR)$(MANDIR)/man1
|
||||
install -d $(DESTDIR)$(MANDIR)/man8
|
||||
install -m644 man/zzz.8 $(DESTDIR)$(MANDIR)/man8/zzz.8
|
||||
|
||||
install: install-runit
|
||||
|
||||
clean-runit:
|
||||
-$(RM) src/pause $(STAGES) $(RCLOCAL)
|
||||
|
||||
clean: clean-runit
|
||||
|
||||
.PHONY: all install clean install-runit clean-runit
|
||||
|
24
README.md
24
README.md
@@ -1,21 +1,11 @@
|
||||
## Runit init scripts for Artix Linux
|
||||
## Supplemental files for runit in Artix
|
||||
|
||||
This repository contains the runit init scripts for the Artix Linux
|
||||
distribution.
|
||||
|
||||
This work is based on Void Linux's
|
||||
[void-runit](https://github.com/voidlinux/void-runit). Patches to Void
|
||||
Linux's repo will also be applied here.
|
||||
These files are supplements for runit implementation in Artix Linux.
|
||||
|
||||
## Dependencies
|
||||
|
||||
- GNU coreutils
|
||||
- A POSIX shell
|
||||
- A POSIX awk
|
||||
- procps-ng (needs pkill -s0,1)
|
||||
- runit
|
||||
- opentmpfiles
|
||||
- opensysusers
|
||||
- runit-rc (https://github.com/artix-linux/runit-rc)
|
||||
|
||||
### How to use it
|
||||
|
||||
@@ -43,9 +33,7 @@ Feel free to send patches and contribute with improvements!
|
||||
|
||||
## Copyright
|
||||
|
||||
runit-artix is in the public domain.
|
||||
Some codes are based on void-runit, which is licensed under CC0-1.0
|
||||
|
||||
To the extent possible under law, the creator of this work has waived
|
||||
all copyright and related or neighboring rights to this work.
|
||||
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
The rest of runit-artix is licensed under the terms as described in the
|
||||
COPYING file.
|
||||
|
@@ -1,17 +0,0 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
msg "Mounting pseudo-filesystems..."
|
||||
mountpoint -q /proc || mount -o nosuid,noexec,nodev -t proc proc /proc
|
||||
mountpoint -q /sys || mount -o nosuid,noexec,nodev -t sysfs sys /sys
|
||||
mountpoint -q /run || mount -o mode=0755,nosuid,nodev -t tmpfs run /run
|
||||
mountpoint -q /dev || mount -o mode=0755,nosuid -t devtmpfs dev /dev
|
||||
mkdir -p -m0755 /run/runit /run/lvm /run/user /run/lock /run/log /dev/pts /dev/shm
|
||||
mountpoint -q /dev/pts || mount -o mode=0620,gid=5,nosuid,noexec -n -t devpts devpts /dev/pts
|
||||
mountpoint -q /dev/shm || mount -o mode=1777,nosuid,nodev -n -t tmpfs shm /dev/shm
|
||||
mountpoint -q /sys/kernel/security || mount -n -t securityfs securityfs /sys/kernel/security
|
||||
|
||||
if [ -z "$VIRTUALIZATION" ]; then
|
||||
mountpoint -q /sys/fs/cgroup || mount -o mode=0755 -t tmpfs cgroup /sys/fs/cgroup
|
||||
mountpoint -q /sys/fs/cgroup/openrc || mkdir -p /sys/fs/cgroup/openrc && mount -t cgroup -o none,name=openrc cgroup /sys/fs/cgroup/openrc
|
||||
awk '$4 == 1 { system("mountpoint -q /sys/fs/cgroup/" $1 " || { mkdir -p /sys/fs/cgroup/" $1 " && mount -t cgroup -o " $1 " cgroup /sys/fs/cgroup/" $1 " ;}" ) }' /proc/cgroups
|
||||
fi
|
@@ -1,6 +0,0 @@
|
||||
# Some kernel modules must be loaded before starting udev(7).
|
||||
# Load them by looking at the output of `kmod static-nodes`.
|
||||
|
||||
for f in $(kmod static-nodes 2>/dev/null|awk '/Module/ {print $2}'); do
|
||||
modprobe -bq $f 2>/dev/null
|
||||
done
|
@@ -1,9 +0,0 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
[ -n "$VIRTUALIZATION" ] && return 0
|
||||
# Do not try to load modules if kernel does not support them.
|
||||
[ ! -e /proc/modules ] && return 0
|
||||
|
||||
msg "Loading kernel modules..."
|
||||
modules-load -v | tr '\n' ' ' | sed 's:insmod [^ ]*/::g; s:\.ko\(\.gz\)\? ::g'
|
||||
echo
|
@@ -1,24 +0,0 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
[ -n "$VIRTUALIZATION" ] && return 0
|
||||
|
||||
if [ -x /usr/lib/systemd/systemd-udevd ]; then
|
||||
_udevd=/usr/lib/systemd/systemd-udevd
|
||||
elif [ -x /sbin/udevd -o -x /bin/udevd ]; then
|
||||
_udevd=udevd
|
||||
else
|
||||
msg_warn "cannot find udevd!"
|
||||
fi
|
||||
|
||||
if [ -x /usr/bin/tmpfiles ]; then
|
||||
msg "Setting up tmpfiles.d entries for /dev..."
|
||||
tmpfiles --prefix=/dev --create --boot
|
||||
fi
|
||||
|
||||
if [ -n "${_udevd}" ]; then
|
||||
msg "Starting udev and waiting for devices to settle..."
|
||||
${_udevd} --daemon
|
||||
udevadm trigger --action=add --type=subsystems
|
||||
udevadm trigger --action=add --type=devices
|
||||
udevadm settle
|
||||
fi
|
@@ -1,26 +0,0 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
[ -n "$VIRTUALIZATION" ] && return 0
|
||||
|
||||
TTYS=${TTYS:-12}
|
||||
if [ -n "$FONT" ]; then
|
||||
msg "Setting up TTYs font to '${FONT}'..."
|
||||
|
||||
_index=0
|
||||
while [ ${_index} -le $TTYS ]; do
|
||||
setfont ${FONT_MAP:+-m $FONT_MAP} ${FONT_UNIMAP:+-u $FONT_UNIMAP} \
|
||||
$FONT -C "/dev/tty${_index}"
|
||||
_index=$((_index + 1))
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "$KEYMAP" ]; then
|
||||
msg "Setting up keymap to '${KEYMAP}'..."
|
||||
loadkeys -q -u ${KEYMAP}
|
||||
fi
|
||||
|
||||
if [ -n "$HARDWARECLOCK" ]; then
|
||||
msg "Setting up RTC to '${HARDWARECLOCK}'..."
|
||||
TZ=$TIMEZONE hwclock --systz \
|
||||
${HARDWARECLOCK:+--$(echo $HARDWARECLOCK |tr A-Z a-z) --noadjfile} || emergency_shell
|
||||
fi
|
@@ -1,70 +0,0 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
[ -n "$VIRTUALIZATION" ] && return 0
|
||||
|
||||
msg "Remounting rootfs read-only..."
|
||||
mount -o remount,ro / || emergency_shell
|
||||
|
||||
if [ -x /sbin/dmraid -o -x /bin/dmraid ]; then
|
||||
msg "Activating dmraid devices..."
|
||||
dmraid -i -ay
|
||||
fi
|
||||
|
||||
if [ -x /bin/btrfs ]; then
|
||||
msg "Activating btrfs devices..."
|
||||
btrfs device scan || emergency_shell
|
||||
fi
|
||||
|
||||
if [ -x /sbin/vgchange -o -x /bin/vgchange ]; then
|
||||
msg "Activating LVM devices..."
|
||||
vgchange --sysinit -a y || emergency_shell
|
||||
fi
|
||||
|
||||
if [ -e /etc/crypttab ]; then
|
||||
msg "Activating encrypted devices..."
|
||||
awk -f /etc/runit/crypt.awk /etc/crypttab
|
||||
|
||||
if [ -x /sbin/vgchange -o -x /bin/vgchange ]; then
|
||||
msg "Activating LVM devices for dm-crypt..."
|
||||
vgchange --sysinit -a y || emergency_shell
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e /etc/zfs/zpool.cache -a -x /usr/bin/zfs ]; then
|
||||
msg "Activating ZFS devices..."
|
||||
zpool import -c /etc/zfs/zpool.cache -N -a
|
||||
|
||||
msg "Mounting ZFS file systems..."
|
||||
zfs mount -a
|
||||
|
||||
msg "Sharing ZFS file systems..."
|
||||
zfs share -a
|
||||
|
||||
# NOTE(dh): ZFS has ZVOLs, block devices on top of storage pools.
|
||||
# In theory, it would be possible to use these as devices in
|
||||
# dmraid, btrfs, LVM and so on. In practice it's unlikely that
|
||||
# anybody is doing that, so we aren't supporting it for now.
|
||||
fi
|
||||
|
||||
[ -f /fastboot ] && FASTBOOT=1
|
||||
[ -f /forcefsck ] && FORCEFSCK="-f"
|
||||
for arg in $(cat /proc/cmdline); do
|
||||
case $arg in
|
||||
fastboot) FASTBOOT=1;;
|
||||
forcefsck) FORCEFSCK="-f";;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$FASTBOOT" ]; then
|
||||
msg "Checking filesystems:"
|
||||
fsck -A -T -a -t noopts=_netdev $FORCEFSCK
|
||||
if [ $? -gt 1 ]; then
|
||||
emergency_shell
|
||||
fi
|
||||
fi
|
||||
|
||||
msg "Mounting rootfs read-write..."
|
||||
mount -o remount,rw / || emergency_shell
|
||||
|
||||
msg "Mounting all non-network filesystems..."
|
||||
mount -a -t "nosysfs,nonfs,nonfs4,nosmbfs,nocifs" -O no_netdev || emergency_shell
|
@@ -1,6 +0,0 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
[ -n "$VIRTUALIZATION" ] && return 0
|
||||
|
||||
msg "Initializing swap..."
|
||||
swapon -a || emergency_shell
|
@@ -1,31 +0,0 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
msg "Initializing random seed..."
|
||||
cp /var/lib/random-seed /dev/urandom >/dev/null 2>&1 || true
|
||||
( umask 077; bytes=$(cat /proc/sys/kernel/random/poolsize) || bytes=512; dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=$bytes >/dev/null 2>&1 )
|
||||
|
||||
msg "Setting up loopback interface..."
|
||||
ip link set up dev lo
|
||||
|
||||
[ -r /etc/hostname ] && read -r HOSTNAME < /etc/hostname
|
||||
if [ -n "$HOSTNAME" ]; then
|
||||
msg "Setting up hostname to '${HOSTNAME}'..."
|
||||
printf "%s" "$HOSTNAME" > /proc/sys/kernel/hostname
|
||||
else
|
||||
msg_warn "Didn't setup a hostname!"
|
||||
fi
|
||||
|
||||
if [ -n "$TIMEZONE" ]; then
|
||||
msg "Setting up timezone to '${TIMEZONE}'..."
|
||||
ln -sf "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
|
||||
fi
|
||||
|
||||
msg "Setting up sysusers.d entries..."
|
||||
if [ -x /usr/bin/sysusers ]; then
|
||||
sysusers
|
||||
fi
|
||||
|
||||
msg "Setting up tmpfiles.d entries..."
|
||||
if [ -x /usr/bin/tmpfiles ]; then
|
||||
tmpfiles --exclude-prefix=/dev --create --remove --boot
|
||||
fi
|
@@ -1,16 +0,0 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
if [ -x /sbin/sysctl -o -x /bin/sysctl ]; then
|
||||
msg "Loading sysctl(8) settings..."
|
||||
for i in /run/sysctl.d/*.conf \
|
||||
/usr/local/lib/sysctl.d/*.conf \
|
||||
/usr/lib/sysctl.d/*.conf \
|
||||
/etc/sysctl.conf \
|
||||
/etc/sysctl.d/*.conf; do
|
||||
|
||||
if [ -e "$i" ]; then
|
||||
printf '* Applying %s ...\n' "$i"
|
||||
sysctl -p "$i"
|
||||
fi
|
||||
done
|
||||
fi
|
@@ -1,12 +0,0 @@
|
||||
# vim: set ts=4 sw=4 et:
|
||||
|
||||
install -m0664 -o root -g utmp /dev/null /run/utmp
|
||||
if [ ! -e /var/log/wtmp ]; then
|
||||
install -m0664 -o root -g utmp /dev/null /var/log/wtmp
|
||||
fi
|
||||
if [ ! -e /var/log/btmp ]; then
|
||||
install -m0600 -o root -g utmp /dev/null /var/log/btmp
|
||||
fi
|
||||
rm -rf /tmp
|
||||
install -dm1777 /tmp /tmp/.X11-unix /tmp/.ICE-unix
|
||||
rm -f /etc/nologin /forcefsck /forcequotacheck /fastboot
|
103
crypt.awk
103
crypt.awk
@@ -1,103 +0,0 @@
|
||||
/^#/ || /^$/ { next }
|
||||
NF>4 { print "a valid crypttab has max 4 cols not " NF >"/dev/stderr"; next }
|
||||
{
|
||||
# decode the src variants
|
||||
split($2, o_src, "=")
|
||||
if (o_src[1] == "UUID") ("blkid -l -o device -t " $2) | getline src;
|
||||
else src=o_src[1];
|
||||
|
||||
# no password or none is given, ask fo it
|
||||
if ( NF == 2 ) {
|
||||
ccmd="cryptsetup luksOpen " src " " $1;
|
||||
system(ccmd);
|
||||
ccmd="";
|
||||
}
|
||||
else if (NF == 3 ) {
|
||||
dest=$1
|
||||
key=$3
|
||||
split($3, po, "=");
|
||||
if ( po[1] == "none") ccmd="cryptsetup luksOpen " src " " dest;
|
||||
else ccmd="cryptsetup luksOpen -d " key " " src" " dest;
|
||||
system(ccmd);
|
||||
ccmd="";
|
||||
}
|
||||
else {
|
||||
# the option field is not empty parse the options
|
||||
dest=$1
|
||||
key=$3
|
||||
split($4, opts, ",");
|
||||
commonopts="";
|
||||
swapopts="";
|
||||
luksopts="";
|
||||
for(i in opts) {
|
||||
split(opts[i], para, "=");
|
||||
par=para[1];
|
||||
val=para[2];
|
||||
if ( par == "readonly" || par == "read-only") commonopts=commonopts "-r ";
|
||||
else if ( par == "discard" ) commonopts=commonopts "--allow-discards ";
|
||||
else if ( par == "tries" ) commonopts=commonopts "-T " val " ";
|
||||
else if ( par == "swap" ) makeswap="y";
|
||||
else if ( par == "cipher" ) swapopts=swapopts "-c " val " ";
|
||||
else if ( par == "size" ) swapopts=swapopts "-s " val " ";
|
||||
else if ( par == "hash" ) swapopts=swapopts "-h " val " ";
|
||||
else if ( par == "offset" ) swapopts=swapopts "-o " val " ";
|
||||
else if ( par == "skip" ) swapopts=swapopts "-p " val " ";
|
||||
else if ( par == "verify" ) swapopts=swapopts "-y ";
|
||||
#else if ( par == "noauto" )
|
||||
#else if ( par == "nofail" )
|
||||
#else if ( par == "plain" )
|
||||
#else if ( par == "timeout" )
|
||||
#else if ( par == "tmp" )
|
||||
else if ( par == "luks" ) use_luks="y";
|
||||
else if ( par == "keyscript" ) {use_keyscript="y"; keyscript=val;}
|
||||
else if ( par == "keyslot" || par == "key-slot" ) luksopts=luksopts "-S " val " ";
|
||||
else if ( par == "keyfile-size" ) luksopts=luksopts "-l " val " ";
|
||||
else if ( par == "keyfile-offset" ) luksopts=luksopts "-keyfile-offset=" val " ";
|
||||
else if ( par == "header" ) luksopts=luksopts "--header=" val " ";
|
||||
else {
|
||||
print "option: " par " not supported " >"/dev/stderr";
|
||||
makeswap="";
|
||||
use_luks="";
|
||||
use_keyscript="";
|
||||
next;
|
||||
}
|
||||
}
|
||||
if ( makeswap == "y" && use_luks != "y" ) {
|
||||
ccmd="cryptsetup " swapopts commonopts "-d " key " create " dest " " src;
|
||||
ccmd_2="mkswap /dev/mapper/" dest;
|
||||
makeswap="";
|
||||
use_luks="";
|
||||
use_keyscript="";
|
||||
system(ccmd);
|
||||
system(ccmd_2);
|
||||
ccmd="";
|
||||
ccmd_2="";
|
||||
next;
|
||||
}
|
||||
if ( use_luks == "y" && makeswap != "y" ){
|
||||
if ( use_keyscript == "y") {
|
||||
ccmd=keyscript " | cryptsetup " luksopts commonopts "luksOpen -d - " src " " dest;
|
||||
use_keyscript="";
|
||||
}
|
||||
else {
|
||||
if ( key == "none" ){
|
||||
ccmd="cryptsetup " luksopts commonopts "luksOpen " src " " dest;
|
||||
}
|
||||
else {
|
||||
ccmd="cryptsetup " luksopts commonopts "luksOpen -d " key " " src " " dest;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
print "use swap OR luks as option" >"/dev/stderr";
|
||||
ccmd="";
|
||||
}
|
||||
makeswap="";
|
||||
use_luks="";
|
||||
use_keyscript="";
|
||||
if ( ccmd != ""){
|
||||
system(ccmd);
|
||||
ccmd=""
|
||||
}
|
||||
}
|
||||
}
|
57
functions
57
functions
@@ -1,57 +0,0 @@
|
||||
# *-*-shell-*-*
|
||||
|
||||
msg() {
|
||||
# bold
|
||||
printf "\033[1m=> $@\033[m\n"
|
||||
}
|
||||
|
||||
msg_ok() {
|
||||
# bold/green
|
||||
printf "\033[1m\033[32m OK\033[m\n"
|
||||
}
|
||||
|
||||
msg_error() {
|
||||
# bold/red
|
||||
printf "\033[1m\033[31mERROR: $@\033[m\n"
|
||||
}
|
||||
|
||||
msg_warn() {
|
||||
# bold/yellow
|
||||
printf "\033[1m\033[33mWARNING: $@\033[m"
|
||||
}
|
||||
|
||||
emergency_shell() {
|
||||
echo
|
||||
echo "Cannot continue due to errors above, starting emergency shell."
|
||||
echo "When ready type exit to continue booting."
|
||||
/bin/sh -l
|
||||
}
|
||||
|
||||
detect_virt() {
|
||||
# Detect LXC containers
|
||||
[ ! -e /proc/self/environ ] && return
|
||||
if grep -q lxc /proc/self/environ >/dev/null; then
|
||||
export VIRTUALIZATION=1
|
||||
fi
|
||||
}
|
||||
|
||||
deactivate_vgs() {
|
||||
_group=${1:-All}
|
||||
if [ -x /sbin/vgchange -o -x /bin/vgchange ]; then
|
||||
vgs=$(vgs|wc -l)
|
||||
if [ $vgs -gt 0 ]; then
|
||||
msg "Deactivating $_group LVM Volume Groups..."
|
||||
vgchange -an
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
deactivate_crypt() {
|
||||
if [ -x /sbin/dmsetup -o -x /bin/dmsetup ]; then
|
||||
msg "Deactivating Crypt Volumes"
|
||||
for v in $(dmsetup ls --target crypt --exec "dmsetup info -c --noheadings -o open,name"); do
|
||||
[ ${v%%:*} -eq 0 ] && cryptsetup close ${v##*:}
|
||||
done
|
||||
deactivate_vgs "Crypt"
|
||||
fi
|
||||
}
|
67
halt.8
67
halt.8
@@ -1,67 +0,0 @@
|
||||
.Dd July 29, 2014
|
||||
.Dt HALT 8
|
||||
.Os Linux
|
||||
.Sh NAME
|
||||
.Nm halt ,
|
||||
.Nm reboot ,
|
||||
.Nm poweroff
|
||||
.Nd stop the system
|
||||
.Sh SYNOPSIS
|
||||
.Nm halt
|
||||
.Op Fl n
|
||||
.Op Fl f
|
||||
.Nm reboot
|
||||
.Op Fl n
|
||||
.Op Fl f
|
||||
.Nm poweroff
|
||||
.Op Fl n
|
||||
.Op Fl f
|
||||
.Sh DESCRIPTION
|
||||
.Nm halt
|
||||
/
|
||||
.Nm reboot
|
||||
/
|
||||
.Nm poweroff
|
||||
tells
|
||||
.Xr init 8
|
||||
to bring down, reboot, or power off the system.
|
||||
Without
|
||||
.Fl f ,
|
||||
it is a shortcut for
|
||||
.Nm init 0
|
||||
/
|
||||
.Nm init 6 .
|
||||
.Bl -tag -width indent
|
||||
.It Fl n
|
||||
Don't sync before reboot or halt.
|
||||
Note that the kernel and storage drivers may still sync.
|
||||
.It Fl f
|
||||
Force halt or reboot, don't call
|
||||
.Xr init 8 .
|
||||
This is
|
||||
.Sy dangerous !
|
||||
.El
|
||||
.Sh UNSUPPORTED OPTIONS
|
||||
This version of
|
||||
.Nm
|
||||
is based on
|
||||
.Xr runit 8 ,
|
||||
the following features are
|
||||
.Sy not
|
||||
supported and silently ignored:
|
||||
.Bl -tag -width indent
|
||||
.It Fl w
|
||||
to just write the wtmp record.
|
||||
.It Fl d
|
||||
to not write the wtmp record.
|
||||
.It Fl h
|
||||
to put hard drives in standby mode.
|
||||
.It Fl i
|
||||
to shut down network interfaces.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr init 8 ,
|
||||
.Xr shutdown 8
|
||||
.Sh AUTHOR
|
||||
.An Leah Neukirchen ,
|
||||
.Mt leah@vuxu.org .
|
77
halt.c
77
halt.c
@@ -1,77 +0,0 @@
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <err.h>
|
||||
#include <string.h>
|
||||
#include <sys/reboot.h>
|
||||
|
||||
extern char *__progname;
|
||||
|
||||
typedef enum {NOOP, HALT, REBOOT, POWEROFF} action_type;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int do_sync = 1;
|
||||
int do_force = 0;
|
||||
int opt;
|
||||
action_type action = NOOP;
|
||||
|
||||
if (strcmp(__progname, "halt") == 0)
|
||||
action = HALT;
|
||||
else if (strcmp(__progname, "reboot") == 0)
|
||||
action = REBOOT;
|
||||
else if (strcmp(__progname, "poweroff") == 0)
|
||||
action = POWEROFF;
|
||||
else
|
||||
warnx("no default behavior, needs to be called as halt/reboot/poweroff.");
|
||||
|
||||
while ((opt = getopt(argc, argv, "dfhinw")) != -1)
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
do_sync = 0;
|
||||
break;
|
||||
case 'w':
|
||||
action = NOOP;
|
||||
do_sync = 0;
|
||||
break;
|
||||
case 'd':
|
||||
case 'h':
|
||||
case 'i':
|
||||
/* silently ignored. */
|
||||
break;
|
||||
case 'f':
|
||||
do_force = 1;
|
||||
break;
|
||||
default:
|
||||
errx(1, "Usage: %s [-n] [-f]", __progname);
|
||||
}
|
||||
|
||||
if (do_sync)
|
||||
sync();
|
||||
|
||||
switch (action) {
|
||||
case HALT:
|
||||
if (do_force)
|
||||
reboot(RB_HALT_SYSTEM);
|
||||
else
|
||||
execl("/bin/runit-init", "init", "0", (char*)0);
|
||||
err(1, "halt failed");
|
||||
break;
|
||||
case POWEROFF:
|
||||
if (do_force)
|
||||
reboot(RB_POWER_OFF);
|
||||
else
|
||||
execl("/bin/runit-init", "init", "0", (char*)0);
|
||||
err(1, "poweroff failed");
|
||||
break;
|
||||
case REBOOT:
|
||||
if (do_force)
|
||||
reboot(RB_AUTOBOOT);
|
||||
else
|
||||
execl("/bin/runit-init", "init", "6", (char*)0);
|
||||
err(1, "reboot failed");
|
||||
break;
|
||||
case NOOP:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
9
misc/tmpfile.conf
Normal file
9
misc/tmpfile.conf
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# /usr/lib/tmpfiles.d/runit.conf
|
||||
#
|
||||
|
||||
d /run/runit 0755 root root -
|
||||
d /run/user 0755 root root -
|
||||
d /run/lock 0755 root root -
|
||||
d /run/log 0755 root root -
|
||||
d /run/lvm 0755 root root -
|
19
modules-load
19
modules-load
@@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
# modules-load [-n] [-v] - modules-load.d(5) compatible kernel module loader
|
||||
|
||||
export PATH=/bin:/sbin
|
||||
|
||||
{
|
||||
# Parameters passed as modules-load= or rd.modules-load= in kernel command line.
|
||||
sed -nr 's/,/\n/;s/(.* |^)(rd\.)?modules-load=([^ ]*).*/\3/p' /proc/cmdline
|
||||
|
||||
# Find files /{etc,run,usr/lib}/modules-load.d/*.conf in that order.
|
||||
find -L /etc/modules-load.d /run/modules-load.d /usr/lib/modules-load.d \
|
||||
-maxdepth 1 -name '*.conf' -printf '%p %P\n' 2>/dev/null |
|
||||
# Load each basename only once.
|
||||
sort -k2 -s | uniq -f1 | cut -d' ' -f1 |
|
||||
# Read the files, output all non-empty, non-comment lines.
|
||||
tr '\012' '\0' | xargs -0 -r grep -h -v -e '^[#;]' -e '^$'
|
||||
} |
|
||||
# Call modprobe on the list of modules
|
||||
tr '\012' '\0' | xargs -0 -r modprobe -ab "$@"
|
@@ -1,52 +0,0 @@
|
||||
.Dd June 1, 2016
|
||||
.Dt MODULES-LOAD 8
|
||||
.Os Linux
|
||||
.Sh NAME
|
||||
.Nm modules-load
|
||||
.Nd Configure kernel modules to load at boot
|
||||
.Sh SYNOPSIS
|
||||
.Nm modules-load
|
||||
.Op Fl nv
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
reads files which contain kernel modules to load during boot from the list of
|
||||
locations below.
|
||||
.Bl -tag -width indent
|
||||
.It Fl n
|
||||
dry-run mode.
|
||||
This option does everything but actually insert or delete the modules.
|
||||
.It Fl v
|
||||
verbose mode.
|
||||
Print messages about what the program is doing.
|
||||
.El
|
||||
.Sh FILES
|
||||
Configuration files are read from the following locations:
|
||||
.Bl -tag -width indent
|
||||
.It /etc/modules-load.d/*.conf
|
||||
.It /run/modules-load.d/*.conf
|
||||
.It /usr/lib/modules-load.d/*.conf
|
||||
.El
|
||||
.Pp
|
||||
The configuration files should simply contain a list of kernel module names
|
||||
to load, separated by newlines.
|
||||
Empty lines and lines whose first non-whitespace character is # or ; are
|
||||
ignored.
|
||||
.Sh EXAMPLES
|
||||
.Pa /etc/modules-load.d/virtio-net.conf :
|
||||
.Bd -literal -offset indent
|
||||
# Load virtio-net.ko at boot
|
||||
virtio-net
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr modprobe 8
|
||||
.Sh HISTORY
|
||||
This program is a replacement for the
|
||||
.Nm modules-load
|
||||
utility provided by
|
||||
.Nm systemd .
|
||||
.Sh AUTHOR
|
||||
.An Leah Neukirchen ,
|
||||
.Mt leah@vuxu.org .
|
||||
.Sh LICENSE
|
||||
.Nm
|
||||
is in the public domain.
|
32
rc.conf
32
rc.conf
@@ -1,32 +0,0 @@
|
||||
# /etc/runit/rc.conf - system configuration
|
||||
|
||||
# Set the service manager (available options: "runit" or "openrc")
|
||||
#SVMANAGER="runit"
|
||||
|
||||
# Set the host name.
|
||||
#
|
||||
# NOTE: it's preferred to declare the hostname in /etc/hostname instead:
|
||||
# - echo myhost > /etc/hostname
|
||||
#
|
||||
#HOSTNAME="artix"
|
||||
|
||||
# Set RTC to UTC or localtime.
|
||||
#HARDWARECLOCK="UTC"
|
||||
|
||||
# Set timezone, availables timezones at /usr/share/zoneinfo.
|
||||
#TIMEZONE="Europe/Madrid"
|
||||
|
||||
# Keymap to load, see loadkeys(8).
|
||||
#KEYMAP="us"
|
||||
|
||||
# Console font to load, see setfont(8).
|
||||
#FONT="lat9w-16"
|
||||
|
||||
# Console map to load, see setfont(8).
|
||||
#FONT_MAP=
|
||||
|
||||
# Font unimap to load, see setfont(8).
|
||||
#FONT_UNIMAP=
|
||||
|
||||
# Amount of ttys which should be setup.
|
||||
#TTYS=6
|
4
rc.local
4
rc.local
@@ -1,4 +0,0 @@
|
||||
# Default rc.local; add your custom commands here.
|
||||
#
|
||||
# This is run by runit in stage 2 before the services are executed
|
||||
# (see /etc/runit/2).
|
@@ -1,4 +0,0 @@
|
||||
# Default rc.shutdown; add your custom commands here.
|
||||
#
|
||||
# This is run by runit in stage 3 after the services are stopped
|
||||
# (see /etc/runit/3).
|
@@ -1 +0,0 @@
|
||||
default
|
@@ -1 +0,0 @@
|
||||
/etc/runit/sv/agetty-tty1
|
@@ -1 +0,0 @@
|
||||
/etc/runit/sv/agetty-tty2
|
@@ -1 +0,0 @@
|
||||
/etc/runit/sv/agetty-tty3
|
@@ -1 +0,0 @@
|
||||
/etc/runit/sv/agetty-tty4
|
@@ -1 +0,0 @@
|
||||
/etc/runit/sv/agetty-tty5
|
@@ -1 +0,0 @@
|
||||
/etc/runit/sv/agetty-tty6
|
@@ -1 +0,0 @@
|
||||
/etc/runit/sv/sulogin
|
12
script/1.in
Executable file
12
script/1.in
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
PATH=/usr/bin:/usr/sbin
|
||||
|
||||
. @RCLIBDIR@/functions
|
||||
|
||||
run_sysinit
|
||||
|
||||
install -m000 /dev/null @RUNDIR@/stopit
|
||||
install -m000 /dev/null @RUNDIR@/reboot
|
||||
|
||||
status "Initialization complete"
|
23
script/2.in
Executable file
23
script/2.in
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
PATH=/usr/bin:/usr/sbin
|
||||
|
||||
runlevel=default
|
||||
for arg in $(cat /proc/cmdline); do
|
||||
if [ -d @RUNITDIR@/runsvdir/"$arg" ]; then
|
||||
echo "Runlevel detected: '$arg' (via kernel cmdline)"
|
||||
runlevel="$arg"
|
||||
fi
|
||||
done
|
||||
|
||||
# Hacky hacky OpenRC compatibility
|
||||
for script in @SYSCONFDIR@/local.d/*.start; do
|
||||
[ -x "$script" ] && "$script"
|
||||
done
|
||||
|
||||
runsvchdir "${runlevel}"
|
||||
|
||||
ln -s @RUNSVDIR@/current @SERVICEDIR@
|
||||
|
||||
exec env - PATH=$PATH \
|
||||
runsvdir -P @SERVICEDIR@ 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................'
|
25
script/3.in
Executable file
25
script/3.in
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
PATH=/usr/bin:/usr/sbin
|
||||
|
||||
. @RCLIBDIR@/functions
|
||||
|
||||
stat_busy "Stop services ..."
|
||||
sv force-stop @RUNDIR@/service/*
|
||||
stat_done
|
||||
stat_busy "Exit services ..."
|
||||
sv exit @RUNDIR@/service/*
|
||||
stat_done
|
||||
|
||||
# Hacky hacky OpenRC compatibility
|
||||
for script in @SYSCONFDIR@/local.d/*.stop; do
|
||||
[ -x "$script" ] && "$script"
|
||||
done
|
||||
|
||||
run_shutdown
|
||||
|
||||
if [ -e @RUNDIR@/reboot ]; then
|
||||
[[ -x $(type -P kexec) ]] && kexec -e &>/dev/null
|
||||
fi
|
||||
|
||||
status "Stage 3 completed."
|
@@ -3,8 +3,11 @@
|
||||
PATH=/usr/bin:/usr/sbin
|
||||
MSG="System is going down..."
|
||||
|
||||
# We check for this file after receiving a SIGCONT to move to stage3
|
||||
chmod 100 @RUNDIR@/stopit
|
||||
|
||||
# We check for this file in stage3 to halt or reboot
|
||||
touch /run/runit/reboot
|
||||
chmod 100 @RUNDIR@/reboot
|
||||
|
||||
# Proceed with shutdown process
|
||||
echo "$MSG" | wall
|
15
script/rc.local.start.in
Normal file
15
script/rc.local.start.in
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ ! -x @SYSCONFDIR@/rc.local ]; then
|
||||
cat > @SYSCONFDIR@/rc.local << EOF
|
||||
# @SYSCONFDIR@/rc.local -- rc.local for Artix Linux
|
||||
#
|
||||
# Enter your custom commands here. It will be executed on stage 2
|
||||
# before running services.
|
||||
EOF
|
||||
chmod +x @SYSCONFDIR@/rc.local
|
||||
fi
|
||||
|
||||
# Execute rc.local only once.
|
||||
# If artix-branding-base exists, that one will execute rc.local instead.
|
||||
[ ! -x @SYSCONFDIR@/local.d/local.start ] && . @SYSCONFDIR@/rc.local
|
13
script/rc.shutdown.stop.in
Normal file
13
script/rc.shutdown.stop.in
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ ! -x @SYSCONFDIR@/rc.shutdown ]; then
|
||||
cat > @SYSCONFDIR@/rc.shutdown << EOF
|
||||
# @SYSCONFDIR@/rc.shutdown -- rc.shutdown for Artix Linux
|
||||
#
|
||||
# Enter your custom commands here. It will be executed on stage 3
|
||||
# after stopping services.
|
||||
EOF
|
||||
chmod +x @SYSCONFDIR@/rc.shutdown
|
||||
fi
|
||||
|
||||
. @SYSCONFDIR@/rc.shutdown
|
@@ -1 +0,0 @@
|
||||
/run/runit/supervise.agetty-console
|
@@ -1 +0,0 @@
|
||||
/run/runit/supervise.agetty-tty1
|
@@ -1 +0,0 @@
|
||||
/run/runit/supervise.agetty-tty2
|
@@ -1 +0,0 @@
|
||||
/run/runit/supervise.agetty-tty3
|
@@ -1 +0,0 @@
|
||||
/run/runit/supervise.agetty-tty4
|
@@ -1 +0,0 @@
|
||||
/run/runit/supervise.agetty-tty5
|
@@ -1 +0,0 @@
|
||||
/run/runit/supervise.agetty-tty6
|
@@ -1 +0,0 @@
|
||||
/run/runit/supervise.agetty-ttyAMA0
|
@@ -1 +0,0 @@
|
||||
/run/runit/supervise.agetty-ttyS0
|
@@ -1 +0,0 @@
|
||||
/run/runit/supervise.agetty-ttyUSB0
|
@@ -1 +0,0 @@
|
||||
/run/runit/supervise.sulogin
|
73
shutdown
73
shutdown
@@ -1,73 +0,0 @@
|
||||
#!/bin/sh
|
||||
# shutdown - shutdown(8) lookalike for runit
|
||||
|
||||
single() {
|
||||
runsvchdir single
|
||||
}
|
||||
|
||||
abort() {
|
||||
printf '%s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
usage() {
|
||||
abort "Usage: ${0##*/} [-fF] [-kchPr] time [warning message]"
|
||||
}
|
||||
|
||||
action=single
|
||||
|
||||
while getopts akrhPHfFnct: opt; do
|
||||
case "$opt" in
|
||||
a|n|H) abort "'-$opt' is not implemented";;
|
||||
t) ;;
|
||||
f) touch /fastboot;;
|
||||
F) touch /forcefsck;;
|
||||
k) action=true;;
|
||||
c) action=cancel;;
|
||||
h|P) action=halt;;
|
||||
r) action=reboot;;
|
||||
[?]) usage;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
[ $# -eq 0 ] && usage
|
||||
|
||||
time=$1; shift
|
||||
message="${*:-system is going down}"
|
||||
|
||||
if [ "$action" = "cancel" ]; then
|
||||
kill "$(cat /run/runit/shutdown.pid)"
|
||||
if [ -e /etc/nologin ] && ! [ -s /etc/nologin ]; then
|
||||
rm /etc/nologin
|
||||
fi
|
||||
echo "${*:-shutdown cancelled}" | wall
|
||||
exit
|
||||
fi
|
||||
|
||||
touch /run/runit/shutdown.pid 2>/dev/null || abort "Not enough permissions to execute ${0#*/}"
|
||||
echo $$ >/run/runit/shutdown.pid
|
||||
|
||||
case "$time" in
|
||||
now) time=0;;
|
||||
+*) time=${time#+};;
|
||||
*:*) abort "absolute time is not implemented";;
|
||||
*) abort "invalid time";;
|
||||
esac
|
||||
|
||||
for break in 5 0; do
|
||||
[ "$time" -gt "$break" ] || continue
|
||||
[ "$break" = 0 ] && touch /etc/nologin
|
||||
|
||||
printf '%s in %s minutes\n' "$message" "$time" | wall
|
||||
printf 'shutdown: sleeping for %s minutes... ' "$(( time - break ))"
|
||||
sleep $(( (time - break) * 60 ))
|
||||
time="$break"
|
||||
printf '\n'
|
||||
|
||||
[ "$break" = 0 ] && rm /etc/nologin
|
||||
done
|
||||
|
||||
printf '%s NOW\n' "$message" | wall
|
||||
|
||||
$action
|
90
shutdown.8
90
shutdown.8
@@ -1,90 +0,0 @@
|
||||
.Dd July 29, 2014
|
||||
.Dt SHUTDOWN 8
|
||||
.Os Linux
|
||||
.Sh NAME
|
||||
.Nm shutdown
|
||||
.Nd bring down the system
|
||||
.Sh SYNOPSIS
|
||||
.Nm shutdown
|
||||
.Op Fl rhP
|
||||
.Op Fl fF
|
||||
.Op Cm now | Cm + Ns Ar mins
|
||||
.Op Ar message ...
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
brings the system down in a secure way.
|
||||
All logged-in users
|
||||
are notified that the system is going down, and
|
||||
.Xr login 1
|
||||
is blocked.
|
||||
.Pp
|
||||
By default,
|
||||
.Nm
|
||||
puts the system into single user mode.
|
||||
Rebooting and halting the system can be done using the following options:
|
||||
.Bl -tag -width indent
|
||||
.It Fl c
|
||||
Cancel an ongoing shutdown.
|
||||
.It Fl f
|
||||
Enable fast booting; skip
|
||||
.Xr fsck 8
|
||||
on next boot.
|
||||
.It Fl F
|
||||
Force run of
|
||||
.Xr fsck 8
|
||||
on next boot.
|
||||
.It Fl h
|
||||
Halt the system.
|
||||
.It Fl k
|
||||
Don't really shutdown; only send the warning messages to everybody.
|
||||
.It Fl P
|
||||
Poweroff the system.
|
||||
.It Fl r
|
||||
Reboot the system.
|
||||
.It Cm now
|
||||
Shutdown without further waiting.
|
||||
.It Cm + Ns Ar mins
|
||||
Wait
|
||||
.Ar mins
|
||||
minutes before shutting down.
|
||||
.It Ar message
|
||||
Message displayed to all users, defaults to "system is going down".
|
||||
.El
|
||||
.Sh UNSUPPORTED OPTIONS
|
||||
This version of
|
||||
.Nm
|
||||
is based on
|
||||
.Xr runit 8 ,
|
||||
the following features are
|
||||
.Sy not
|
||||
supported:
|
||||
.Bl -tag -width indent
|
||||
.It Fl t Ar secs
|
||||
to wait
|
||||
.Ar secs
|
||||
seconds between SIGKILL and SIGTERM on shutdown is silently ignored.
|
||||
.It Fl a
|
||||
Use
|
||||
.Pa /etc/shutdown.allow .
|
||||
.It Fl H
|
||||
Drop into boot monitor.
|
||||
.It Fl n
|
||||
Don't call
|
||||
.Xr init 8 .
|
||||
.It Ar hh Ns : Ns Ar mm
|
||||
Absolute time specification is not implemented.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
Turn off the system:
|
||||
.Dl # shutdown -h now
|
||||
.Sh SEE ALSO
|
||||
.Xr fsck 8 ,
|
||||
.Xr halt 8 ,
|
||||
.Xr init 8 ,
|
||||
.Xr poweroff 8 ,
|
||||
.Xr reboot 8 ,
|
||||
.Xr runit 8 ,
|
||||
.Xr runsvchdir 8
|
||||
.Sh AUTHOR
|
||||
.An Leah Neukirchen ,
|
||||
.Mt leah@vuxu.org .
|
3
sv/udevd/run
Executable file
3
sv/udevd/run
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
udevadm control --exit
|
||||
exec udevd
|
Reference in New Issue
Block a user