mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-28 13:46:32 +00:00
Merge pull request #14 from ccrisan/configurable-panic-action
Intelligent Panic Action
This commit is contained in:
commit
3b4da58f69
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
test -n "$os_version" || source /etc/init.d/base
|
test -n "$os_version" || source /etc/init.d/base
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
msg_begin "Detecting disk device"
|
msg_begin "Detecting disk device"
|
||||||
root_dev=$(cat /proc/cmdline | grep -oE 'root=[/a-z0-9]+' | cut -d '=' -f 2)
|
root_dev=$(cat /proc/cmdline | grep -oE 'root=[/a-z0-9]+' | cut -d '=' -f 2)
|
||||||
if [[ "$root_dev" =~ ^([/a-z0-9]+)(p[0-9])$ ]]; then # e.g. /dev/mmcblk0p2
|
if [[ "$root_dev" =~ ^([/a-z0-9]+)(p[0-9])$ ]]; then # e.g. /dev/mmcblk0p2
|
||||||
@ -20,8 +22,6 @@ msg_done "$disk_dev"
|
|||||||
|
|
||||||
test -b $data_dev && exit 0
|
test -b $data_dev && exit 0
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
msg_begin "Creating data partition"
|
msg_begin "Creating data partition"
|
||||||
root_end=$(partx -s -g -o END $root_dev)
|
root_end=$(partx -s -g -o END $root_dev)
|
||||||
data_start=$(($root_end + 1))
|
data_start=$(($root_end + 1))
|
||||||
@ -68,5 +68,3 @@ case "$1" in
|
|||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# always exit with a successful status
|
|
||||||
exit 0
|
|
||||||
|
@ -6,7 +6,7 @@ mount_fs() {
|
|||||||
msg_begin "Mounting filesystems"
|
msg_begin "Mounting filesystems"
|
||||||
/bin/mount -T /etc/fstab.disk -a &&
|
/bin/mount -T /etc/fstab.disk -a &&
|
||||||
/bin/mount -T /etc/fstab.extra -a &&
|
/bin/mount -T /etc/fstab.extra -a &&
|
||||||
if [ -r /data/etc/fstab.user ]; then /bin/mount -T /data/etc/fstab.user -a; fi
|
if [[ -r /data/etc/fstab.user ]]; then /bin/mount -T /data/etc/fstab.user -a; fi
|
||||||
|
|
||||||
test $? == 0 && msg_done || msg_fail
|
test $? == 0 && msg_done || msg_fail
|
||||||
}
|
}
|
||||||
@ -29,6 +29,8 @@ mk_tty_login() {
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
mount_fs
|
mount_fs
|
||||||
|
|
||||||
|
# we need to source conf again, now that /data is available
|
||||||
test -n "$os_debug" || source /etc/init.d/conf
|
test -n "$os_debug" || source /etc/init.d/conf
|
||||||
test "$os_debug" == "true" && remount_rw
|
test "$os_debug" == "true" && remount_rw
|
||||||
mk_tty_login
|
mk_tty_login
|
||||||
|
@ -9,11 +9,11 @@ case "$1" in
|
|||||||
start)
|
start)
|
||||||
msg_begin "Loading kernel modules"
|
msg_begin "Loading kernel modules"
|
||||||
|
|
||||||
if [ -r $sys_modules_file ]; then
|
if [[ -r $sys_modules_file ]]; then
|
||||||
cat $sys_modules_file | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done
|
cat $sys_modules_file | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -r $modules_file ]; then
|
if [[ -r $modules_file ]]; then
|
||||||
cat $modules_file | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done
|
cat $modules_file | while read line; do test -n "$line" && /sbin/modprobe $line &>/dev/null; done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -10,15 +10,15 @@ case "$1" in
|
|||||||
start)
|
start)
|
||||||
msg_begin "Setting hostname"
|
msg_begin "Setting hostname"
|
||||||
|
|
||||||
if ! [ -f $hostname_file ]; then
|
if ! [[ -f $hostname_file ]]; then
|
||||||
if [ -f $boot_hostname_file ]; then
|
if [[ -f $boot_hostname_file ]]; then
|
||||||
cp $boot_hostname_file $hostname_file
|
cp $boot_hostname_file $hostname_file
|
||||||
elif [ -f $sys_hostname_file ]; then
|
elif [[ -f $sys_hostname_file ]]; then
|
||||||
cp $sys_hostname_file $hostname_file
|
cp $sys_hostname_file $hostname_file
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f $hostname_file ]; then
|
if [[ -f $hostname_file ]]; then
|
||||||
hostname=$(cat $hostname_file)
|
hostname=$(cat $hostname_file)
|
||||||
else
|
else
|
||||||
hostname="$os_prefix-$board_sn"
|
hostname="$os_prefix-$board_sn"
|
||||||
|
@ -16,7 +16,7 @@ test "$hash" == "$sys_hash" && exit 0
|
|||||||
test -d $post_upgrade_dir || exit 0
|
test -d $post_upgrade_dir || exit 0
|
||||||
|
|
||||||
function version_gt() {
|
function version_gt() {
|
||||||
if [ "$1" != "$2" ] && [ $(echo -e "$2\n$1" | sort -t . | head -n 1) == "$2" ]; then
|
if [[ "$1" != "$2" ]] && [[ $(echo -e "$2\n$1" | sort -t . | head -n 1) == "$2" ]]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
@ -29,7 +29,7 @@ function run_post_upgrade() {
|
|||||||
|
|
||||||
versions=$(ls -1 $post_upgrade_dir | cut -d '.' -f 1)
|
versions=$(ls -1 $post_upgrade_dir | cut -d '.' -f 1)
|
||||||
for v in $versions; do
|
for v in $versions; do
|
||||||
if [ -z "$version" ] || version_gt $v $version; then
|
if [[ -z "$version" ]] || version_gt $v $version; then
|
||||||
msg_begin "Post-upgrading to version $v"
|
msg_begin "Post-upgrading to version $v"
|
||||||
out=$($post_upgrade_dir/$v.sh 2>&1)
|
out=$($post_upgrade_dir/$v.sh 2>&1)
|
||||||
test $? == 0 && msg_done || msg_fail
|
test $? == 0 && msg_done || msg_fail
|
||||||
|
@ -14,10 +14,10 @@ link_watch_timeout=20
|
|||||||
|
|
||||||
test -f $watch_conf && source $watch_conf
|
test -f $watch_conf && source $watch_conf
|
||||||
|
|
||||||
if ! [ -f $conf ]; then
|
if ! [[ -f $conf ]]; then
|
||||||
if [ -f $boot_conf ]; then
|
if [[ -f $boot_conf ]]; then
|
||||||
cp $boot_conf $conf
|
cp $boot_conf $conf
|
||||||
elif [ -f $sys_conf ]; then
|
elif [[ -f $sys_conf ]]; then
|
||||||
cp $sys_conf $conf
|
cp $sys_conf $conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -34,8 +34,8 @@ watch() {
|
|||||||
while true; do
|
while true; do
|
||||||
sleep 5
|
sleep 5
|
||||||
if ! running; then
|
if ! running; then
|
||||||
logger -t hostapd -s "dead, rebooting"
|
logger -t hostapd -s "dead, calling panic action"
|
||||||
reboot
|
panic_action hostapd
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -49,7 +49,7 @@ start() {
|
|||||||
while ! ifconfig $iface >/dev/null 2>&1; do
|
while ! ifconfig $iface >/dev/null 2>&1; do
|
||||||
sleep 1
|
sleep 1
|
||||||
count=$(($count + 1))
|
count=$(($count + 1))
|
||||||
if [ $count -ge 5 ]; then
|
if [[ $count -ge 5 ]]; then
|
||||||
msg_fail "no device"
|
msg_fail "no device"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -61,7 +61,7 @@ start() {
|
|||||||
iwconfig $iface power off &> /dev/null
|
iwconfig $iface power off &> /dev/null
|
||||||
$prog $conf &> $log &
|
$prog $conf &> $log &
|
||||||
|
|
||||||
if [ "$link_watch" == "yes" ]; then
|
if [[ "$link_watch" == "yes" ]]; then
|
||||||
watch &
|
watch &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -12,20 +12,20 @@ sys_watch_conf="/etc/watch.conf"
|
|||||||
boot_watch_conf="/boot/watch.conf"
|
boot_watch_conf="/boot/watch.conf"
|
||||||
watch_conf="/data/etc/watch.conf"
|
watch_conf="/data/etc/watch.conf"
|
||||||
|
|
||||||
if ! [ -f $watch_conf ]; then
|
if ! [[ -f $watch_conf ]]; then
|
||||||
if [ -f $boot_watch_conf ]; then
|
if [[ -f $boot_watch_conf ]]; then
|
||||||
cp $boot_watch_conf $watch_conf
|
cp $boot_watch_conf $watch_conf
|
||||||
elif [ -f $sys_watch_conf ]; then
|
elif [[ -f $sys_watch_conf ]]; then
|
||||||
cp $sys_watch_conf $watch_conf
|
cp $sys_watch_conf $watch_conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source $watch_conf
|
source $watch_conf
|
||||||
|
|
||||||
if ! [ -f $conf ]; then
|
if ! [[ -f $conf ]]; then
|
||||||
if [ -f $boot_conf ]; then
|
if [[ -f $boot_conf ]]; then
|
||||||
cp $boot_conf $conf
|
cp $boot_conf $conf
|
||||||
elif [ -f $sys_conf ]; then
|
elif [[ -f $sys_conf ]]; then
|
||||||
cp $sys_conf $conf
|
cp $sys_conf $conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -39,7 +39,6 @@ ssid=$(cat $conf | grep ssid | grep -v scan_ssid | cut -d '"' -f 2)
|
|||||||
test -n "$ssid" || exit 0
|
test -n "$ssid" || exit 0
|
||||||
|
|
||||||
test -n "$os_version" || source /etc/init.d/base
|
test -n "$os_version" || source /etc/init.d/base
|
||||||
test -n "$os_debug" || source /etc/init.d/conf
|
|
||||||
|
|
||||||
test "$os_networkless" == "true" && exit 0
|
test "$os_networkless" == "true" && exit 0
|
||||||
|
|
||||||
@ -54,12 +53,12 @@ watch() {
|
|||||||
if connected; then
|
if connected; then
|
||||||
count=0
|
count=0
|
||||||
else
|
else
|
||||||
if [ $count -lt $link_watch_timeout ]; then
|
if [[ $count -lt $link_watch_timeout ]]; then
|
||||||
count=$(($count + 5))
|
count=$(($count + 5))
|
||||||
logger -t wifi -s "disconnected"
|
logger -t wifi -s "disconnected"
|
||||||
else
|
else
|
||||||
logger -t wifi -s "disconnected for $link_watch_timeout seconds, rebooting"
|
logger -t wifi -s "disconnected for $link_watch_timeout seconds, calling panic action"
|
||||||
reboot
|
panic_action wifi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -75,7 +74,7 @@ start() {
|
|||||||
while ! ifconfig $os_wlan >/dev/null 2>&1; do
|
while ! ifconfig $os_wlan >/dev/null 2>&1; do
|
||||||
sleep 1
|
sleep 1
|
||||||
count=$(($count + 1))
|
count=$(($count + 1))
|
||||||
if [ $count -ge 5 ]; then
|
if [[ $count -ge 5 ]]; then
|
||||||
msg_fail "no device"
|
msg_fail "no device"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -94,7 +93,7 @@ start() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $count -gt $link_watch_timeout ] || ! pidof wpa_supplicant > /dev/null; then
|
if [[ $count -gt $link_watch_timeout ]] || ! pidof wpa_supplicant > /dev/null; then
|
||||||
test -n "$module" && msg_fail "failed ($module)"|| msg_fail
|
test -n "$module" && msg_fail "failed ($module)"|| msg_fail
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -102,7 +101,7 @@ start() {
|
|||||||
count=$(($count + 1))
|
count=$(($count + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$link_watch" == "true" ]; then
|
if [[ "$link_watch" == "true" ]]; then
|
||||||
watch &
|
watch &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -11,10 +11,10 @@ watch_conf="/data/etc/watch.conf"
|
|||||||
|
|
||||||
source $watch_conf
|
source $watch_conf
|
||||||
|
|
||||||
if ! [ -d $conf ]; then
|
if ! [[ -d $conf ]]; then
|
||||||
if [ -d $boot_conf ]; then
|
if [[ -d $boot_conf ]]; then
|
||||||
cp -r $boot_conf $conf
|
cp -r $boot_conf $conf
|
||||||
elif [ -d $sys_conf ]; then
|
elif [[ -d $sys_conf ]]; then
|
||||||
cp -r $sys_conf $conf
|
cp -r $sys_conf $conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -23,7 +23,6 @@ test -e $conf/modem || exit 0
|
|||||||
test -e $conf/apn || exit 0
|
test -e $conf/apn || exit 0
|
||||||
|
|
||||||
test -n "$os_version" || source /etc/init.d/base
|
test -n "$os_version" || source /etc/init.d/base
|
||||||
test -n "$os_debug" || source /etc/init.d/conf
|
|
||||||
|
|
||||||
test "$os_networkless" == "true" && exit 0
|
test "$os_networkless" == "true" && exit 0
|
||||||
|
|
||||||
@ -38,12 +37,12 @@ watch() {
|
|||||||
if connected; then
|
if connected; then
|
||||||
count=0
|
count=0
|
||||||
else
|
else
|
||||||
if [ $count -lt $link_watch_timeout ]; then
|
if [[ $count -lt $link_watch_timeout ]]; then
|
||||||
count=$(($count + 5))
|
count=$(($count + 5))
|
||||||
logger -t ppp -s "disconnected"
|
logger -t ppp -s "disconnected"
|
||||||
else
|
else
|
||||||
logger -t ppp -s "disconnected for $link_watch_timeout seconds, rebooting"
|
logger -t ppp -s "disconnected for $link_watch_timeout seconds, calling panic action"
|
||||||
reboot
|
panic_action ppp
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -65,13 +64,13 @@ start() {
|
|||||||
|
|
||||||
# wait for modem
|
# wait for modem
|
||||||
modem=$(head -n 1 $conf/modem)
|
modem=$(head -n 1 $conf/modem)
|
||||||
if ! [ -e /dev/$modem ]; then
|
if ! [[ -e /dev/$modem ]]; then
|
||||||
udev_trigger_add 4 &
|
udev_trigger_add 4 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
count=0
|
count=0
|
||||||
while true; do
|
while true; do
|
||||||
if [ -e /dev/$modem ] || [ $count -gt $link_watch_timeout ]; then
|
if [[ -e /dev/$modem ]] || [[ $count -gt $link_watch_timeout ]]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -79,7 +78,7 @@ start() {
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
if ! [ -e /dev/$modem ]; then
|
if ! [[ -e /dev/$modem ]]; then
|
||||||
msg_fail "modem /dev/$modem not present"
|
msg_fail "modem /dev/$modem not present"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -93,7 +92,7 @@ start() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $count -gt $link_watch_timeout ] || ! pidof pppd > /dev/null; then
|
if [[ $count -gt $link_watch_timeout ]] || ! pidof pppd > /dev/null; then
|
||||||
msg_fail
|
msg_fail
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -101,7 +100,7 @@ start() {
|
|||||||
count=$(($count + 1))
|
count=$(($count + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$link_watch" == "true" ]; then
|
if [[ "$link_watch" == "true" ]]; then
|
||||||
watch &
|
watch &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@ sys_conf="/etc/bluetooth.conf"
|
|||||||
boot_conf="/boot/bluetooth.conf"
|
boot_conf="/boot/bluetooth.conf"
|
||||||
conf="/data/etc/bluetooth.conf"
|
conf="/data/etc/bluetooth.conf"
|
||||||
|
|
||||||
if ! [ -f $conf ]; then
|
if ! [[ -f $conf ]]; then
|
||||||
if [ -f $boot_conf ]; then
|
if [[ -f $boot_conf ]]; then
|
||||||
cp $boot_conf $conf
|
cp $boot_conf $conf
|
||||||
elif [ -f $sys_conf ]; then
|
elif [[ -f $sys_conf ]]; then
|
||||||
cp $sys_conf $conf
|
cp $sys_conf $conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -46,10 +46,10 @@ start() {
|
|||||||
while ! hciconfig $hci &>/dev/null; do
|
while ! hciconfig $hci &>/dev/null; do
|
||||||
sleep 1
|
sleep 1
|
||||||
count=$(($count + 1))
|
count=$(($count + 1))
|
||||||
if [ $count -ge 10 ]; then
|
if [[ $count -ge 10 ]]; then
|
||||||
msg_fail "no device"
|
msg_fail "no device"
|
||||||
logger -t bluetooth -s "bluetooth device not available, rebooting"
|
logger -t bluetooth -s "bluetooth device not available, calling panic action"
|
||||||
reboot
|
panic_action bluetooth
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -11,10 +11,10 @@ link_nego_timeout=10
|
|||||||
|
|
||||||
source $watch_conf
|
source $watch_conf
|
||||||
|
|
||||||
if ! [ -f $static_conf ]; then
|
if ! [[ -f $static_conf ]]; then
|
||||||
if [ -f $boot_static_conf ]; then
|
if [[ -f $boot_static_conf ]]; then
|
||||||
cp $boot_static_conf $static_conf
|
cp $boot_static_conf $static_conf
|
||||||
elif [ -f $sys_static_conf ]; then
|
elif [[ -f $sys_static_conf ]]; then
|
||||||
cp $sys_static_conf $static_conf
|
cp $sys_static_conf $static_conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -22,21 +22,20 @@ fi
|
|||||||
test -r $static_conf && source $static_conf
|
test -r $static_conf && source $static_conf
|
||||||
|
|
||||||
test -n "$os_version" || source /etc/init.d/base
|
test -n "$os_version" || source /etc/init.d/base
|
||||||
test -n "$os_debug" || source /etc/init.d/conf
|
|
||||||
|
|
||||||
watch_eth() {
|
watch_eth() {
|
||||||
count=0
|
count=0
|
||||||
while true; do
|
while true; do
|
||||||
sleep 5
|
sleep 5
|
||||||
if [ "$(cat /sys/class/net/$os_eth/operstate 2>/dev/null)" == "up" ]; then
|
if [[ "$(cat /sys/class/net/$os_eth/operstate 2>/dev/null)" == "up" ]]; then
|
||||||
count=0
|
count=0
|
||||||
else
|
else
|
||||||
if [ $count -lt $link_watch_timeout ]; then
|
if [[ $count -lt $link_watch_timeout ]]; then
|
||||||
count=$(($count + 5))
|
count=$(($count + 5))
|
||||||
logger -t ethernet -s "disconnected"
|
logger -t ethernet -s "disconnected"
|
||||||
else
|
else
|
||||||
logger -t ethernet -s "disconnected for $link_watch_timeout seconds, rebooting"
|
logger -t ethernet -s "disconnected for $link_watch_timeout seconds, calling panic action"
|
||||||
reboot
|
panic_action network
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -50,12 +49,12 @@ watch_ip() {
|
|||||||
if ip addr show dev $iface | grep inet &>/dev/null; then
|
if ip addr show dev $iface | grep inet &>/dev/null; then
|
||||||
count=0
|
count=0
|
||||||
else
|
else
|
||||||
if [ $count -lt $ip_watch_timeout ]; then
|
if [[ $count -lt $ip_watch_timeout ]]; then
|
||||||
count=$(($count + 5))
|
count=$(($count + 5))
|
||||||
logger -t network -s "$iface has no IP address"
|
logger -t network -s "$iface has no IP address"
|
||||||
else
|
else
|
||||||
logger -t network -s "$iface had no IP address for $ip_watch_timeout seconds, rebooting"
|
logger -t network -s "$iface had no IP address for $ip_watch_timeout seconds, calling panic action"
|
||||||
reboot
|
panic_action network
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -72,16 +71,16 @@ start_wlan() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(cat /sys/class/net/$os_wlan/carrier 2>/dev/null)" != "1" ]; then
|
if [[ "$(cat /sys/class/net/$os_wlan/carrier 2>/dev/null)" != "1" ]]; then
|
||||||
msg_fail "no link"
|
msg_fail "no link"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$mtu" ]; then
|
if [[ -n "$mtu" ]]; then
|
||||||
ip link set mtu $mtu dev $os_wlan
|
ip link set mtu $mtu dev $os_wlan
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$static_ip" ]; then
|
if [[ -n "$static_ip" ]]; then
|
||||||
msg_done $static_ip
|
msg_done $static_ip
|
||||||
ifconfig $os_wlan $static_ip up
|
ifconfig $os_wlan $static_ip up
|
||||||
static_ip="" # won't be used again
|
static_ip="" # won't be used again
|
||||||
@ -90,7 +89,7 @@ start_wlan() {
|
|||||||
dhclient -cf "$dh_conf" $os_wlan
|
dhclient -cf "$dh_conf" $os_wlan
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ip_watch" == "true" ] && ip addr show dev $os_wlan | grep inet &>/dev/null; then
|
if [[ "$ip_watch" == "true" ]] && ip addr show dev $os_wlan | grep inet &>/dev/null; then
|
||||||
watch_ip $os_wlan &
|
watch_ip $os_wlan &
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -104,7 +103,7 @@ start_eth() {
|
|||||||
while ! ifconfig $os_eth >/dev/null 2>&1; do
|
while ! ifconfig $os_eth >/dev/null 2>&1; do
|
||||||
sleep 1
|
sleep 1
|
||||||
count=$(($count + 1))
|
count=$(($count + 1))
|
||||||
if [ $count -ge $w ]; then
|
if [[ $count -ge $w ]]; then
|
||||||
msg_done "no device"
|
msg_done "no device"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -116,10 +115,10 @@ start_eth() {
|
|||||||
# wait for operstate
|
# wait for operstate
|
||||||
w=3
|
w=3
|
||||||
count=0
|
count=0
|
||||||
while [ "$(cat /sys/class/net/$os_eth/operstate 2>&1)" == "unknown" ]; do
|
while [[ "$(cat /sys/class/net/$os_eth/operstate 2>&1)" == "unknown" ]]; do
|
||||||
sleep 1
|
sleep 1
|
||||||
count=$(($count + 1))
|
count=$(($count + 1))
|
||||||
if [ $count -ge $w ]; then
|
if [[ $count -ge $w ]]; then
|
||||||
msg_done "no link"
|
msg_done "no link"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -128,20 +127,20 @@ start_eth() {
|
|||||||
# wait for link
|
# wait for link
|
||||||
test "$link_watch" == "true" || link_nego_timeout=5
|
test "$link_watch" == "true" || link_nego_timeout=5
|
||||||
count=0
|
count=0
|
||||||
while [ "$(cat /sys/class/net/$os_eth/carrier 2>&1)" != "1" ]; do
|
while [[ "$(cat /sys/class/net/$os_eth/carrier 2>&1)" != "1" ]]; do
|
||||||
sleep 1
|
sleep 1
|
||||||
count=$(($count + 1))
|
count=$(($count + 1))
|
||||||
if [ $count -ge $link_nego_timeout ]; then
|
if [[ $count -ge $link_nego_timeout ]]; then
|
||||||
msg_done "no link"
|
msg_done "no link"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$mtu" ]; then
|
if [[ -n "$mtu" ]]; then
|
||||||
ip link set mtu $mtu dev $os_eth
|
ip link set mtu $mtu dev $os_eth
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$static_ip" ]; then
|
if [[ -n "$static_ip" ]]; then
|
||||||
msg_done $static_ip
|
msg_done $static_ip
|
||||||
ifconfig $os_eth $static_ip up
|
ifconfig $os_eth $static_ip up
|
||||||
static_ip="" # won't be used again
|
static_ip="" # won't be used again
|
||||||
@ -150,11 +149,11 @@ start_eth() {
|
|||||||
dhclient -cf "$dh_conf" $os_eth
|
dhclient -cf "$dh_conf" $os_eth
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$link_watch" == "true" ]; then
|
if [[ "$link_watch" == "true" ]]; then
|
||||||
watch_eth &
|
watch_eth &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ip_watch" == "true" ] && ip addr show dev $os_eth | grep inet &>/dev/null; then
|
if [[ "$ip_watch" == "true" ]] && ip addr show dev $os_eth | grep inet &>/dev/null; then
|
||||||
watch_ip $os_eth &
|
watch_ip $os_eth &
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -173,16 +172,16 @@ start() {
|
|||||||
test -r /data/etc/ppp/modem && ifconfig | grep $os_ppp &>/dev/null && ppp_ok="ok"
|
test -r /data/etc/ppp/modem && ifconfig | grep $os_ppp &>/dev/null && ppp_ok="ok"
|
||||||
|
|
||||||
# if wifi or ppp link ok, start eth in background
|
# if wifi or ppp link ok, start eth in background
|
||||||
if [ "$wlan_ok" == "ok" ] || [ "$ppp_ok" == "ok" ]; then
|
if [[ "$wlan_ok" == "ok" ]] || [[ "$ppp_ok" == "ok" ]]; then
|
||||||
start_eth &>/dev/null &
|
start_eth &>/dev/null &
|
||||||
else
|
else
|
||||||
start_eth && eth_ok="ok"
|
start_eth && eth_ok="ok"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$eth_ok" != "ok" ] && [ "$wlan_ok" != "ok" ] && [ "$ppp_ok" != "ok" ]; then
|
if [[ "$eth_ok" != "ok" ]] && [[ "$wlan_ok" != "ok" ]] && [[ "$ppp_ok" != "ok" ]]; then
|
||||||
if [ "$link_watch" == "true" ]; then
|
if [[ "$link_watch" == "true" ]]; then
|
||||||
logger -t network -s "no network connection available, rebooting"
|
logger -t network -s "no network connection available, calling panic action"
|
||||||
reboot
|
panic_action network
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
logger -t network -s "no network connection available"
|
logger -t network -s "no network connection available"
|
||||||
@ -190,13 +189,13 @@ start() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$static_gw" ]; then
|
if [[ -n "$static_gw" ]]; then
|
||||||
msg_begin "Setting static gateway to $static_gw"
|
msg_begin "Setting static gateway to $static_gw"
|
||||||
ip route add default via $static_gw
|
ip route add default via $static_gw
|
||||||
test $? == 0 && msg_done || msg_fail
|
test $? == 0 && msg_done || msg_fail
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$static_dns" ]; then
|
if [[ -n "$static_dns" ]]; then
|
||||||
msg_begin "Setting static DNS server to $static_dns"
|
msg_begin "Setting static DNS server to $static_dns"
|
||||||
echo "nameserver $static_dns" > /etc/resolv.conf
|
echo "nameserver $static_dns" > /etc/resolv.conf
|
||||||
test $? == 0 && msg_done || msg_fail
|
test $? == 0 && msg_done || msg_fail
|
||||||
|
@ -7,12 +7,11 @@ netwatch_interval=20
|
|||||||
|
|
||||||
test -f $watch_conf && source $watch_conf || exit 0
|
test -f $watch_conf && source $watch_conf || exit 0
|
||||||
|
|
||||||
if [ -z "$netwatch_host" ] || [ -z "$netwatch_port" ]; then
|
if [[ -z "$netwatch_host" ]] || [[ -z "$netwatch_port" ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
test -n "$os_version" || source /etc/init.d/base
|
test -n "$os_version" || source /etc/init.d/base
|
||||||
test -n "$os_debug" || source /etc/init.d/conf
|
|
||||||
|
|
||||||
test "$os_networkless" == "true" && exit 0
|
test "$os_networkless" == "true" && exit 0
|
||||||
|
|
||||||
@ -24,13 +23,13 @@ watch() {
|
|||||||
if nc -z -w $netwatch_timeout $netwatch_host $netwatch_port </dev/null >/dev/null 2>&1; then
|
if nc -z -w $netwatch_timeout $netwatch_host $netwatch_port </dev/null >/dev/null 2>&1; then
|
||||||
count=0
|
count=0
|
||||||
else
|
else
|
||||||
if [ $count -lt $netwatch_retries ]; then
|
if [[ $count -lt $netwatch_retries ]]; then
|
||||||
logger -t netwatch -s "cannot connect to $netwatch_host:$netwatch_port"
|
logger -t netwatch -s "cannot connect to $netwatch_host:$netwatch_port"
|
||||||
count=$(($count + 1))
|
count=$(($count + 1))
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
logger -t netwatch -s "cannot connect to $netwatch_host:$netwatch_port, rebooting"
|
logger -t netwatch -s "cannot connect to $netwatch_host:$netwatch_port, calling panic action"
|
||||||
reboot
|
panic_action netwatch
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -4,10 +4,10 @@ sys_conf="/etc/firewall.sh"
|
|||||||
boot_conf="/boot/firewall.sh"
|
boot_conf="/boot/firewall.sh"
|
||||||
conf="/data/etc/firewall.sh"
|
conf="/data/etc/firewall.sh"
|
||||||
|
|
||||||
if ! [ -f $conf ]; then
|
if ! [[ -f $conf ]]; then
|
||||||
if [ -f $boot_conf ]; then
|
if [[ -f $boot_conf ]]; then
|
||||||
cp $boot_conf $conf
|
cp $boot_conf $conf
|
||||||
elif [ -f $sys_conf ]; then
|
elif [[ -f $sys_conf ]]; then
|
||||||
cp $sys_conf $conf
|
cp $sys_conf $conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -7,10 +7,10 @@ conf="/data/etc/dnsmasq.conf"
|
|||||||
log="/var/log/dnsmasq.log"
|
log="/var/log/dnsmasq.log"
|
||||||
prog="/usr/sbin/dnsmasq"
|
prog="/usr/sbin/dnsmasq"
|
||||||
|
|
||||||
if ! [ -f $conf ]; then
|
if ! [[ -f $conf ]]; then
|
||||||
if [ -f $boot_conf ]; then
|
if [[ -f $boot_conf ]]; then
|
||||||
cp $boot_conf $conf
|
cp $boot_conf $conf
|
||||||
elif [ -f $sys_conf ]; then
|
elif [[ -f $sys_conf ]]; then
|
||||||
cp $sys_conf $conf
|
cp $sys_conf $conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -11,18 +11,18 @@ sys_ntp_conf="/etc/ntp.conf"
|
|||||||
boot_ntp_conf="/boot/ntp.conf"
|
boot_ntp_conf="/boot/ntp.conf"
|
||||||
ntp_conf="/data/etc/ntp.conf"
|
ntp_conf="/data/etc/ntp.conf"
|
||||||
|
|
||||||
if ! [ -f $conf ]; then
|
if ! [[ -f $conf ]]; then
|
||||||
if [ -f $boot_conf ]; then
|
if [[ -f $boot_conf ]]; then
|
||||||
cp $boot_conf $conf
|
cp $boot_conf $conf
|
||||||
elif [ -f $sys_conf ]; then
|
elif [[ -f $sys_conf ]]; then
|
||||||
cp $sys_conf $conf
|
cp $sys_conf $conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [ -f $ntp_conf ]; then
|
if ! [[ -f $ntp_conf ]]; then
|
||||||
if [ -f $boot_ntp_conf ]; then
|
if [[ -f $boot_ntp_conf ]]; then
|
||||||
cp $boot_ntp_conf $ntp_conf
|
cp $boot_ntp_conf $ntp_conf
|
||||||
elif [ -f $sys_ntp_conf ]; then
|
elif [[ -f $sys_ntp_conf ]]; then
|
||||||
cp $sys_ntp_conf $ntp_conf
|
cp $sys_ntp_conf $ntp_conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -30,7 +30,6 @@ fi
|
|||||||
test -f $conf || exit 0
|
test -f $conf || exit 0
|
||||||
|
|
||||||
test -n "$os_version" || source /etc/init.d/base
|
test -n "$os_version" || source /etc/init.d/base
|
||||||
test -n "$os_debug" || source /etc/init.d/conf
|
|
||||||
|
|
||||||
test "$os_networkless" == "true" && exit 0
|
test "$os_networkless" == "true" && exit 0
|
||||||
|
|
||||||
@ -70,7 +69,7 @@ start_ntp() {
|
|||||||
|
|
||||||
cat $ntp_conf | grep -v iburst > ${ntp_conf}.tmp
|
cat $ntp_conf | grep -v iburst > ${ntp_conf}.tmp
|
||||||
|
|
||||||
if [ -n "$date_ntp_server" ]; then
|
if [[ -n "$date_ntp_server" ]]; then
|
||||||
echo "server $date_ntp_server iburst" > $ntp_conf
|
echo "server $date_ntp_server iburst" > $ntp_conf
|
||||||
else
|
else
|
||||||
cat $sys_ntp_conf | grep iburst > $ntp_conf
|
cat $sys_ntp_conf | grep iburst > $ntp_conf
|
||||||
@ -101,7 +100,7 @@ stop_ntp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
if [ "$date_method" == "http" ]; then
|
if [[ "$date_method" == "http" ]]; then
|
||||||
start_http
|
start_http
|
||||||
else
|
else
|
||||||
start_ntp
|
start_ntp
|
||||||
@ -111,7 +110,7 @@ start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
if [ "$date_method" == "http" ]; then
|
if [[ "$date_method" == "http" ]]; then
|
||||||
stop_http
|
stop_http
|
||||||
else
|
else
|
||||||
stop_ntp
|
stop_ntp
|
||||||
|
@ -8,7 +8,7 @@ test -n "$os_version" || source /etc/init.d/base
|
|||||||
start() {
|
start() {
|
||||||
msg_begin "Starting crond"
|
msg_begin "Starting crond"
|
||||||
|
|
||||||
if [ -d $sys_conf ]; then
|
if [[ -d $sys_conf ]]; then
|
||||||
/usr/sbin/crond -c $sys_conf
|
/usr/sbin/crond -c $sys_conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ conf="/etc/sshd_config"
|
|||||||
test -f $conf || exit 0
|
test -f $conf || exit 0
|
||||||
|
|
||||||
test -n "$os_version" || source /etc/init.d/base
|
test -n "$os_version" || source /etc/init.d/base
|
||||||
test -n "$os_debug" || source /etc/init.d/conf
|
|
||||||
|
|
||||||
test "$os_networkless" == "true" && exit 0
|
test "$os_networkless" == "true" && exit 0
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
test -n "$os_version" || source /etc/init.d/base
|
test -n "$os_version" || source /etc/init.d/base
|
||||||
test -n "$os_debug" || source /etc/init.d/conf
|
|
||||||
|
|
||||||
msg_info() {
|
msg_info() {
|
||||||
echo " # $1"
|
echo " # $1"
|
||||||
|
@ -4,6 +4,10 @@ source /etc/version
|
|||||||
board_sn=$(/etc/init.d/boardsn)
|
board_sn=$(/etc/init.d/boardsn)
|
||||||
board_name=$(cat /etc/board)
|
board_name=$(cat /etc/board)
|
||||||
|
|
||||||
|
test -n "$os_debug" || source /etc/init.d/conf
|
||||||
|
|
||||||
|
source /etc/init.d/panic
|
||||||
|
|
||||||
msg_begin() {
|
msg_begin() {
|
||||||
echo -n " * $1: "
|
echo -n " * $1: "
|
||||||
}
|
}
|
||||||
|
7
board/common/overlay/etc/init.d/bootdone
Executable file
7
board/common/overlay/etc/init.d/bootdone
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source /etc/init.d/panic
|
||||||
|
|
||||||
|
# reset panic counter after a successful boot
|
||||||
|
echo 0 > ${_PANIC_COUNTER_FILE}
|
||||||
|
|
@ -4,26 +4,26 @@ _sys_conf="/etc/os.conf"
|
|||||||
_boot_conf="/boot/os.conf"
|
_boot_conf="/boot/os.conf"
|
||||||
_conf="/data/etc/os.conf"
|
_conf="/data/etc/os.conf"
|
||||||
|
|
||||||
if ! [ -f $_conf ]; then
|
if ! [[ -d /data/etc ]]; then
|
||||||
if [ -f $_boot_conf ]; then
|
# use boot/system variants if we don't have the data partition mounted
|
||||||
|
if [[ -f $_boot_conf ]]; then
|
||||||
|
source $_boot_conf
|
||||||
|
elif [[ -f $_sys_conf ]]; then
|
||||||
|
source $_sys_conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ -f $_conf ]]; then
|
||||||
|
if [[ -f $_boot_conf ]]; then
|
||||||
cp $_boot_conf $_conf
|
cp $_boot_conf $_conf
|
||||||
elif [ -f $_sys_conf ]; then
|
elif [[ -f $_sys_conf ]]; then
|
||||||
cp $_sys_conf $_conf
|
cp $_sys_conf $_conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -f $_conf ]]; then
|
||||||
source $_conf
|
source $_conf
|
||||||
|
|
||||||
has_net_conn() {
|
|
||||||
test "$os_networkless" == "true" && return 1
|
|
||||||
|
|
||||||
addr_eth=$(ip addr show dev $os_eth 2>/dev/null | grep inet | tr -s ' ' | sed -r 's/^\s+//' | cut -d ' ' -f 2)
|
|
||||||
addr_wlan=$(ip addr show dev $os_wlan 2>/dev/null | grep inet | tr -s ' ' | sed -r 's/^\s+//' | cut -d ' ' -f 2)
|
|
||||||
|
|
||||||
if [ -n "$addr_eth" ] || [ -n "$addr_wlan" ]; then
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
|
28
board/common/overlay/etc/init.d/panic
Executable file
28
board/common/overlay/etc/init.d/panic
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
_PANIC_COUNTER_FILE="/var/lib/panic_counter"
|
||||||
|
_PANIC_REBOOT_DELAY_FACTOR=10
|
||||||
|
_PANIC_REBOOT_DELAY_MAX=3600 # reboot at least once an hour in case of panic
|
||||||
|
|
||||||
|
|
||||||
|
panic_action() {
|
||||||
|
# read counter from file
|
||||||
|
panic_counter=$(cat ${_PANIC_COUNTER_FILE} 2>/dev/null || echo 0)
|
||||||
|
|
||||||
|
# write increased counter back to file
|
||||||
|
echo $((panic_counter + 1)) > ${_PANIC_COUNTER_FILE}
|
||||||
|
|
||||||
|
delay=$((_PANIC_REBOOT_DELAY_FACTOR * panic_counter))
|
||||||
|
if [[ "${delay}" -gt "${_PANIC_REBOOT_DELAY_MAX}" ]]; then
|
||||||
|
delay=${_PANIC_REBOOT_DELAY_MAX}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${delay}" -gt 0 ]]; then
|
||||||
|
logger -t panic -s "rebooting in ${delay} seconds (caused by $1)"
|
||||||
|
sleep ${delay}
|
||||||
|
fi
|
||||||
|
|
||||||
|
logger -t panic -s "rebooting (caused by $1)"
|
||||||
|
/sbin/reboot
|
||||||
|
}
|
||||||
|
|
@ -10,8 +10,8 @@ echo "---- shutting down $os_name $os_version ----" >> $boot_log
|
|||||||
# stop all init scripts in /etc/init.d,
|
# stop all init scripts in /etc/init.d,
|
||||||
# executing them in reverse numerical order.
|
# executing them in reverse numerical order.
|
||||||
(for i in $(ls -r /etc/init.d/S??*); do
|
(for i in $(ls -r /etc/init.d/S??*); do
|
||||||
[ ! -x "$i" ] && continue
|
if ! [[ -x "$i" ]]; then continue; fi
|
||||||
[ -f /data/etc/no_$(basename $i) ] && continue
|
if [[ -f /data/etc/no_$(basename $i) ]]; then continue; fi
|
||||||
$i stop
|
$i stop
|
||||||
done& echo $! > $pid_file) | tee -a $boot_log &
|
done& echo $! > $pid_file) | tee -a $boot_log &
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ echo "---- booting $os_name $os_version ----" >> $tmp_boot_log
|
|||||||
|
|
||||||
# start all init scripts in /etc/init.d,
|
# start all init scripts in /etc/init.d,
|
||||||
# executing them in numerical order.
|
# executing them in numerical order.
|
||||||
(for i in /etc/init.d/S??*; do
|
(for i in /etc/init.d/S??* /etc/init.d/bootdone; do
|
||||||
[ ! -x "$i" ] && continue
|
if ! [[ -x "$i" ]]; then continue; fi
|
||||||
[ -f /data/etc/no_$(basename $i) ] && continue
|
if [[ -f /data/etc/no_$(basename $i) ]]; then continue; fi
|
||||||
$i start || break
|
$i start || break
|
||||||
done& echo $! > $pid_file) | tee -a $tmp_boot_log &
|
done& echo $! > $pid_file) | tee -a $tmp_boot_log &
|
||||||
|
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# carry on with the script in case of error
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
|
# write buffers to disk
|
||||||
/bin/sync
|
/bin/sync
|
||||||
(sleep 10 && /usr/bin/killall -STOP watchdog) &
|
|
||||||
|
# allow the shutdown script 20 seconds to shut down,
|
||||||
|
# after which we stop feeding the watchdog
|
||||||
|
(sleep 20 && /usr/bin/killall -STOP watchdog) &
|
||||||
|
|
||||||
|
# actual reboot command
|
||||||
/bin/busybox reboot
|
/bin/busybox reboot
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ govdir="/sys/devices/system/cpu/cpufreq/$gov"
|
|||||||
|
|
||||||
configure() {
|
configure() {
|
||||||
echo $gov > $cpufreqdir/scaling_governor
|
echo $gov > $cpufreqdir/scaling_governor
|
||||||
if [ $gov == "ondemand" ]; then
|
if [[ $gov == "ondemand" ]]; then
|
||||||
echo 50 > $govdir/up_threshold
|
echo 50 > $govdir/up_threshold
|
||||||
echo 100000 > $govdir/sampling_rate
|
echo 100000 > $govdir/sampling_rate
|
||||||
echo 50 > $govdir/sampling_down_factor
|
echo 50 > $govdir/sampling_down_factor
|
||||||
|
@ -21,7 +21,7 @@ get_throttled_since_boot() {
|
|||||||
watch_now() {
|
watch_now() {
|
||||||
while true; do
|
while true; do
|
||||||
t=$(get_throttled_now)
|
t=$(get_throttled_now)
|
||||||
if [ -n "$t" ]; then
|
if [[ -n "$t" ]]; then
|
||||||
logger -t throttlewatch -s "currently: $t"
|
logger -t throttlewatch -s "currently: $t"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ watch_now() {
|
|||||||
watch_since_boot() {
|
watch_since_boot() {
|
||||||
while true; do
|
while true; do
|
||||||
t=$(get_throttled_since_boot)
|
t=$(get_throttled_since_boot)
|
||||||
if [ -n "$t" ]; then
|
if [[ -n "$t" ]]; then
|
||||||
logger -t throttlewatch -s "since boot: $t"
|
logger -t throttlewatch -s "since boot: $t"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -11,8 +11,8 @@ test -d "/proc/device-tree/soc/gpio@7e200000/uart0_pins" || exit 0 # no rpi blu
|
|||||||
test -n "$os_version" || source /etc/init.d/base
|
test -n "$os_version" || source /etc/init.d/base
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
if [ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ] ; then
|
if [[ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ]] ; then
|
||||||
if [ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = " 16" ] ; then
|
if [[ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = " 16" ]] ; then
|
||||||
/usr/bin/hciattach -t5 /dev/serial1 bcm43xx 3000000 flow - &>/dev/null
|
/usr/bin/hciattach -t5 /dev/serial1 bcm43xx 3000000 flow - &>/dev/null
|
||||||
else
|
else
|
||||||
/usr/bin/hciattach -t5 /dev/serial1 bcm43xx 921600 noflow - &>/dev/null
|
/usr/bin/hciattach -t5 /dev/serial1 bcm43xx 921600 noflow - &>/dev/null
|
||||||
|
@ -8,7 +8,7 @@ govdir="/sys/devices/system/cpu/cpufreq/$gov"
|
|||||||
|
|
||||||
configure() {
|
configure() {
|
||||||
echo $gov > $cpufreqdir/scaling_governor
|
echo $gov > $cpufreqdir/scaling_governor
|
||||||
if [ $gov == "ondemand" ]; then
|
if [[ $gov == "ondemand" ]]; then
|
||||||
echo 50 > $govdir/up_threshold
|
echo 50 > $govdir/up_threshold
|
||||||
echo 100000 > $govdir/sampling_rate
|
echo 100000 > $govdir/sampling_rate
|
||||||
echo 50 > $govdir/sampling_down_factor
|
echo 50 > $govdir/sampling_down_factor
|
||||||
|
@ -21,7 +21,7 @@ get_throttled_since_boot() {
|
|||||||
watch_now() {
|
watch_now() {
|
||||||
while true; do
|
while true; do
|
||||||
t=$(get_throttled_now)
|
t=$(get_throttled_now)
|
||||||
if [ -n "$t" ]; then
|
if [[ -n "$t" ]]; then
|
||||||
logger -t throttlewatch -s "currently: $t"
|
logger -t throttlewatch -s "currently: $t"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ watch_now() {
|
|||||||
watch_since_boot() {
|
watch_since_boot() {
|
||||||
while true; do
|
while true; do
|
||||||
t=$(get_throttled_since_boot)
|
t=$(get_throttled_since_boot)
|
||||||
if [ -n "$t" ]; then
|
if [[ -n "$t" ]]; then
|
||||||
logger -t throttlewatch -s "since boot: $t"
|
logger -t throttlewatch -s "since boot: $t"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -8,7 +8,7 @@ govdir="/sys/devices/system/cpu/cpufreq/$gov"
|
|||||||
|
|
||||||
configure() {
|
configure() {
|
||||||
echo $gov > $cpufreqdir/scaling_governor
|
echo $gov > $cpufreqdir/scaling_governor
|
||||||
if [ $gov == "ondemand" ]; then
|
if [[ $gov == "ondemand" ]]; then
|
||||||
echo 50 > $govdir/up_threshold
|
echo 50 > $govdir/up_threshold
|
||||||
echo 100000 > $govdir/sampling_rate
|
echo 100000 > $govdir/sampling_rate
|
||||||
echo 50 > $govdir/sampling_down_factor
|
echo 50 > $govdir/sampling_down_factor
|
||||||
|
@ -21,7 +21,7 @@ get_throttled_since_boot() {
|
|||||||
watch_now() {
|
watch_now() {
|
||||||
while true; do
|
while true; do
|
||||||
t=$(get_throttled_now)
|
t=$(get_throttled_now)
|
||||||
if [ -n "$t" ]; then
|
if [[ -n "$t" ]]; then
|
||||||
logger -t throttlewatch -s "currently: $t"
|
logger -t throttlewatch -s "currently: $t"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ watch_now() {
|
|||||||
watch_since_boot() {
|
watch_since_boot() {
|
||||||
while true; do
|
while true; do
|
||||||
t=$(get_throttled_since_boot)
|
t=$(get_throttled_since_boot)
|
||||||
if [ -n "$t" ]; then
|
if [[ -n "$t" ]]; then
|
||||||
logger -t throttlewatch -s "since boot: $t"
|
logger -t throttlewatch -s "since boot: $t"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -9,8 +9,8 @@ test -f $conf || test -f $boot_conf || test -f $sys_conf || exit 0
|
|||||||
test -n "$os_version" || source /etc/init.d/base
|
test -n "$os_version" || source /etc/init.d/base
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
if [ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ] ; then
|
if [[ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ]] ; then
|
||||||
if [ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = " 16" ] ; then
|
if [[ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = " 16" ]] ; then
|
||||||
/usr/bin/hciattach -t5 /dev/serial1 bcm43xx 3000000 flow - &>/dev/null
|
/usr/bin/hciattach -t5 /dev/serial1 bcm43xx 3000000 flow - &>/dev/null
|
||||||
else
|
else
|
||||||
/usr/bin/hciattach -t5 /dev/serial1 bcm43xx 921600 noflow - &>/dev/null
|
/usr/bin/hciattach -t5 /dev/serial1 bcm43xx 921600 noflow - &>/dev/null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user