21 Commits
1.5.3 ... 1.8.3

Author SHA1 Message Date
fbt
63eda033cc not a hashtable 2015-08-31 02:03:26 +03:00
fbt
2b32655365 Indexed arrays were only needed to override defaults. 2015-08-31 01:56:54 +03:00
fbt
ec2ff428f8 change defaluts, move mountpoints to rc.conf 2015-08-31 01:45:16 +03:00
fbt
358824da8f oops 2015-08-30 16:48:20 +03:00
fbt
c0364011e0 Use an indexed array for mount definitions 2015-08-26 14:44:08 +03:00
fbt
f93cfc9056 git you silly thing 2015-08-17 17:13:39 +03:00
fbt
e59c449b0e Merge branch 'master' of builder:git/spark-rc 2015-08-17 17:10:28 +03:00
fbt
90c8943782 create the default XDG_RUNTIME dirs 2015-08-17 17:10:19 +03:00
fbt
33cea83d1b sync 2015-08-08 19:38:56 +03:00
fbt
79bccd989e Merge branch 'master' of builder:git/spark-rc 2015-06-16 16:45:40 +03:00
fbt
6d2a516b64 sync disks before shutting down 2015-06-16 16:45:33 +03:00
Alad Wenter
87de61f78c support for owner/group permissions in tmpfiles 2015-03-03 10:28:07 +03:00
fbt
22bb388fdb more robust umount 2015-03-02 18:02:16 +03:00
fbt
8af7868947 even better: configurable tpdirs and tmpfiles creation 2015-03-02 18:00:23 +03:00
fbt
e4b9660bce Merge branch 'master' of builder:git/spark-rc 2015-03-02 17:40:16 +03:00
fbt
550fabfc8e tmpfiles 2015-03-02 17:40:09 +03:00
fbt
a607a63107 Code cleanup, thx to http://www.shellcheck.net 2015-01-17 16:37:15 +03:00
fbt
782b0a3fe8 Newline, bitch 2015-01-08 15:35:06 +03:00
fbt
440eada379 simplify the default rc.conf 2015-01-08 12:42:44 +03:00
fbt
1c91d74984 support for reading hostname from /etc/hostname 2015-01-08 11:13:47 +03:00
fbt
31f80cc8da avoid heredocs, they don't work on a fully readonly VFS 2015-01-05 22:32:29 +03:00
6 changed files with 109 additions and 42 deletions

View File

@@ -3,15 +3,19 @@
# Please modify config.mk and not this
sinclude config.mk
.PHONY: clean install uninstall all
.PHONY: clean install uninstall all tools
build: rc
build: rc tools
all: build
tools:
make -C tools
rc: rc.in
sed -r \
-e 's%@ETC@%$(ETC)%' \
-e 's%@BASH_PATH@%$(BASH_PATH)%' \
rc.in > rc
chmod 750 $@
@@ -19,6 +23,8 @@ rc: rc.in
clean:
rm rc
make -C tools clean
install: build
install -dm755 $(BINDIR)
install -dm755 $(ETCDIR)
@@ -29,5 +35,9 @@ install: build
install -m755 tools/killall5 $(BINDIR)/killall5
make -C tools install
uninstall:
rm $(BINDIR)/rc
make -C tools uninstall

View File

@@ -4,5 +4,7 @@ USR ?= /usr/local
ETC ?= /etc
BIN ?= $(USR)/bin
BASH_PATH ?= /bin/bash
BINDIR = $(DESTDIR)$(PREFIX)$(BIN)
ETCDIR = $(DESTDIR)$(PREFIX)$(ETC)

34
rc.conf
View File

@@ -1,21 +1,37 @@
# System-wide configuration
export PATH='/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin'
export PATH='/usr/local/bin:/usr/local/sbin:/usr/bin'
# Hostname
cfg_hostname='changeme'
cfg_hostname='spark'
# Timezone
# Change this to yours
# Uncomment and change this to yours
#cfg_timezone='Europe/Moscow'
# Services
cfg_services+=( 'fsck' 'mount' 'systemd-udevd' 'sysctl' ) # Services that need tp be started in an order
cfg_services+=( '@lo.iface' '@crond' '@dbus' '@alsa' ) # These start in parallel.
cfg_services+=( @agetty-tty{2..6} ) # Comment this if your init starts something on the ttys itself.
cfg_services+=( 'rc.local' ) # Traditionally, rc.local starts last. Technically here it doesn't. Not quite :)
# Services that start with @ are executed in parallel
cfg_services+=(
'fsck' 'mount' 'sysctl' 'rsyslogd'
'@lo.iface' '@scron'
)
# Add modules you want to be loaded at boot time here
# Uncomment and add modules you want to be loaded at boot time here
#cfg_modules=( )
# Make C-A-D perform a soft reset
ctrlaltdel soft
# Virtual filesystems
cfg_mounts=(
'proc:proc:/proc'
'run:tmpfs:/run'
'sys:sysfs:/sys'
'dev:devtmpfs:/dev'
'pts:devpts:/dev/pts:noexec,nosuid,gid=5,mode=0620'
'mqueue:mqueue:/dev/mqueue:noexec,nosuid,nodev'
'shm:tmpfs:/dev/shm:defaults,mode=0777'
)
# Some temporary directories and files
cfg_tmpdirs+=( '/run/lock' '/run/lock/lvm' '/run/lvm' '/run/user' )
cfg_tmpfiles+=( '/run/utmp' )

