all init scripts are now fully refactored

This commit is contained in:
Calin Crisan 2015-11-15 17:47:19 +02:00
parent 2b13aacfe5
commit 21c7ea9143
41 changed files with 169 additions and 158 deletions

View File

@ -1,4 +1,4 @@
setenv bootargs console=tty1 root=/dev/mmcblk0p2 rootwait panic=10 earlyprintk ${extra} setenv bootargs console=tty1 root=/dev/mmcblk0p2 rootwait panic=10 earlyprintk quiet loglevel=1 ${extra}
fatload mmc 0 0x49000000 sun7i-a20-bananapi.dtb fatload mmc 0 0x49000000 sun7i-a20-bananapi.dtb
fatload mmc 0 0x46000000 uImage fatload mmc 0 0x46000000 uImage
setenv fdt_high ffffffff setenv fdt_high ffffffff

View File

@ -1,7 +1,7 @@
# #
# Automatically generated make config: don't edit # Automatically generated make config: don't edit
# Busybox version: 1.23.2 # Busybox version: 1.23.2
# Sat Nov 14 19:10:47 2015 # Sun Nov 15 16:54:44 2015
# #
CONFIG_HAVE_DOT_CONFIG=y CONFIG_HAVE_DOT_CONFIG=y
@ -1027,16 +1027,16 @@ CONFIG_FEATURE_BASH_IS_NONE=y
# System Logging Utilities # System Logging Utilities
# #
CONFIG_SYSLOGD=y CONFIG_SYSLOGD=y
CONFIG_FEATURE_ROTATE_LOGFILE=y # CONFIG_FEATURE_ROTATE_LOGFILE is not set
CONFIG_FEATURE_REMOTE_LOG=y # CONFIG_FEATURE_REMOTE_LOG is not set
# CONFIG_FEATURE_SYSLOGD_DUP is not set # CONFIG_FEATURE_SYSLOGD_DUP is not set
# CONFIG_FEATURE_SYSLOGD_CFG is not set CONFIG_FEATURE_SYSLOGD_CFG=y
CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=256 CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=256
# CONFIG_FEATURE_IPC_SYSLOG is not set # CONFIG_FEATURE_IPC_SYSLOG is not set
CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=0 CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=0
# CONFIG_LOGREAD is not set # CONFIG_LOGREAD is not set
# CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING is not set # CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING is not set
# CONFIG_FEATURE_KMSG_SYSLOG is not set CONFIG_FEATURE_KMSG_SYSLOG=y
CONFIG_KLOGD=y # CONFIG_KLOGD is not set
CONFIG_FEATURE_KLOGD_KLOGCTL=y # CONFIG_FEATURE_KLOGD_KLOGCTL is not set
CONFIG_LOGGER=y CONFIG_LOGGER=y

View File

@ -3,6 +3,8 @@
sys_hostname_file="/etc/hostname" sys_hostname_file="/etc/hostname"
hostname_file="/data/etc/hostname" hostname_file="/data/etc/hostname"
test -n "$os_version" || source /etc/init.d/base
case "$1" in case "$1" in
start) start)
msg_begin "Setting hostname" msg_begin "Setting hostname"

View File

@ -1,7 +1,9 @@
#!/bin/bash #!/bin/bash
sys_modules_file="/etc_modules" sys_modules_file="/etc/modules"
modules_file="/data/etc_modules" modules_file="/data/etc/modules"
test -n "$os_version" || source /etc/init.d/base
case "$1" in case "$1" in
start) start)

View File

@ -1,21 +1,23 @@
#!/bin/bash #!/bin/bash
test -n "$os_version" || source /etc/init.d/base
case "$1" in case "$1" in
start) start)
msg_begin "Starting logging" msg_begin "Starting syslogd"
start-stop-daemon -b -S -q -m -p /var/run/syslogd.pid --exec /sbin/syslogd -- -n syslogd
msg_done test $? == 0 && msg_done || msg_fail
;; ;;
stop) stop)
msg_begin "Stopping logging" msg_begin "Stopping syslogd"
start-stop-daemon -K -q -p /var/run/syslogd.pid killall syslogd &>/dev/null
msg_done test $? == 0 && msg_done || msg_fail
;; ;;
*) *)
echo "Usage: $0 {start|stop}" echo "Usage: $0 {start|stop}"
exit 1 exit 1
esac esac
exit $? exit $?

