moving starting agettys to rc

This commit is contained in:
Jack L. Frost 2014-02-25 09:28:01 +04:00
parent 2c27df892d
commit 776454a7e3
2 changed files with 38 additions and 14 deletions

37
bin/rc
View File

@ -2,33 +2,48 @@
rc.hostname() { hostname "$cfg_hostname"; } rc.hostname() { hostname "$cfg_hostname"; }
rc.services() { rc.services_start() {
local service_name bg_start local service_name start_mode
for i in "${cfg_services[@]}"; do for i in "${cfg_services[@]}"; do
unset service_name
[[ "$i" =~ ^@ ]] && { [[ "$i" =~ ^@ ]] && {
service_name="${i##*@}" service_name="${i##*@}"
bg_start='1' start_mode='bg'
} || {
service_name="$i"
} }
[[ "$bg_start" ]] && { [[ "$i" =~ ^% ]] && {
"${cfg_initscripts_dir}/$service_name" "$1" & true service_name="${i##*%}"
} || { start_mode='watch'
"${cfg_initscripts_dir}/$service_name" "$1"
} }
service_name=${service_name:-$i}
start_mode="${start_mode:-start}"
case "$start_mode" in
bg) "${cfg_initscripts_dir}/$service_name" start &;;
watch) "${cfg_initscripts_dir}/$service_name" watch &;;
start) "${cfg_initscripts_dir}/$service_name" start;;
*) echo "Mode $start_mode not supported";;
esac
done
}
rc.services_stop() {
for i in "${cfg_services[@]}"; do
"${cfg_initscripts_dir}/$i" stop
done done
} }
rc.boot() { rc.boot() {
rc.hostname rc.hostname
rc.modules rc.modules
rc.services start rc.services_start
} }
rc.shutdown() { rc.shutdown() {
rc.services stop rc.services_stop
} }
rc.hostname() { rc.hostname() {

View File

@ -1,8 +1,17 @@
# System-wide configuration # System-wide configuration
export PATH='/usr/local/bin:/usr/bin' export PATH='/usr/local/bin:/usr/bin'
# Where to look for initscripts
cfg_initscripts_dir='/etc/rc.d' cfg_initscripts_dir='/etc/rc.d'
cfg_hostname='generic' # Hostname
cfg_services=( 'fsck' 'udev' 'mount' 'syslog-ng' 'crond' 'network' 'dhcpcd' '@sshd' 'rc.local' ) cfg_hostname='cetaganda'
# cfg_modules=()
# Services to start at boot time
cfg_services+=( 'mount' 'udev' 'rc.local' ) # You probably do need these
cfg_services+=( '@syslog-ng' '@crond' '@network' '@sshd' '@dbus' '@alsa' ) # Services starting with '@' start in background.
cfg_services+=( %agetty-tty{2..6} ) # Do not modify this unless you know what you are doing!
# Modules to be loaded at boot time. Most people don't need this
#cfg_modules=( 'tun' )