removed various motioneye-specific files

This commit is contained in:
Calin Crisan 2017-02-18 20:59:30 +02:00
parent c27276deb6
commit c4a0ea3a8b
32 changed files with 13 additions and 5149 deletions

View File

@ -176,7 +176,7 @@ rm -f $TARGET/usr/share/perl5
rm -rf $TARGET/usr/lib/python2.7/site-packages/samba/ rm -rf $TARGET/usr/lib/python2.7/site-packages/samba/
rm -rf $TARGET/usr/lib/python2.7/ensurepip/ rm -rf $TARGET/usr/lib/python2.7/ensurepip/
# startup scripts # buildroot default startup scripts
rm -f $TARGET/etc/init.d/S01logging rm -f $TARGET/etc/init.d/S01logging
rm -f $TARGET/etc/init.d/S10udev rm -f $TARGET/etc/init.d/S10udev
rm -f $TARGET/etc/init.d/S15watchdog rm -f $TARGET/etc/init.d/S15watchdog

View File

@ -34,6 +34,7 @@ ROOT_IMG=$IMG_DIR/root.img
ROOT_SIZE="180" # MB ROOT_SIZE="180" # MB
DISK_SIZE="220" # MB DISK_SIZE="220" # MB
OS_NAME=$(source $IMG_DIR/../../../board/common/overlay/etc/version && echo $os_short_name)
# boot filesystem # boot filesystem
msg "creating boot loop device" msg "creating boot loop device"
@ -163,8 +164,8 @@ msg "destroying root loop device"
losetup -d $loop_dev losetup -d $loop_dev
sync sync
mv $DISK_IMG $(dirname $DISK_IMG)/motioneyeos-$BOARD.img mv $DISK_IMG $(dirname $DISK_IMG)/$OS_NAME-$BOARD.img
DISK_IMG=$(dirname $DISK_IMG)/motioneyeos-$BOARD.img DISK_IMG=$(dirname $DISK_IMG)/$OS_NAME-$BOARD.img
msg "$(realpath "$DISK_IMG") is ready" msg "$(realpath "$DISK_IMG") is ready"

View File

@ -6,6 +6,4 @@ tmpfs /tmp tmpfs mode=1777 0 0
sysfs /sys sysfs defaults 0 0 sysfs /sys sysfs defaults 0 0
/dev/mmcblk0p1 /boot vfat ro,defaults 0 0 /dev/mmcblk0p1 /boot vfat ro,defaults 0 0
/dev/mmcblk0p3 /data ext4 defaults,noatime 0 0 /dev/mmcblk0p3 /data ext4 defaults,noatime 0 0
/data/output /home/ftp/sdcard rbind rbind 0 0
/data/media /home/ftp/storage rbind rbind 0 0

View File