View File

@ -1,16 +1,9 @@
#!/bin/bash #!/bin/bash
# these aren't used in this file but
# throughout various init scripts
sys_watch_conf="/etc/watch.conf"
watch_conf="/data/etc/watch.conf"
if [ -f $sys_watch_conf ] && ! [ -f $watch_conf ]; then
cp $sys_watch_conf $watch_conf
fi
test -c /dev/watchdog || exit 0 test -c /dev/watchdog || exit 0
test -n "$os_version" || source /etc/init.d/base
case "$1" in case "$1" in
start) start)
msg_begin "Starting watchdog" msg_begin "Starting watchdog"

View File

@ -5,6 +5,8 @@ data_dev="${disk_dev}p3"
test -b $data_dev && exit 0 test -b $data_dev && exit 0
test -n "$os_version" || source /etc/init.d/base
case "$1" in case "$1" in
start) start)
msg_begin "Creating data partition" msg_begin "Creating data partition"
@ -13,13 +15,12 @@ case "$1" in
3 3
\n \n
\n \n
w" | /sbin/fdisk $disk_dev >/dev/null w" | /sbin/fdisk $disk_dev 2>&1 >/dev/null | grep -v "Device or resource busy" | grep -v '^$'
test $? == 0 && msg_done || msg_fail
sync
partx -a $disk_dev &>/dev/null partx -a $disk_dev &>/dev/null
test -b $data_dev && msg_done || msg_fail
msg_begin "Formatting data partition" msg_begin "Formatting data partition"
mkfs.ext4 $data_dev mkfs.ext4 -q $data_dev
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
msg_begin "Mounting data partition" msg_begin "Mounting data partition"

View File

@ -2,12 +2,14 @@
test -f /etc/udev/udev.conf || exit 0 test -f /etc/udev/udev.conf || exit 0
test -n "$os_version" || source /etc/init.d/base
source /etc/udev/udev.conf source /etc/udev/udev.conf
start() { start() {
msg_begin "Starting eudev" msg_begin "Starting eudev"
echo '\000\000\000\000' > /proc/sys/kernel/hotplug echo '\000\000\000\000' > /proc/sys/kernel/hotplug
/sbin/udevd --daemon /sbin/udevd --daemon --resolve-names=never
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
/sbin/udevadm trigger --type=subsystems --action=add /sbin/udevadm trigger --type=subsystems --action=add

View File

@ -3,13 +3,7 @@
sys_conf="/etc/os.conf" sys_conf="/etc/os.conf"
conf="/data/etc/os.conf" conf="/data/etc/os.conf"
if [ -f $sys_conf ] && ! [ -f $conf ]; then test -n "$os_version" || source /etc/init.d/base
cp $sys_conf $conf
fi
if [ -f $conf ]; then
source $conf
fi
case "$1" in case "$1" in
start) start)
@ -17,12 +11,20 @@ case "$1" in
/bin/mount -a /bin/mount -a
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
if [ -f $sys_conf ] && ! [ -f $conf ]; then
cp $sys_conf $conf
fi
if [ -f $conf ]; then
source $conf
fi
if [ "$os_debug" == "true" ]; then if [ "$os_debug" == "true" ]; then
msg_begin "Remounting boot partition read-write" msg_begin "Remounting boot partition read-write"
mount -o remount,rw /boot mount -o remount,rw /boot
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
echo -n "Remounting root partition read-write: " msg_begin "Remounting root partition read-write: "
mount -o remount,rw / mount -o remount,rw /
test $? == 0 && msg_done || msg_fail test $? == 0 && msg_done || msg_fail
fi fi

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
test -n "$os_version" || source /etc/init.d/base
case "$1" in case "$1" in
start) start)
# make sure root and admin users exist in shadow file # make sure root and admin users exist in shadow file
@ -14,11 +16,7 @@ case "$1" in
# set root and admin passwords # set root and admin passwords
password=$(/etc/init.d/adminpw) password=$(/etc/init.d/adminpw)
if [ -z "$password" ]; then msg_begin "Setting root password"
echo "Setting empty root/admin password"
else
echo "Setting custom root/admin password"
fi
rm -f /data/etc/shadow+ rm -f /data/etc/shadow+
rm -f /data/etc/shadow- rm -f /data/etc/shadow-
@ -28,6 +26,8 @@ case "$1" in
sed -r -i 's/root:([^:]+):[[:digit:]]+:/root:\1::/' /data/etc/shadow # removes pwd expiration sed -r -i 's/root:([^:]+):[[:digit:]]+:/root:\1::/' /data/etc/shadow # removes pwd expiration
sed -r -i 's/admin:([^:]+):[[:digit:]]+:/admin:\1::/' /data/etc/shadow # removes pwd expiration sed -r -i 's/admin:([^:]+):[[:digit:]]+:/admin:\1::/' /data/etc/shadow # removes pwd expiration
msg_done
;; ;;
stop) stop)

View File

@ -2,26 +2,35 @@
sys_conf="/etc/wpa_supplicant.conf" sys_conf="/etc/wpa_supplicant.conf"
conf="/data/etc/wpa_supplicant.conf" conf="/data/etc/wpa_supplicant.conf"
log="/var/log/wpa_supplicant.log" log="/var/log/wpa_supplicant.log"
prog="/usr/sbin/wpa_supplicant" prog="/usr/sbin/wpa_supplicant"
iface=wlan0 iface=wlan0
driver=wext driver=wext
sys_watch_conf="/etc/watch.conf"
watch_conf="/data/etc/watch.conf" watch_conf="/data/etc/watch.conf"
link_watch=yes link_watch=yes
link_watch_timeout=20 link_watch_timeout=20
if [ -f $sys_watch_conf ] && ! [ -f $watch_conf ]; then
cp $sys_watch_conf $watch_conf
fi
test -f $watch_conf && source $watch_conf test -f $watch_conf && source $watch_conf
if [ -f $sys_conf ] && ! [ -f $conf ]; then if [ -f $sys_conf ] && ! [ -f $conf ]; then
cp $sys_conf $conf cp $sys_conf $conf
fi fi
test -f $watch_conf || exit 0 test -f $conf || exit 0
ssid=$(cat $conf | grep ssid | grep -v scan_ssid | cut -d '"' -f 2) 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
connected() { connected() {
ip link show dev $iface 2>&1 | grep LOWER_UP &> /dev/null && return 0 || return 1 ip link show dev $iface 2>&1 | grep LOWER_UP &> /dev/null && return 0 || return 1
} }

View File

@ -17,6 +17,8 @@ fi
test -f $conf/modem || exit 0 test -f $conf/modem || exit 0
test -n "$os_version" || source /etc/init.d/base
connected() { connected() {
ifconfig | grep $dev &>/dev/null 2>&1 && return 0 || return 1 ifconfig | grep $dev &>/dev/null 2>&1 && return 0 || return 1
} }

View File

@ -18,12 +18,13 @@ wlan=wlan0
test -r $watch_conf && source $watch_conf test -r $watch_conf && source $watch_conf
if [ -f $sys_static_conf ] && ! [ -f $static_conf ]; then if [ -f $sys_static_conf ] && ! [ -f $static_conf ]; then
mkdir -p $(dirname $static_conf)
cp $sys_static_conf $static_conf cp $sys_static_conf $static_conf
fi fi
test -r $static_conf && source $static_conf test -r $static_conf && source $static_conf
test -n "$os_version" || source /etc/init.d/base
watch_eth() { watch_eth() {
count=0 count=0
while true; do while true; do

View File

@ -9,6 +9,8 @@ test -f $watch_conf && source $watch_conf || exit 0
test -z "$netwatch_host" || -z "$netwatch_port" && exit 0 test -z "$netwatch_host" || -z "$netwatch_port" && exit 0
test -n "$os_version" || source /etc/init.d/base
watch() { watch() {
count=0 count=0
netwatch_retries=$(($netwatch_retries - 1)) netwatch_retries=$(($netwatch_retries - 1))

View File

@ -9,6 +9,8 @@ fi
test -f $conf || exit 0 test -f $conf || exit 0
test -n "$os_version" || source /etc/init.d/base
date_timeout=10 date_timeout=10
date_method=http date_method=http
date_host="google.com" date_host="google.com"
@ -41,7 +43,7 @@ set_current_date_ntp() {
start_http() { start_http() {
msg_begin "Setting current date using http" msg_begin "Setting current date using http"
set_current_date_http set_current_date_http
test $? == 0 && msg_done $(date) || msg_fail test $? == 0 && msg_done "$(date)" || msg_fail
msg_begin "Starting http date updater" msg_begin "Starting http date updater"
while true; do while true; do
@ -56,7 +58,7 @@ start_ntp() {
msg_begin "Setting current date using ntp" msg_begin "Setting current date using ntp"
set_current_date_ntp set_current_date_ntp
test $? == 0 && msg_done $(date) || msg_fail test $? == 0 && msg_done "$(date)" || msg_fail
msg_begin "Starting ntpd" msg_begin "Starting ntpd"
ntpd -g -c /etc/ntp.conf ntpd -g -c /etc/ntp.conf

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
test -n "$os_version" || source /etc/init.d/base
start() { start() {
msg_begin "Starting crond" msg_begin "Starting crond"

View File

@ -4,11 +4,17 @@ conf="/etc/sshd_config"
test -f $conf || exit 0 test -f $conf || exit 0
test -n "$os_version" || source /etc/init.d/base
start() { start() {
msg_begin "Starting sshd" msg_begin "Starting sshd"
# create any missing keys # create any missing keys
/usr/bin/ssh-keygen -A if ! /usr/bin/ssh-keygen -A >/dev/null; then
msg_fail
return 1
fi
umask 077 umask 077
hostname=$(hostname) hostname=$(hostname)
echo "Welcome to $hostname!" > /var/cache/sshd_banner echo "Welcome to $hostname!" > /var/cache/sshd_banner
@ -30,11 +36,11 @@ case "$1" in
stop) stop)
stop stop
start
;; ;;
restart|reload) restart)
restart stop
start
;; ;;
*) *)

View File

@ -2,6 +2,8 @@
test -f /etc/proftpd.conf || exit 0 test -f /etc/proftpd.conf || exit 0
test -n "$os_version" || source /etc/init.d/base
start() { start() {
msg_begin "Starting proftpd" msg_begin "Starting proftpd"
mkdir -p /var/run/proftpd mkdir -p /var/run/proftpd

View File

@ -2,6 +2,8 @@
test -f /etc/samba/smb.conf || exit 0 test -f /etc/samba/smb.conf || exit 0
test -n "$os_version" || source /etc/init.d/base
start() { start() {
msg_begin "Setting smb admin password" msg_begin "Setting smb admin password"

View File

@ -12,6 +12,8 @@ fi
test -f "$conf" || exit 0 test -f "$conf" || exit 0
test -n "$os_version" || source /etc/init.d/base
opts=$(cat "$conf" | while read line; do echo "--$line"; done) opts=$(cat "$conf" | while read line; do echo "--$line"; done)
port=$(echo "$opts" | grep -oE 'port [[:digit:]]+' | cut -d ' ' -f 2) port=$(echo "$opts" | grep -oE 'port [[:digit:]]+' | cut -d ' ' -f 2)

View File

@ -4,6 +4,8 @@ userinit_sh="/data/etc/userinit.sh"
test -f $userinit_sh || exit 0 test -f $userinit_sh || exit 0
test -n "$os_version" || source /etc/init.d/base
case "$1" in case "$1" in
start) start)
msg_begin "Executing user init script" msg_begin "Executing user init script"

View File

@ -1,7 +1,11 @@
#!/bin/bash #!/bin/bash
source /etc/version
board_sn=$(/etc/init.d/boardsn)
board_name=$(cat /etc/board)
msg_begin() { msg_begin() {
echo -n "$1: " echo -n "* $1: "
} }
msg_done() { msg_done() {

View File

@ -3,14 +3,13 @@
boot_log=/var/log/boot.log boot_log=/var/log/boot.log
pid_file=/tmp/rc.pid pid_file=/tmp/rc.pid
source /etc/init.d/vars source /etc/init.d/base
source /etc/init.d/functions
echo "---- shutting down $os_name $os_version ----" >> $boot_log 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 numerical order. # executing them in reverse numerical order.
(for i in /etc/init.d/S??*; do (for i in $(ls -r /etc/init.d/S??*); do
[ ! -x "$i" ] && continue [ ! -x "$i" ] && continue
[ -f /data/etc/no_$(basename $i) ] && continue [ -f /data/etc/no_$(basename $i) ] && continue

View File

@ -1,19 +1,12 @@
#!/bin/sh #!/bin/sh
boot_log=/var/log/boot.log boot_log=/var/log/boot.log
tmp_boot_log=/tmp/boot.log
pid_file=/tmp/rc.pid pid_file=/tmp/rc.pid
if ! [ -d /var/log ]; then source /etc/init.d/base
# at the very first boot,
# we won't have the /var/log directory
boot_log=/tmp/boot.log
tmp_log=yes
fi
source /etc/init.d/vars echo "---- booting $os_name $os_version----" >> $tmp_boot_log
source /etc/init.d/functions
echo "---- booting $os_name $os_version----" >> $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.
@ -26,15 +19,12 @@ echo "---- booting $os_name $os_version----" >> $boot_log
set start set start
. $i . $i
) )
done& echo $! > $pid_file) | tee -a $boot_log & done& echo $! > $pid_file) | tee -a $tmp_boot_log &
pid=$(cat $pid_file) pid=$(cat $pid_file)
while kill -0 $pid 2>/dev/null; do while kill -0 $pid 2>/dev/null; do
sleep 1 sleep 1
done done
if [ -n "$tmp_log" ]; then test -d $(dirname $boot_log) && cat $tmp_boot_log >> $boot_log
# persist the boot log at first boot
mv $boot_log /var/log
fi

View File

@ -1,6 +0,0 @@
#!/bin/bash
source /etc/version
board_sn=$(/etc/init.d/boardsn)
board_name=$(cat /etc/board)

View File

@ -26,5 +26,5 @@ tty1::respawn:/sbin/getty -L tty1 115200 vt100
# Stuff to do before rebooting # Stuff to do before rebooting
::shutdown:/etc/init.d/rcK ::shutdown:/etc/init.d/rcK
::shutdown:/bin/umount -a -r null::shutdown:/bin/umount -a -r

View File

@ -1,4 +1,4 @@
ServerName "motionEye" ServerIdent off
ServerType standalone ServerType standalone
DefaultServer on DefaultServer on
Port 21 Port 21

View File

@ -0,0 +1,2 @@
syslog.=info /dev/null
*.*;syslog.!info /var/log/messages

View File

@ -6,10 +6,10 @@ if [ -z "$TARGET" ]; then
fi fi
# disable startup scripts # disable startup scripts
rm -f $TARGET/etc/init.d/S15watchdog # replaced by S02watchdog rm -f $TARGET/etc/init.d/S01logging
rm -f $TARGET/etc/init.d/S49ntp # replaced by S60date rm -f $TARGET/etc/init.d/S15watchdog
rm -f $TARGET/etc/init.d/S50nginx # not needed rm -f $TARGET/etc/init.d/S49ntp
rm -f $TARGET/etc/init.d/S50proftpd # replaced by S70proftpd rm -f $TARGET/etc/init.d/S50proftpd
rm -f $TARGET/etc/init.d/S20urandom rm -f $TARGET/etc/init.d/S20urandom
rm -f $TARGET/etc/init.d/S80dhcp-relay rm -f $TARGET/etc/init.d/S80dhcp-relay
rm -f $TARGET/etc/init.d/S80dhcp-server rm -f $TARGET/etc/init.d/S80dhcp-server

View File

@ -1,4 +1,4 @@
setenv bootargs console=tty1 root=/dev/mmcblk0p2 rootwait panic=10 earlyprintk ${extra} setenv bootargs console=tty1 root=/dev/mmcblk0p2 rootwait panic=10 earlyprintk quiet loglevel=1 ${extra}
fatload mmc 0 0x49000000 sun7i-a20-cubietruck.dtb fatload mmc 0 0x49000000 sun7i-a20-cubietruck.dtb
fatload mmc 0 0x46000000 uImage fatload mmc 0 0x46000000 uImage
setenv fdt_high ffffffff setenv fdt_high ffffffff

View File

@ -47,7 +47,7 @@ setenv vpu "0"
setenv hdmioutput "0" setenv hdmioutput "0"
# Boot Arguments # Boot Arguments
setenv bootargs "console=ttyS0,115200n8 root=/dev/mmcblk0p2 rootwait ro no_console_suspend vdaccfg=0xa000 logo=osd1,loaded,0x7900000,720p,full dmfc=3 cvbsmode=576cvbs hdmimode=${m} m_bpp=${m_bpp} vout=${vout_mode} ${disableuhs}" setenv bootargs "console=ttyS0,115200n8 root=/dev/mmcblk0p2 rootwait ro no_console_suspend panic=10 quiet loglevel=1 vdaccfg=0xa000 logo=osd1,loaded,0x7900000,720p,full dmfc=3 cvbsmode=576cvbs hdmimode=${m} m_bpp=${m_bpp} vout=${vout_mode} ${disableuhs}"
# Booting # Booting
fatload mmc 0:1 0x21000000 uImage fatload mmc 0:1 0x21000000 uImage

View File

@ -1 +1 @@
dwc_otg.fiq_fix_enable=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait ro rootflags=noload dwc_otg.fiq_fix_enable=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait ro rootflags=noload panic=10 quiet loglevel=1

View File

@ -1,10 +1,12 @@
#!/bin/sh #!/bin/bash
gpio=35 gpio=35
check_interval=30 check_interval=30
export=/sys/class/gpio/export export=/sys/class/gpio/export
read=/sys/class/gpio/gpio$gpio/value read=/sys/class/gpio/gpio$gpio/value
test -n "$os_version" || source /etc/init.d/base
configure() { configure() {
echo $gpio > $export echo $gpio > $export
} }
@ -20,20 +22,20 @@ watch() {
case "$1" in case "$1" in
start) start)
echo -n "Starting brownout detector: " msg_begin "Starting brownout detector"
configure configure
test $? == 0 && msg_done || msg_fail
watch & watch &
echo "done"
;; ;;
stop) stop)
echo -n "Stopping brownout detector: " msg_begin "Stopping brownout detector"
ps | grep brownout | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill ps | grep brownout | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
echo "done" test $? == 0 && msg_done || msg_fail
;; ;;
*) *)
echo $"Usage: $0 {start|stop|restart}" echo $"Usage: $0 {start|stop}"
exit 1 exit 1
esac esac

View File

@ -1,40 +1,31 @@
#!/bin/sh #!/bin/sh
MOTIONEYE_CONF_DIR=/data/etc/ motioneye_conf_dir="/data/etc/"
test -n "$os_version" || source /etc/init.d/base
enabled() { enabled() {
if [ $(ls -1 $MOTIONEYE_CONF_DIR/thread-*.conf 2>/dev/null| wc -l) != 1 ]; then test $(ls -1 $motioneye_conf_dir/thread-*.conf 2>/dev/null| wc -l) == 1 || return 1
return 1
fi
if ! grep '# @proto mjpeg' $MOTIONEYE_CONF_DIR/thread-1.conf &>/dev/null; then grep '# @proto mjpeg' $motioneye_conf_dir/thread-1.conf &>/dev/null || return 1
return 1
fi
if ! grep -E '# @url http://(.*)127.0.0.1:' $MOTIONEYE_CONF_DIR/thread-1.conf &>/dev/null; then
return 1
fi
grep -E '# @url http://(.*)127.0.0.1:' $motioneye_conf_dir/thread-1.conf &>/dev/null || return 1
return 0 return 0
} }
enabled || exit 0 enabled || exit 0
start() { start() {
echo -n "Starting streameye: " msg_begin "Starting streameye"
streameye.sh start streameye.sh start
echo "done" test $? == 0 && msg_done || msg_fail
} }
stop() { stop() {
echo -n "Shutting down streameye: " msg_begin "Stopping streameye"
streameye.sh stop streameye.sh stop
echo "done" test $? == 0 && msg_done || msg_fail
}
restart() {
stop
start
} }
case "$1" in case "$1" in
@ -47,7 +38,8 @@ case "$1" in
;; ;;
restart) restart)
restart stop
start
;; ;;
*) *)

View File

@ -67,7 +67,7 @@ function stop() {
sleep 1 sleep 1
count=$(($count + 1)) count=$(($count + 1))
done done
kill -KILL "$pid" &>/dev/null kill -KILL "$pid" &>/dev/null || true
} }
case "$1" in case "$1" in

View File

@ -1 +1 @@
dwc_otg.fiq_fix_enable=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait ro rootflags=noload dwc_otg.fiq_fix_enable=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait ro rootflags=noload panic=10 quiet loglevel=1

View File

@ -1,10 +1,12 @@
#!/bin/sh #!/bin/bash
gpio=35 gpio=35
check_interval=30 check_interval=30
export=/sys/class/gpio/export export=/sys/class/gpio/export
read=/sys/class/gpio/gpio$gpio/value read=/sys/class/gpio/gpio$gpio/value
test -n "$os_version" || source /etc/init.d/base
configure() { configure() {
echo $gpio > $export echo $gpio > $export
} }
@ -20,20 +22,20 @@ watch() {
case "$1" in case "$1" in
start) start)
echo -n "Starting brownout detector: " msg_begin "Starting brownout detector"
configure configure
test $? == 0 && msg_done || msg_fail
watch & watch &
echo "done"
;; ;;
stop) stop)
echo -n "Stopping brownout detector: " msg_begin "Stopping brownout detector"
ps | grep brownout | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill ps | grep brownout | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
echo "done" test $? == 0 && msg_done || msg_fail
;; ;;
*) *)
echo $"Usage: $0 {start|stop|restart}" echo $"Usage: $0 {start|stop}"
exit 1 exit 1
esac esac

