Compare commits
27 Commits
Author | SHA1 | Date | |
---|---|---|---|
63eda033cc | |||
2b32655365 | |||
ec2ff428f8 | |||
358824da8f | |||
c0364011e0 | |||
f93cfc9056 | |||
e59c449b0e | |||
90c8943782 | |||
33cea83d1b | |||
79bccd989e | |||
6d2a516b64 | |||
|
87de61f78c | ||
22bb388fdb | |||
8af7868947 | |||
e4b9660bce | |||
550fabfc8e | |||
a607a63107 | |||
782b0a3fe8 | |||
440eada379 | |||
1c91d74984 | |||
31f80cc8da | |||
f3cc18fcc2 | |||
c23f30e7ca | |||
14e07dbedf | |||
88f0fa6acb | |||
1d0bc30bb2 | |||
158c5939fd |
15
Makefile
15
Makefile
@@ -3,15 +3,19 @@
|
|||||||
# Please modify config.mk and not this
|
# Please modify config.mk and not this
|
||||||
sinclude config.mk
|
sinclude config.mk
|
||||||
|
|
||||||
.PHONY: clean install uninstall all
|
.PHONY: clean install uninstall all tools
|
||||||
|
|
||||||
build: rc
|
build: rc tools
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
|
tools:
|
||||||
|
make -C tools
|
||||||
|
|
||||||
rc: rc.in
|
rc: rc.in
|
||||||
sed -r \
|
sed -r \
|
||||||
-e 's%@ETC@%$(ETC)%' \
|
-e 's%@ETC@%$(ETC)%' \
|
||||||
|
-e 's%@BASH_PATH@%$(BASH_PATH)%' \
|
||||||
rc.in > rc
|
rc.in > rc
|
||||||
|
|
||||||
chmod 750 $@
|
chmod 750 $@
|
||||||
@@ -19,14 +23,21 @@ rc: rc.in
|
|||||||
clean:
|
clean:
|
||||||
rm rc
|
rm rc
|
||||||
|
|
||||||
|
make -C tools clean
|
||||||
|
|
||||||
install: build
|
install: build
|
||||||
install -dm755 $(BINDIR)
|
install -dm755 $(BINDIR)
|
||||||
install -dm755 $(ETCDIR)
|
install -dm755 $(ETCDIR)
|
||||||
|
|
||||||
install -m750 rc $(BINDIR)/rc
|
install -m750 rc $(BINDIR)/rc
|
||||||
install -m644 rc.conf $(ETCDIR)/rc.conf
|
install -m644 rc.conf $(ETCDIR)/rc.conf
|
||||||
|
install -m644 rc.motd $(ETCDIR)/rc.motd
|
||||||
|
|
||||||
install -m755 tools/killall5 $(BINDIR)/killall5
|
install -m755 tools/killall5 $(BINDIR)/killall5
|
||||||
|
|
||||||
|
make -C tools install
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm $(BINDIR)/rc
|
rm $(BINDIR)/rc
|
||||||
|
|
||||||
|
make -C tools uninstall
|
||||||
|
@@ -4,5 +4,7 @@ USR ?= /usr/local
|
|||||||
ETC ?= /etc
|
ETC ?= /etc
|
||||||
BIN ?= $(USR)/bin
|
BIN ?= $(USR)/bin
|
||||||
|
|
||||||
|
BASH_PATH ?= /bin/bash
|
||||||
|
|
||||||
BINDIR = $(DESTDIR)$(PREFIX)$(BIN)
|
BINDIR = $(DESTDIR)$(PREFIX)$(BIN)
|
||||||
ETCDIR = $(DESTDIR)$(PREFIX)$(ETC)
|
ETCDIR = $(DESTDIR)$(PREFIX)$(ETC)
|
||||||
|
35
rc.conf
35
rc.conf
@@ -1,20 +1,37 @@
|
|||||||
# System-wide configuration
|
# 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
|
# Hostname
|
||||||
cfg_hostname='changeme'
|
cfg_hostname='spark'
|
||||||
|
|
||||||
# Timezone
|
# Timezone
|
||||||
|
# Uncomment and change this to yours
|
||||||
#cfg_timezone='Europe/Moscow'
|
#cfg_timezone='Europe/Moscow'
|
||||||
|
|
||||||
# Services
|
# Services that start with @ are executed in parallel
|
||||||
cfg_services+=( 'fsck' 'mount' 'systemd-udevd' 'sysctl' ) # Services that need tp be started in an order
|
cfg_services+=(
|
||||||
cfg_services+=( @agetty-tty{2..6} ) # Comment this if your init starts something on the ttys itself.
|
'fsck' 'mount' 'sysctl' 'rsyslogd'
|
||||||
cfg_services+=( '@crond' '@network' '@dbus' '@alsa' ) # These start in parallel.
|
'@lo.iface' '@scron'
|
||||||
cfg_services+=( 'rc.local' ) # Traditionally, rc.local starts last.
|
)
|
||||||
|
|
||||||
# Modules
|
# Uncomment and add modules you want to be loaded at boot time here
|
||||||
cfg_modules=( ) # Add modules you want to be loaded at boot time here
|
#cfg_modules=( )
|
||||||
|
|
||||||
# Make C-A-D perform a soft reset
|
# Make C-A-D perform a soft reset
|
||||||
ctrlaltdel soft
|
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' )
|
||||||
|
58
rc.in
Executable file → Normal file
58
rc.in
Executable file → Normal file
@@ -1,15 +1,4 @@
|
|||||||
#!/bin/bash
|
#!@BASH_PATH@
|
||||||
|
|
||||||
# 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' )
|
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
rc.rescue() { exec "${cfg_rc_rescue_shell:-"$SHELL"}"; }
|
rc.rescue() { exec "${cfg_rc_rescue_shell:-"$SHELL"}"; }
|
||||||
@@ -17,24 +6,38 @@ rc.rescue() { exec "${cfg_rc_rescue_shell:-"$SHELL"}"; }
|
|||||||
rc.motd() {
|
rc.motd() {
|
||||||
[[ -f "/etc/rc.motd" ]] && {
|
[[ -f "/etc/rc.motd" ]] && {
|
||||||
while read; do
|
while read; do
|
||||||
printf "$REPLY"
|
printf "%s\n" "$REPLY"
|
||||||
done < "/etc/rc.motd"
|
done < "/etc/rc.motd"
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
rc.mount_misc() {
|
rc.tmpfiles() {
|
||||||
for m in "${cfg_mounts[@]}"; do
|
printf '%s\n' "${cfg_tmpdirs[@]}" | while IFS=':' read dir perm own grp; do
|
||||||
IFS=':' read fs fs_type mountpoint mount_options <<< "$m"
|
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() {
|
||||||
|
for fs in "${cfg_mounts[@]}"; do
|
||||||
|
echo "$fs" | while IFS=':' read device fs_type mountpoint mount_options; do
|
||||||
|
|
||||||
[[ "$mount_options" ]] || { mount_options='defaults'; }
|
[[ "$mount_options" ]] || { mount_options='defaults'; }
|
||||||
|
|
||||||
mountpoint -q "$mountpoint" || {
|
mountpoint -q "$mountpoint" || {
|
||||||
[[ -d "$mountpoint" ]] || { mkdir -p "$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
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
rc.parse_cmdline() {
|
rc.parse_cmdline() {
|
||||||
@@ -97,7 +100,7 @@ rc.stop_everything() {
|
|||||||
|
|
||||||
rc.unmount_everything() {
|
rc.unmount_everything() {
|
||||||
echo "Unmounting filesystems..."
|
echo "Unmounting filesystems..."
|
||||||
umount -a
|
umount -r -a
|
||||||
}
|
}
|
||||||
|
|
||||||
rc.remount_root() {
|
rc.remount_root() {
|
||||||
@@ -106,7 +109,8 @@ rc.remount_root() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc.boot() {
|
rc.boot() {
|
||||||
rc.mount_misc
|
rc.mount
|
||||||
|
rc.tmpfiles
|
||||||
rc.hostname
|
rc.hostname
|
||||||
rc.timezone
|
rc.timezone
|
||||||
rc.modules
|
rc.modules
|
||||||
@@ -123,9 +127,14 @@ rc.halt() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc.sync() {
|
||||||
|
echo "Syncing disks."
|
||||||
|
}
|
||||||
|
|
||||||
rc.shutdown() {
|
rc.shutdown() {
|
||||||
rc.services_stop
|
rc.services_stop
|
||||||
rc.stop_everything
|
rc.stop_everything
|
||||||
|
rc.sync
|
||||||
rc.unmount_everything
|
rc.unmount_everything
|
||||||
rc.remount_root
|
rc.remount_root
|
||||||
|
|
||||||
@@ -135,6 +144,7 @@ rc.shutdown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc.hostname() {
|
rc.hostname() {
|
||||||
|
[[ -f '/etc/hostname' ]] && { hostname "$(</etc/hostname)"; }
|
||||||
[[ "$cfg_hostname" ]] && { hostname "$cfg_hostname"; }
|
[[ "$cfg_hostname" ]] && { hostname "$cfg_hostname"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,11 +163,19 @@ rc.timezone() {
|
|||||||
rc.main() {
|
rc.main() {
|
||||||
source "@ETC@/rc.conf"
|
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}"
|
action="${1:-boot}"
|
||||||
|
|
||||||
case "$action" in
|
case "$action" in
|
||||||
boot)
|
boot)
|
||||||
echo "Welcome to `uname -rs`"
|
echo "Welcome to $(uname -rs)"
|
||||||
rc.boot
|
rc.boot
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
29
tools/Makefile
Normal file
29
tools/Makefile
Normal 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
|
6
tools/killall5 → tools/killall5.in
Executable file → Normal file
6
tools/killall5 → tools/killall5.in
Executable file → Normal file
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!@BASH_PATH@
|
||||||
# A simple reimplementation of killall5 from sysvinit-tools
|
# A simple reimplementation of killall5 from sysvinit-tools
|
||||||
|
|
||||||
get_my_tree() {
|
get_my_tree() {
|
||||||
@@ -13,10 +13,6 @@ get_my_tree() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
get_realname() {
|
|
||||||
readlink -e "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_all_procs() {
|
get_all_procs() {
|
||||||
local processlist
|
local processlist
|
||||||
|
|
Reference in New Issue
Block a user