Compare commits
70 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
571079581d | ||
![]() |
5153867c5c | ||
![]() |
3edf09f112 | ||
![]() |
7cceba59ba | ||
![]() |
f443c45b58 | ||
![]() |
a02517cd6c | ||
![]() |
780ccf8ccf | ||
![]() |
69b9f7ec7f | ||
![]() |
a0f3aa87f3 | ||
![]() |
2859cd5fa4 | ||
![]() |
a29d97570b | ||
![]() |
4e0a612d6c | ||
![]() |
426afc67cb | ||
![]() |
16f76d0e89 | ||
![]() |
3e198ee09d | ||
![]() |
157561ff1a | ||
![]() |
ee63627f34 | ||
![]() |
8aa20b50f3 | ||
![]() |
aaf133355a | ||
![]() |
69b64ba057 | ||
![]() |
376d28df6f | ||
![]() |
ca57ac6852 | ||
![]() |
c7b42d7b02 | ||
![]() |
9e6b8bf1b5 | ||
![]() |
a8a8109903 | ||
![]() |
3289c6c736 | ||
![]() |
1d17321c9a | ||
![]() |
f2ed6b08ac | ||
![]() |
8a2cd0bd2a | ||
![]() |
638a03632d | ||
![]() |
c1f8e69e31 | ||
![]() |
1188fd5a02 | ||
![]() |
66ff1cd25a | ||
![]() |
5dd10c21ab | ||
![]() |
f02e3e77f6 | ||
![]() |
c39d4eaa9f | ||
![]() |
5118d345f5 | ||
![]() |
0fdfb07785 | ||
![]() |
71c69a3712 | ||
![]() |
6e9aa207a9 | ||
![]() |
776956629c | ||
![]() |
9c398628df | ||
![]() |
1e3db3d992 | ||
![]() |
d734920302 | ||
![]() |
45228a409b | ||
![]() |
b05eb70a1a | ||
![]() |
f0e4ef7e71 | ||
![]() |
76bd850f2e | ||
![]() |
6a3223a718 | ||
![]() |
9c034c223c | ||
![]() |
08d073fe82 | ||
![]() |
aa834f05e4 | ||
![]() |
e4a337d82d | ||
![]() |
ef93123fc6 | ||
![]() |
96c517fbb6 | ||
![]() |
928bcb559f | ||
![]() |
e2d67d7c8c | ||
![]() |
a483e72826 | ||
![]() |
5aa4632678 | ||
![]() |
c7d9be62f8 | ||
![]() |
608df4bd47 | ||
![]() |
c32cc76462 | ||
![]() |
065c79b9ff | ||
![]() |
97f13d2f1a | ||
![]() |
983d28ae45 | ||
![]() |
1470fda317 | ||
![]() |
9e41be013b | ||
![]() |
b53a85ef5c | ||
![]() |
3790871455 | ||
![]() |
4aece292a1 |
18
LICENSE
18
LICENSE
@@ -1,4 +1,14 @@
|
||||
# "THE BEERWARE LICENSE" (Revision 42):
|
||||
# <eric@obarun.org> wrote this file. As long as you retain this notice you
|
||||
# can do whatever you want with this stuff. If we meet some day, and you think
|
||||
# this stuff is worth it, you can buy me a beer in return. Eric Vidal http://obarun.org
|
||||
Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
All rights reserved.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
83
Makefile
Normal file
83
Makefile
Normal file
@@ -0,0 +1,83 @@
|
||||
# Makefile for s6-boot
|
||||
|
||||
VERSION = $(git describe --tags| sed 's/-.*//g;s/^v//;')
|
||||
PKGNAME = s6-boot
|
||||
|
||||
BINDIR_EXECLINE = /usr/local/bin
|
||||
BINDIR = /usr/bin
|
||||
|
||||
CLASSIC = `find classic/ -type f`
|
||||
DATA = `find data/scripts -type f`
|
||||
RC = `find rc/ -type f`
|
||||
FILESYSTEM = `find filesystem-env/ -type f`
|
||||
ENV = `find env/ -type f`
|
||||
|
||||
DIRS= \
|
||||
/usr/bin \
|
||||
/etc/s6 \
|
||||
/etc/s6/compiled \
|
||||
/etc/s6/data/scripts \
|
||||
/etc/s6/env \
|
||||
/etc/s6/filesystem-env \
|
||||
/etc/s6/rc \
|
||||
/etc/s6/classic/service \
|
||||
/etc/s6/classic/uncaught-logs \
|
||||
/usr/share/zsh/site-functions \
|
||||
/usr/share/licenses
|
||||
|
||||
install:
|
||||
install -dm755 $(addprefix $(DESTDIR),$(DIRS))
|
||||
|
||||
for i in $(CLASSIC) $(RC) init stage2 stage2.tini stage3 poweroff reboot ; do \
|
||||
sed -i 's,@BINDIR_EXECLINE@,$(BINDIR_EXECLINE),' $$i; \
|
||||
done
|
||||
|
||||
for i in $(DATA) shutdown $(CLASSIC); do \
|
||||
sed -i 's,@BINDIR@,$(BINDIR),' $$i; \
|
||||
done
|
||||
|
||||
for i in $(CLASSIC); do \
|
||||
install -Dm755 $$i $(DESTDIR)/etc/s6/$$i; \
|
||||
done
|
||||
|
||||
for i in $(RC); do \
|
||||
install -Dm644 $$i $(DESTDIR)/etc/s6/$$i; \
|
||||
done
|
||||
|
||||
for i in $(FILESYSTEM); do \
|
||||
install -Dm644 $$i $(DESTDIR)/etc/s6/$$i;\
|
||||
done
|
||||
|
||||
for i in $(ENV); do \
|
||||
install -m644 $$i $(DESTDIR)/etc/s6/$$i; \
|
||||
done
|
||||
|
||||
rm $(DESTDIR)/etc/s6/classic/uncaught-logs/README
|
||||
|
||||
install -m755 data/scripts/s6.local $(DESTDIR)/etc/s6/data/scripts/s6.local
|
||||
ln -sf /etc/s6/data/scripts/s6.local $(DESTDIR)/etc/s6.local
|
||||
install -m755 data/scripts/user.sh $(DESTDIR)/etc/s6/data/scripts/user.sh
|
||||
|
||||
cp -P -a compiled/default $(DESTDIR)/etc/s6/compiled/default
|
||||
ln -sf /etc/s6/compiled/default $(DESTDIR)/etc/s6/compiled/current
|
||||
ln -sf /etc/s6/compiled/default $(DESTDIR)/etc/s6/compiled/previous
|
||||
|
||||
install -m755 init $(DESTDIR)/$(BINDIR)
|
||||
for i in stage2 stage2.tini stage3 reboot shutdown poweroff; do \
|
||||
install -m755 $$i $(DESTDIR)/etc/s6/$$i;\
|
||||
done
|
||||
ln -sf /etc/s6/poweroff $(DESTDIR)/$(BINDIR)
|
||||
ln -sf /etc/s6/reboot $(DESTDIR)/$(BINDIR)
|
||||
ln -sf /etc/s6/shutdown $(DESTDIR)/$(BINDIR)
|
||||
|
||||
install -m644 s6.conf $(DESTDIR)/etc/s6
|
||||
ln -sf /etc/s6/s6.conf $(DESTDIR)/etc/s6.conf
|
||||
|
||||
install -m644 _s6-svc $(DESTDIR)/usr/share/zsh/site-functions
|
||||
|
||||
install -Dm644 LICENSE $(DESTDIR)/usr/share/licenses/$(PKGNAME)/LICENSE
|
||||
|
||||
version:
|
||||
@echo $(VERSION)
|
||||
|
||||
.PHONY: install version
|
28
NEWS
Normal file
28
NEWS
Normal file
@@ -0,0 +1,28 @@
|
||||
Changelog for s6-boot
|
||||
|
||||
In 0.1.7
|
||||
--------
|
||||
|
||||
- Pass to ISC license
|
||||
- S6opts is now a dependences of s6-boot
|
||||
- Rename boot-serv directory to classic
|
||||
- Rename boot-rc-serv directory to rc
|
||||
- Rename base-env directory to env :
|
||||
- rename DESTBOOTSERV to DEST
|
||||
- rename DESTRCSERV to DESTRC : this variable point now to /run/boot/rc
|
||||
- rename SRCBOOTSERV to SRC : this variable point now to /etc/s6/classic
|
||||
- rename SRCRCCOMPILED to SRCRC
|
||||
- remove SRCRCSERV
|
||||
- add HANDLE : point to /etc/s6/data/scripts to find user.sh scripts
|
||||
- add TEMPLATE : point to /usr/share/obarun/s6opts/template to find supervison tree creation scheme
|
||||
- Modify files in classic/.s6-svscan to reflect the change into env/ directory
|
||||
- Modify files init, stage2, stage2.tini, poweroff, shutdown, reboot to reflect the change into env/ directory
|
||||
- Simplify stage2.tini : random-seed and hwclock command is now made by down file of respectively services
|
||||
- Use *.conf files at _s6-svc to define path for completion
|
||||
- Remove all-Switch bundle, switch-{user,svscan,ready} rc service and replace it by adduser service:
|
||||
- the supervision tree for root user is now created by adduser service calling data/scripts/user.sh to do it
|
||||
- Remove s6-serv directory (added to s6opts)
|
||||
- Add data/scripts/user.sh scripts : This scripts allow to create a supervison tree whatever the user calling it.
|
||||
The scripts source {s6opts,service}.conf to define path, name of the different elements of the supervision tree.
|
||||
- Add Makefile
|
||||
- Block tty1 service until boot procedure is not fully operational.
|
11
README.md
11
README.md
@@ -1,4 +1,9 @@
|
||||
# s6-boot
|
||||
Boot files for s6
|
||||
For instructions about S6 supervision suite : http://skarnet.org/software/
|
||||
Please see here http://obarun.org/forum/viewtopic.php?id=123 for futher informations about obarun use it.
|
||||
|
||||
Obarun boot files for s6
|
||||
|
||||
For instructions about [S6 supervision suite.](https://skarnet.org/software/)
|
||||
|
||||
[Bug reports](https://forum.obarun.org)
|
||||
|
||||
|
||||
|
25
_s6-svc
25
_s6-svc
@@ -1,11 +1,28 @@
|
||||
#compdef s6-svc
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
# completion for s6-svc
|
||||
# Copyright (C) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# services in /run/s6/service. Change the path variable to suit your needs.
|
||||
# Change the path variable to suit your needs.
|
||||
|
||||
first_word=${${(z)BUFFER}[1]}
|
||||
|
||||
#overwrite config with user specification
|
||||
|
||||
if [[ $first_word == "sudo" ]] || [[ $first_word == "su" ]] || [[ $EUID == 0 ]]; then
|
||||
source /etc/obarun/s6opts.conf
|
||||
else
|
||||
source $(getent passwd $(whoami)|cut -d : -f 6)/service/service.conf
|
||||
fi
|
||||
|
||||
path_dir_boot=/run/boot/service
|
||||
path_dir_user=/run/user/service
|
||||
path_dir_user=${LIVE_CLASSIC_PATH}
|
||||
|
||||
typeset -A opt_args
|
||||
|
||||
@@ -13,7 +30,7 @@ _path() {
|
||||
local list_dir
|
||||
list_dir_boot=( $path_dir_boot/* )
|
||||
list_dir_user=( $path_dir_user/* )
|
||||
compadd "$@" -a list_dir_boot list_dir_user
|
||||
compadd "$@" -a list_dir_boot list_dir_root list_dir_user
|
||||
}
|
||||
|
||||
_list_common=(
|
||||
|
@@ -1,50 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- 00 started }
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
# mount proc sys dev run if doesn't exist
|
||||
#import -i HOSTNAME
|
||||
#if { s6-hostname $HOSTNAME }
|
||||
foreground {
|
||||
forx -p first { proc sys dev run }
|
||||
importas -ui -D "" first first
|
||||
foreground {
|
||||
if -n { mountpoint -q /$first }
|
||||
s6-envdir /etc/s6/env/mount/$first
|
||||
importas -ui -D "" fstype fstype
|
||||
importas -ui -D "" device device
|
||||
importas -ui -D "" mountpoint mountpoint
|
||||
importas -ui -D "" options options
|
||||
s6-mount -o $options -t $fstype $device $mountpoint
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# create needed directory on run if doesn't exist
|
||||
if {
|
||||
forx -p second { lvm user lock }
|
||||
importas -ui -D "" second second
|
||||
foreground {
|
||||
if -n { s6-test -d /run/$second }
|
||||
s6-mkdir -p -m 0755 /run/$second
|
||||
}
|
||||
}
|
||||
|
||||
# finaly mount /dev/shm /dev/pts
|
||||
if {
|
||||
forx -p third { shm pts }
|
||||
importas -ui -D "" third third
|
||||
if {
|
||||
foreground {
|
||||
if -n { mountpoint -q /dev/$third }
|
||||
if { s6-mkdir -p -m 0755 /dev/$third }
|
||||
s6-envdir /etc/s6/env/mount/$third
|
||||
importas -ui -D "" fstype fstype
|
||||
importas -ui -D "" device device
|
||||
importas -ui -D "" mountpoint mountpoint
|
||||
importas -ui -D "" options options
|
||||
s6-mount -o $options -n -t $fstype $device $mountpoint
|
||||
}
|
||||
}
|
||||
}
|
||||
s6-echo -- 00 successfully started
|
@@ -1,3 +0,0 @@
|
||||
all-Boot
|
||||
#all-User
|
||||
all-Switch
|
@@ -1,3 +0,0 @@
|
||||
switch-ready
|
||||
switch-svscan
|
||||
switch-user
|
@@ -1,12 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- checkfs-brtfs started }
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
importas -D "" USEBTRFS USEBTRFS
|
||||
foreground {
|
||||
if { s6-test $USEBTRFS = yes }
|
||||
if { s6-test -x /usr/bin/btrfs }
|
||||
btrfs device scan
|
||||
}
|
||||
s6-echo -- checkfs-brtfs successfully started
|
@@ -1,12 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- checkfs-dmraid started }
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
importas -D "" USEDMRAID USEDMRAID
|
||||
foreground {
|
||||
if { s6-test $USEDMRAID = yes }
|
||||
if { s6-test -x /usr/bin/dmraid }
|
||||
dmraid -i -ay
|
||||
}
|
||||
s6-echo -- checkfs-dmraid successfully started
|
@@ -1,19 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- checkfs-fsckeck started }
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
importas -D "" FORCECHCK FORCECHCK
|
||||
foreground {
|
||||
if { s6-test $FORCECHCK = yes }
|
||||
redirfd -w 1 /dev/console
|
||||
if { s6-echo -- Check of filesystem was asked, please wait }
|
||||
foreground { fsck -A -T -a -f noopts=_netdev }
|
||||
s6-echo -- Filesystem checked
|
||||
}
|
||||
|
||||
# if partition is checked, fsck return a fail exit
|
||||
# and a crash occurs, so whatever happens with fsck, the output need to be a success
|
||||
if -t {
|
||||
foreground { fsck -A -T -a noopts=_netdev }
|
||||
}
|
||||
s6-echo -- checkfs-fscheck successfully started
|
@@ -1,19 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
importas -D "" USELVM USELVM
|
||||
foreground {
|
||||
if { s6-test $USELVM = yes }
|
||||
if { s6-echo -- checkfs-lvm started }
|
||||
foreground {
|
||||
if -nt { s6-test -d /run/lvm }
|
||||
s6-mkdir /run/lvm
|
||||
}
|
||||
if { /usr/bin/lvmetad -p /run/lvm/lvmetad.pid }
|
||||
foreground {
|
||||
if { /usr/bin/vgscan }
|
||||
/usr/bin/vgchange -ay
|
||||
}
|
||||
pkill lvmetad
|
||||
}
|
||||
s6-echo -- lvm-prepare successfully started
|
@@ -1 +0,0 @@
|
||||
bundle
|
@@ -1,14 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
foreground {
|
||||
redirfd -r 0 /proc/cgroups
|
||||
pipeline { s6-tail -n +2 }
|
||||
pipeline { s6-cut -d"\t" -f1 }
|
||||
pipeline { s6-grep -vF -- devices }
|
||||
forstdin -d"\n" -- i
|
||||
importas -u -D "" i i
|
||||
if { mountpoint -q /sys/fs/cgroup/${i} }
|
||||
umount -R /sys/fs/cgroup/${i}
|
||||
}
|
||||
umount /sys/fs/cgroup
|
@@ -1,20 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rofs-cgroups started }
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
importas -D "" CGROUPS CGROUPS
|
||||
foreground {
|
||||
if { s6-test $CGROUPS = yes }
|
||||
if { mkdir -p -m 0755 /sys/fs/cgroup }
|
||||
if { s6-mount -wt tmpfs cgroup /sys/fs/cgroup }
|
||||
redirfd -r 0 /proc/cgroups
|
||||
pipeline { s6-tail -n +2 }
|
||||
pipeline { s6-cut -d"\t" -f1 }
|
||||
pipeline { s6-grep -vF -- devices }
|
||||
forstdin -d"\n" -- i
|
||||
importas -u -D "" i i
|
||||
if { s6-mkdir /sys/fs/cgroup/${i} }
|
||||
s6-mount -t cgroup -o ${i} -- cgroup /sys/fs/cgroup/${i}
|
||||
}
|
||||
s6-echo -- rofs-cgroups successfully started
|
@@ -1,19 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rofs-console started }
|
||||
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
importas -D "" KEYMAP KEYMAP
|
||||
importas -D "" FONT FONT
|
||||
importas -D "" FONT_MAP FONT_MAP
|
||||
importas -D "" FONT_UNIMAP FONT_UNIMAP
|
||||
foreground {
|
||||
loadkeys -q -u $KEYMAP
|
||||
}
|
||||
foreground {
|
||||
forx index { 0 1 2 3 4 5 6 7 8 9 10 }
|
||||
importas -u -D "" index index
|
||||
setfont -m $FONT_MAP -u $FONT_UNIMAP $FONT -C /dev/tty${index}
|
||||
}
|
||||
s6-echo -- rofs-console successfully started
|
@@ -1,15 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rofs-hardclock started }
|
||||
foreground {
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
importas -D "" TZ TZ
|
||||
importas -D "" HARDWARECLOCK HARDWARECLOCK
|
||||
pipeline -d { echo $HARDWARECLOCK }
|
||||
pipeline { tr A-Z a-z }
|
||||
forstdin -- clock
|
||||
importas -iu -D "" clock clock
|
||||
hwclock --systz --${clock} --noadjfile
|
||||
}
|
||||
s6-echo -- rofs-hardclock successfully started
|
@@ -1,14 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rofs-kermod started }
|
||||
foreground {
|
||||
pipeline -d { kmod static-nodes }
|
||||
pipeline { s6-grep -F -- Module: }
|
||||
pipeline { s6-cut -d":" -f2 }
|
||||
pipeline { s6-cut -d" " -f2 }
|
||||
forstdin -d"\n" -- mod
|
||||
importas -iu -D "" mod mod
|
||||
modprobe $mod
|
||||
}
|
||||
s6-echo -- rofs-kermod successfully started
|
@@ -1,13 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rofs-kernruntime started }
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
importas -D "" KERNELRUNTIME KERNELRUNTIME
|
||||
foreground {
|
||||
if { s6-test $KERNELRUNTIME = yes }
|
||||
if { s6-test -x /usr/bin/sysctl }
|
||||
if { s6-test -e /etc/sysctl.conf }
|
||||
sysctl -p /etc/sysctl.conf
|
||||
}
|
||||
s6-echo -- rofs-kernruntime successfully started
|
@@ -1,15 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rofs-modules started }
|
||||
foreground {
|
||||
if { s6-test -e /etc/s6/env/s6-conf/MODULES }
|
||||
redirfd -r 0 /etc/s6/env/s6-conf/MODULES
|
||||
forstdin -n -- mods
|
||||
importas -ui -D "" mods mods
|
||||
foreground {
|
||||
if { s6-test -n $mods }
|
||||
modprobe -ab $mods
|
||||
}
|
||||
}
|
||||
s6-echo -- rofs-modules successfully started
|
@@ -1,4 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
swapoff -a
|
@@ -1,11 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rofs-swap started }
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
importas -D "" USESWAP USESWAP
|
||||
foreground {
|
||||
if { s6-test $USESWAP = yes }
|
||||
swapon -a
|
||||
}
|
||||
s6-echo -- rofs-swap successfully started
|
@@ -1,8 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rwfs-dmesglog started }
|
||||
foreground {
|
||||
redirfd -w 1 /var/log/dmesg.log
|
||||
dmesg
|
||||
}
|
||||
s6-echo -- rwfs-dmesglog successfully started
|
@@ -1,5 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rwfs-fsrw started }
|
||||
if { s6-mount -o remount,rw / / }
|
||||
s6-echo -- rwfs-fsrw successfully started
|
@@ -1,17 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
import -D "" IPTABLES
|
||||
import -D "" IP6TABLES
|
||||
foreground {
|
||||
if { s6-test $IPTABLES = yes }
|
||||
if { s6-echo -- Flushing iptables }
|
||||
/usr/lib/iptables/scripts/iptables-flush
|
||||
|
||||
}
|
||||
foreground {
|
||||
if { s6-test $IP6TABLES = yes }
|
||||
if { s6-echo -- Flushing ip6tables }
|
||||
/usr/lib/iptables/scripts/iptables-flush 6
|
||||
}
|
||||
s6-echo -- Iptables flushed
|
@@ -1,22 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rwfs-iptables started }
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
importas -D "" IPTABLES IPTABLES
|
||||
importas -D "" IP6TABLES IP6TABLES
|
||||
foreground {
|
||||
if { s6-test $IPTABLES = yes }
|
||||
if { s6-test -e /etc/iptables/iptables.rules }
|
||||
if { s6-echo -- Activing iptables }
|
||||
foreground { iptables-restore /etc/iptables/iptables.rules }
|
||||
s6-echo -- Iptables actived
|
||||
}
|
||||
foreground {
|
||||
if { s6-test $IP6TABLES = yes }
|
||||
if { s6-test -e /etc/iptables/ip6tables.rules }
|
||||
if { s6-echo -- Activing ip6tables }
|
||||
foreground { ip6tables-restore /etc/iptables/ip6tables.rules }
|
||||
s6-echo -- Ip6tables actived
|
||||
}
|
||||
s6-echo -- rwfs-iptables successfully started
|
@@ -1,8 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rwfs-localtime started }
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
importas -D "" TZ TZ
|
||||
if { s6-ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime }
|
||||
s6-echo -- rwfs-localtime successfully started
|
@@ -1,6 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rwfs-loopback started }
|
||||
if { ip link set up dev lo }
|
||||
s6-echo -- rwfs-loopback successfully started
|
@@ -1,6 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rwfs-nonetwork started }
|
||||
if { mount -a -t "nosysfs,nonfs,nonfs4,nosmbfs,nocifs" -O no_netdev }
|
||||
s6-echo -- rwfs-nonetwork successfully started
|
@@ -1,22 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rwfs-random started }
|
||||
foreground {
|
||||
cp /var/lib/random-seed /dev/urandom
|
||||
}
|
||||
|
||||
backtick -n bytes { cat /proc/sys/kernel/random/poolsize }
|
||||
importas -u -D "" bytes bytes
|
||||
if -t {
|
||||
foreground {
|
||||
if { s6-test -z $bytes }
|
||||
define defbytes 512
|
||||
umask 077
|
||||
dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=$defbytes
|
||||
}
|
||||
s6-true
|
||||
}
|
||||
umask 077
|
||||
foreground { dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=$bytes }
|
||||
s6-echo -- rwfs-random successfully started
|
@@ -1,7 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
s6-envdir /etc/s6/env/s6-conf
|
||||
importas -D "" S6LOCAL S6LOCAL
|
||||
ifelse -X { s6-test $S6LOCAL = yes }
|
||||
{ exec -c /etc/s6/data/scripts/s6.local }
|
||||
s6-echo -- s6.local desactived
|
@@ -1,10 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- rwfs-tmpdir started }
|
||||
|
||||
foreground {
|
||||
if { s6-echo -- Create /tmp directory }
|
||||
mkdir -p -m1777 /tmp
|
||||
}
|
||||
|
||||
s6-echo -- rwfs-tmpdir successfully started
|
@@ -1 +0,0 @@
|
||||
all-Boot
|
@@ -1,7 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- start switch-presvscan }
|
||||
if { s6-mkdir -p -m 0755 /run/user/service }
|
||||
forbacktickx -p -0 serv { s6-ls -0 /etc/s6-serv/enabled/classic }
|
||||
importas -u -D "" serv serv
|
||||
s6-ln -s -- /etc/s6-serv/enabled/classic/${serv} /run/user/service
|
@@ -1 +0,0 @@
|
||||
switch-ready
|
@@ -1,3 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
s6-svscan -t0 /run/user/service
|
@@ -1,2 +0,0 @@
|
||||
switch-ready
|
||||
switch-svscan
|
@@ -1,2 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
s6-rc -l /run/user-rc -da change
|
@@ -1,6 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- switch-user started }
|
||||
if { s6-rc-init -c /etc/s6-serv/enabled/rc/compiled/current -l /run/user-rc /run/user/service }
|
||||
if { s6-rc -l /run/user-rc -u change All }
|
||||
s6-echo -- switch-user successfully started
|
@@ -1,6 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- udevd-udev longrun started }
|
||||
exec -c
|
||||
udevd
|
||||
|
@@ -1,5 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- udevd-udevadm started }
|
||||
s6-devd
|
||||
/usr/bin/udevadm settle
|
@@ -1 +0,0 @@
|
||||
longrun
|
@@ -1,8 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- udevd-udevrules started }
|
||||
foreground {
|
||||
if { udevadm trigger --action=add --type=subsystems }
|
||||
udevadm trigger --action=add --type=devices
|
||||
}
|
||||
s6-echo -- udevd-udevrules successfully started
|
@@ -1,4 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
foreground { /etc/s6/stage2.tini }
|
||||
s6-svscanctl -h -- /run/boot/service
|
@@ -1,4 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
foreground { /etc/s6/stage2.tini }
|
||||
s6-svscanctl -6 -- /run/boot/service
|
@@ -1,4 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
foreground { /etc/s6/stage2.tini }
|
||||
s6-svscanctl -q -- /run/boot/service
|
@@ -1,4 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
foreground { /etc/s6/stage2.tini }
|
||||
s6-svscanctl -t -- /run/boot/service
|
@@ -1,3 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
s6-svscanctl -an -- /run/boot/service
|
@@ -1,4 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
foreground { /etc/s6/stage2.tini }
|
||||
s6-svscanctl -7 -- /run/boot/service
|
@@ -1,7 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
redirfd -r 0 /dev/console
|
||||
redirfd -w 1 /dev/console
|
||||
fdmove -c 2 1
|
||||
foreground { s6-echo -- "s6-svscan crashed. Dropping to an interactive shell." }
|
||||
/bin/sh -i
|
@@ -1,9 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -S0
|
||||
|
||||
cd /
|
||||
redirfd -w 2 /dev/console
|
||||
fdmove -c 1 2
|
||||
foreground { s6-svc -X -- /run/boot/service/s6-svscan-log }
|
||||
unexport ?
|
||||
wait -r -- { }
|
||||
/etc/s6/stage3 ${@}
|
@@ -1,8 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
redirfd -w 2 /dev/console
|
||||
fdmove -c 1 2
|
||||
#redirfd -w 1 /dev/null
|
||||
redirfd -rnb 0 fifo
|
||||
s6-applyuidgid -u 19 -g 19 --
|
||||
s6-log -bp -- t /run/boot/uncaught-logs
|
@@ -1,3 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
/usr/bin/agetty -J 38400 tty1
|
@@ -1,3 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
|
||||
/usr/bin/agetty -J 38400 tty2
|
15
classic/service/.s6-svscan/SIGHUP
Executable file
15
classic/service/.s6-svscan/SIGHUP
Executable file
@@ -0,0 +1,15 @@
|
||||
#!@BINDIR_EXECLINE@/execlineb -P
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
fdmove -c 2 1
|
||||
s6-envdir -if /etc/s6/env
|
||||
importas -i DEST DEST
|
||||
foreground { /etc/s6/stage2.tini }
|
||||
s6-svscanctl -h -- ${DEST}/service
|
15
classic/service/.s6-svscan/SIGINT
Executable file
15
classic/service/.s6-svscan/SIGINT
Executable file
@@ -0,0 +1,15 @@
|
||||
#!@BINDIR_EXECLINE@/execlineb -P
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
fdmove -c 2 1
|
||||
s6-envdir -if /etc/s6/env
|
||||
importas -i DEST DEST
|
||||
foreground { /etc/s6/stage2.tini }
|
||||
s6-svscanctl -6 -- ${DEST}/service
|
15
classic/service/.s6-svscan/SIGQUIT
Executable file
15
classic/service/.s6-svscan/SIGQUIT
Executable file
@@ -0,0 +1,15 @@
|
||||
#!@BINDIR_EXECLINE@/execlineb -P
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
fdmove -c 2 1
|
||||
s6-envdir -if /etc/s6/env
|
||||
importas -i DEST DEST
|
||||
foreground { /etc/s6/stage2.tini }
|
||||
s6-svscanctl -7 -- ${DEST}/service
|
15
classic/service/.s6-svscan/SIGTERM
Executable file
15
classic/service/.s6-svscan/SIGTERM
Executable file
@@ -0,0 +1,15 @@
|
||||
#!@BINDIR_EXECLINE@/execlineb -P
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
fdmove -c 2 1
|
||||
s6-envdir -if /etc/s6/env
|
||||
importas -i DEST DEST
|
||||
foreground { /etc/s6/stage2.tini }
|
||||
s6-svscanctl -t -- ${DEST}/service
|
14
classic/service/.s6-svscan/SIGUSR1
Executable file
14
classic/service/.s6-svscan/SIGUSR1
Executable file
@@ -0,0 +1,14 @@
|
||||
#!@BINDIR_EXECLINE@/execlineb -P
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
fdmove -c 2 1
|
||||
s6-envdir -if /etc/s6/env
|
||||
importas -i DEST DEST
|
||||
s6-svscanctl -an -- ${DEST}/service
|
16
classic/service/.s6-svscan/SIGUSR2
Executable file
16
classic/service/.s6-svscan/SIGUSR2
Executable file
@@ -0,0 +1,16 @@
|
||||
#!@BINDIR_EXECLINE@/execlineb -P
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
fdmove -c 2 1
|
||||
s6-envdir -if /etc/s6/env
|
||||
importas -i DEST DEST
|
||||
foreground { /etc/s6/stage2.tini }
|
||||
s6-svscanctl -0 -- ${DEST}/service
|
||||
|
17
classic/service/.s6-svscan/crash
Executable file
17
classic/service/.s6-svscan/crash
Executable file
@@ -0,0 +1,17 @@
|
||||
#!@BINDIR_EXECLINE@/execlineb -P
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
s6-envdir -if /etc/s6/env
|
||||
importas -i DEST DEST
|
||||
redirfd -r 0 /dev/console
|
||||
redirfd -w 1 /dev/console
|
||||
fdmove -c 2 1
|
||||
foreground { s6-echo -- "s6-svscan at ${DEST}/service crashed. Dropping to an interactive shell." }
|
||||
/bin/sh -i
|
19
classic/service/.s6-svscan/finish
Executable file
19
classic/service/.s6-svscan/finish
Executable file
@@ -0,0 +1,19 @@
|
||||
#!@BINDIR_EXECLINE@/execlineb -S0
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
s6-envdir -if /etc/s6/env
|
||||
importas -i DEST DEST
|
||||
cd /
|
||||
redirfd -w 2 /dev/console
|
||||
fdmove -c 1 2
|
||||
foreground { s6-svc -X -- ${DEST}/service/s6-svscan-log }
|
||||
unexport ?
|
||||
wait -r -- { }
|
||||
/etc/s6/stage3 ${@}
|
16
classic/service/s6-svscan-log/run
Executable file
16
classic/service/s6-svscan-log/run
Executable file
@@ -0,0 +1,16 @@
|
||||
#!@BINDIR_EXECLINE@/execlineb -P
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
importas -i DEST DEST
|
||||
redirfd -w 2 /dev/console
|
||||
fdmove -c 1 2
|
||||
redirfd -rnb 0 fifo
|
||||
s6-setuidgid s6log
|
||||
s6-log -bp -- t ${DEST}/uncaught-logs
|
14
classic/service/tty1/run
Executable file
14
classic/service/tty1/run
Executable file
@@ -0,0 +1,14 @@
|
||||
#!@BINDIR@/bash
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
source /etc/obarun/s6opts.conf
|
||||
if s6-svok ${LIVE_CLASSIC_PATH}/s6rc-fdholder; then
|
||||
exec -c /usr/bin/agetty -J 38400 tty1
|
||||
fi
|
11
classic/service/tty2/run
Executable file
11
classic/service/tty2/run
Executable file
@@ -0,0 +1,11 @@
|
||||
#!@BINDIR_EXECLINE@/execlineb -P
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
/usr/bin/agetty --delay 02 -J 38400 tty2
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -4,5 +4,5 @@ fdmove 1 3
|
||||
s6-ipcserver-socketbinder -- s
|
||||
s6-ipcserverd -1 --
|
||||
s6-ipcserver-access -v0 -E -l0 -i data/rules --
|
||||
s6-sudod -t 2000 --
|
||||
s6-sudod -t 30000 --
|
||||
/usr/libexec/s6-rc-oneshot-run -l ../.. --
|
||||
|
@@ -1,3 +0,0 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
fdmove -c 2 1
|
||||
s6-svscan -t0 /run/user/service
|
@@ -1,4 +1,13 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- udevd-udev longrun started }
|
||||
exec -c
|
||||
|
@@ -1,4 +1,13 @@
|
||||
#!/usr/local/bin/execlineb -P
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
fdmove -c 2 1
|
||||
if { s6-echo -- udevd-udevadm started }
|
||||
s6-devd
|
||||
|
@@ -1,3 +1,12 @@
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
#
|
||||
# Default s6.local for obarun; add your custom commands here.
|
||||
#
|
||||
# This is run by s6 before the user services are executed.
|
||||
|
254
data/scripts/user.sh
Executable file
254
data/scripts/user.sh
Executable file
@@ -0,0 +1,254 @@
|
||||
#!@BINDIR@/bash
|
||||
# Copyright (c) 2015-2017 Eric Vidal <eric@obarun.org>
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of Obarun. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/Obarun/s6-boot/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
exec 2>&1
|
||||
exec 1>>/var/log/user.log
|
||||
|
||||
log(){
|
||||
printf "%s %s %s\n" "$(date +"%Y-%m-%d %H:%M:%S")" "${FUNCNAME[1]} ::" "${@}"
|
||||
}
|
||||
|
||||
# ${1} user name
|
||||
# ${2} action to do, add or del
|
||||
|
||||
if [[ -z "${1}" ]] || [[ -z "${2}" ]];then
|
||||
log "handle-user :: Missing arguments, existing"
|
||||
exit 1
|
||||
fi
|
||||
if [[ "${1}" == "root" ]]; then
|
||||
log "root user, nothing to do, exiting 0"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ENV="/etc/s6/env"
|
||||
DEST=$(head -n1 ${ENV}/DEST) #/run/boot
|
||||
TEMPLATE=$(head -n1 ${ENV}/TEMPLATE) #/usr/share/obarun/s6opts/template
|
||||
SOURCE=""
|
||||
|
||||
USER="${1}"
|
||||
# special case here, adduser scipts call
|
||||
# user.sh with boot as user, but this user
|
||||
# doesn't exist, wrap the uid,gid to root
|
||||
if [[ "${USER}" == "boot" ]]; then
|
||||
_UID=$(id -u 0)
|
||||
_GID=$(id -g 0)
|
||||
else
|
||||
_UID=$(id -u ${USER})
|
||||
_GID=$(id -g ${USER})
|
||||
fi
|
||||
|
||||
# overwrite conf if connected with user
|
||||
if ! (( "${_UID}" == 0 )); then
|
||||
if ! source $(getent passwd ${USER}|cut -d : -f 6)/service/service.conf 2>/dev/null; then
|
||||
out_error "$(getent passwd ${USER}|cut -d : -f 6)/service/service.conf doesn't exist"
|
||||
out_error "Use s6opts user command first"
|
||||
exit 1
|
||||
else
|
||||
SOURCE="$(getent passwd ${USER}|cut -d : -f 6)/service/service.conf"
|
||||
fi
|
||||
elif ! source /etc/obarun/s6opts.conf; then
|
||||
out_error "/etc/obarun/s6opts.conf not found, existing"
|
||||
exit 1
|
||||
else
|
||||
SOURCE="/etc/obarun/s6opts.conf"
|
||||
fi
|
||||
|
||||
# at this point, the good .conf file is sourced
|
||||
# we know all needed variables
|
||||
|
||||
# do not pass if DEST_USER already exist
|
||||
if [[ -d "${DEST_USER}" ]] && [[ "${2}" == "add" ]]; then
|
||||
log "${DEST_USER} already exist, nothing to do"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
LIST_SERV=$(ls ${CLASSIC_ENABLED})
|
||||
# coming from boot time? so respect the choice of the .conf files
|
||||
# and change the name of USER variable.
|
||||
if [[ "${USER}" == "boot" ]]; then
|
||||
USER="${DEST_USER##*/}"
|
||||
fi
|
||||
|
||||
copy_template() {
|
||||
log "mkdir ${DEST}/service/${USER}/{log,env}"
|
||||
mkdir -p -m 0755 ${DEST}/service/${USER}/{log,env}
|
||||
log "s6-hiercopy from ${TEMPLATE}/base/ to ${DEST}/service/${USER}"
|
||||
/usr/bin/s6-hiercopy ${TEMPLATE}/base/run ${DEST}/service/${USER}/run
|
||||
/usr/bin/s6-hiercopy ${TEMPLATE}/base/log ${DEST}/service/${USER}/log
|
||||
/usr/bin/s6-hiercopy ${TEMPLATE}/base/env ${DEST}/service/${USER}/env
|
||||
}
|
||||
|
||||
parse_env() {
|
||||
local named
|
||||
log "replace base by ${USER} at LOG,run,log/run files"
|
||||
for named in ${DEST}/service/${USER}/env/LOG ${DEST}/service/${USER}/{run,log/run}; do
|
||||
sed -i "s:base:${USER}:g" $named
|
||||
done
|
||||
|
||||
unset named
|
||||
}
|
||||
|
||||
add_env() {
|
||||
local -a list_env=$(printenv)
|
||||
local var value line list
|
||||
|
||||
|
||||
while read line;do
|
||||
|
||||
if [[ "${line:0:1}" == "#" ]] || [[ -z "${line}" ]];then
|
||||
continue
|
||||
fi
|
||||
|
||||
var=$(awk -F"=" '{print $1}' <<< "${line}")
|
||||
value=$(echo ${!var})
|
||||
|
||||
log "create new file ${var} with ${value} at ${DEST}/service/${USER}/env/"
|
||||
touch ${DEST}/service/${USER}/env/"${var}"
|
||||
echo "${value}" > ${DEST}/service/${USER}/env/"${var}"
|
||||
|
||||
done < "${SOURCE}"
|
||||
|
||||
#special env need to be create
|
||||
log "create new file USER with ${USER} at ${DEST}/service/${USER}/env/"
|
||||
touch ${DEST}/service/${USER}/env/USER
|
||||
echo "${USER}" > ${DEST}/service/${USER}/env/USER
|
||||
|
||||
log "create new file UID with ${_UID} at ${DEST}/service/${USER}/env/"
|
||||
touch ${DEST}/service/${USER}/env/UID
|
||||
echo "${_UID}" > ${DEST}/service/${USER}/env/UID
|
||||
|
||||
log "create new file GID with ${_GID} at ${DEST}/service/${USER}/env/"
|
||||
touch ${DEST}/service/${USER}/env/UID
|
||||
echo "${_GID}" > ${DEST}/service/${USER}/env/GID
|
||||
|
||||
#su -l "${USER}" -c 'env'
|
||||
|
||||
# need improvement
|
||||
for list in ${list_env[@]};do
|
||||
|
||||
while read line;do
|
||||
|
||||
var=$(awk -F"=" '{print $1}' <<< "${line}")
|
||||
value=$(echo ${!var})
|
||||
|
||||
case "${var}" in
|
||||
_|?|GID|UID|PWD|G_DEBUG|LOG) continue
|
||||
;;
|
||||
*)
|
||||
log "create new file ${var} with ${value} at ${DEST}/service/${USER}/env/"
|
||||
touch ${DEST}/service/${USER}/env/"${var}"
|
||||
echo "${value}" > ${DEST}/service/${USER}/env/"${var}"
|
||||
;;
|
||||
esac
|
||||
done <<< "${list}"
|
||||
|
||||
done
|
||||
|
||||
unset list_env var value line list
|
||||
}
|
||||
create_destuser() {
|
||||
local tidy
|
||||
|
||||
log "create ${DEST_USER} directory"
|
||||
mkdir -p ${DEST_USER}
|
||||
log "create ${LIVE_CLASSIC_PATH} directory"
|
||||
mkdir -p ${LIVE_CLASSIC_PATH}/.s6-svscan
|
||||
log "create ${LIVE_RC_PATH} directory"
|
||||
mkdir -p ${LIVE_RC_PATH}
|
||||
|
||||
|
||||
log "copy ${TEMPLATE}/base/.s6-svscan to ${LIVE_CLASSIC_PATH}}/.s6-svscan"
|
||||
/usr/bin/s6-hiercopy ${TEMPLATE}/base/.s6-svscan ${LIVE_CLASSIC_PATH}/.s6-svscan
|
||||
|
||||
# parse all SIG* file to point to the right place
|
||||
for tidy in ${LIVE_CLASSIC_PATH}/.s6-svscan/{SIG{HUP,INT,QUIT,TERM,USR1,USR2},finish,crash}; do
|
||||
log "change base by ${USER} at $tidy"
|
||||
sed -i "s:base:${USER}:g" $tidy
|
||||
done
|
||||
|
||||
log "change owner and permissions of ${DEST_USER} directory"
|
||||
chown -R ${_UID}:root ${DEST_USER}
|
||||
chmod 755 -R ${DEST_USER}
|
||||
unset tidy
|
||||
}
|
||||
|
||||
# copy daemon enabled by USER
|
||||
enabled_daemon() {
|
||||
log "enable daemon for $USER"
|
||||
for serv in ${LIST_SERV[@]};do
|
||||
ln -sfT ${CLASSIC_ENABLED}/${serv} ${LIVE_CLASSIC_PATH}/${serv}
|
||||
done
|
||||
}
|
||||
|
||||
start_database() {
|
||||
log "init s6-rc database"
|
||||
if [[ "${_UID}" == 0 ]]; then
|
||||
s6-rc-init -l ${LIVE_RC_PATH}/${LIVE_RC_NAME} -c ${RC_DATABASE_COMPILED}/current ${LIVE_CLASSIC_PATH}
|
||||
s6-rc -v 3 -l ${LIVE_RC_PATH}/${LIVE_RC_NAME} -u change All
|
||||
else
|
||||
su ${USER} -c "s6-rc-init -l ${LIVE_RC_PATH}/${LIVE_RC_NAME} -c ${RC_DATABASE_COMPILED}/current ${LIVE_CLASSIC_PATH}"
|
||||
su ${USER} -c "s6-rc -v 3 -l ${LIVE_RC_PATH}/${LIVE_RC_NAME} -u change All"
|
||||
fi
|
||||
}
|
||||
|
||||
# ${1} s6 program
|
||||
# ${2} command to pass
|
||||
# ${3} target
|
||||
s6_cmd() {
|
||||
local prog="${1}" cmd="${2}" target="${3}"
|
||||
log "do a s6-${prog} -${cmd} ${target} command"
|
||||
eval s6-"${prog}" -"${cmd}" "${target}"
|
||||
|
||||
unset prog cmd target
|
||||
}
|
||||
|
||||
add() {
|
||||
|
||||
copy_template || exit 1
|
||||
|
||||
parse_env || exit 1
|
||||
|
||||
add_env || exit 1
|
||||
|
||||
create_destuser || exit 1
|
||||
|
||||
s6_cmd "svscanctl" "an" "${DEST}/service" || exit 1
|
||||
|
||||
enabled_daemon || exit 1
|
||||
|
||||
s6_cmd "svscanctl" "an" "${DESTUSER}/${USER}/${DESTCLASSIC}" 2>/dev/null || exit 1
|
||||
|
||||
start_database || exit 1
|
||||
}
|
||||
|
||||
del() {
|
||||
s6_cmd "svc" "wD -d -T2000" "${DEST}/service/${USER}"
|
||||
|
||||
if ! [[ -z $(s6-svstat ${DEST}/service/${USER}|grep down) ]];then
|
||||
s6_cmd "svc" "kO" "${DEST}/service/${USER}"
|
||||
fi
|
||||
log "remove ${DEST}/service/${USER} directory"
|
||||
rm -rf "${DEST}/service/${USER}/"
|
||||
s6_cmd "svscanctl" "an" "${DEST}/service/"
|
||||
log "remove ${DEST_USER} directory"
|
||||
rm -rf "${DEST_USER}"
|
||||
}
|
||||
|
||||
case "${2}" in
|
||||
add)
|
||||
add
|
||||
;;
|
||||
del)
|
||||
del
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
1
env/BOOTSERV
vendored
1
env/BOOTSERV
vendored
@@ -1 +0,0 @@
|
||||
/etc/s6/boot-serv
|
1
env/DESTRC
vendored
Normal file
1
env/DESTRC
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/run/boot/rc
|
1
env/HANDLE
vendored
Normal file
1
env/HANDLE
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/etc/s6/data/scripts
|
1
env/S6CONF
vendored
Normal file
1
env/S6CONF
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/run/s6-conf
|
1
env/TEMPLATE
vendored
Normal file
1
env/TEMPLATE
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/usr/share/obarun/s6opts/template
|
1
env/s6-conf
vendored
1
env/s6-conf
vendored
@@ -1 +0,0 @@
|
||||
/run/s6-conf
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user