View File

@ -1,40 +1,31 @@
#!/bin/sh #!/bin/sh
MOTIONEYE_CONF_DIR=/data/etc/ motioneye_conf_dir="/data/etc/"
test -n "$os_version" || source /etc/init.d/base
enabled() { enabled() {
if [ $(ls -1 $MOTIONEYE_CONF_DIR/thread-*.conf 2>/dev/null| wc -l) != 1 ]; then test $(ls -1 $motioneye_conf_dir/thread-*.conf 2>/dev/null| wc -l) == 1 || return 1
return 1
fi
if ! grep '# @proto mjpeg' $MOTIONEYE_CONF_DIR/thread-1.conf &>/dev/null; then grep '# @proto mjpeg' $motioneye_conf_dir/thread-1.conf &>/dev/null || return 1
return 1
fi
if ! grep -E '# @url http://(.*)127.0.0.1:' $MOTIONEYE_CONF_DIR/thread-1.conf &>/dev/null; then
return 1
fi
grep -E '# @url http://(.*)127.0.0.1:' $motioneye_conf_dir/thread-1.conf &>/dev/null || return 1
return 0 return 0
} }
enabled || exit 0 enabled || exit 0
start() { start() {
echo -n "Starting streameye: " msg_begin "Starting streameye"
streameye.sh start streameye.sh start
echo "done" test $? == 0 && msg_done || msg_fail
} }
stop() { stop() {
echo -n "Shutting down streameye: " msg_begin "Stopping streameye"
streameye.sh stop streameye.sh stop
echo "done" test $? == 0 && msg_done || msg_fail
}
restart() {
stop
start
} }
case "$1" in case "$1" in
@ -47,7 +38,8 @@ case "$1" in
;; ;;
restart) restart)
restart stop
start
;; ;;
*) *)

