diff options
Diffstat (limited to 'package/base-files/files/etc/init.d')
-rwxr-xr-x | package/base-files/files/etc/init.d/boot | 103 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/done | 20 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/led | 80 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/rcS | 26 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/sysctl | 7 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/sysntpd | 37 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/umount | 8 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/usb | 9 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/watchdog | 13 |
9 files changed, 303 insertions, 0 deletions
diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot new file mode 100755 index 000000000..43837a80f --- /dev/null +++ b/package/base-files/files/etc/init.d/boot @@ -0,0 +1,103 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=10 +STOP=98 + +system_config() { + local cfg="$1" + + local hostname conloglevel timezone + + config_get hostname "$cfg" hostname 'OpenWrt' + echo "$hostname" > /proc/sys/kernel/hostname + + config_get conloglevel "$cfg" conloglevel + config_get buffersize "$cfg" buffersize + [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize} + + config_get timezone "$cfg" timezone 'UTC' + echo "$timezone" > /tmp/TZ + + config_get zonename "$cfg" zonename + [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime + + # apply timezone to kernel + date -k + + if [ -x /sbin/syslogd ]; then + local args log_ip log_size log_port log_type log_file + config_get log_ip "$cfg" log_ip + config_get log_size "$cfg" log_size 16 + config_get log_port "$cfg" log_port 514 + config_get log_type "$cfg" log_type circular + config_get log_file "$cfg" log_file "/var/log/messages" + args="${log_ip:+-L -R ${log_ip}:${log_port}} ${conloglevel:+-l $conloglevel}" + if [ "$log_type" = "file" ]; then + args="$args -s $log_size -O $log_file -S" + else + args="$args -C${log_size}" + fi + service_start /sbin/syslogd $args + fi + if [ -x /sbin/klogd ]; then + config_get klogconloglevel "$cfg" klogconloglevel + args="${klogconloglevel:+-c $klogconloglevel}" + service_start /sbin/klogd $args + fi +} + +apply_uci_config() { + sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults' +} + +start() { + [ -f /proc/mounts ] || /sbin/mount_root + [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc + [ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD + + mkdir -p /var/run + mkdir -p /var/log + mkdir -p /var/lock + mkdir -p /var/state + mkdir -p /tmp/.uci + chmod 0700 /tmp/.uci + touch /var/log/wtmp + touch /var/log/lastlog + touch /tmp/resolv.conf.auto + ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf + grep -q debugfs /proc/filesystems && mount -t debugfs debugfs /sys/kernel/debug + [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe + + load_modules /etc/modules.d/* + + # allow wifi modules time to settle + sleep 1 + + /sbin/wifi detect > /tmp/wireless.tmp + [ -s /tmp/wireless.tmp ] && { + cat /tmp/wireless.tmp >> /etc/config/wireless + } + rm -f /tmp/wireless.tmp + + apply_uci_config + config_load system + config_foreach system_config system + + killall -q hotplug2 + [ -x /sbin/hotplug2 ] && /sbin/hotplug2 --override --persistent \ + --set-rules-file /etc/hotplug2.rules \ + --set-coldplug-cmd /sbin/udevtrigger \ + --max-children 1 >/dev/null 2>&1 & + + # create /dev/root if it doesn't exist + [ -e /dev/root -o -h /dev/root ] || { + rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline) + [ -n "$rootdev" ] && ln -s "$rootdev" /dev/root + } +} + +stop() { + service_stop /sbin/klogd + service_stop /sbin/syslogd +} diff --git a/package/base-files/files/etc/init.d/done b/package/base-files/files/etc/init.d/done new file mode 100755 index 000000000..827866912 --- /dev/null +++ b/package/base-files/files/etc/init.d/done @@ -0,0 +1,20 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=95 +boot() { + [ -d /tmp/root ] && { + lock /tmp/.switch2jffs + firstboot switch2jffs + lock -u /tmp/.switch2jffs + } + + # process user commands + [ -f /etc/rc.local ] && { + sh /etc/rc.local + } + + # set leds to normal state + . /etc/diag.sh + set_state done +} diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led new file mode 100755 index 000000000..43964bf0b --- /dev/null +++ b/package/base-files/files/etc/init.d/led @@ -0,0 +1,80 @@ +#!/bin/sh /etc/rc.common +# (C) 2008 openwrt.org + +START=96 + +load_led() { + local name + local sysfs + local trigger + local dev + local mode + local default + local delayon + local delayoff + local interval + + config_get sysfs $1 sysfs + config_get name $1 name "$sysfs" + config_get trigger $1 trigger "none" + config_get dev $1 dev + config_get mode $1 mode "link" + config_get_bool default $1 default "nil" + config_get delayon $1 delayon + config_get delayoff $1 delayoff + config_get interval $1 interval "50" + config_get port_state $1 port_state + + [ -e /sys/class/leds/${sysfs}/brightness ] && { + echo "setting up led ${name}" + [ "$default" != nil ] && { + [ $default -eq 1 ] && + echo 1 >/sys/class/leds/${sysfs}/brightness + [ $default -eq 1 ] || + echo 0 >/sys/class/leds/${sysfs}/brightness + } + echo $trigger > /sys/class/leds/${sysfs}/trigger + case "$trigger" in + "netdev") + [ -n "$dev" ] && { + echo $dev > /sys/class/leds/${sysfs}/device_name + echo $mode > /sys/class/leds/${sysfs}/mode + } + ;; + + "timer") + [ -n "$delayon" ] && \ + echo $delayon > /sys/class/leds/${sysfs}/delay_on + [ -n "$delayoff" ] && \ + echo $delayoff > /sys/class/leds/${sysfs}/delay_off + ;; + + "usbdev") + [ -n "$dev" ] && { + echo $dev > /sys/class/leds/${sysfs}/device_name + echo $interval > /sys/class/leds/${sysfs}/activity_interval + } + ;; + + "port_state") + [ -n "$port_state" ] && \ + echo $port_state > /sys/class/leds/${sysfs}/port_state + ;; + + switch[0-9]*) + local port_mask + + config_get port_mask $1 port_mask + [ -n "$port_mask" ] && \ + echo $port_mask > /sys/class/leds/${sysfs}/port_mask + ;; + esac + } +} + +start() { + [ -e /sys/class/leds/ ] && { + config_load system + config_foreach load_led led + } +} diff --git a/package/base-files/files/etc/init.d/rcS b/package/base-files/files/etc/init.d/rcS new file mode 100755 index 000000000..3ec9bfef6 --- /dev/null +++ b/package/base-files/files/etc/init.d/rcS @@ -0,0 +1,26 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org + +run_scripts() { + for i in /etc/rc.d/$1*; do + [ -x $i ] && $i $2 2>&1 + done | $LOGGER +} + +system_config() { + config_get_bool foreground $1 foreground 0 +} + +LOGGER="cat" +[ -x /usr/bin/logger ] && LOGGER="logger -s -p 6 -t sysinit" + +. /lib/functions.sh + +config_load system +config_foreach system_config system + +if [ "$1" = "S" -a "$foreground" != "1" ]; then + run_scripts "$1" "$2" & +else + run_scripts "$1" "$2" +fi diff --git a/package/base-files/files/etc/init.d/sysctl b/package/base-files/files/etc/init.d/sysctl new file mode 100755 index 000000000..239779055 --- /dev/null +++ b/package/base-files/files/etc/init.d/sysctl @@ -0,0 +1,7 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=99 +start() { + [ -f /etc/sysctl.conf ] && sysctl -p -e >&- +} diff --git a/package/base-files/files/etc/init.d/sysntpd b/package/base-files/files/etc/init.d/sysntpd new file mode 100755 index 000000000..bb42ef7d3 --- /dev/null +++ b/package/base-files/files/etc/init.d/sysntpd @@ -0,0 +1,37 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2011 OpenWrt.org + +START=98 + +SERVICE_DAEMONIZE=1 +SERVICE_WRITE_PID=1 +SERVICE_PID_FILE=/var/run/sysntpd.pid + +start() { + local peers + local args="-n" + local enable_server + + config_load system + config_get peers ntp server + config_get_bool enable_server ntp enable_server 0 + + if [ $enable_server -ne 0 ]; then + append args "-l" + fi + + if [ -n "$peers" ]; then + local peer + for peer in $peers; do + append args "-p $peer" + done + fi + + if [ "$args" != "-n" ]; then + service_start /usr/sbin/ntpd $args + fi +} + +stop() { + service_stop /usr/sbin/ntpd +} diff --git a/package/base-files/files/etc/init.d/umount b/package/base-files/files/etc/init.d/umount new file mode 100755 index 000000000..5a750b93c --- /dev/null +++ b/package/base-files/files/etc/init.d/umount @@ -0,0 +1,8 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +STOP=99 +stop() { + sync + umount -a -d -r +} diff --git a/package/base-files/files/etc/init.d/usb b/package/base-files/files/etc/init.d/usb new file mode 100755 index 000000000..7b443b651 --- /dev/null +++ b/package/base-files/files/etc/init.d/usb @@ -0,0 +1,9 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=39 +start() { + [ -d /proc/bus/usb ] && { + /bin/mount -t usbfs none /proc/bus/usb + } +} diff --git a/package/base-files/files/etc/init.d/watchdog b/package/base-files/files/etc/init.d/watchdog new file mode 100755 index 000000000..299c89142 --- /dev/null +++ b/package/base-files/files/etc/init.d/watchdog @@ -0,0 +1,13 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2008-2011 OpenWrt.org + +START=97 + +start() { + [ -c /dev/watchdog ] || return 1 + [ -x /sbin/watchdog ] || return 1 + service_start /sbin/watchdog -t 5 /dev/watchdog +} +stop() { + service_stop /sbin/watchdog +} |