diff options
author | James <> | 2015-11-04 11:49:21 +0000 |
---|---|---|
committer | James <> | 2015-11-04 11:49:21 +0000 |
commit | 716ca530e1c4515d8683c9d5be3d56b301758b66 (patch) | |
tree | 700eb5bcc1a462a5f21dcec15ce7c97ecfefa772 /package/base-files/files/etc/init.d | |
download | trunk-47381-master.tar.gz trunk-47381-master.tar.bz2 trunk-47381-master.zip |
Diffstat (limited to 'package/base-files/files/etc/init.d')
-rwxr-xr-x | package/base-files/files/etc/init.d/boot | 62 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/done | 17 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/gpio_switch | 42 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/led | 106 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/sysctl | 9 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/sysfixtime | 11 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/system | 49 | ||||
-rwxr-xr-x | package/base-files/files/etc/init.d/umount | 8 |
8 files changed, 304 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 0000000..b4e6171 --- /dev/null +++ b/package/base-files/files/etc/init.d/boot @@ -0,0 +1,62 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=10 +STOP=98 + +uci_apply_defaults() { + . /lib/functions/system.sh + + cd /etc/uci-defaults || return 0 + files="$(ls)" + [ -z "$files" ] && return 0 + mkdir -p /tmp/.uci + for file in $files; do + ( . "./$(basename $file)" ) && rm -f "$file" + done + uci commit +} + +boot() { + [ -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 /var/tmp + mkdir -p /tmp/.uci + chmod 0700 /tmp/.uci + mkdir -p /tmp/.jail + 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 && /bin/mount -o noatime -t debugfs debugfs /sys/kernel/debug + [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe + + /sbin/kmodloader + + # 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 + + /bin/board_detect + uci_apply_defaults + + # temporary hack until configd exists + /sbin/reload_config + + # 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 + } +} 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 0000000..374353a --- /dev/null +++ b/package/base-files/files/etc/init.d/done @@ -0,0 +1,17 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=95 +boot() { + mount_root done + rm -f /sysupgrade.tgz + + # 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/gpio_switch b/package/base-files/files/etc/init.d/gpio_switch new file mode 100755 index 0000000..1f1b44b --- /dev/null +++ b/package/base-files/files/etc/init.d/gpio_switch @@ -0,0 +1,42 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2015 OpenWrt.org + +START=98 +STOP=10 +USE_PROCD=1 + + +load_gpio_switch() +{ + local name + local gpio_pin + local value + + config_get gpio_pin "$1" gpio_pin + config_get name "$1" name + config_get value "$1" value 0 + + local gpio_path="/sys/class/gpio/gpio${gpio_pin}" + # export GPIO pin for access + [ -d "$gpio_path" ] || { + echo "$gpio_pin" >/sys/class/gpio/export + # we need to wait a bit until the GPIO appears + [ -d "$gpio_path" ] || sleep 1 + echo out >"$gpio_path/direction" + } + # write 0 or 1 to the "value" field + { [ "$value" = "0" ] && echo "0" || echo "1"; } >"$gpio_path/value" +} + +service_triggers() +{ + procd_add_reload_trigger "system" +} + +start_service() +{ + [ -e /sys/class/gpio/ ] && { + config_load system + config_foreach load_gpio_switch gpio_switch + } +} 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 0000000..3f45732 --- /dev/null +++ b/package/base-files/files/etc/init.d/led @@ -0,0 +1,106 @@ +#!/bin/sh /etc/rc.common +# Copyright (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 + config_get delay $1 delay "150" + config_get message $1 message "" + config_get gpio $1 gpio "0" + config_get inverted $1 inverted "0" + + if [ "$trigger" = "rssi" ]; then + # handled by rssileds userspace process + return + fi + + [ -e /sys/class/leds/${sysfs}/brightness ] && { + echo "setting up led ${name}" + + [ "$default" = 0 ] && + echo 0 >/sys/class/leds/${sysfs}/brightness + + echo $trigger > /sys/class/leds/${sysfs}/trigger 2> /dev/null + ret="$?" + + [ $default = 1 ] && + echo 1 >/sys/class/leds/${sysfs}/brightness + + [ $ret = 0 ] || { + echo >&2 "Skipping trigger '$trigger' for led '$name' due to missing kernel module" + return 1 + } + 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 + ;; + + "morse") + echo $message > /sys/class/leds/${sysfs}/message + echo $delay > /sys/class/leds/${sysfs}/delay + ;; + + "gpio") + echo $gpio > /sys/class/leds/${sysfs}/gpio + echo $inverted > /sys/class/leds/${sysfs}/inverted + ;; + + 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/sysctl b/package/base-files/files/etc/init.d/sysctl new file mode 100755 index 0000000..2dfbaf7 --- /dev/null +++ b/package/base-files/files/etc/init.d/sysctl @@ -0,0 +1,9 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=11 +start() { + for CONF in /etc/sysctl.conf /etc/sysctl.d/*.conf; do + [ -f "$CONF" ] && sysctl -p "$CONF" -e >&- + done +} diff --git a/package/base-files/files/etc/init.d/sysfixtime b/package/base-files/files/etc/init.d/sysfixtime new file mode 100755 index 0000000..4010e06 --- /dev/null +++ b/package/base-files/files/etc/init.d/sysfixtime @@ -0,0 +1,11 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2013-2014 OpenWrt.org + +START=00 + +boot() { + local curtime="$(date +%s)" + local maxtime="$(find /etc -type f -exec date -r {} +%s \; | sort -nr | head -n1)" + [ $curtime -lt $maxtime ] && date -s @$maxtime +} + diff --git a/package/base-files/files/etc/init.d/system b/package/base-files/files/etc/init.d/system new file mode 100755 index 0000000..6388d62 --- /dev/null +++ b/package/base-files/files/etc/init.d/system @@ -0,0 +1,49 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2014 OpenWrt.org + +START=10 +USE_PROCD=1 + +validate_system_section() +{ + uci_validate_section system system "${1}" \ + 'hostname:string:OpenWrt' \ + 'conloglevel:uinteger' \ + 'buffersize:uinteger' \ + 'timezone:string:UTC' \ + 'zonename:string' +} + +system_config() { + local cfg="$1" + + local hostname conloglevel buffersize timezone zonename + + validate_system_section "${1}" || { + echo "validation failed" + return 1 + } + + echo "$hostname" > /proc/sys/kernel/hostname + [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize} + echo "$timezone" > /tmp/TZ + [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime + + # apply timezone to kernel + date -k +} + +reload_service() { + config_load system + config_foreach system_config system +} + +service_triggers() +{ + procd_add_reload_trigger "system" + procd_add_validation validate_system_section +} + +start_service() { + reload_service +} 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 0000000..349b2b3 --- /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 + /bin/umount -a -d -r +} |