View File

@ -67,7 +67,7 @@ function stop() {
sleep 1 sleep 1
count=$(($count + 1)) count=$(($count + 1))
done done
kill -KILL "$pid" &>/dev/null kill -KILL "$pid" &>/dev/null || true
} }
case "$1" in case "$1" in

View File

@ -142,15 +142,13 @@ def _set_os_settings(s):
line = line.strip() line = line.strip()
if not line: if not line:
continue continue
try: try:
name, _ = line.split(' ', 2) name, _ = line.split('=', 2)
except: except:
continue continue
name = name.replace('_', '-')
if name == 'os_prereleases': if name == 'os_prereleases':
lines[i] = 'os_prereleases="%s"' % str(s.pop('prereleases')).lower() lines[i] = 'os_prereleases="%s"' % str(s.pop('prereleases')).lower()
@ -217,7 +215,7 @@ def _set_motioneye_settings(s):
s = dict(s) s = dict(s)
s.setdefault('port', 80) s.setdefault('port', 80)
s.setdefault('motionBinary', '/usr/bin/motion') s.setdefault('motionBinary', '/usr/bin/motion')
s.setdefault('debug', False) debug = s.setdefault('debug', False) # value needed later
s.setdefault('motion_keep_alive', False) s.setdefault('motion_keep_alive', False)
logging.debug('writing motioneye settings to %s: ' % MOTIONEYE_CONF + logging.debug('writing motioneye settings to %s: ' % MOTIONEYE_CONF +
@ -274,11 +272,11 @@ def _set_motioneye_settings(s):
f.write(line) f.write(line)
# also update debug in os.conf # also update debug in os.conf
if s['debug']: if debug:
cmd = "sed -r 's/os_debug=\"?false\"?/os_debug=\"true\"/' %s" % OS_CONF cmd = "sed -i -r 's/os_debug=\"?false\"?/os_debug=\"true\"/' %s" % OS_CONF
else: else:
cmd = "sed -r 's/os_debug=\"?true\"?/os_debug=\"false\"/' %s" % OS_CONF cmd = "sed -i -r 's/os_debug=\"?true\"?/os_debug=\"false\"/' %s" % OS_CONF
if os.system(cmd): if os.system(cmd):
logging.error('failed to set debug flag in os.conf') logging.error('failed to set debug flag in os.conf')
@ -468,8 +466,8 @@ def prereleases():
'type': 'bool', 'type': 'bool',
'section': 'expertSettings', 'section': 'expertSettings',
'advanced': True, 'advanced': True,
'get': _get_motioneye_settings, 'get': _get_os_settings,
'set': _set_motioneye_settings, 'set': _set_os_settings,
'get_set_dict': True 'get_set_dict': True
} }