@ -1,45 +0,0 @@
#!/bin/bash
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
test "$os_networkless" == "true" && exit 0
start() {
msg_begin "Starting proftpd"
mkdir -p /var/run/proftpd
touch /var/log/wtmp
/usr/sbin/proftpd &>/dev/null
test $? == 0 && msg_done || msg_fail
}
stop() {
msg_begin "Stopping proftpd"
killall proftpd &>/dev/null
test $? == 0 && msg_done || msg_fail
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0

View File

@ -1,59 +0,0 @@
#!/bin/bash
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
test "$os_networkless" == "true" && exit 0
start() {
msg_begin "Setting smb admin password"
mkdir -p /var/log/samba
mkdir -p /var/lib/samba/private
password=$(/etc/init.d/adminpw)
echo -e "$password\n$password\n" | /usr/bin/smbpasswd -a admin -s > /dev/null
test $? == 0 && msg_done || msg_fail
msg_begin "Starting smbd"
smbd -D
test $? == 0 && msg_done || msg_fail
msg_begin "Starting nmbd"
nmbd -D
test $? == 0 && msg_done || msg_fail
}
stop() {
msg_begin "Stopping smbd"
killall smbd &>/dev/null
test $? == 0 && msg_done || msg_fail
msg_begin "Stopping nmbd"
killall nmbd &>/dev/null
test $? == 0 && msg_done || msg_fail
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?

View File

@ -1,149 +0,0 @@
#!/bin/bash
sys_conf="/etc/motioneye.conf"
boot_conf="/boot/motioneye.conf"
conf="/data/etc/motioneye.conf"
motion_conf="/data/etc/motion.conf"
watch_conf="/data/etc/watch.conf"
meyewatch_timeout=120
meyewatch_disable="false"
dev_v4l_by_id="/dev/v4l/by-id/"
media_dir="/data/output"
if ! [ -f $conf ]; then
if [ -f $boot_conf ]; then
cp $boor_conf $conf
elif [ -f $sys_conf ]; then
cp $sys_conf $conf
fi
fi
test -f "$conf" || exit 0
test -r $watch_conf && source $watch_conf
test -n "$os_version" || source /etc/init.d/base
opts=$(cat "$conf" | while read line; do echo "--$line"; done)
port=$(echo "$opts" | grep -oE 'port [[:digit:]]+' | cut -d ' ' -f 2)
responsive() {
wget --method=HEAD -q -t 1 -T 2 -O - http://127.0.0.1:$port &>/dev/null && return 0 || return 1
}
watch() {
count=0
while true; do
sleep 5
if responsive; then
count=0
else
if [ $count -lt $meyewatch_timeout ]; then
count=$(($count + 5))
else
logger -t motioneye -s "not responding for $meyewatch_timeout seconds, rebooting"
reboot
fi
fi
done
}
find_persistent_device() {
device=$1
if ! [ -d $dev_v4l_by_id ]; then
echo $device
return
fi
for p in $dev_v4l_by_id/*; do
if [ $(realpath "$p") == $device ]; then
echo $p | sed 's#//*#/#g'
return
fi
done
echo $device
}
start() {
msg_begin "Starting motioneye"
mkdir -p $media_dir
meyectl startserver -b -c $conf -l
count=0
while true; do
sleep 1
if responsive; then
break
fi
if [ $count -gt $meyewatch_timeout ]; then
msg_fail
test "$meyewatch_disable" == "false" && reboot
return 1
fi
count=$(($count + 1))
done
# add connected camera(s) with default settings
if responsive && ! [ -f $motion_conf ]; then
count=$(ls /dev/video* 2>/dev/null | wc -l)
index=1
for device in $(ls /dev/video* 2>/dev/null); do
if [ "$count" -gt "1" ]; then
output_dir="/data/output/camera$index/"
else
output_dir="/data/output/"
fi
loc="/config/add/?_username=admin"
device=$(find_persistent_device $device)
body="{\"path\": \"$device\", \"proto\": \"v4l2\"}"
signature=$(echo -n "POST:$loc:$body:" | sha1sum | cut -d ' ' -f 1)
curl -s -m 60 --data "$body" "http://127.0.0.1:$port$loc&_signature=$signature" > /dev/null
index=$(($index + 1))
done
sync
fi
if [ "$meyewatch_disable" == "false" ]; then
watch &
fi
msg_done
}
stop() {
msg_begin "Stopping motioneye"
meyectl stopserver -c $conf &>/dev/null
test $? == 0 && msg_done || msg_fail
ps | grep motioneye | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?

View File

@ -5,7 +5,3 @@ options rndis_wlan power_save=0
options b43 hwpctl=0 options b43 hwpctl=0
options ath6kl_core suspend_mode=1 options ath6kl_core suspend_mode=1
options brcmfmac roamoff=1 options brcmfmac roamoff=1
# media
options stk1160 keep_buffers=1

View File

@ -1,24 +0,0 @@
conf_path /data/etc
run_path /tmp
log_path /var/log
media_path /data/output
motion_binary /usr/bin/motion
log_level info
listen 0.0.0.0
port 80
mount_check_interval 300
motion_check_interval 10
cleanup_interval 43200
remote_request_timeout 10
mjpg_client_timeout 10
mjpg_client_idle_timeout 10
smb_shares true
smb_mount_root /data/media
wpa_supplicant_conf /data/etc/wpa_supplicant.conf
local_time_file /data/etc/localtime
enable_reboot true
enable_update true
smtp_timeout 60
zip_timeout 500
add_remove_cameras true

View File

@ -6,9 +6,7 @@ os_wlan="wlan0"
os_ppp="ppp0" os_ppp="ppp0"
os_networkless="false" os_networkless="false"
os_country="GB" os_country="GB"
os_firmware_method="github" os_firmware_method="github"
os_firmware_repo="ccrisan/motioneyeos" os_firmware_repo="ccrisan/thingos"
os_firmware_username="" os_firmware_username=""
os_firmware_password="" os_firmware_password=""

View File

@ -1,25 +0,0 @@
ServerIdent off
ServerType standalone
DefaultServer on
Port 21
UseIPv6 off
Umask 022
MaxInstances 4
User ftp
Group nogroup
DefaultRoot /home/ftp
AllowOverwrite on
RequireValidShell off
UseFtpUsers off
RootLogin on
<Limit SITE_CHMOD>
DenyAll
</Limit>
<Limit WRITE>
DenyAll
</Limit>
Include /data/etc/proftpd*.conf

View File

@ -1,31 +0,0 @@
[global]
workgroup = MOTIONEYE
server string = motionEye
security = user
map to guest = bad user
encrypt passwords = yes
private dir = /var/lib/samba/private
public = no
writable = no
include = /data/etc/smb.conf
load printers = no
printing = bsd
printcap name = /dev/null
disable spoolss = yes
bind interfaces only = yes
interfaces = eth0 wlan0
log level = 0
syslog = 0
preferred master = no
domain master = no
local master = no
os level = 0
[sdcard]
comment = SD Card Output Directory
path = /data/output
[storage]
comment = Attached Storage Devices
path = /data/media

View File

@ -1,7 +0,0 @@
#!/bin/bash
# option "thumbnailer_interval" has been removed from motionEye config
grep -v 'thumbnailer_interval' /data/etc/motioneye.conf > /tmp/motioneye.conf
mv /tmp/motioneye.conf /data/etc/

View File

@ -5,4 +5,7 @@ os_eth="eth0"
os_wlan="wlan0" os_wlan="wlan0"
os_ppp="ppp0" os_ppp="ppp0"
os_networkless="false" os_networkless="false"
os_firmware_method="github"
os_firmware_repo="ccrisan/thingos"
os_firmware_username=""
os_firmware_password=""

View File

@ -5,4 +5,7 @@ os_eth="eth0"
os_wlan="wlan0" os_wlan="wlan0"
os_ppp="ppp0" os_ppp="ppp0"
os_networkless="false" os_networkless="false"
os_firmware_method="github"
os_firmware_repo="ccrisan/thingos"
os_firmware_username=""
os_firmware_password=""

View File

@ -1,310 +0,0 @@
# Copyright (c) 2015 Calin Crisan
# This file is part of motionEyeOS.
#
# motionEyeOS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import os.path
import subprocess
from config import additional_config
import streameyectl
CONFIG_TXT = '/boot/config.txt'
MONITOR = '/data/etc/monitor_1'
MONITOR_SCRIPT = '''#!/bin/bash
net_tmp=/tmp/netspeed.tmp
temp=$(($(cat /sys/devices/virtual/thermal/thermal_zone0/temp) / 1000))
load=$(cat /proc/loadavg | cut -d ' ' -f 2)
recv=$(cat /proc/net/dev | grep -v 'lo:' | tr -s ' ' | cut -d ' ' -f 3 | tail -n +3 | awk '{s+=$1} END {print s}')
send=$(cat /proc/net/dev | grep -v 'lo:' | tr -s ' ' | cut -d ' ' -f 11 | tail -n +3 | awk '{s+=$1} END {print s}')
total=$(($recv + $send))
if [ -e $net_tmp ]; then
prev_total=$(cat $net_tmp)
speed=$(($total - $prev_total))
else
speed=0
fi
echo $total > $net_tmp
speed=$(($speed / 1024))
echo -n "$temp&deg;|$load|${speed}kB/s"
'''
OVERCLOCK = {
700: '700|250|400|0',
800: '800|250|400|0',
900: '900|250|450|0',
950: '950|250|450|0',
1000: '1000|500|600|6',
1001: '1001|300|450|6'
}
def _is_pi_zero():
try:
subprocess.check_call('grep -q "^Revision\s*:\s*[ 123][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]09[0-9a-fA-F]$" /proc/cpuinfo', shell=True)
return True
except:
return False
def _get_board_settings():
gpu_mem = 128
camera_led = True
if _is_pi_zero():
arm_freq = 1001
else:
arm_freq = 700
if os.path.exists(CONFIG_TXT):
logging.debug('reading board settings from %s' % CONFIG_TXT)
with open(CONFIG_TXT) as f:
for line in f:
line = line.strip()
if not line or line.startswith('#'):
continue
parts = line.split('=', 1)
if len(parts) != 2:
continue
name, value = parts
name = name.strip()
value = value.strip()
if name.startswith('gpu_mem'):
gpu_mem = int(value)
elif name == 'arm_freq':
arm_freq = int(value)
elif name == 'disable_camera_led':
camera_led = value == '0'
overclock = OVERCLOCK.get(arm_freq, '700|250|400|0')
s = {
'gpuMem': gpu_mem,
'overclock': overclock,
'cameraLed': camera_led
}
logging.debug('board settings: gpu_mem=%(gpuMem)s, overclock=%(overclock)s, camera_led=%(cameraLed)s' % s)
return s
def _set_board_settings(s):
s.setdefault('gpuMem', 128)
s.setdefault('overclock', '700|250|400|0')
s.setdefault('cameraLed', True)
old_settings = _get_board_settings()
if s == old_settings:
return # nothing has changed
seen = set()
logging.debug('writing board settings to %s: ' % CONFIG_TXT +
'gpu_mem=%(gpuMem)s, overclock=%(overclock)s, camera_led=%(cameraLed)s' % s)
arm_freq, gpu_freq, sdram_freq, over_voltage = s['overclock'].split('|')
lines = []
if os.path.exists(CONFIG_TXT):
with open(CONFIG_TXT) as f:
lines = f.readlines()
for i, line in enumerate(lines):
line = line.strip()
if not line:
continue
line = line.strip('#')
try:
name, _ = line.split('=', 1)
name = name.strip()
except:
continue
seen.add(name)
if name.startswith('gpu_mem'):
lines[i] = '%s=%s' % (name, s['gpuMem'])
elif name == 'arm_freq':
lines[i] = 'arm_freq=%s' % arm_freq
elif name in ['gpu_freq', 'core_freq']:
lines[i] = '%s=%s' % (name, gpu_freq)
elif name == 'sdram_freq':
lines[i] = 'sdram_freq=%s' % sdram_freq
elif name == 'over_voltage':
lines[i] = 'over_voltage=%s' % over_voltage
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 'gpu_mem_256' not in seen:
lines.append('gpu_mem_256=%s' % s['gpuMem'])
if 'gpu_mem_512' not in seen:
lines.append('gpu_mem_512=%s' % s['gpuMem'])
if 'arm_freq' not in seen:
lines.append('arm_freq=%s' % arm_freq)
if 'gpu_freq' not in seen:
lines.append('gpu_freq=%s' % gpu_freq)
if 'sdram_freq' not in seen:
lines.append('sdram_freq=%s' % sdram_freq)
if 'over_voltage' not in seen:
lines.append('over_voltage=%s' % over_voltage)
if 'disable_camera_led' not in seen:
lines.append('disable_camera_led=%s' % ['1', '0'][s['cameraLed']])
logging.debug('remounting /boot read-write')
if os.system('mount -o remount,rw /boot'):
logging.error('failed to remount /boot read-write')
with open(CONFIG_TXT, 'w') as f:
for line in lines:
if not line.strip():
continue
if not line.endswith('\n'):
line += '\n'
f.write(line)
def _get_sys_mon():
return os.access(MONITOR, os.X_OK)
def _set_sys_mon(sys_mon):
if sys_mon:
if os.access(MONITOR, os.X_OK):
pass
else:
if os.path.exists(MONITOR):
os.system('chmod +x %s' % MONITOR)
else:
with open(MONITOR, 'w') as f:
f.write(MONITOR_SCRIPT)
os.system('chmod +x %s' % MONITOR)
else:
if os.access(MONITOR, os.X_OK):
os.system('chmod -x %s' % MONITOR)
@additional_config
def boardSeparator():
return {
'type': 'separator',
'section': 'expertSettings',
'advanced': True
}
@additional_config
def gpuMem():
return {
'label': 'GPU Memory',
'description': 'set the amount of memory reserved for the GPU (choose at least 96MB if you use the CSI camera board)',
'type': 'number',
'min': '16',
'max': '448',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_board_settings,
'set': _set_board_settings,
'get_set_dict': True
}
@additional_config
def cameraLed():
return {
'label': 'Enable CSI Camera Led',
'description': 'control the led on the CSI camera board',
'type': 'bool',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_board_settings,
'set': _set_board_settings,
'get_set_dict': True
}
@additional_config
def overclock():
return {
'label': 'Overclocking',
'description': 'choose an overclocking preset for your Raspberry PI',
'type': 'choices',
'choices': [
('700|250|400|0', 'none (700/250/400/0)'),
('800|250|400|0', 'modest (800/250/400/0)'),
('900|250|450|0', 'medium (900/250/450/0)'),
('950|250|450|0', 'high (950/250/450/0)'),
('1000|500|600|6', 'turbo (1000/500/600/6)'),
('1001|300|450|6', 'PiZero (1000/300/450/6)'),
],
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_board_settings,
'set': _set_board_settings,
'get_set_dict': True
}
@additional_config
def sysMon():
return {
'label': 'Enable System Monitoring',
'description': 'when this is enabled, system monitoring info will be overlaid on top of the first camera frame',
'type': 'bool',
'section': 'expertSettings',
'advanced': True,
'reboot': False,
'get': _get_sys_mon,
'set': _set_sys_mon
}

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +0,0 @@
#!/bin/sh
motioneye_conf_dir="/data/etc/"
test -n "$os_version" || source /etc/init.d/base
enabled() {
test $(ls -1 $motioneye_conf_dir/thread-*.conf 2>/dev/null| wc -l) == 1 || return 1
grep '# @proto mjpeg' $motioneye_conf_dir/thread-1.conf &>/dev/null || return 1
grep -E '# @url http://(.*)127.0.0.1:' $motioneye_conf_dir/thread-1.conf &>/dev/null || return 1
return 0
}
enabled || exit 0
start() {
msg_begin "Starting streameye"
streameye.sh start
test $? == 0 && msg_done || msg_fail
}
stop() {
msg_begin "Stopping streameye"
streameye.sh stop
test $? == 0 && msg_done || msg_fail
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?

View File

@ -1,3 +0,0 @@
bcm2835-v4l2 max_video_width=2592 max_video_height=1944
bcm2835-wdt

View File

@ -1,93 +0,0 @@
#!/bin/bash
RASPIMJPEG_CONF=/data/etc/raspimjpeg.conf
RASPIMJPEG_LOG=/var/log/raspimjpeg.log
MOTIONEYE_CONF=/data/etc/motioneye.conf
STREAMEYE_CONF=/data/etc/streameye.conf
STREAMEYE_LOG=/var/log/streameye.log
test -r $RASPIMJPEG_CONF || exit 1
test -r $STREAMEYE_CONF || exit 1
watch() {
count=0
while true; do
sleep 5
if ! ps aux | grep raspimjpeg.py | grep -v grep &>/dev/null; then
logger -t streameye -s "not running, respawning"
start
fi
done
}
function start() {
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -n "$pid" ]; then
return
fi
raspimjpeg_opts=""
while read line; do
if echo "$line" | grep false &>/dev/null; then
continue
fi
if echo "$line" | grep true &>/dev/null; then
line=$(echo $line | cut -d ' ' -f 1)
fi
raspimjpeg_opts="$raspimjpeg_opts --$line"
done < $RASPIMJPEG_CONF
source $STREAMEYE_CONF
streameye_opts="-p $PORT"
if [ -n "$CREDENTIALS" ] && [ "$AUTH" = "basic" ]; then
streameye_opts="$streameye_opts -a basic -c $CREDENTIALS"
fi
if [ -r $MOTIONEYE_CONF ] && grep 'log-level debug' $MOTIONEYE_CONF >/dev/null; then
raspimjpeg_opts="$raspimjpeg_opts -d"
streameye_opts="$streameye_opts -d"
fi
raspimjpeg.py $raspimjpeg_opts 2>$RASPIMJPEG_LOG | streameye $streameye_opts &>$STREAMEYE_LOG &
}
function stop() {
# stop the streameye background watch process
ps | grep streameye.sh | grep -v $$ | grep -v S94streameye| grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
# stop the raspimjpeg process
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -z "$pid" ]; then
return
fi
kill -HUP "$pid" &>/dev/null
count=0
while kill -0 "$pid" &>/dev/null && [ $count -lt 5 ]; do
sleep 1
count=$(($count + 1))
done
kill -KILL "$pid" &>/dev/null || true
}
case "$1" in
start)
start
watch &
;;
stop)
stop
;;
restart)
stop
start
watch &
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac

View File

@ -1,290 +0,0 @@
# Copyright (c) 2015 Calin Crisan
# This file is part of motionEyeOS.
#
# motionEyeOS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import os.path
from config import additional_config
import streameyectl
CONFIG_TXT = '/boot/config.txt'
MONITOR = '/data/etc/monitor_1'
MONITOR_SCRIPT = '''#!/bin/bash
net_tmp=/tmp/netspeed.tmp
temp=$(($(cat /sys/devices/virtual/thermal/thermal_zone0/temp) / 1000))
load=$(cat /proc/loadavg | cut -d ' ' -f 2)
recv=$(cat /proc/net/dev | grep -v 'lo:' | tr -s ' ' | cut -d ' ' -f 3 | tail -n +3 | awk '{s+=$1} END {print s}')
send=$(cat /proc/net/dev | grep -v 'lo:' | tr -s ' ' | cut -d ' ' -f 11 | tail -n +3 | awk '{s+=$1} END {print s}')
total=$(($recv + $send))
if [ -e $net_tmp ]; then
prev_total=$(cat $net_tmp)
speed=$(($total - $prev_total))
else
speed=0
fi
echo $total > $net_tmp
speed=$(($speed / 1024))
echo -n "$temp&deg;|$load|${speed}kB/s"
'''
OVERCLOCK = {
700: '700|250|400|0',
800: '800|250|400|0',
900: '900|250|450|0',
950: '950|250|450|0',
1000: '1000|500|600|6',
1001: '1001|500|500|2'
}
def _get_board_settings():
gpu_mem = 128
camera_led = True
arm_freq = 1001
if os.path.exists(CONFIG_TXT):
logging.debug('reading board settings from %s' % CONFIG_TXT)
with open(CONFIG_TXT) as f:
for line in f:
line = line.strip()
if not line or line.startswith('#'):
continue
parts = line.split('=', 1)
if len(parts) != 2:
continue
name, value = parts
name = name.strip()
value = value.strip()
if name == 'gpu_mem':
gpu_mem = int(value)
elif name == 'arm_freq':
arm_freq = int(value)
elif name == 'disable_camera_led':
camera_led = value == '0'
overclock = OVERCLOCK.get(arm_freq, '700|250|400|0')
s = {
'gpuMem': gpu_mem,
'overclock': overclock,
'cameraLed': camera_led
}
logging.debug('board settings: gpu_mem=%(gpuMem)s, overclock=%(overclock)s, camera_led=%(cameraLed)s' % s)
return s
def _set_board_settings(s):
s.setdefault('gpuMem', 128)
s.setdefault('overclock', '700|250|400|0')
s.setdefault('cameraLed', True)
old_settings = _get_board_settings()
if s == old_settings:
return # nothing has changed
seen = set()
logging.debug('writing board settings to %s: ' % CONFIG_TXT +
'gpu_mem=%(gpuMem)s, overclock=%(overclock)s, camera_led=%(cameraLed)s' % s)
arm_freq, gpu_freq, sdram_freq, over_voltage = s['overclock'].split('|')
lines = []
if os.path.exists(CONFIG_TXT):
with open(CONFIG_TXT) as f:
lines = f.readlines()
for i, line in enumerate(lines):
line = line.strip()
if not line:
continue
line = line.strip('#')
try:
name, _ = line.split('=', 1)
name = name.strip()
except:
continue
seen.add(name)
if name == 'gpu_mem':
lines[i] = '%s=%s' % (name, s['gpuMem'])
elif name == 'arm_freq':
lines[i] = 'arm_freq=%s' % arm_freq
elif name in ['gpu_freq', 'core_freq']:
lines[i] = '%s=%s' % (name, gpu_freq)
elif name == 'sdram_freq':
lines[i] = 'sdram_freq=%s' % sdram_freq
elif name == 'over_voltage':
lines[i] = 'over_voltage=%s' % over_voltage
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 'arm_freq' not in seen:
lines.append('arm_freq=%s' % arm_freq)
if 'gpu_freq' not in seen:
lines.append('gpu_freq=%s' % gpu_freq)
if 'sdram_freq' not in seen:
lines.append('sdram_freq=%s' % sdram_freq)
if 'over_voltage' not in seen:
lines.append('over_voltage=%s' % over_voltage)
if 'disable_camera_led' not in seen:
lines.append('disable_camera_led=%s' % ['1', '0'][s['cameraLed']])
logging.debug('remounting /boot read-write')
if os.system('mount -o remount,rw /boot'):
logging.error('failed to remount /boot read-write')
with open(CONFIG_TXT, 'w') as f:
for line in lines:
if not line.strip():
continue
if not line.endswith('\n'):
line += '\n'
f.write(line)
def _get_sys_mon():
return os.access(MONITOR, os.X_OK)
def _set_sys_mon(sys_mon):
if sys_mon:
if os.access(MONITOR, os.X_OK):
pass
else:
if os.path.exists(MONITOR):
os.system('chmod +x %s' % MONITOR)
else:
with open(MONITOR, 'w') as f:
f.write(MONITOR_SCRIPT)
os.system('chmod +x %s' % MONITOR)
else:
if os.access(MONITOR, os.X_OK):
os.system('chmod -x %s' % MONITOR)
@additional_config
def boardSeparator():
return {
'type': 'separator',
'section': 'expertSettings',
'advanced': True
}
@additional_config
def gpuMem():
return {
'label': 'GPU Memory',
'description': 'set the amount of memory reserved for the GPU (choose at least 96MB if you use the CSI camera board)',
'type': 'number',
'min': '16',
'max': '944',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_board_settings,
'set': _set_board_settings,
'get_set_dict': True
}
@additional_config
def cameraLed():
return {
'label': 'Enable CSI Camera Led',
'description': 'control the led on the CSI camera board',
'type': 'bool',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_board_settings,
'set': _set_board_settings,
'get_set_dict': True
}
@additional_config
def overclock():
return {
'label': 'Overclocking',
'description': 'choose an overclocking preset for your Raspberry PI',
'type': 'choices',
'choices': [
('700|250|400|0', 'none (700/250/400/0)'),
('800|250|400|0', 'modest (800/250/400/0)'),
('900|250|450|0', 'medium (900/250/450/0)'),
('950|250|450|0', 'high (950/250/450/0)'),
('1000|500|600|6', 'turbo (1000/500/600/6)'),
('1001|500|500|2', 'Pi2 (1000/500/500/2)')
],
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_board_settings,
'set': _set_board_settings,
'get_set_dict': True
}
@additional_config
def sysMon():
return {
'label': 'Enable System Monitoring',
'description': 'when this is enabled, system monitoring info will be overlaid on top of the first camera frame',
'type': 'bool',
'section': 'expertSettings',
'advanced': True,
'reboot': False,
'get': _get_sys_mon,
'set': _set_sys_mon
}

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +0,0 @@
#!/bin/sh
motioneye_conf_dir="/data/etc/"
test -n "$os_version" || source /etc/init.d/base
enabled() {
test $(ls -1 $motioneye_conf_dir/thread-*.conf 2>/dev/null| wc -l) == 1 || return 1
grep '# @proto mjpeg' $motioneye_conf_dir/thread-1.conf &>/dev/null || return 1
grep -E '# @url http://(.*)127.0.0.1:' $motioneye_conf_dir/thread-1.conf &>/dev/null || return 1
return 0
}
enabled || exit 0
start() {
msg_begin "Starting streameye"
streameye.sh start
test $? == 0 && msg_done || msg_fail
}
stop() {
msg_begin "Stopping streameye"
streameye.sh stop
test $? == 0 && msg_done || msg_fail
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?

View File

@ -1,3 +0,0 @@
bcm2835-v4l2 max_video_width=2592 max_video_height=1944
bcm2835-wdt

View File

@ -1,93 +0,0 @@
#!/bin/bash
RASPIMJPEG_CONF=/data/etc/raspimjpeg.conf
RASPIMJPEG_LOG=/var/log/raspimjpeg.log
MOTIONEYE_CONF=/data/etc/motioneye.conf
STREAMEYE_CONF=/data/etc/streameye.conf
STREAMEYE_LOG=/var/log/streameye.log
test -r $RASPIMJPEG_CONF || exit 1
test -r $STREAMEYE_CONF || exit 1
watch() {
count=0
while true; do
sleep 5
if ! ps aux | grep raspimjpeg.py | grep -v grep &>/dev/null; then
logger -t streameye -s "not running, respawning"
start
fi
done
}
function start() {
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -n "$pid" ]; then
return
fi
raspimjpeg_opts=""
while read line; do
if echo "$line" | grep false &>/dev/null; then
continue
fi
if echo "$line" | grep true &>/dev/null; then
line=$(echo $line | cut -d ' ' -f 1)
fi
raspimjpeg_opts="$raspimjpeg_opts --$line"
done < $RASPIMJPEG_CONF
source $STREAMEYE_CONF
streameye_opts="-p $PORT"
if [ -n "$CREDENTIALS" ] && [ "$AUTH" = "basic" ]; then
streameye_opts="$streameye_opts -a basic -c $CREDENTIALS"
fi
if [ -r $MOTIONEYE_CONF ] && grep 'log-level debug' $MOTIONEYE_CONF >/dev/null; then
raspimjpeg_opts="$raspimjpeg_opts -d"
streameye_opts="$streameye_opts -d"
fi
raspimjpeg.py $raspimjpeg_opts 2>$RASPIMJPEG_LOG | streameye $streameye_opts &>$STREAMEYE_LOG &
}
function stop() {
# stop the streameye background watch process
ps | grep streameye.sh | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
# stop the raspimjpeg process
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -z "$pid" ]; then
return
fi
kill -HUP "$pid" &>/dev/null
count=0
while kill -0 "$pid" &>/dev/null && [ $count -lt 5 ]; do
sleep 1
count=$(($count + 1))
done
kill -KILL "$pid" &>/dev/null || true
}
case "$1" in
start)
start
watch &
;;
stop)
stop
;;
restart)
stop
start
watch &
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac

View File

@ -1,238 +0,0 @@
# Copyright (c) 2015 Calin Crisan
# This file is part of motionEyeOS.
#
# motionEyeOS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import os.path
from config import additional_config
import streameyectl
CONFIG_TXT = '/boot/config.txt'
MONITOR = '/data/etc/monitor_1'
MONITOR_SCRIPT = '''#!/bin/bash
net_tmp=/tmp/netspeed.tmp
temp=$(($(cat /sys/devices/virtual/thermal/thermal_zone0/temp) / 1000))
load=$(cat /proc/loadavg | cut -d ' ' -f 2)
recv=$(cat /proc/net/dev | grep -v 'lo:' | tr -s ' ' | cut -d ' ' -f 3 | tail -n +3 | awk '{s+=$1} END {print s}')
send=$(cat /proc/net/dev | grep -v 'lo:' | tr -s ' ' | cut -d ' ' -f 11 | tail -n +3 | awk '{s+=$1} END {print s}')
total=$(($recv + $send))
if [ -e $net_tmp ]; then
prev_total=$(cat $net_tmp)
speed=$(($total - $prev_total))
else
speed=0
fi
echo $total > $net_tmp
speed=$(($speed / 1024))
echo -n "$temp&deg;|$load|${speed}kB/s"
'''
OVERCLOCK = {
700: '700|250|400|0',
800: '800|250|400|0',
900: '900|250|450|0',
950: '950|250|450|0',
1000: '1000|500|600|6',
1001: '1001|500|500|2'
}
def _get_board_settings():
gpu_mem = 128
camera_led = True
arm_freq = 700
if os.path.exists(CONFIG_TXT):
logging.debug('reading board settings from %s' % CONFIG_TXT)
with open(CONFIG_TXT) as f:
for line in f:
line = line.strip()
if not line or line.startswith('#'):
continue
parts = line.split('=', 1)
if len(parts) != 2:
continue
name, value = parts
name = name.strip()
value = value.strip()
if name == 'gpu_mem':
gpu_mem = int(value)
elif name == 'arm_freq':
arm_freq = int(value)
elif name == 'disable_camera_led':
camera_led = value == '0'
s = {
'gpuMem': gpu_mem,
'cameraLed': camera_led
}
logging.debug('board settings: gpu_mem=%(gpuMem)s, camera_led=%(cameraLed)s' % s)
return s
def _set_board_settings(s):
s.setdefault('gpuMem', 128)
s.setdefault('cameraLed', True)
old_settings = _get_board_settings()
if s == old_settings:
return # nothing has changed
seen = set()
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):
with open(CONFIG_TXT) as f:
lines = f.readlines()
for i, line in enumerate(lines):
line = line.strip()
if not line:
continue
line = line.strip('#')
try:
name, _ = line.split('=', 1)
name = name.strip()
except:
continue
seen.add(name)
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']])
logging.debug('remounting /boot read-write')
if os.system('mount -o remount,rw /boot'):
logging.error('failed to remount /boot read-write')
with open(CONFIG_TXT, 'w') as f:
for line in lines:
if not line.strip():
continue
if not line.endswith('\n'):
line += '\n'
f.write(line)
def _get_sys_mon():
return os.access(MONITOR, os.X_OK)
def _set_sys_mon(sys_mon):
if sys_mon:
if os.access(MONITOR, os.X_OK):
pass
else:
if os.path.exists(MONITOR):
os.system('chmod +x %s' % MONITOR)
else:
with open(MONITOR, 'w') as f:
f.write(MONITOR_SCRIPT)
os.system('chmod +x %s' % MONITOR)
else:
if os.access(MONITOR, os.X_OK):
os.system('chmod -x %s' % MONITOR)
@additional_config
def boardSeparator():
return {
'type': 'separator',
'section': 'expertSettings',
'advanced': True
}
@additional_config
def gpuMem():
return {
'label': 'GPU Memory',
'description': 'set the amount of memory reserved for the GPU (choose at least 96MB if you use the CSI camera board)',
'type': 'number',
'min': '16',
'max': '944',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_board_settings,
'set': _set_board_settings,
'get_set_dict': True
}
@additional_config
def cameraLed():
return {
'label': 'Enable CSI Camera Led',
'description': 'control the led on the CSI camera board',
'type': 'bool',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_board_settings,
'set': _set_board_settings,
'get_set_dict': True
}
@additional_config
def sysMon():
return {
'label': 'Enable System Monitoring',
'description': 'when this is enabled, system monitoring info will be overlaid on top of the first camera frame',
'type': 'bool',
'section': 'expertSettings',
'advanced': True,
'reboot': False,
'get': _get_sys_mon,
'set': _set_sys_mon
}

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +0,0 @@
#!/bin/sh
motioneye_conf_dir="/data/etc/"
test -n "$os_version" || source /etc/init.d/base
enabled() {
test $(ls -1 $motioneye_conf_dir/thread-*.conf 2>/dev/null| wc -l) == 1 || return 1
grep '# @proto mjpeg' $motioneye_conf_dir/thread-1.conf &>/dev/null || return 1
grep -E '# @url http://(.*)127.0.0.1:' $motioneye_conf_dir/thread-1.conf &>/dev/null || return 1
return 0
}
enabled || exit 0
start() {
msg_begin "Starting streameye"
streameye.sh start
test $? == 0 && msg_done || msg_fail
}
stop() {
msg_begin "Stopping streameye"
streameye.sh stop
test $? == 0 && msg_done || msg_fail
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?

View File

@ -1,3 +0,0 @@
bcm2835-v4l2 max_video_width=2592 max_video_height=1944
bcm2835-wdt

View File

@ -1,93 +0,0 @@
#!/bin/bash
RASPIMJPEG_CONF=/data/etc/raspimjpeg.conf
RASPIMJPEG_LOG=/var/log/raspimjpeg.log
MOTIONEYE_CONF=/data/etc/motioneye.conf
STREAMEYE_CONF=/data/etc/streameye.conf
STREAMEYE_LOG=/var/log/streameye.log
test -r $RASPIMJPEG_CONF || exit 1
test -r $STREAMEYE_CONF || exit 1
watch() {
count=0
while true; do
sleep 5
if ! ps aux | grep raspimjpeg.py | grep -v grep &>/dev/null; then
logger -t streameye -s "not running, respawning"
start
fi
done
}
function start() {
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -n "$pid" ]; then
return
fi
raspimjpeg_opts=""
while read line; do
if echo "$line" | grep false &>/dev/null; then
continue
fi
if echo "$line" | grep true &>/dev/null; then
line=$(echo $line | cut -d ' ' -f 1)
fi
raspimjpeg_opts="$raspimjpeg_opts --$line"
done < $RASPIMJPEG_CONF
source $STREAMEYE_CONF
streameye_opts="-p $PORT"
if [ -n "$CREDENTIALS" ] && [ "$AUTH" = "basic" ]; then
streameye_opts="$streameye_opts -a basic -c $CREDENTIALS"
fi
if [ -r $MOTIONEYE_CONF ] && grep 'log-level debug' $MOTIONEYE_CONF >/dev/null; then
raspimjpeg_opts="$raspimjpeg_opts -d"
streameye_opts="$streameye_opts -d"
fi
raspimjpeg.py $raspimjpeg_opts 2>$RASPIMJPEG_LOG | streameye $streameye_opts &>$STREAMEYE_LOG &
}
function stop() {
# stop the streameye background watch process
ps | grep streameye.sh | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
# stop the raspimjpeg process
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -z "$pid" ]; then
return
fi
kill -HUP "$pid" &>/dev/null
count=0
while kill -0 "$pid" &>/dev/null && [ $count -lt 5 ]; do
sleep 1
count=$(($count + 1))
done
kill -KILL "$pid" &>/dev/null || true
}
case "$1" in
start)
start
watch &
;;
stop)
stop
;;
restart)
stop
start
watch &
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac