diff --git a/board/common/overlay/etc/init.d/S01mountall b/board/common/overlay/etc/init.d/S01mountall index 481c65f543..71ce7bb018 100755 --- a/board/common/overlay/etc/init.d/S01mountall +++ b/board/common/overlay/etc/init.d/S01mountall @@ -1,37 +1,21 @@ #!/bin/bash -sys_conf="/etc/os.conf" -boot_conf="/boot/os.conf" -conf="/data/etc/os.conf" - test -n "$os_version" || source /etc/init.d/base mount_fs() { msg_begin "Mounting filesystems" /bin/mount -a test $? == 0 && msg_done || msg_fail +} - if ! [ -f $conf ]; then - if [ -f $boot_conf ]; then - cp $boot_conf $conf - elif [ -f $sys_conf ]; then - cp $sys_conf $conf - fi - fi +remount_rw() { + msg_begin "Remounting boot partition read-write" + mount -o remount,rw /boot + test $? == 0 && msg_done || msg_fail - if [ -f $conf ]; then - source $conf - fi - - if [ "$os_debug" == "true" ]; then - msg_begin "Remounting boot partition read-write" - mount -o remount,rw /boot - test $? == 0 && msg_done || msg_fail - - msg_begin "Remounting root partition read-write" - mount -o remount,rw / - test $? == 0 && msg_done || msg_fail - fi + msg_begin "Remounting root partition read-write" + mount -o remount,rw / + test $? == 0 && msg_done || msg_fail } mk_tty_login() { @@ -42,6 +26,8 @@ mk_tty_login() { case "$1" in start) mount_fs + test -n "$os_debug" || source /etc/init.d/conf + test "$os_debug" == "true" && remount_rw mk_tty_login ;; diff --git a/board/common/overlay/etc/init.d/S35wifi b/board/common/overlay/etc/init.d/S35wifi index 0332ba5b91..62362b567e 100755 --- a/board/common/overlay/etc/init.d/S35wifi +++ b/board/common/overlay/etc/init.d/S35wifi @@ -6,16 +6,12 @@ conf="/data/etc/wpa_supplicant.conf" log="/var/log/wpa_supplicant.log" prog="/usr/sbin/wpa_supplicant" -iface=wlan0 driver=wext sys_watch_conf="/etc/watch.conf" boot_watch_conf="/boot/watch.conf" watch_conf="/data/etc/watch.conf" -link_watch=yes -link_watch_timeout=20 - if ! [ -f $watch_conf ]; then if [ -f $boot_watch_conf ]; then cp $boot_watch_conf $watch_conf @@ -24,7 +20,7 @@ if ! [ -f $watch_conf ]; then fi fi -test -f $watch_conf && source $watch_conf +source $watch_conf if ! [ -f $conf ]; then if [ -f $boot_conf ]; then @@ -40,9 +36,12 @@ ssid=$(cat $conf | grep ssid | grep -v scan_ssid | cut -d '"' -f 2) test -n "$ssid" || exit 0 test -n "$os_version" || source /etc/init.d/base +test -n "$os_debug" || source /etc/init.d/conf + +test "$os_networkless" == "true" && exit 0 connected() { - ip link show dev $iface 2>&1 | grep LOWER_UP &> /dev/null && return 0 || return 1 + ip link show dev $os_wlan 2>&1 | grep LOWER_UP &> /dev/null && return 0 || return 1 } watch() { @@ -68,7 +67,7 @@ start() { # wait up to 5 seconds for interface count=0 - while ! ifconfig $iface >/dev/null 2>&1; do + while ! ifconfig $os_wlan >/dev/null 2>&1; do sleep 1 count=$(($count + 1)) if [ $count -ge 5 ]; then @@ -77,10 +76,10 @@ start() { fi done - module=$(basename $(readlink /sys/class/net/$iface/device/driver/module 2>/dev/null) 2>/dev/null) + module=$(basename $(readlink /sys/class/net/$os_wlan/device/driver/module 2>/dev/null) 2>/dev/null) - iwconfig $iface power off &> /dev/null - $prog -i$iface -c$conf -D$driver -B &> $log + iwconfig $os_wlan power off &> /dev/null + $prog -i$os_wlan -c$conf -D$driver -B &> $log count=0 while true; do sleep 1 @@ -97,7 +96,7 @@ start() { count=$(($count + 1)) done - if [ "$link_watch" == "yes" ]; then + if [ "$link_watch" == "true" ]; then watch & fi diff --git a/board/common/overlay/etc/init.d/S36ppp b/board/common/overlay/etc/init.d/S36ppp index 041b042b83..9ba5822c9e 100755 --- a/board/common/overlay/etc/init.d/S36ppp +++ b/board/common/overlay/etc/init.d/S36ppp @@ -5,12 +5,11 @@ boot_conf="/boot/ppp" conf="/data/etc/ppp" prog="/usr/sbin/pppd" -dev="ppp0" provider="mobile" watch_conf="/data/etc/watch.conf" -test -f $watch_conf && source $watch_conf +source $watch_conf if ! [ -d $conf ]; then if [ -d $boot_conf ]; then @@ -24,9 +23,12 @@ test -e $conf/modem || exit 0 test -e $conf/apn || exit 0 test -n "$os_version" || source /etc/init.d/base +test -n "$os_debug" || source /etc/init.d/conf + +test "$os_networkless" == "true" && exit 0 connected() { - ifconfig | grep $dev &>/dev/null 2>&1 && return 0 || return 1 + ifconfig | grep $os_ppp &>/dev/null 2>&1 && return 0 || return 1 } watch() { @@ -99,7 +101,7 @@ start() { count=$(($count + 1)) done - if [ "$link_watch" == "yes" ]; then + if [ "$link_watch" == "true" ]; then watch & fi diff --git a/board/common/overlay/etc/init.d/S40network b/board/common/overlay/etc/init.d/S40network index 9bf07f4359..9d19886753 100755 --- a/board/common/overlay/etc/init.d/S40network +++ b/board/common/overlay/etc/init.d/S40network @@ -7,16 +7,9 @@ boot_static_conf="/boot/static_ip.conf" static_conf="/data/etc/static_ip.conf" watch_conf="/data/etc/watch.conf" -link_watch=yes -link_watch_timeout=20 -ip_watch=yes -ip_watch_timeout=40 - link_nego_timeout=10 -eth=eth0 -wlan=wlan0 -test -r $watch_conf && source $watch_conf +source $watch_conf if ! [ -f $static_conf ]; then if [ -f $boot_static_conf ]; then @@ -29,12 +22,13 @@ fi test -r $static_conf && source $static_conf test -n "$os_version" || source /etc/init.d/base +test -n "$os_debug" || source /etc/init.d/conf watch_eth() { count=0 while true; do sleep 5 - if [ "$(cat /sys/class/net/$eth/operstate 2>/dev/null)" == "up" ]; then + if [ "$(cat /sys/class/net/$os_eth/operstate 2>/dev/null)" == "up" ]; then count=0 else if [ $count -lt $link_watch_timeout ]; then @@ -73,65 +67,68 @@ start_lo() { start_wlan() { msg_begin "Configuring wireless network" - if ! ifconfig $wlan &>/dev/null; then + if ! ifconfig $os_wlan &>/dev/null; then msg_fail "no device" return 1 fi - if [ "$(cat /sys/class/net/$wlan/carrier 2>/dev/null)" != "1" ]; then + if [ "$(cat /sys/class/net/$os_wlan/carrier 2>/dev/null)" != "1" ]; then msg_fail "no link" return 1 fi if [ -n "$mtu" ]; then - ip link set mtu $mtu dev $wlan + ip link set mtu $mtu dev $os_wlan fi if [ -n "$static_ip" ]; then msg_done $static_ip - ifconfig $wlan $static_ip up + ifconfig $os_wlan $static_ip up static_ip="" # won't be used again else msg_done dhcp - dhclient -cf "$dh_conf" $wlan + dhclient -cf "$dh_conf" $os_wlan fi - if [ "$ip_watch" == "yes" ] && ip addr show dev $wlan | grep inet &>/dev/null; then - watch_ip $wlan & + if [ "$ip_watch" == "true" ] && ip addr show dev $os_wlan | grep inet &>/dev/null; then + watch_ip $os_wlan & fi } start_eth() { msg_begin "Configuring wired network" - # wait up to 3 seconds for driver + # wait for driver + w=3 count=0 - while ! ifconfig $eth >/dev/null 2>&1; do + while ! ifconfig $os_eth >/dev/null 2>&1; do sleep 1 count=$(($count + 1)) - if [ $count -ge 3 ]; then + if [ $count -ge $w ]; then msg_done "no device" return 1 fi done # bring it up - ifconfig $eth up + ifconfig $os_eth up - # wait up to 3 seconds for operstate + # wait for operstate + w=3 count=0 - while [ "$(cat /sys/class/net/$eth/operstate 2>&1)" == "unknown" ]; do + while [ "$(cat /sys/class/net/$os_eth/operstate 2>&1)" == "unknown" ]; do sleep 1 count=$(($count + 1)) - if [ $count -ge 3 ]; then + if [ $count -ge $w ]; then msg_done "no link" return 1 fi done - # wait up to $link_nego_timeout seconds for link + # wait for link + test "$link_watch" == "true" || link_nego_timeout=5 count=0 - while [ "$(cat /sys/class/net/$eth/carrier 2>&1)" != "1" ]; do + while [ "$(cat /sys/class/net/$os_eth/carrier 2>&1)" != "1" ]; do sleep 1 count=$(($count + 1)) if [ $count -ge $link_nego_timeout ]; then @@ -141,24 +138,24 @@ start_eth() { done if [ -n "$mtu" ]; then - ip link set mtu $mtu dev $eth + ip link set mtu $mtu dev $os_eth fi if [ -n "$static_ip" ]; then msg_done $static_ip - ifconfig $eth $static_ip up + ifconfig $os_eth $static_ip up static_ip="" # won't be used again else msg_done dhcp - dhclient -cf "$dh_conf" $eth + dhclient -cf "$dh_conf" $os_eth fi - if [ "$link_watch" == "yes" ]; then + if [ "$link_watch" == "true" ]; then watch_eth & fi - if [ "$ip_watch" == "yes" ] && ip addr show dev $eth | grep inet &>/dev/null; then - watch_ip $eth & + if [ "$ip_watch" == "true" ] && ip addr show dev $os_eth | grep inet &>/dev/null; then + watch_ip $os_eth & fi } @@ -166,10 +163,11 @@ start() { hostname=$(hostname) echo "send host-name = \"$hostname\";" > /var/cache/dhclient.conf - ssid=$(cat /data/etc/wpa_supplicant.conf 2>&1 | grep ssid | grep -v scan_ssid | cut -d '"' -f 2) - start_lo + test "$os_networkless" == "true" && return 0 + + ssid=$(cat /data/etc/wpa_supplicant.conf 2>&1 | grep ssid | grep -v scan_ssid | cut -d '"' -f 2) test -n "$ssid" && start_wlan && wlan_ok="ok" test -r /data/etc/ppp/modem && ppp_ok="ok" # TODO actually test the ppp link @@ -182,9 +180,14 @@ start() { fi if [ "$eth_ok" != "ok" ] && [ "$wlan_ok" != "ok" ] && [ "$ppp_ok" != "ok" ]; then - logger -t ethernet -s "no network connection available" - reboot - return 1 + if [ "$link_watch" == "true" ]; then + logger -t ethernet -s "no network connection available, rebooting" + reboot + return 1 + else + logger -t ethernet -s "no network connection available" + return 0 + fi fi if [ -n "$static_gw" ]; then diff --git a/board/common/overlay/etc/init.d/S41netwatch b/board/common/overlay/etc/init.d/S41netwatch index 925681a782..940d515083 100755 --- a/board/common/overlay/etc/init.d/S41netwatch +++ b/board/common/overlay/etc/init.d/S41netwatch @@ -10,6 +10,9 @@ test -f $watch_conf && source $watch_conf || exit 0 test -z "$netwatch_host" || -z "$netwatch_port" && exit 0 test -n "$os_version" || source /etc/init.d/base +test -n "$os_debug" || source /etc/init.d/conf + +test "$os_networkless" == "true" && exit 0 watch() { count=0 diff --git a/board/common/overlay/etc/init.d/S50date b/board/common/overlay/etc/init.d/S50date index 10e90483c5..d8231be6a2 100755 --- a/board/common/overlay/etc/init.d/S50date +++ b/board/common/overlay/etc/init.d/S50date @@ -27,7 +27,10 @@ fi test -f $conf || exit 0 test -n "$os_version" || source /etc/init.d/base +test -n "$os_debug" || source /etc/init.d/conf +has_net_conn || exit 0 + date_timeout=10 date_method=http date_host="google.com" diff --git a/board/common/overlay/etc/init.d/S60sshd b/board/common/overlay/etc/init.d/S60sshd index bc48ccde0b..f94b4639ce 100755 --- a/board/common/overlay/etc/init.d/S60sshd +++ b/board/common/overlay/etc/init.d/S60sshd @@ -5,6 +5,9 @@ conf="/etc/sshd_config" test -f $conf || exit 0 test -n "$os_version" || source /etc/init.d/base +test -n "$os_debug" || source /etc/init.d/conf + +has_net_conn || exit 0 start() { msg_begin "Starting sshd" diff --git a/board/common/overlay/etc/init.d/S61proftpd b/board/common/overlay/etc/init.d/S61proftpd index 550f05dcf8..ef358941b2 100755 --- a/board/common/overlay/etc/init.d/S61proftpd +++ b/board/common/overlay/etc/init.d/S61proftpd @@ -3,6 +3,9 @@ test -f /etc/proftpd.conf || exit 0 test -n "$os_version" || source /etc/init.d/base +test -n "$os_debug" || source /etc/init.d/conf + +has_net_conn || exit 0 start() { msg_begin "Starting proftpd" diff --git a/board/common/overlay/etc/init.d/S62smb b/board/common/overlay/etc/init.d/S62smb index 379e34c2ca..dfd2ba0324 100755 --- a/board/common/overlay/etc/init.d/S62smb +++ b/board/common/overlay/etc/init.d/S62smb @@ -3,6 +3,9 @@ test -f /etc/samba/smb.conf || exit 0 test -n "$os_version" || source /etc/init.d/base +test -n "$os_debug" || source /etc/init.d/conf + +has_net_conn || exit 0 start() { msg_begin "Setting smb admin password" diff --git a/board/common/overlay/etc/init.d/S85motioneye b/board/common/overlay/etc/init.d/S85motioneye index a8d48fa7f8..34f758e294 100755 --- a/board/common/overlay/etc/init.d/S85motioneye +++ b/board/common/overlay/etc/init.d/S85motioneye @@ -7,7 +7,7 @@ motion_conf="/data/etc/motion.conf" watch_conf="/data/etc/watch.conf" meyewatch_timeout=120 -meyewatch_disable="" +meyewatch_disable="false" dev_v4l_by_id="/dev/v4l/by-id/" media_dir="/data/output" @@ -83,7 +83,7 @@ start() { if [ $count -gt $meyewatch_timeout ]; then msg_fail - test -z "$meyewatch_disable" && reboot + test "$meyewatch_disable" == "false" && reboot return 1 fi @@ -112,7 +112,7 @@ start() { sync fi - if [ -z "$meyewatch_disable" ]; then + if [ "$meyewatch_disable" == "false" ]; then watch & fi diff --git a/board/common/overlay/etc/init.d/S99showinfo b/board/common/overlay/etc/init.d/S99showinfo index 98da17c4e4..1e0b7390d1 100755 --- a/board/common/overlay/etc/init.d/S99showinfo +++ b/board/common/overlay/etc/init.d/S99showinfo @@ -1,6 +1,7 @@ #!/bin/bash test -n "$os_version" || source /etc/init.d/base +test -n "$os_debug" || source /etc/init.d/conf msg_info() { echo " # $1" @@ -17,15 +18,16 @@ show_gateway() { } show_dns() { - dns=$(cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2) - test -n "$gateway" && msg_info "DNS server address is $dns" + test -r /etc/resolv.conf || return + dns=$(cat /etc/resolv.conf | grep nameserver | head -n 1 | cut -d ' ' -f 2) + test -n "$dns" && msg_info "DNS server address is $dns" } case "$1" in start) - show_iface_ip_addr eth0 - show_iface_ip_addr wlan0 - show_iface_ip_addr ppp0 + show_iface_ip_addr $os_eth + show_iface_ip_addr $os_wlan + show_iface_ip_addr $os_ppp show_gateway show_dns ;; diff --git a/board/common/overlay/etc/init.d/conf b/board/common/overlay/etc/init.d/conf new file mode 100644 index 0000000000..fd1afc129c --- /dev/null +++ b/board/common/overlay/etc/init.d/conf @@ -0,0 +1,29 @@ +#!/bin/bash + +_sys_conf="/etc/os.conf" +_boot_conf="/boot/os.conf" +_conf="/data/etc/os.conf" + +if ! [ -f $_conf ]; then + if [ -f $_boot_conf ]; then + cp $_boot_conf $_conf + elif [ -f $_sys_conf ]; then + cp $_sys_conf $_conf + fi +fi + +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 +} + diff --git a/board/common/overlay/etc/os.conf b/board/common/overlay/etc/os.conf index 2cc5d3e21b..b4e03dce30 100644 --- a/board/common/overlay/etc/os.conf +++ b/board/common/overlay/etc/os.conf @@ -1,4 +1,8 @@ os_debug="false" os_prereleases="false" os_tty_login="tty1" +os_eth="eth0" +os_wlan="wlan0" +os_ppp="ppp0" +os_networkless="false" diff --git a/board/common/overlay/etc/version b/board/common/overlay/etc/version index 127a769782..52fb0a7522 100644 --- a/board/common/overlay/etc/version +++ b/board/common/overlay/etc/version @@ -1,4 +1,4 @@ os_name="motionEyeOS" os_short_name="motioneyeos" os_prefix="meye" -os_version="20160801" +os_version="20160828" diff --git a/board/common/overlay/etc/watch.conf b/board/common/overlay/etc/watch.conf index 22968f58cb..34d46b9089 100644 --- a/board/common/overlay/etc/watch.conf +++ b/board/common/overlay/etc/watch.conf @@ -1,7 +1,7 @@ -link_watch=yes +link_watch="true" link_watch_timeout=20 -ip_watch=yes +ip_watch="true" ip_watch_timeout=40 #netwatch_host=www.google.com @@ -10,6 +10,6 @@ netwatch_retries=3 netwatch_timeout=5 netwatch_interval=20 -#meyewatch_disable=yes +#meyewatch_disable="true" meyewatch_timeout=120 diff --git a/board/common/overlay/usr/share/post-upgrade/20160828.sh b/board/common/overlay/usr/share/post-upgrade/20160828.sh new file mode 100755 index 0000000000..8a66549a9a --- /dev/null +++ b/board/common/overlay/usr/share/post-upgrade/20160828.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# more settings have been added to [/data]/etc/os.conf + +echo 'os_networkless="false"' >> /data/etc/os.conf +echo 'os_eth="eth0"' >> /data/etc/os.conf +echo 'os_wlan="wlan0"' >> /data/etc/os.conf +echo 'os_ppp="ppp0"' >> /data/etc/os.conf + +# boolean values in watch.conf have been normalized to "true" and "false" +sed -i 's/=no/="false"/' /data/etc/watch.conf +sed -i 's/=yes/="true"/' /data/etc/watch.conf + diff --git a/board/raspberrypi3/motioneye-modules/boardctl.py b/board/raspberrypi3/motioneye-modules/boardctl.py index 9716713cf4..27f208d912 100644 --- a/board/raspberrypi3/motioneye-modules/boardctl.py +++ b/board/raspberrypi3/motioneye-modules/boardctl.py @@ -111,7 +111,6 @@ def _set_board_settings(s): logging.debug('writing board settings to %s: ' % CONFIG_TXT + 'gpu_mem=%(gpuMem)s, camera_led=%(cameraLed)s' % s) - lines = [] if os.path.exists(CONFIG_TXT): @@ -136,17 +135,12 @@ def _set_board_settings(s): if name == 'gpu_mem': lines[i] = '%s=%s' % (name, s['gpuMem']) - elif name == 'disable_camera_led': lines[i] = 'disable_camera_led=%s' % ['1', '0'][s['cameraLed']] if 'gpu_mem' not in seen: lines.append('gpu_mem=%s' % s['gpuMem']) - - - - if 'disable_camera_led' not in seen: lines.append('disable_camera_led=%s' % ['1', '0'][s['cameraLed']]) @@ -228,8 +222,6 @@ def cameraLed(): } - - @additional_config def sysMon(): return { diff --git a/package/motioneye/extractl.py b/package/motioneye/extractl.py index ecfad899eb..d8eb0a3c35 100644 --- a/package/motioneye/extractl.py +++ b/package/motioneye/extractl.py @@ -368,7 +368,7 @@ def hostname(): 'advanced': True, 'reboot': True, 'required': False, - 'validate': '^[a-z0-9\-_]{0,15}$', + 'validate': '^[a-z0-9\-_.]{0,64}$', 'get': _get_hostname, 'set': _set_hostname } diff --git a/package/motioneye/motioneye.mk b/package/motioneye/motioneye.mk index 31fde570c9..cef4fb8f9a 100644 --- a/package/motioneye/motioneye.mk +++ b/package/motioneye/motioneye.mk @@ -4,7 +4,7 @@ # ############################################################# -MOTIONEYE_VERSION = c09764c55e20519f38c64332703ddaf55e3e10f2 +MOTIONEYE_VERSION = 093c61ea811c92b5168797e4f4fd7398eb31bb5d MOTIONEYE_SITE = $(call github,ccrisan,motioneye,$(MOTIONEYE_VERSION)) MOTIONEYE_SOURCE = $(MOTIONEYE_VERSION).tar.gz MOTIONEYE_LICENSE = GPLv3 diff --git a/package/motioneye/watchctl.py b/package/motioneye/watchctl.py index e7952dc096..045a12fbcf 100644 --- a/package/motioneye/watchctl.py +++ b/package/motioneye/watchctl.py @@ -57,7 +57,7 @@ def _get_watch_settings(): continue if name == 'link_watch': - watch_link = (value == 'yes') and not comment + watch_link = (value == 'true') and not comment elif name == 'link_watch_timeout': watch_link_timeout = int(value) @@ -115,10 +115,10 @@ def _set_watch_settings(s): with open(WATCH_CONF, 'w') as f: - f.write('link_watch=%s\n' % ['no', 'yes'][s['watchLink']]) + f.write('link_watch=%s\n' % ['"false"', '"true"'][s['watchLink']]) f.write('link_watch_timeout=%s\n' % s['watchLinkTimeout']) f.write('\n') - f.write('ip_watch=%s\n' % ['no', 'yes'][s['watchLink']]) + f.write('ip_watch=%s\n' % ['"false"', '"true"'][s['watchLink']]) f.write('ip_watch_timeout=%s\n' % s['watchLinkTimeout']) f.write('\n') f.write('%snetwatch_host=%s\n' % (('#' if not s['watchConnect'] else ''), s['watchConnectHost']))