View File

@ -43,7 +43,7 @@ define MOTIONEYE_INSTALL_TARGET_CMDS
echo " 'motioneye': ('/var/log/motioneye.log', 'motioneye.log')," >> /tmp/handlers.py.new; \ echo " 'motioneye': ('/var/log/motioneye.log', 'motioneye.log')," >> /tmp/handlers.py.new; \
echo " 'messages': ('/var/log/messages', 'messages.log')," >> /tmp/handlers.py.new; \ echo " 'messages': ('/var/log/messages', 'messages.log')," >> /tmp/handlers.py.new; \
echo " 'boot': ('/var/log/boot.log', 'boot.log')," >> /tmp/handlers.py.new; \ echo " 'boot': ('/var/log/boot.log', 'boot.log')," >> /tmp/handlers.py.new; \
echo " 'dmesg': ('dmesg', 'dmesg.log')," >> /tmp/handlers.py.new; \ echo " 'dmesg': ('dmesg -T', 'dmesg.log')," >> /tmp/handlers.py.new; \
tail -n +$$(($$lineno + 2)) $(DST_DIR)/handlers.py >> /tmp/handlers.py.new; \ tail -n +$$(($$lineno + 2)) $(DST_DIR)/handlers.py >> /tmp/handlers.py.new; \
mv /tmp/handlers.py.new $(DST_DIR)/handlers.py; \ mv /tmp/handlers.py.new $(DST_DIR)/handlers.py; \
fi fi