62
rc.in Executable file → Normal file
View File

@@ -1,18 +1,4 @@
#!/bin/bash
# Default virtual mounts for linux systems
cfg_mounts+=( 'proc:proc:/proc:' )
cfg_mounts+=( 'run:tmpfs:/run:' )
cfg_mounts+=( 'sys:sysfs:/sys:' )
# devfs and its children
cfg_mounts+=( 'dev:devtmpfs:/dev:' )
cfg_mounts+=( 'pts:devpts:/dev/pts:noexec,nosuid,gid=5,mode=0620' )
cfg_mounts+=( 'mqueue:mqueue:/dev/mqueue:noexec,nosuid,nodev' )
cfg_mounts+=( 'shm:tmpfs:/dev/shm:defaults,mode=0777' )
# Some temporary directories
cfg_tmpdirs+=( '/run/lock' '/run/lock/lvm' '/run/lvm' '/run/user' )
#!@BASH_PATH@
# Functions
rc.rescue() { exec "${cfg_rc_rescue_shell:-"$SHELL"}"; }
@@ -20,28 +6,38 @@ rc.rescue() { exec "${cfg_rc_rescue_shell:-"$SHELL"}"; }
rc.motd() {
[[ -f "/etc/rc.motd" ]] && {
while read; do
printf "$REPLY"
printf "%s\n" "$REPLY"
done < "/etc/rc.motd"
}
return 0
}
rc.tmpdirs() {
mkdir -p -m0755 "${cfg_tmpdirs[@]}"
rc.tmpfiles() {
printf '%s\n' "${cfg_tmpdirs[@]}" | while IFS=':' read dir perm own grp; do
mkdir -pm "${perm:-755}" "$dir"
chown -c "${own:-root}:${grp:-root}" "$dir"
done
printf '%s\n' "${cfg_tmpfiles[@]}" | while IFS=':' read file perm own grp; do
> "$file"
chmod -c "${perm:-644}" "$file"
chown -c "${own:-root}:${grp:-root}" "$file"
done
}
rc.mount_misc() {
for m in "${cfg_mounts[@]}"; do
IFS=':' read fs fs_type mountpoint mount_options <<< "$m"
rc.mount() {
for fs in "${cfg_mounts[@]}"; do
echo "$fs" | while IFS=':' read device fs_type mountpoint mount_options; do
[[ "$mount_options" ]] || { mount_options='defaults'; }
mountpoint -q "$mountpoint" || {
[[ -d "$mountpoint" ]] || { mkdir -p "$mountpoint"; }
mount "$fs" -n -t "$fs_type" -o "$mount_options" "$mountpoint"
mount "$device" -n -t "$fs_type" -o "$mount_options" "$mountpoint"
}
done
done
}
rc.parse_cmdline() {
@@ -104,7 +100,7 @@ rc.stop_everything() {
rc.unmount_everything() {
echo "Unmounting filesystems..."
umount -a
umount -r -a
}
rc.remount_root() {
@@ -113,8 +109,8 @@ rc.remount_root() {
}
rc.boot() {
rc.mount_misc
rc.tmpdirs
rc.mount
rc.tmpfiles
rc.hostname
rc.timezone
rc.modules
@@ -131,9 +127,14 @@ rc.halt() {
esac
}
rc.sync() {
echo "Syncing disks."
}
rc.shutdown() {
rc.services_stop
rc.stop_everything
rc.sync
rc.unmount_everything
rc.remount_root
@@ -143,6 +144,7 @@ rc.shutdown() {
}
rc.hostname() {
[[ -f '/etc/hostname' ]] && { hostname "$(</etc/hostname)"; }
[[ "$cfg_hostname" ]] && { hostname "$cfg_hostname"; }
}
@@ -161,11 +163,19 @@ rc.timezone() {
rc.main() {
source "@ETC@/rc.conf"
# Default XDG_RUNTIME_DIR for all non-system users
# rtkit:x:133:133:RealtimeKit:/proc:/sbin/nologin
while IFS=':' read -r _ _ uid gid _; do
if (( uid >= 1000 )); then
cfg_tmpdirs+=( "/run/user/$uid:700:$uid:$gid" )
fi
done < /etc/passwd
action="${1:-boot}"
case "$action" in
boot)
echo "Welcome to `uname -rs`"
echo "Welcome to $(uname -rs)"
rc.boot
;;

29
tools/Makefile Normal file
View File

@@ -0,0 +1,29 @@
# spark-rc tools makefile
# Please modify config.mk and not this
sinclude ../config.mk
.PHONY: clean install uninstall all
build: killall5
all: build
killall5: killall5.in
sed -r \
-e 's%@BASH_PATH@%$(BASH_PATH)%' \
killall5.in > killall5
chmod 750 $@
clean:
rm killall5
install: build
install -dm755 $(BINDIR)
install -dm755 $(ETCDIR)
install -m750 killall5 $(BINDIR)/killall5
uninstall:
rm $(BINDIR)/killall5

2
tools/killall5 → tools/killall5.in Executable file → Normal file
View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!@BASH_PATH@
# A simple reimplementation of killall5 from sysvinit-tools
get_my_tree() {