From 7ef5bbeecb2122b0e80e90c0ffe700dded46c7a4 Mon Sep 17 00:00:00 2001 From: fbt Date: Sun, 29 Sep 2013 05:53:44 +0400 Subject: [PATCH] init --- bin/rc | 42 ++++++++++++++++++++++++++++++++++++++++++ etc/rc.conf | 8 ++++++++ 2 files changed, 50 insertions(+) create mode 100755 bin/rc create mode 100644 etc/rc.conf diff --git a/bin/rc b/bin/rc new file mode 100755 index 0000000..6e19ef6 --- /dev/null +++ b/bin/rc @@ -0,0 +1,42 @@ +#!/bin/bash + +rc.hostname() { hostname "$cfg_hostname"; } + +rc.services() { + for i in "${cfg_services[@]}"; do + "${cfg_initscripts_dir}/$i" "$1" + done +} + +rc.boot() { + rc.hostname + rc.modules + rc.services start +} + +rc.shutdown() { + rc.services stop +} + +rc.hostname() { + [[ "$cfg_hostname" ]] && { hostname "$cfg_hostname"; } +} + +rc.modules() { + for i in "${cfg_modules[@]}"; do + modprobe "$i" + done +} + +source "/etc/rc.conf" + +action="$1" +action="${action:-boot}" + +case "$action" in + boot) + echo "Welcome to `uname -rs`" + rc.boot + ;; + shutdown) rc.shutdown;; +esac diff --git a/etc/rc.conf b/etc/rc.conf new file mode 100644 index 0000000..9a82ee2 --- /dev/null +++ b/etc/rc.conf @@ -0,0 +1,8 @@ +# System-wide configuration +export PATH='/usr/local/bin:/usr/bin' + +cfg_initscripts_dir='/etc/rc.d' + +cfg_hostname='generic' +cfg_services=( 'fsck' 'udev' 'mount' 'syslog-ng' 'crond' 'network' 'dhcpcd' 'sshd' 'rc.local' ) +# cfg_modules=()