Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
8
1.in
8
1.in
@@ -8,20 +8,16 @@ PATH=/usr/bin:/usr/sbin
|
|||||||
# Prints distro name and URL
|
# Prints distro name and URL
|
||||||
print_welcome
|
print_welcome
|
||||||
|
|
||||||
# log all console messages
|
|
||||||
bootlogd_start
|
|
||||||
|
|
||||||
run_hook sysinit_start
|
run_hook sysinit_start
|
||||||
|
|
||||||
for sysinit in @RCDIR@/sysinit.d/*; do
|
for sysinit in @RCDIR@/sysinit.d/*; do
|
||||||
. $sysinit
|
. $sysinit
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove leftover files
|
|
||||||
# remove_leftover
|
|
||||||
|
|
||||||
run_hook sysinit_end
|
run_hook sysinit_end
|
||||||
|
|
||||||
install -m100 /dev/null @RUNDIR@/stopit
|
install -m100 /dev/null @RUNDIR@/stopit
|
||||||
|
|
||||||
status "Initialization complete"
|
status "Initialization complete"
|
||||||
|
|
||||||
|
bootlogd_stop
|
||||||
|
6
2.in
6
2.in
@@ -2,14 +2,12 @@
|
|||||||
|
|
||||||
PATH=/usr/bin:/usr/sbin
|
PATH=/usr/bin:/usr/sbin
|
||||||
|
|
||||||
. @RCDIR@/functions
|
[ -x @RCDIR@/rc.local ] && . @RCDIR@/rc.local
|
||||||
|
|
||||||
status "Running stage 2"
|
|
||||||
|
|
||||||
runlevel=default
|
runlevel=default
|
||||||
for arg in $(cat /proc/cmdline); do
|
for arg in $(cat /proc/cmdline); do
|
||||||
if [ -d @RUNITDIR@/runsvdir/"$arg" ]; then
|
if [ -d @RUNITDIR@/runsvdir/"$arg" ]; then
|
||||||
status "Runlevel detected: '$arg' (via kernel cmdline)"
|
echo "Runlevel detected: '$arg' (via kernel cmdline)"
|
||||||
runlevel="$arg"
|
runlevel="$arg"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
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.
|
51
Makefile
51
Makefile
@@ -9,7 +9,6 @@ SVDIR = $(RUNITDIR)/sv
|
|||||||
RUNSVDIR = $(RUNITDIR)/runsvdir
|
RUNSVDIR = $(RUNITDIR)/runsvdir
|
||||||
SERVICEDIR = /etc/service
|
SERVICEDIR = /etc/service
|
||||||
RUNDIR = /run/runit
|
RUNDIR = /run/runit
|
||||||
RCBINDIR = $(PREFIX)/lib/rc/bin
|
|
||||||
RCDIR = $(SYSCONFDIR)/rc
|
RCDIR = $(SYSCONFDIR)/rc
|
||||||
|
|
||||||
TMPFILES = tmpfile.conf
|
TMPFILES = tmpfile.conf
|
||||||
@@ -18,6 +17,8 @@ BIN = zzz pause modules-load
|
|||||||
|
|
||||||
STAGES = 1 2 3 ctrlaltdel
|
STAGES = 1 2 3 ctrlaltdel
|
||||||
|
|
||||||
|
RC = rc/rc.local rc/rc.shutdown rc/functions rc/rc.conf
|
||||||
|
|
||||||
LN = ln -sf
|
LN = ln -sf
|
||||||
CP = cp -R --no-dereference --preserve=mode,links -v
|
CP = cp -R --no-dereference --preserve=mode,links -v
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
@@ -45,32 +46,27 @@ EDIT = sed \
|
|||||||
|
|
||||||
|
|
||||||
all: all-runit
|
all: all-runit
|
||||||
|
|
||||||
ifeq ($(HASRC),yes)
|
ifeq ($(HASRC),yes)
|
||||||
|
|
||||||
all: all-rc
|
all: all-rc
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all-runit: $(STAGES)
|
all-runit:
|
||||||
$(CC) $(CFLAGS) pause.c -o pause $(LDFLAGS)
|
$(CC) $(CFLAGS) pause.c -o pause $(LDFLAGS)
|
||||||
|
|
||||||
all-rc:
|
all-rc: $(RC) $(STAGES)
|
||||||
make RCDIR=$(RCDIR) -C rc
|
|
||||||
|
|
||||||
install-runit:
|
install-runit:
|
||||||
install -d $(DESTDIR)$(RUNITDIR)
|
install -d $(DESTDIR)$(RUNITDIR)
|
||||||
install -m755 $(STAGES) $(DESTDIR)$(RUNITDIR)
|
install -d $(DESTDIR)$(RUNSVDIR)
|
||||||
|
install -d $(DESTDIR)$(RUNSVDIR)/default
|
||||||
|
install -d $(DESTDIR)$(SVDIR)/sulogin
|
||||||
|
$(LN) $(RUNSVDIR)/default $(DESTDIR)$(RUNSVDIR)/current
|
||||||
|
$(CP) sv/sulogin $(DESTDIR)$(SVDIR)/
|
||||||
|
$(CP) runsvdir/single $(DESTDIR)$(RUNSVDIR)/
|
||||||
|
|
||||||
$(LN) $(RUNDIR)/reboot $(DESTDIR)$(RUNITDIR)/
|
$(LN) $(RUNDIR)/reboot $(DESTDIR)$(RUNITDIR)/
|
||||||
$(LN) $(RUNDIR)/stopit $(DESTDIR)$(RUNITDIR)/
|
$(LN) $(RUNDIR)/stopit $(DESTDIR)$(RUNITDIR)/
|
||||||
|
|
||||||
install -d $(DESTDIR)$(SVDIR)
|
|
||||||
$(CP) sv/* $(DESTDIR)$(SVDIR)/
|
|
||||||
|
|
||||||
install -d $(DESTDIR)$(RUNSVDIR)
|
|
||||||
$(CP) runsvdir/* $(DESTDIR)$(RUNSVDIR)/
|
|
||||||
|
|
||||||
install -d $(DESTDIR)$(BINDIR)
|
install -d $(DESTDIR)$(BINDIR)
|
||||||
install -m755 $(BIN) $(DESTDIR)$(BINDIR)
|
install -m755 $(BIN) $(DESTDIR)$(BINDIR)
|
||||||
|
|
||||||
@@ -84,7 +80,25 @@ install-runit:
|
|||||||
install -m644 modules-load.8 $(DESTDIR)$(MANDIR)/man8
|
install -m644 modules-load.8 $(DESTDIR)$(MANDIR)/man8
|
||||||
|
|
||||||
install-rc:
|
install-rc:
|
||||||
make install BINDIR=$(BINDIR) RCDIR=$(RCDIR) RCBINDIR=$(RCBINDIR) MANDIR=$(MANDIR) DESTDIR=$(DESTDIR) -C rc
|
install -d $(DESTDIR)$(RUNITDIR)
|
||||||
|
install -m755 $(STAGES) $(DESTDIR)$(RUNITDIR)
|
||||||
|
|
||||||
|
install -d $(DESTDIR)$(RCDIR)
|
||||||
|
install -d $(DESTDIR)$(RCDIR)/sysinit.d
|
||||||
|
install -d $(DESTDIR)$(RCDIR)/shutdown.d
|
||||||
|
install -m755 $(RC) $(DESTDIR)$(RCDIR)
|
||||||
|
install -m644 rc/sysinit.d/* $(DESTDIR)$(RCDIR)/sysinit.d
|
||||||
|
install -m644 rc/shutdown.d/* $(DESTDIR)$(RCDIR)/shutdown.d
|
||||||
|
install -m644 rc/crypt.awk $(DESTDIR)$(RCDIR)
|
||||||
|
install -d $(DESTDIR)$(RUNITDIR)
|
||||||
|
install -m755 $(STAGES) $(DESTDIR)$(RUNITDIR)
|
||||||
|
|
||||||
|
install-getty:
|
||||||
|
install -d $(DESTDIR)$(SVDIR)
|
||||||
|
$(CP) sv/agetty-* $(DESTDIR)$(SVDIR)/
|
||||||
|
|
||||||
|
install -d $(DESTDIR)$(RUNSVDIR)/default
|
||||||
|
$(CP) runsvdir/default $(DESTDIR)$(RUNSVDIR)/
|
||||||
|
|
||||||
install: install-runit
|
install: install-runit
|
||||||
ifeq ($(HASRC),yes)
|
ifeq ($(HASRC),yes)
|
||||||
@@ -93,10 +107,10 @@ endif
|
|||||||
|
|
||||||
clean-runit:
|
clean-runit:
|
||||||
-rm -f pause
|
-rm -f pause
|
||||||
-rm -f $(STAGES)
|
|
||||||
|
|
||||||
clean-rc:
|
clean-rc:
|
||||||
make -C rc clean
|
-rm -f $(RC)
|
||||||
|
-rm -f $(STAGES)
|
||||||
|
|
||||||
clean: clean-runit
|
clean: clean-runit
|
||||||
ifeq ($(HASRC),yes)
|
ifeq ($(HASRC),yes)
|
||||||
@@ -105,5 +119,4 @@ endif
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
||||||
|
.PHONY: all install clean install-runit install-rc install-getty clean-runit clean-rc all-runit all-rc
|
||||||
.PHONY: all install clean install-runit install-rc clean-runit clean-rc all-runit all-rc
|
|
||||||
|
16
README.md
16
README.md
@@ -3,16 +3,12 @@
|
|||||||
This repository contains the runit init scripts for the Artix Linux
|
This repository contains the runit init scripts for the Artix Linux
|
||||||
distribution.
|
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.
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
- GNU coreutils
|
- GNU coreutils
|
||||||
- A POSIX shell
|
- GNU bash
|
||||||
- A POSIX awk
|
- A POSIX awk
|
||||||
- procps-ng (needs pkill -s0,1)
|
- procps-ng
|
||||||
- runit
|
- runit
|
||||||
- opentmpfiles
|
- opentmpfiles
|
||||||
- opensysusers
|
- opensysusers
|
||||||
@@ -43,9 +39,7 @@ Feel free to send patches and contribute with improvements!
|
|||||||
|
|
||||||
## Copyright
|
## 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
|
The rest of runit-artix is licensed under the terms as described in the
|
||||||
all copyright and related or neighboring rights to this work.
|
COPYING file.
|
||||||
|
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/
|
|
||||||
|
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=""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
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;
|
|
||||||
}
|
|
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).
|
|
55
rc/Makefile
55
rc/Makefile
@@ -1,55 +0,0 @@
|
|||||||
RCBIN = halt shutdown
|
|
||||||
RC = rc.local rc.shutdown functions rc.conf
|
|
||||||
|
|
||||||
LN = ln -sf
|
|
||||||
RM = rm -f
|
|
||||||
M4 = m4 -P
|
|
||||||
CHMODAW = chmod a-w
|
|
||||||
CHMODX = chmod +x
|
|
||||||
|
|
||||||
EDIT = sed -e "s|@RCDIR[@]|$(RCDIR)|g"
|
|
||||||
|
|
||||||
%: %.in Makefile
|
|
||||||
@echo "GEN $@"
|
|
||||||
@$(RM) "$@"
|
|
||||||
@$(M4) $@.in | $(EDIT) >$@
|
|
||||||
@$(CHMODAW) "$@"
|
|
||||||
@$(CHMODX) "$@"
|
|
||||||
|
|
||||||
all: $(RC) shutdown
|
|
||||||
$(CC) $(CFLAGS) halt.c -o halt $(LDFLAGS)
|
|
||||||
|
|
||||||
install:
|
|
||||||
install -d $(DESTDIR)$(RCDIR)
|
|
||||||
install -d $(DESTDIR)$(RCDIR)/sysinit.d
|
|
||||||
install -d $(DESTDIR)$(RCDIR)/shutdown.d
|
|
||||||
install -m755 $(RC) $(DESTDIR)$(RCDIR)
|
|
||||||
install -m644 sysinit.d/* $(DESTDIR)$(RCDIR)/sysinit.d
|
|
||||||
install -m644 shutdown.d/* $(DESTDIR)$(RCDIR)/shutdown.d
|
|
||||||
install -m644 crypt.awk $(DESTDIR)$(RCDIR)
|
|
||||||
|
|
||||||
install -d $(DESTDIR)$(RCBINDIR)
|
|
||||||
install -m644 $(RCBIN) $(DESTDIR)$(RCBINDIR)
|
|
||||||
|
|
||||||
$(LN) halt $(DESTDIR)$(RCBINDIR)/poweroff
|
|
||||||
$(LN) halt $(DESTDIR)$(RCBINDIR)/reboot
|
|
||||||
|
|
||||||
|
|
||||||
install_sysv:
|
|
||||||
install -d $(DESTDIR)$(BINDIR)
|
|
||||||
$(LN) runit-init $(DESTDIR)$(BINDIR)/init
|
|
||||||
$(LN) $(RCBINDIR)/halt $(DESTDIR)$(BINDIR)/halt
|
|
||||||
$(LN) $(RCBINDIR)/shutdown $(DESTDIR)$(BINDIR)/shutdown
|
|
||||||
$(LN) halt $(DESTDIR)$(BINDIR)/poweroff
|
|
||||||
$(LN) halt $(DESTDIR)$(BINDIR)/reboot
|
|
||||||
install -d $(DESTDIR)$(MANDIR)/man8
|
|
||||||
install -m644 shutdown.8 $(DESTDIR)$(MANDIR)/man8/shutdown.8
|
|
||||||
install -m644 halt.8 $(DESTDIR)$(MANDIR)/man8/halt.8
|
|
||||||
$(LN) halt.8 $(DESTDIR)$(MANDIR)/man8/poweroff.8
|
|
||||||
$(LN) halt.8 $(DESTDIR)$(MANDIR)/man8/reboot.8
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -f halt
|
|
||||||
-rm -f shutdown $(RC)
|
|
||||||
|
|
||||||
.PHONY: all install install_sysv clean
|
|
@@ -57,16 +57,6 @@ if (( $? != 3 )); then
|
|||||||
fi
|
fi
|
||||||
unset TERM_COLORS
|
unset TERM_COLORS
|
||||||
|
|
||||||
unquote() {
|
|
||||||
local -r quotes=$'[\'"]'
|
|
||||||
|
|
||||||
if [[ ${1:0:1} = $quotes && ${1:(-1)} = "${1:0:1}" ]]; then
|
|
||||||
printf '%s' "${1:1:(-1)}"
|
|
||||||
else
|
|
||||||
printf '%s' "$1"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# functions:
|
# functions:
|
||||||
|
|
||||||
deltext() {
|
deltext() {
|
||||||
@@ -134,15 +124,9 @@ in_array() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kill_all() {
|
kill_all() {
|
||||||
stat_busy "Sending TERM signal to processes"
|
status "Sending TERM signal to processes" pkill --inverse -s0,1 -TERM
|
||||||
pkill --inverse -s0,1 -TERM
|
sleep 1
|
||||||
if (( $? == 0 )); then
|
status "Sending KILL signal to processes" pkill --inverse -s0,1 -KILL
|
||||||
stat_done
|
|
||||||
else
|
|
||||||
stat_fail
|
|
||||||
sleep 1
|
|
||||||
status "Sending KILL signal to processes" pkill --inverse -s0,1 -KILL
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print_welcome() {
|
print_welcome() {
|
||||||
@@ -317,6 +301,21 @@ set_timezone() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_binfmt() {
|
||||||
|
mountpoint -q /proc/sys/fs/binfmt_misc || \
|
||||||
|
mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc
|
||||||
|
|
||||||
|
for path in /usr/lib/binfmt.d /etc/binfmt.d /run/binfmt.d; do
|
||||||
|
[[ ! -d $path ]] && continue;
|
||||||
|
for file in $(ls -1 $path); do
|
||||||
|
grep "^:" $file | \
|
||||||
|
while read -r line; do
|
||||||
|
printf "%s" "$line" > /proc/sys/fs/binfmt_misc/register
|
||||||
|
done
|
||||||
|
done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Filesystem functions
|
# Filesystem functions
|
||||||
# These can be overridden/reused for customizations like shutdown/loop-fsck.
|
# These can be overridden/reused for customizations like shutdown/loop-fsck.
|
||||||
NETFS="nfs,nfs4,smbfs,cifs,codafs,ncpfs,shfs,fuse,fuseblk,glusterfs,davfs,fuse.glusterfs"
|
NETFS="nfs,nfs4,smbfs,cifs,codafs,ncpfs,shfs,fuse,fuseblk,glusterfs,davfs,fuse.glusterfs"
|
||||||
@@ -373,23 +372,19 @@ mount_all() {
|
|||||||
mount -a -t "no${NETFS//,/,no}" -O no_netdev
|
mount -a -t "no${NETFS//,/,no}" -O no_netdev
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_leftover() {
|
|
||||||
status 'Removing leftover files' tmpfiles --create --remove --clean
|
|
||||||
}
|
|
||||||
|
|
||||||
bootlogd_stop() {
|
bootlogd_stop() {
|
||||||
[[ -f /run/bootlogd.pid ]] || return 0
|
[[ -f /run/bootlogd.pid ]] || return 0
|
||||||
touch /var/log/boot
|
touch /var/log/boot.log
|
||||||
kill $(< /run/bootlogd.pid)
|
kill $(< /run/bootlogd.pid)
|
||||||
rm -f /run/bootlogd.pid
|
rm -f /run/bootlogd.pid
|
||||||
}
|
}
|
||||||
|
|
||||||
bootlogd_start(){
|
bootlogd_start(){
|
||||||
[[ ! -f /var/log/boot ]] && touch /var/log/boot
|
bootlogd -p /run/bootlogd.pid -l /var/log/boot.log
|
||||||
bootlogd -p /run/bootlogd.pid
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console_setup(){
|
console_setup(){
|
||||||
|
[ -r /etc/vconsole.conf ] && . /etc/vconsole.conf
|
||||||
TTYS=${TTYS:-6}
|
TTYS=${TTYS:-6}
|
||||||
if [ -n "$FONT" ]; then
|
if [ -n "$FONT" ]; then
|
||||||
_index=0
|
_index=0
|
||||||
@@ -430,25 +425,16 @@ mk_tmpfiles_setup(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove_leftover() {
|
||||||
|
status 'Removing leftover files' tmpfiles --create --remove --clean
|
||||||
|
}
|
||||||
|
|
||||||
mk_sysusers(){
|
mk_sysusers(){
|
||||||
if [ -x /usr/bin/sysusers ]; then
|
if [ -x /usr/bin/sysusers ]; then
|
||||||
sysusers
|
sysusers
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup_1(){
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
# Custom hooks in initscripts #
|
# Custom hooks in initscripts #
|
||||||
###############################
|
###############################
|
||||||
|
67
rc/halt.8
67
rc/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
rc/halt.c
77
rc/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;
|
|
||||||
}
|
|
@@ -2,12 +2,11 @@
|
|||||||
|
|
||||||
# Storage
|
# Storage
|
||||||
#
|
#
|
||||||
|
# Enable dmraid support (yes/no)
|
||||||
# USEDMRAID="no"
|
# USEDMRAID="no"
|
||||||
|
|
||||||
|
# Enable LVM2 support (yes/no)
|
||||||
# USELVM="no"
|
# USELVM="no"
|
||||||
|
|
||||||
# Network
|
# Enable btrfs support (yes/no)
|
||||||
#
|
# USEBTRFS="no"
|
||||||
# interface=
|
|
||||||
# address=
|
|
||||||
# netmask=
|
|
||||||
# gateway=
|
|
||||||
|
@@ -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 .
|
|
@@ -1,2 +0,0 @@
|
|||||||
[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) ]] &&
|
|
||||||
status "Deactivating LVM2 groups" vgchange --sysinit -a n &>/dev/null
|
|
@@ -1,2 +1,3 @@
|
|||||||
status "Remounting root filesystem read-only" \
|
status "Remounting root filesystem read-only" \
|
||||||
mount -o remount,ro /
|
mount -o remount,ro /
|
||||||
|
sync
|
2
rc/shutdown.d/13-lvm2.sh
Normal file
2
rc/shutdown.d/13-lvm2.sh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[[ $USELVM = [Yy][Ee][Ss] && -x $(type -P lvm) ]] &&
|
||||||
|
status "Deactivating LVM2 groups" vgchange --sysinit -an &>/dev/null
|
@@ -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 @RUNDIR@/shutdown.pid)"
|
|
||||||
if [ -e /etc/nologin ] && ! [ -s /etc/nologin ]; then
|
|
||||||
rm /etc/nologin
|
|
||||||
fi
|
|
||||||
echo "${*:-shutdown cancelled}" | wall
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
touch @RUNDIR@/shutdown.pid 2>/dev/null || abort "Not enough permissions to execute ${0#*/}"
|
|
||||||
echo $$ >@RUNDIR@/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
|
|
@@ -8,9 +8,11 @@ mkdir -p /dev/{pts,shm}
|
|||||||
mountpoint -q /dev/pts || mount -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec
|
mountpoint -q /dev/pts || mount -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec
|
||||||
mountpoint -q /dev/shm || mount -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev
|
mountpoint -q /dev/shm || mount -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev
|
||||||
mountpoint -q /sys/kernel/security || mount -n -t securityfs securityfs /sys/kernel/security
|
mountpoint -q /sys/kernel/security || mount -n -t securityfs securityfs /sys/kernel/security
|
||||||
mountpoint -q /sys/firmware/efi/efivars || mount -n -t efivarfs -o ro efivarfs /sys/firmware/efi/efivars
|
[ -d /sys/firmware/efi ] && (mountpoint -q /sys/firmware/efi/efivars || mount -n -t efivarfs -o ro efivarfs /sys/firmware/efi/efivars)
|
||||||
mountpoint -q /sys/fs/cgroup || mount -o mode=0755 -t tmpfs cgroup /sys/fs/cgroup
|
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
|
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
|
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
|
||||||
|
|
||||||
findmnt / --options ro &>/dev/null || status "Mounting root read-only" mount -o remount,ro /
|
findmnt / --options ro &>/dev/null || status "Mounting root read-only" mount -o remount,ro /
|
||||||
|
|
||||||
|
bootlogd_start
|
||||||
|
1
rc/sysinit.d/11-btrfs.sh
Normal file
1
rc/sysinit.d/11-btrfs.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
status "Activating btrfs devices" btrfs device scan
|
1
rc/sysinit.d/22-sysctl.sh
Normal file
1
rc/sysinit.d/22-sysctl.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
status "Loading sysctl(8) settings" sysctl --system
|
1
rc/sysinit.d/23-binfmt.sh
Normal file
1
rc/sysinit.d/23-binfmt.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
status "Running binfmt" run_binfmt
|
10
rc/sysinit.d/99-cleanup.sh
Normal file
10
rc/sysinit.d/99-cleanup.sh
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
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 -f /etc/nologin /forcefsck /forcequotacheck /fastboot
|
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 .
|
|
73
shutdown.in
73
shutdown.in
@@ -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 @RUNDIR@/shutdown.pid)"
|
|
||||||
if [ -e /etc/nologin ] && ! [ -s /etc/nologin ]; then
|
|
||||||
rm /etc/nologin
|
|
||||||
fi
|
|
||||||
echo "${*:-shutdown cancelled}" | wall
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
touch @RUNDIR@/shutdown.pid 2>/dev/null || abort "Not enough permissions to execute ${0#*/}"
|
|
||||||
echo $$ >@RUNDIR@/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
|
|
Reference in New Issue
Block a user