Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
409f6f8cd2 | |||
ff28e04a20 | |||
e2b068e45d | |||
0afbcc55f2 | |||
1d5e825201 | |||
15592c0daa | |||
e379e8efff |
@@ -1,4 +1,7 @@
|
|||||||
spark-rc
|
# spark-rc
|
||||||
========
|
|
||||||
|
|
||||||
A simple rc script to kickstart your system.
|
A simple rc script to kickstart your system.
|
||||||
|
|
||||||
|
## depends
|
||||||
|
|
||||||
|
* Enabled sysrq or halt from suckless.org's ubase.
|
||||||
|
9
rc.conf
9
rc.conf
@@ -1,6 +1,9 @@
|
|||||||
# System-wide configuration
|
# A default PATH
|
||||||
export PATH='/usr/local/bin:/usr/local/sbin:/usr/bin'
|
export PATH='/usr/local/bin:/usr/local/sbin:/usr/bin'
|
||||||
|
|
||||||
|
# Locale
|
||||||
|
export LC_ALL='en_US.UTF-8'
|
||||||
|
|
||||||
# Hostname
|
# Hostname
|
||||||
cfg_hostname='spark'
|
cfg_hostname='spark'
|
||||||
|
|
||||||
@@ -11,7 +14,7 @@ cfg_hostname='spark'
|
|||||||
# Services that start with @ are executed in parallel
|
# Services that start with @ are executed in parallel
|
||||||
cfg_services+=(
|
cfg_services+=(
|
||||||
'fsck' 'mount' 'sysctl' 'rsyslogd'
|
'fsck' 'mount' 'sysctl' 'rsyslogd'
|
||||||
'@lo.iface' '@scron' '@agetty-tty{2..6}'
|
'@lo.iface' '@scron' @agetty-tty{2..6}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Uncomment and add modules you want to be loaded at boot time here
|
# Uncomment and add modules you want to be loaded at boot time here
|
||||||
@@ -25,7 +28,7 @@ cfg_mounts=(
|
|||||||
'run:tmpfs:/run'
|
'run:tmpfs:/run'
|
||||||
'tmp:tmpfs:/tmp'
|
'tmp:tmpfs:/tmp'
|
||||||
|
|
||||||
'proc:proc:/proc'
|
'proc:proc:/proc:defaults,hidepid=2'
|
||||||
'sys:sysfs:/sys'
|
'sys:sysfs:/sys'
|
||||||
|
|
||||||
'dev:devtmpfs:/dev'
|
'dev:devtmpfs:/dev'
|
||||||
|
32
rc.in
32
rc.in
@@ -1,4 +1,5 @@
|
|||||||
#!@BASH_PATH@
|
#!@BASH_PATH@
|
||||||
|
# vim: ft=zsh
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
rc.rescue() { exec "${cfg_rc_rescue_shell:-"$SHELL"}"; }
|
rc.rescue() { exec "${cfg_rc_rescue_shell:-"$SHELL"}"; }
|
||||||
@@ -29,13 +30,21 @@ rc.tmpfiles() {
|
|||||||
rc.mount() {
|
rc.mount() {
|
||||||
for fs in "${cfg_mounts[@]}"; do
|
for fs in "${cfg_mounts[@]}"; do
|
||||||
echo "$fs" | while IFS=':' read device fs_type mountpoint mount_options; do
|
echo "$fs" | while IFS=':' read device fs_type mountpoint mount_options; do
|
||||||
|
if mountpoint -q "$mountpoint"; then
|
||||||
|
if [[ "$mount_options" ]]; then
|
||||||
|
mount -o "remount,$mount_options" "$mountpoint"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if ! [[ -d "$mountpoint" ]]; then
|
||||||
|
mkdir -p "$mountpoint"
|
||||||
|
fi
|
||||||
|
|
||||||
[[ "$mount_options" ]] || { mount_options='defaults'; }
|
if ! [[ "$mount_options" ]]; then
|
||||||
|
mount_options='defaults'
|
||||||
|
fi
|
||||||
|
|
||||||
mountpoint -q "$mountpoint" || {
|
|
||||||
[[ -d "$mountpoint" ]] || { mkdir -p "$mountpoint"; }
|
|
||||||
mount "$device" -n -t "$fs_type" -o "$mount_options" "$mountpoint"
|
mount "$device" -n -t "$fs_type" -o "$mount_options" "$mountpoint"
|
||||||
}
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -120,10 +129,21 @@ rc.boot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc.halt() {
|
rc.halt() {
|
||||||
|
if type -P halt; then
|
||||||
|
function rc.halt_poweroff { halt -p; }
|
||||||
|
function rc.halt_reboot { halt -r; }
|
||||||
|
elif [[ -f /proc/sysrq-trigger ]]; then
|
||||||
|
function rc.halt_poweroff { echo 'o' > /proc/sysrq-trigger; }
|
||||||
|
function rc.halt_reboot { echo 'b' > /proc/sysrq-trigger; }
|
||||||
|
else
|
||||||
|
printf 'Cannot halt, please install halt from suckless.org ubase or enable sysrq.\n'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
case "$action" in
|
case "$action" in
|
||||||
poweroff|shutdown) echo 'o' > /proc/sysrq-trigger;;
|
|
||||||
halt) :;;
|
halt) :;;
|
||||||
reboot|*) echo 'b' > /proc/sysrq-trigger;;
|
poweroff|shutdown) rc.halt_poweroff;;
|
||||||
|
reboot|*) rc.halt_reboot;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user