removed motioneye-specific packages

This commit is contained in:
Calin Crisan 2017-02-18 20:42:39 +02:00
parent 9f8ca2c0ce
commit 1237d45e02
19 changed files with 0 additions and 1973 deletions

View File

@ -2,7 +2,6 @@ menu "Target packages"
source "package/busybox/Config.in" source "package/busybox/Config.in"
source "package/skeleton/Config.in" source "package/skeleton/Config.in"
source "package/motioneye/Config.in"
menu "Audio and video applications" menu "Audio and video applications"
source "package/alsa-utils/Config.in" source "package/alsa-utils/Config.in"
@ -22,12 +21,9 @@ menu "Audio and video applications"
source "package/jack2/Config.in" source "package/jack2/Config.in"
source "package/kodi/Config.in" source "package/kodi/Config.in"
source "package/lame/Config.in" source "package/lame/Config.in"
source "package/libwebcam/Config.in"
source "package/madplay/Config.in" source "package/madplay/Config.in"
source "package/miraclecast/Config.in" source "package/miraclecast/Config.in"
source "package/mjpegtools/Config.in" source "package/mjpegtools/Config.in"
source "package/motion/Config.in"
source "package/motion-mmal/Config.in"
source "package/modplugtools/Config.in" source "package/modplugtools/Config.in"
source "package/mpd/Config.in" source "package/mpd/Config.in"
source "package/mpd-mpc/Config.in" source "package/mpd-mpc/Config.in"
@ -41,7 +37,6 @@ menu "Audio and video applications"
source "package/opus-tools/Config.in" source "package/opus-tools/Config.in"
source "package/pulseaudio/Config.in" source "package/pulseaudio/Config.in"
source "package/sox/Config.in" source "package/sox/Config.in"
source "package/streameye/Config.in"
source "package/squeezelite/Config.in" source "package/squeezelite/Config.in"
source "package/tidsp-binaries/Config.in" source "package/tidsp-binaries/Config.in"
source "package/tovid/Config.in" source "package/tovid/Config.in"

View File

@ -1,3 +0,0 @@
config BR2_PACKAGE_LIBWEBCAM
bool "libwebcam"

View File

@ -1,18 +0,0 @@
################################################################################
#
# libwebcam
#
################################################################################
LIBWEBCAM_VERSION = 0.2.5
LIBWEBCAM_SOURCE = libwebcam-src-$(LIBWEBCAM_VERSION).tar.gz
LIBWEBCAM_SITE = http://freefr.dl.sourceforge.net/project/libwebcam/source
LIBWEBCAM_DEPENDENCIES = libxml2
define LIBWEBCAM_INSTALL_TARGET_CMDS
rm $(@D)/uvcdynctrl/uvcdynctrl-*.gz
cp $(@D)/uvcdynctrl/uvcdynctrl $(TARGET_DIR)/usr/bin/uvcdynctrl
cp -d $(@D)/libwebcam/libwebcam.so* $(TARGET_DIR)/usr/lib
endef
$(eval $(cmake-package))

View File

@ -1,4 +0,0 @@
config BR2_PACKAGE_MOTION_MMAL
bool "motion-mmal"
depends on BR2_PACKAGE_RPI_FIRMWARE && BR2_PACKAGE_RPI_USERLAND
help

View File

@ -1,21 +0,0 @@
################################################################################
#
# motion-mmal
#
################################################################################
MOTION_MMAL_SITE = $(call github,dozencrows,motion,$(MOTION_MMAL_VERSION))
MOTION_MMAL_VERSION = c37101be
MOTION_MMAL_DEPENDENCIES = rpi-firmware rpi-userland
define MOTION_MMAL_BUILD_CMDS
cd $(@D); \
USERLANDPATH="$$(ls -d $(BUILD_DIR)/rpi-userland-*)" TOOLPREFIX="arm-linux-" TOOLPATH="$(HOST_DIR)/usr" ROOTFSPATH="$(STAGING_DIR)" $(HOST_DIR)/usr/bin/cmake .; \
make
endef
define MOTION_MMAL_INSTALL_TARGET_CMDS
cp $(@D)/motion $(TARGET_DIR)/usr/bin/motion-mmal
endef
$(eval $(generic-package))

View File

@ -1,41 +0,0 @@
diff -uNr motion-mmal-test/CMakeLists.txt motion-mmal-patched/CMakeLists.txt
--- motion-mmal-test/CMakeLists.txt 2014-12-14 14:02:22.000000000 +0200
+++ motion-mmal-patched/CMakeLists.txt 2015-01-17 19:18:53.145027025 +0200
@@ -67,8 +67,6 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(
- ${ROOTFSPATH}/usr/include/mysql
- ${ROOTFSPATH}/usr/include/postgresql
${USERLANDPATH}
${USERLANDPATH}/interface/vcos
${USERLANDPATH}/interface/vcos/pthreads
@@ -144,11 +142,10 @@
avcodec
avutil
z
- mysqlclient
- pq
rt
bcm_host
vcos
+ vchostif
vchiq_arm
mmal_core
mmal_util
diff -uNr motion-mmal-test/config.h motion-mmal-patched/config.h
--- motion-mmal-test/config.h 2014-12-14 14:02:22.000000000 +0200
+++ motion-mmal-patched/config.h 2015-01-17 19:19:20.952463935 +0200
@@ -20,10 +20,10 @@
#define HAVE_MEMORY_H 1
/* Define to 1 if you have MySQL support */
-#define HAVE_MYSQL 1
+//#define HAVE_MYSQL 1
/* Define to 1 if you have PostgreSQL support */
-#define HAVE_PGSQL 1
+//#define HAVE_PGSQL 1
/* Define to 1 if you have SDL support */
/* #undef HAVE_SDL */

View File

@ -1,16 +0,0 @@
diff -uNr motion/version.sh motion.new/version.sh
--- motion/version.sh 2016-11-13 12:45:14.143548855 +0200
+++ motion.new/version.sh 2016-11-13 12:45:31.683635991 +0200
@@ -1,8 +1,9 @@
#!/bin/sh
BASE_VERSION="4.0.1"
if [ -d .git ]; then
- GIT_COMMIT=`git show -s --format=%h`
- printf "$BASE_VERSION+git$GIT_COMMIT"
+ GIT_COMMIT=`git show -s --format=%h`
+ printf "$BASE_VERSION+git$GIT_COMMIT"
else
- printf "$BASE_VERSION+gitUNKNOWN"
+ printf "$BASE_VERSION+git$(basename $(pwd) | cut -d '-' -f 2)"
fi
+

View File

@ -1,3 +0,0 @@
config BR2_PACKAGE_MOTION
bool "motion"
help

View File

@ -1,18 +0,0 @@
################################################################################
#
# motion
#
################################################################################
MOTION_VERSION = 37b3595
MOTION_SITE = $(call github,motion-project,motion,$(MOTION_VERSION))
MOTION_AUTORECONF = YES
MOTION_CONF_OPTS = --without-pgsql --without-sdl --without-sqlite3 --without-mysql --with-ffmpeg=$(STAGING_DIR)/usr/lib \
--with-ffmpeg-headers=$(STAGING_DIR)/usr/include
define MOTION_INSTALL_TARGET_CMDS
cp $(@D)/motion $(TARGET_DIR)/usr/bin/motion
endef
$(eval $(autotools-package))

View File

@ -1,2 +0,0 @@
config BR2_PACKAGE_MOTIONEYE
bool "motioneye"

View File

@ -1,2 +0,0 @@
CLIENT_ID="dwiw710jz6r60pq"
CLIENT_SECRET="8jz75qo405ritd5"

View File

@ -1,638 +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
MOTIONEYE_CONF = '/data/etc/motioneye.conf'
OS_CONF = '/data/etc/os.conf'
HOSTNAME_CONF = '/data/etc/hostname'
DATE_CONF = '/data/etc/date.conf'
def _get_hostname():
try:
with open(HOSTNAME_CONF) as f:
hostname = f.read().strip()
logging.debug('hostname %s read from %s' % (hostname, HOSTNAME_CONF))
return hostname
except:
return ''
def _set_hostname(hostname):
if hostname:
with open(HOSTNAME_CONF, 'w') as f:
f.write(hostname)
logging.debug('hostname %s written to %s' % (hostname, HOSTNAME_CONF))
else:
try:
os.remove(HOSTNAME_CONF)
logging.debug('hostname file %s removed' % HOSTNAME_CONF)
except:
pass
def _get_date_settings():
date_method = 'http'
date_host = 'google.com'
date_ntp_server = ''
date_timeout = 10
date_interval = 900
if os.path.exists(DATE_CONF):
logging.debug('reading date settings from %s' % DATE_CONF)
with open(DATE_CONF) as f:
for line in f:
line = line.strip()
if not line:
continue
if line.startswith('#'):
continue
try:
name, value = line.split('=')
value = value.strip('"').strip("'")
except:
continue
if name == 'date_method':
date_method = value
elif name == 'date_host':
date_host = value
elif name == 'date_ntp_server':
date_ntp_server = value
elif name == 'date_timeout':
date_timeout = int(value)
elif name == 'date_interval':
date_interval = int(value)
s = {
'dateMethod': date_method,
'dateHost': date_host,
'dateNtpServer': date_ntp_server,
'dateTimeout': date_timeout,
'dateInterval': date_interval
}
logging.debug('date settings: method=%(dateMethod)s, host=%(dateHost)s, ntp_server=%(dateNtpServer)s, timeout=%(dateTimeout)s, interval=%(dateInterval)s' % s)
return s
def _set_date_settings(s):
s.setdefault('dateMethod', 'http')
s.setdefault('dateHost', 'google.com')
s.setdefault('dateNtpServer', '')
s.setdefault('dateTimeout', 10)
s.setdefault('dateInterval', 900)
logging.debug('writing date settings to %s: ' % DATE_CONF +
'method=%(dateMethod)s, host=%(dateHost)s, ntp_server=%(dateNtpServer)s, timeout=%(dateTimeout)s, interval=%(dateInterval)s' % s)
with open(DATE_CONF, 'w') as f:
f.write('date_method=%s\n' % s['dateMethod'])
f.write('date_host=%s\n' % s['dateHost'])
f.write('date_ntp_server=%s\n' % s['dateNtpServer'])
f.write('date_timeout=%s\n' % s['dateTimeout'])
f.write('date_interval=%s\n' % s['dateInterval'])
def _get_os_settings():
prereleases = False
if os.path.exists(OS_CONF):
logging.debug('reading OS settings from %s' % OS_CONF)
with open(OS_CONF) as f:
for line in f:
line = line.strip()
if not line:
continue
if line.startswith('#'):
continue
try:
name, value = line.split('=')
value = value.strip('"').strip("'")
except:
continue
if name == 'os_prereleases':
prereleases = value == 'true'
s = {
'prereleases': prereleases
}
logging.debug('OS settings: prereleases=%(prereleases)s' % s)
return s
def _set_os_settings(s):
s = dict(s)
s.setdefault('prereleases', False)
logging.debug('writing OS settings to %s: ' % OS_CONF +
'prereleases=%(prereleases)s' % s)
lines = []
if os.path.exists(OS_CONF):
with open(OS_CONF) as f:
lines = f.readlines()
for i, line in enumerate(lines):
line = line.strip()
if not line:
continue
try:
name, _ = line.split('=', 2)
except:
continue
if name == 'os_prereleases':
lines[i] = 'os_prereleases="%s"' % str(s.pop('prereleases')).lower()
if 'prereleases' in s:
lines.append('os_prereleases="%s"' % str(s.pop('prereleases')).lower())
with open(OS_CONF, 'w') as f:
for line in lines:
if not line.strip():
continue
if not line.endswith('\n'):
line += '\n'
f.write(line)
def _get_motioneye_settings():
port = 80
base_path = ''
motion_binary = '/usr/bin/motion'
debug = False
motion_keep_alive = False
if os.path.exists(MOTIONEYE_CONF):
logging.debug('reading motioneye settings from %s' % MOTIONEYE_CONF)
with open(MOTIONEYE_CONF) as f:
for line in f:
line = line.strip()
if not line:
continue
try:
name, value = line.split(' ', 1)
except:
continue
name = name.replace('-', '_')
if name == 'port':
port = int(value)
elif name == 'base_path':
base_path = value.strip()
elif name == 'motion_binary':
motion_binary = value
elif name == 'log_level':
debug = value == 'debug'
elif name == 'mjpg_client_idle_timeout':
motion_keep_alive = value == '0'
s = {
'port': port,
'basePath': base_path,
'motionBinary': motion_binary,
'motionKeepAlive': motion_keep_alive,
'debug': debug
}
logging.debug(('motioneye settings: port=%(port)s, base_path=%(basePath)s, motion_binary=%(motionBinary)s, ' +
'motion_keep_alive=%(motionKeepAlive)s, debug=%(debug)s') % s)
return s
def _set_motioneye_settings(s):
s = dict(s)
s.setdefault('port', 80)
s.setdefault('basePath', '')
s.setdefault('motionBinary', '/usr/bin/motion')
debug = s.setdefault('debug', False) # value needed later
s.setdefault('motion_keep_alive', False)
logging.debug('writing motioneye settings to %s: ' % MOTIONEYE_CONF +
('port=%(port)s, base_path=%(basePath)s, motion_binary=%(motionBinary)s, ' +
'motion_keep_alive=%(motionKeepAlive)s, debug=%(debug)s') % s)
lines = []
if os.path.exists(MOTIONEYE_CONF):
with open(MOTIONEYE_CONF) as f:
lines = f.readlines()
for i, line in enumerate(lines):
line = line.strip()
if not line:
continue
try:
name, _ = line.split(' ', 2)
except:
continue
name = name.replace('-', '_')
if name == 'port':
lines[i] = 'port %s' % s.pop('port')
elif name == 'base_path':
base_path = s.pop('basePath')
if base_path:
lines[i] = 'base_path %s' % base_path
else:
lines[i] = None
elif name == 'motion_binary':
lines[i] = 'motion_binary %s' % s.pop('motionBinary')
elif name == 'log_level':
lines[i] = 'log_level %s' % ['info', 'debug'][s.pop('debug')]
elif name == 'mjpg_client_idle_timeout':
lines[i] = 'mjpg_client_idle_timeout %s' % [10, 0][s.pop('motionKeepAlive')]
lines = [l for l in lines if l is not None]
if 'port' in s:
lines.append('port %s' % s.pop('port'))
if s.get('basePath'):
lines.append('base_path %s' % s.pop('basePath'))
if 'motionBinary' in s:
lines.append('motion_binary %s' % s.pop('motionBinary'))
if 'debug' in s:
lines.append('log_level %s' % ['info', 'debug'][s.pop('debug')])
if 'motionKeepAlive' in s:
lines.append('mjpg_client_idle_timeout %s' % [10, 0][s.pop('motionKeepAlive')])
with open(MOTIONEYE_CONF, 'w') as f:
for line in lines:
if not line.strip():
continue
if not line.endswith('\n'):
line += '\n'
f.write(line)
# also update debug in os.conf
if debug:
cmd = "sed -i -r 's/os_debug=\"?false\"?/os_debug=\"true\"/' %s" % OS_CONF
else:
cmd = "sed -i -r 's/os_debug=\"?true\"?/os_debug=\"false\"/' %s" % OS_CONF
if os.system(cmd):
logging.error('failed to set debug flag in os.conf')
def _get_motion_log():
return '<a href="javascript:downloadFile(\'log/motion/\');">motion.log</a>'
def _get_motion_eye_log():
return '<a href="javascript:downloadFile(\'log/motioneye/\');">motioneye.log</a>'
def _get_messages_log():
return '<a href="javascript:downloadFile(\'log/messages/\');">messages.log</a>'
def _get_boot_log():
return '<a href="javascript:downloadFile(\'log/boot/\');">boot.log</a>'
def _get_dmesg_log():
return '<a href="javascript:downloadFile(\'log/dmesg/\');">dmesg.log</a>'
@additional_config
def hostname():
return {
'label': 'Hostname',
'description': 'sets a custom hostname for the device (leave blank for default)',
'type': 'str',
'section': 'general',
'advanced': True,
'reboot': True,
'required': False,
'validate': '^[a-z0-9\-_.]{0,64}$',
'get': _get_hostname,
'set': _set_hostname
}
@additional_config
def extraDateSeparator():
return {
'type': 'separator',
'section': 'expertSettings',
'advanced': True
}
@additional_config
def dateMethod():
return {
'label': 'Date Method',
'description': 'decides whether NTP or HTTP is used for setting and updating the system date',
'type': 'choices',
'choices': [('http', 'HTTP'), ('ntp', 'NTP')],
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'required': True,
'get': _get_date_settings,
'set': _set_date_settings,
'get_set_dict': True
}
@additional_config
def dateHost():
return {
'label': 'Date HTTP Host',
'description': 'sets the hostname or IP address to which the HTTP request will be made',
'type': 'str',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'required': True,
'depends': ['dateMethod==http'],
'get': _get_date_settings,
'set': _set_date_settings,
'get_set_dict': True
}
@additional_config
def dateNtpServer():
return {
'label': 'NTP Server',
'description': 'sets a custom NTP server (leave blank to use the default server)',
'type': 'str',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'required': False,
'depends': ['dateMethod==ntp'],
'get': _get_date_settings,
'set': _set_date_settings,
'get_set_dict': True
}
@additional_config
def dateTimeout():
return {
'label': 'Date Updating Timeout',
'description': 'sets the number of seconds to wait when requesting the date/time',
'type': 'number',
'min': 1,
'max': 3600,
'unit': 's',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'required': True,
'get': _get_date_settings,
'set': _set_date_settings,
'get_set_dict': True
}
@additional_config
def dateInterval():
return {
'label': 'Date Updating Interval',
'description': 'sets the interval between system date updates',
'type': 'number',
'min': 10,
'max': 86400,
'unit': 's',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'required': True,
'depends': ['dateMethod==http'],
'get': _get_date_settings,
'set': _set_date_settings,
'get_set_dict': True
}
@additional_config
def extraMotionEyeSeparator():
return {
'type': 'separator',
'section': 'expertSettings',
'advanced': True
}
@additional_config
def port():
return {
'label': 'HTTP Port',
'description': 'sets the port on which the motionEye HTTP server listens',
'type': 'number',
'min': 1,
'max': 65535,
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'required': True,
'get': _get_motioneye_settings,
'set': _set_motioneye_settings,
'get_set_dict': True
}
@additional_config
def basePath():
return {
'label': 'Base Path',
'description': 'sets a base path of all the URIs used by motionEye (useful when running behind a reverse proxy exposing the motionEye UI at /cams, for example)',
'type': 'str',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_motioneye_settings,
'set': _set_motioneye_settings,
'get_set_dict': True
}
@additional_config
def motionBinary():
return {
'label': 'Motion Binary',
'description': 'sets the path to the motion binary',
'type': 'str',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'required': True,
'get': _get_motioneye_settings,
'set': _set_motioneye_settings,
'get_set_dict': True
}
@additional_config
def motionKeepAlive():
return {
'label': 'Motion Keep-alive',
'description': 'enables continuous motion daemon hang detection (at the expense of a slightly higher CPU usage)',
'type': 'bool',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_motioneye_settings,
'set': _set_motioneye_settings,
'get_set_dict': True
}
@additional_config
def debug():
return {
'label': 'Enable Debugging',
'description': 'turning debugging on will generate verbose log messages and will mount all the partitions in read-write mode',
'type': 'bool',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_motioneye_settings,
'set': _set_motioneye_settings,
'get_set_dict': True
}
@additional_config
def prereleases():
return {
'label': 'Enable Prereleases',
'description': 'turning this option on will allow updating to prereleases (untested, possibly unstable versions)',
'type': 'bool',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_os_settings,
'set': _set_os_settings,
'get_set_dict': True
}
@additional_config
def extraLogsSeparator():
return {
'type': 'separator',
'section': 'expertSettings',
'advanced': True
}
@additional_config
def motionLog():
return {
'label': 'Log Files',
'description': 'download the log files and include them with any issue you want to report',
'type': 'html',
'section': 'expertSettings',
'advanced': True,
'get': _get_motion_log,
}
@additional_config
def motionEyeLog():
return {
'type': 'html',
'section': 'expertSettings',
'advanced': True,
'get': _get_motion_eye_log,
}
@additional_config
def messagesLog():
return {
'type': 'html',
'section': 'expertSettings',
'advanced': True,
'get': _get_messages_log,
}
@additional_config
def bootLog():
return {
'type': 'html',
'section': 'expertSettings',
'advanced': True,
'get': _get_boot_log,
}
@additional_config
def dmesgLog():
return {
'type': 'html',
'section': 'expertSettings',
'advanced': True,
'get': _get_dmesg_log,
}

View File

@ -1,248 +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 re
from collections import OrderedDict
from config import additional_config
STATIC_IP_CONF = '/data/etc/static_ip.conf'
def _get_ip_settings():
ip = None
ip_comment = False
cidr = '24'
gw = '192.168.1.1'
gw_comment = False
dns = '8.8.8.8'
dns_comment = False
if os.path.exists(STATIC_IP_CONF):
logging.debug('reading ip settings from %s' % STATIC_IP_CONF)
with open(STATIC_IP_CONF) as f:
for line in f:
line = line.strip()
if line.startswith('#'):
comment = True
line = line.strip('#')
else:
comment = False
if not line:
continue
match = re.match('^static_ip="(.*)/(.*)"$', line)
if match:
ip, cidr = match.groups()
ip_comment = comment
continue
match = re.match('^static_gw="(.*)"$', line)
if match:
gw = match.group(1)
gw_comment = comment
continue
match = re.match('^static_dns="(.*)"$', line)
if match:
dns = match.group(1)
dns_comment = comment
continue
if ip is None or ip_comment:
type = 'dhcp'
else:
type = 'static'
if ip is None:
ip = '192.168.1.101'
bits = 0
for i in xrange(32 - int(cidr), 32):
bits |= (1 << i)
mask = '%d.%d.%d.%d' % ((bits & 0xff000000) >> 24, (bits & 0xff0000) >> 16, (bits & 0xff00) >> 8 , (bits & 0xff))
if gw_comment and type == 'static':
gw = None
if dns_comment and type == 'static':
dns = None
s = {
'ipConfigType': type,
'ipConfigStaticAddr': ip,
'ipConfigStaticMask': mask,
'ipConfigStaticGw': gw,
'ipConfigStaticDns': dns
}
logging.debug(('ip settings: type=%(ipConfigType)s, addr=%(ipConfigStaticAddr)s, mask=%(ipConfigStaticMask)s, ' +
'gw=%(ipConfigStaticGw)s, dns=%(ipConfigStaticDns)s') % s)
return s
def _set_ip_settings(s):
type = s.get('ipConfigType', 'dhcp')
ip = s.get('ipConfigStaticAddr', '192.168.1.101')
mask = s.get('ipConfigStaticMask', '255.255.255.0')
gw = s.get('ipConfigStaticGw', '192.168.1.1')
dns = s.get('ipConfigStaticDns', '8.8.8.8')
logging.debug('writing ip settings to %s: ' % STATIC_IP_CONF +
('type=%(ipConfigType)s, addr=%(ipConfigStaticAddr)s, mask=%(ipConfigStaticMask)s, ' +
'gw=%(ipConfigStaticGw)s, dns=%(ipConfigStaticDns)s') % s)
cidr = '24'
if mask:
binary_str = ''
for octet in mask.split('.'):
binary_str += bin(int(octet))[2:].zfill(8)
cidr = str(len(binary_str.rstrip('0')))
current_settings = OrderedDict()
if os.path.exists(STATIC_IP_CONF):
with open(STATIC_IP_CONF, 'r') as f:
for line in f:
line = line.strip().split('=', 1)
if len(line) != 2:
continue
key, value = line
if key.startswith('#'):
current_settings[key.strip('#')] = (value, False)
else:
current_settings[key] = (value, True)
enabled = type != 'dhcp'
current_settings['static_ip'] = ('"%s/%s"' % (ip, cidr), enabled)
current_settings['static_gw'] = ('"%s"' % gw, enabled)
current_settings['static_dns'] = ('"%s"' % dns, enabled)
with open(STATIC_IP_CONF, 'w') as f:
for key, value in current_settings.items():
(value, enabled) = value
if not enabled:
key = '#' + key
f.write('%s=%s\n' % (key, value))
@additional_config
def ipSeparator():
return {
'type': 'separator',
'section': 'network',
'advanced': True
}
@additional_config
def ipConfigType():
return {
'label': 'IP Configuration',
'description': 'select the way your IP address is configured',
'type': 'choices',
'choices': [('dhcp', 'Automatic (DHCP)'), ('static', 'Manual (Static IP)')],
'section': 'network',
'advanced': True,
'reboot': True,
'get': _get_ip_settings,
'set': _set_ip_settings,
'get_set_dict': True
}
@additional_config
def ipConfigStaticAddr():
return {
'label': 'IP Address',
'description': 'manually set your static IP address',
'type': 'str',
'validate': '^[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?$',
'section': 'network',
'advanced': True,
'required': True,
'depends': ['ipConfigType==static'],
'reboot': True,
'get': _get_ip_settings,
'set': _set_ip_settings,
'get_set_dict': True,
}
@additional_config
def ipConfigStaticMask():
return {
'label': 'Network Mask',
'description': 'manually set your network mask',
'type': 'str',
'validate': '^[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?$',
'section': 'network',
'advanced': True,
'required': True,
'depends': ['ipConfigType==static'],
'reboot': True,
'get': _get_ip_settings,
'set': _set_ip_settings,
'get_set_dict': True,
}
@additional_config
def ipConfigStaticGw():
return {
'label': 'Default Gateway',
'description': 'manually set your default gateway',
'type': 'str',
'validate': '^[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?$',
'section': 'network',
'advanced': True,
'required': True,
'depends': ['ipConfigType==static'],
'reboot': True,
'get': _get_ip_settings,
'set': _set_ip_settings,
'get_set_dict': True,
}
@additional_config
def ipConfigStaticDns():
return {
'label': 'DNS Server',
'description': 'manually set your DNS server',
'type': 'str',
'validate': '^[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?$',
'section': 'network',
'advanced': True,
'required': True,
'depends': ['ipConfigType==static'],
'reboot': True,
'get': _get_ip_settings,
'set': _set_ip_settings,
'get_set_dict': True,
}

View File

@ -1,71 +0,0 @@
#############################################################
#
# motioneye
#
#############################################################
MOTIONEYE_VERSION = 0f92e7bd26a79f1c0d55b4d0ce17c3d434496c10
MOTIONEYE_SITE = $(call github,ccrisan,motioneye,$(MOTIONEYE_VERSION))
MOTIONEYE_SOURCE = $(MOTIONEYE_VERSION).tar.gz
MOTIONEYE_LICENSE = GPLv3
MOTIONEYE_LICENSE_FILES = LICENCE
MOTIONEYE_INSTALL_TARGET = YES
MOTIONEYE_SETUP_TYPE = setuptools
DST_DIR = $(TARGET_DIR)/usr/lib/python2.7/site-packages/motioneye
SHARE_DIR = $(TARGET_DIR)/usr/share/motioneye
BOARD = $(shell basename $(BASE_DIR))
BOARD_DIR = $(BASE_DIR)/../../board/$(BOARD)
COMMON_DIR = $(BASE_DIR)/../../board/common
define MOTIONEYE_INSTALL_TARGET_CMDS
# setuptools install
(cd $($(PKG)_BUILDDIR)/; \
$($(PKG)_BASE_ENV) $($(PKG)_ENV) \
$($(PKG)_PYTHON_INTERPRETER) setup.py install \
$($(PKG)_BASE_INSTALL_TARGET_OPTS) \
$($(PKG)_INSTALL_TARGET_OPTS))
# additional config modules
cp package/motioneye/update.py $(DST_DIR)
cp package/motioneye/ipctl.py $(DST_DIR)
cp package/motioneye/servicectl.py $(DST_DIR)
cp package/motioneye/watchctl.py $(DST_DIR)
cp package/motioneye/extractl.py $(DST_DIR)
test -d $(BOARD_DIR)/motioneye-modules && cp $(BOARD_DIR)/motioneye-modules/*.py $(DST_DIR) || true
grep servicectl $(DST_DIR)/config.py &>/dev/null || echo -e '\nimport ipctl\nimport servicectl\nimport watchctl\nimport extractl\ntry:\n import boardctl\nexcept ImportError:\n pass' >> $(DST_DIR)/config.py
# log files
if ! grep 'motioneye.log' $(DST_DIR)/handlers.py &>/dev/null; then \
lineno=$$(grep -n -m1 LOGS $(DST_DIR)/handlers.py | cut -d ':' -f 1); \
head -n $$(($$lineno + 1)) $(DST_DIR)/handlers.py > /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 " 'boot': ('/var/log/boot.log', 'boot.log')," >> /tmp/handlers.py.new; \
echo " 'dmesg': ('/var/log/dmesg.log', 'dmesg.log')," >> /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; \
fi
# version & update
source $(COMMON_DIR)/overlay/etc/version; \
sed -r -i "s%VERSION = .*%VERSION = '$$os_version'%" $(DST_DIR)/__init__.py
sed -r -i "s%enable_update=False%enable_update=True%" $(DST_DIR)/handlers.py
source package/motioneye/dropbox.keys; \
sed -i "s/dropbox_client_id_placeholder/$$CLIENT_ID/" $(DST_DIR)/uploadservices.py; \
sed -i "s/dropbox_client_secret_placeholder/$$CLIENT_SECRET/" $(DST_DIR)/uploadservices.py
# (re)compile all python modules
$($(PKG)_PYTHON_INTERPRETER) -m compileall -d /usr/lib/python2.7/site-packages/motioneye -f $(DST_DIR)
# meyectl
echo -e '#!/bin/bash\n/usr/bin/python /usr/lib/python2.7/site-packages/motioneye/meyectl.pyc "$$@"' > $(TARGET_DIR)/usr/bin/meyectl
chmod +x $(TARGET_DIR)/usr/bin/meyectl
# cleanups
rm -rf $(SHARE_DIR)/extra
endef
$(eval $(python-package))

View File

@ -1,314 +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 re
from config import additional_config, additional_section
FTP_CONF = '/data/etc/proftpd.conf'
FTP_DISABLE_FILE = '/data/etc/no_S61proftpd'
SMB_CONF = '/data/etc/smb.conf'
SMB_DISABLE_FILE = '/data/etc/no_S62smb'
SSH_DISABLE_FILE = '/data/etc/no_S60sshd'
def _get_service_settings():
ftp_enabled = True
ftp_auth = True
ftp_writable = False
smb_enabled = True
smb_auth = True
smb_writable = False
ssh_enabled = True
# FTP
if os.path.exists(FTP_DISABLE_FILE):
ftp_enabled = False
if os.path.exists(FTP_CONF):
logging.debug('reading ftp settings from %s' % FTP_CONF)
with open(FTP_CONF) as f:
for line in f:
line = line.strip()
if not line or line.startswith('#'):
continue
if line == '<Anonymous ~ftp>':
ftp_auth = False
elif line == 'AllowAll':
ftp_writable = True
# SMB
if os.path.exists(SMB_DISABLE_FILE):
smb_enabled = False
if os.path.exists(SMB_CONF):
logging.debug('reading smb settings from %s' % SMB_CONF)
with open(SMB_CONF) as f:
for line in f:
line = line.strip()
if re.match('^\s*public\s*=\s*yes\s*$', line):
smb_auth = False
elif re.match('^\s*writable\s*=\s*yes\s*$', line):
smb_writable = True
# SSH
if os.path.exists(SSH_DISABLE_FILE):
ssh_enabled = False
s = {
'ftpEnabled': ftp_enabled,
'ftpAuth': ftp_auth,
'ftpWritable': ftp_writable,
'smbEnabled': smb_enabled,
'smbAuth': smb_auth,
'smbWritable': smb_writable,
'sshEnabled': ssh_enabled
}
logging.debug(('service settings: ftp=%(ftpEnabled)s, ftp_auth=%(ftpAuth)s, ftp_writable=%(ftpWritable)s, ' +
'smb=%(smbEnabled)s, smb_auth=%(smbAuth)s, smb_writable=%(smbWritable)s, ' +
'ssh=%(sshEnabled)s') % s)
return s
def _set_service_settings(s):
s.setdefault('ftpEnabled', True)
s.setdefault('ftpAuth', True)
s.setdefault('ftpWritable', False)
s.setdefault('smbEnabled', True)
s.setdefault('smbAuth', True)
s.setdefault('smbWritable', False)
s.setdefault('sshEnabled', True)
logging.debug(('saving service settings: ftp=%(ftpEnabled)s, ftp_auth=%(ftpAuth)s, ftp_writable=%(ftpWritable)s, ' +
'smb=%(smbEnabled)s, smb_auth=%(smbAuth)s, smb_writable=%(smbWritable)s, ' +
'ssh=%(sshEnabled)s') % s)
# FTP
ftp_mode = 'off' if not s['ftpEnabled'] else ('public' if not s['ftpAuth'] else ('auth' if not s['ftpWritable'] else 'writable'))
logging.debug('setting FTP mode: %s' % ftp_mode)
if s['ftpEnabled']:
try:
os.remove(FTP_DISABLE_FILE)
except:
pass
else:
with open(FTP_DISABLE_FILE, 'w'):
pass
with open(FTP_CONF, 'w') as f:
if s['ftpAuth']:
if s['ftpWritable']:
f.write('<Limit WRITE>\n')
f.write(' AllowAll\n')
f.write('</Limit>\n')
else:
f.write('<Anonymous ~ftp>\n')
f.write(' User ftp\n')
f.write(' Group nogroup\n')
f.write(' UserAlias anonymous ftp\n')
f.write(' MaxClients 4\n')
f.write(' <Limit WRITE>\n')
f.write(' DenyAll\n')
f.write(' </Limit>\n')
f.write('</Anonymous>\n')
# SMB
smb_mode = 'off' if not s['smbEnabled'] else ('public' if not s['smbAuth'] else ('auth' if not s['smbWritable'] else 'writable'))
logging.debug('setting SMB mode: %s' % smb_mode)
if s['smbEnabled']:
try:
os.remove(SMB_DISABLE_FILE)
except:
pass
else:
with open(SMB_DISABLE_FILE, 'w'):
pass
with open(SMB_CONF, 'w') as f:
if s['smbAuth']:
if s['smbWritable']:
f.write('writable = yes\n')
f.write('public = no\n')
else:
f.write('writable = no\n')
f.write('public = yes\n')
# SSH
ssh_mode = 'off' if not s['sshEnabled'] else 'enabled'
logging.debug('setting SSH mode: %s' % ssh_mode)
if s['sshEnabled']:
try:
os.remove(SSH_DISABLE_FILE)
except:
pass
else:
with open(SSH_DISABLE_FILE, 'w'):
pass
@additional_section
def services():
return {
'label': 'Services',
'description': 'configure extra services (such as FTP or SSH)',
'advanced': True
}
@additional_config
def ftpEnabled():
return {
'label': 'Enable FTP Server',
'description': 'enable this if you want to access the files on your motionEyeOS system using FTP',
'type': 'bool',
'section': 'services',
'advanced': True,
'reboot': True,
'get': _get_service_settings,
'set': _set_service_settings,
'get_set_dict': True
}
@additional_config
def ftpAuth():
return {
'label': 'Require FTP Authentication',
'description': 'enable this if you want the FTP server to ask for credentials (i.e. to disable anonymous logins)',
'type': 'bool',
'section': 'services',
'advanced': True,
'reboot': True,
'depends': ['ftpEnabled'],
'get': _get_service_settings,
'set': _set_service_settings,
'get_set_dict': True
}
@additional_config
def ftpWritable():
return {
'label': 'Enable FTP Write Support',
'description': 'enable this if you want to allow creating, editing or removing files/directories through FTP (i.e. to disable read-only mode)',
'type': 'bool',
'section': 'services',
'advanced': True,
'reboot': True,
'depends': ['ftpAuth', 'ftpEnabled'],
'get': _get_service_settings,
'set': _set_service_settings,
'get_set_dict': True
}
@additional_config
def ftpSeparator():
return {
'type': 'separator',
'section': 'services',
'advanced': True
}
@additional_config
def smbEnabled():
return {
'label': 'Enable Samba Server',
'description': 'enable this if you want files on your motionEyeOS system to be visible on the local network (using SMB protocol)',
'type': 'bool',
'section': 'services',
'advanced': True,
'reboot': True,
'get': _get_service_settings,
'set': _set_service_settings,
'get_set_dict': True
}
@additional_config
def smbAuth():
return {
'label': 'Require Samba Authentication',
'description': 'enable this if you want the Samba server to ask for credentials (i.e. to disable guest access)',
'type': 'bool',
'section': 'services',
'advanced': True,
'reboot': True,
'depends': ['smbEnabled'],
'get': _get_service_settings,
'set': _set_service_settings,
'get_set_dict': True
}
@additional_config
def smbWritable():
return {
'label': 'Enable Samba Write Support',
'description': 'enable this if you want to allow creating, editing or removing files/directories on your motionEyeOS system from the local network',
'type': 'bool',
'section': 'services',
'advanced': True,
'reboot': True,
'depends': ['smbAuth', 'smbEnabled'],
'get': _get_service_settings,
'set': _set_service_settings,
'get_set_dict': True
}
@additional_config
def smbSeparator():
return {
'type': 'separator',
'section': 'services',
'advanced': True
}
@additional_config
def sshEnabled():
return {
'label': 'Enable SSH Server',
'description': 'enable this if you want to login remotely on your motionEyeOS system using an SSH client (such as Putty)',
'type': 'bool',
'section': 'services',
'advanced': True,
'reboot': True,
'get': _get_service_settings,
'set': _set_service_settings,
'get_set_dict': True
}

View File

@ -1,263 +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 json
import logging
import os.path
import re
import shutil
import ssl
import subprocess
import time
import urllib2
import settings
_BOARD = open('/etc/board').read().strip()
_REPO = ('ccrisan', 'motioneyeos')
_DOWNLOAD_URL = 'https://github.com/{owner}/{repo}/releases/download/%(version)s/motioneyeos-%(board)s-%(version)s.img.gz'.format(
owner=_REPO[0], repo=_REPO[1])
_LIST_VERSIONS_URL = 'https://api.github.com/repos/{owner}/{repo}/releases'.format(
owner=_REPO[0], repo=_REPO[1])
_DOWNLOAD_DIR = '/data/.firmware_update'
_DOWNLOAD_FILE_NAME = os.path.join(_DOWNLOAD_DIR, 'firmware.gz')
# versions
def get_version():
import motioneye
return motioneye.VERSION
def get_all_versions():
url = _LIST_VERSIONS_URL
url += '?_=' + str(int(time.time())) # prevents caching
want_prereleases = subprocess.check_output('source /data/etc/os.conf && echo $os_prereleases', shell=True, stderr=subprocess.STDOUT).strip() == 'true'
try:
logging.debug('board is %s' % _BOARD)
logging.debug('fetching %s...' % url)
context = ssl._create_unverified_context()
response = urllib2.urlopen(url, timeout=settings.REMOTE_REQUEST_TIMEOUT, context=context)
releases = json.load(response)
versions = []
for release in releases:
if release.get('prerelease') and not want_prereleases:
continue
for asset in release.get('assets', []):
if not re.match('^motioneyeos-%s-\d{8}\.img.gz$' % _BOARD, asset['name']):
continue
versions.append(release['name'])
logging.debug('available versions: %(versions)s' % {'versions': ', '.join(versions)})
return sorted(versions)
except Exception as e:
logging.error('could not get versions: %s' % e, exc_info=True)
return []
def compare_versions(version1, version2):
version1 = re.sub('[^0-9.]', '', version1)
version2 = re.sub('[^0-9.]', '', version2)
def int_or_0(n):
try:
return int(n)
except:
return 0
version1 = [int_or_0(n) for n in version1.split('.')]
version2 = [int_or_0(n) for n in version2.split('.')]
len1 = len(version1)
len2 = len(version2)
length = min(len1, len2)
for i in xrange(length):
p1 = version1[i]
p2 = version2[i]
if p1 < p2:
return -1
elif p1 > p2:
return 1
if len1 < len2:
return -1
elif len1 > len2:
return 1
else:
return 0
# updating
def download(version):
url = _DOWNLOAD_URL % {'version': version, 'board': _BOARD}
try:
logging.info('downloading %s...' % url)
shutil.rmtree(_DOWNLOAD_DIR, ignore_errors=True)
os.makedirs(_DOWNLOAD_DIR)
subprocess.check_call(['/usr/bin/wget', url, '--no-check-certificate', '-O', _DOWNLOAD_FILE_NAME])
except Exception as e:
logging.error('could not download update: %s' % e)
raise
try:
logging.info('decompressing %s...' % _DOWNLOAD_FILE_NAME)
subprocess.check_call(['/bin/gunzip', _DOWNLOAD_FILE_NAME])
except Exception as e:
logging.error('could not decompress archive: %s' % e)
raise
extracted_file_name = _DOWNLOAD_FILE_NAME.replace('.gz', '')
try:
logging.info('reading partiton table...')
output = subprocess.check_output(['/sbin/fdisk', '-l', extracted_file_name])
lines = [l.strip().replace('*', ' ') for l in output.split('\n') if l.startswith(extracted_file_name)]
boot_info = lines[0].split()
root_info = lines[1].split()
boot_start, boot_end = int(boot_info[1]), int(boot_info[2])
root_start, root_end = int(root_info[1]), int(root_info[2])
except Exception as e:
logging.error('could not read partition table: %s' % e)
raise
try:
logging.info('extracting boot.img...')
subprocess.check_call(['/bin/dd', 'if=' + extracted_file_name, 'of=' + os.path.join(_DOWNLOAD_DIR, 'boot.img'),
'bs=2048', 'skip=' + str(boot_start / 4), 'count=' + str((boot_end - boot_start + 1) / 4)])
except Exception as e:
logging.error('could not extract boot.img: %s' % e)
raise
try:
logging.info('extracting root.img...')
subprocess.check_call(['/bin/dd', 'if=' + extracted_file_name, 'of=' + os.path.join(_DOWNLOAD_DIR, 'root.img'),
'bs=2048', 'skip=' + str(root_start / 4), 'count=' + str((root_end - root_start + 1) / 4)])
except Exception as e:
logging.error('could not extract root.img: %s' % e)
raise
def perform_update(version):
logging.info('updating to version %(version)s...' % {'version': version})
logging.info('killing motioneye init script...')
os.system('kill $(pidof S85motioneye)')
logging.info('stopping netwatch init script...')
os.system('/etc/init.d/S41netwatch stop')
download(version)
logging.info('backing up /boot/config.txt')
if os.system('/bin/cp /boot/config.txt /tmp/config.txt'):
logging.error('failed to backup /boot/config.txt')
raise Exception('failed to backup /boot/config.txt')
logging.info('unmounting boot partition...')
if os.system('/bin/umount /boot'):
logging.error('failed to unmount boot partition')
raise Exception('failed to unmount boot partition')
try:
logging.info('installing boot image...')
boot_img = os.path.join(_DOWNLOAD_DIR, 'boot.img')
subprocess.check_call(['/bin/dd', 'if=' + boot_img, 'of=/dev/mmcblk0p1', 'bs=1M'])
except Exception as e:
logging.error('could not install boot image: %s' % e)
raise
logging.info('mounting boot partition read-write...')
if os.system('/bin/mount -o rw /dev/mmcblk0p1 /boot'):
logging.error('failed to mount boot partition')
raise Exception('failed to mount boot partition')
logging.info('restoring up /boot/config.txt')
if os.system('/bin/cp /tmp/config.txt /boot/config.txt'):
logging.error('failed to restore /boot/config.txt')
raise Exception('failed to restore /boot/config.txt')
logging.info('preparing to boot in fwupdate mode...')
try:
config_lines = [c.strip() for c in open('/boot/config.txt', 'r').readlines() if c.strip()]
except Exception as e:
logging.error('failed to read /boot/config.txt: %s' % e, exc_info=True)
raise
config_lines.append('initramfs fwupdater.gz')
try:
with open('/boot/config.txt', 'w') as f:
for line in config_lines:
f.write(line + '\n')
except Exception as e:
logging.error('failed to write /boot/config.txt: %s' % e, exc_info=True)
raise
logging.info('rebooting...')
if os.system('/sbin/reboot'):
logging.error('failed to reboot')
logging.info('hard rebooting...')
open('/proc/sysrq-trigger', 'w').write('b') # reboot

View File

@ -1,282 +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, additional_section
WATCH_CONF = '/data/etc/watch.conf'
def _get_watch_settings():
watch_link = False
watch_link_timeout = 20
watch_connect = False
watch_connect_host = 'www.google.com'
watch_connect_port = 80
watch_connect_retries = 3
watch_connect_timeout = 5
watch_connect_interval = 20
if os.path.exists(WATCH_CONF):
logging.debug('reading watch settings from %s' % WATCH_CONF)
with open(WATCH_CONF) as f:
for line in f:
line = line.strip()
if not line:
continue
comment = False
if line.startswith('#'):
line = line.strip('#')
comment = True
try:
name, value = line.split('=')
value = value.strip('"').strip("'")
except:
continue
if name == 'link_watch':
watch_link = (value == 'true') and not comment
elif name == 'link_watch_timeout':
watch_link_timeout = int(value)
elif name == 'netwatch_host':
watch_connect = not comment
watch_connect_host = value
elif name == 'netwatch_port':
watch_connect_port = int(value)
elif name == 'netwatch_timeout':
watch_connect_timeout = int(value)
elif name == 'netwatch_retries':
watch_connect_retries = int(value)
elif name == 'netwatch_interval':
watch_connect_interval = int(value)
s = {
'watchLink': watch_link,
'watchLinkTimeout': watch_link_timeout,
'watchConnect': watch_connect,
'watchConnectHost': watch_connect_host,
'watchConnectPort': watch_connect_port,
'watchConnectRetries': watch_connect_retries,
'watchConnectTimeout': watch_connect_timeout,
'watchConnectInterval': watch_connect_interval
}
logging.debug(('watch settings: watch_link=%(watchLink)s, watch_link_timeout=%(watchLinkTimeout)s, ' +
'watch_connect=%(watchConnect)s, watch_connect_host=%(watchConnectHost)s, ' +
'watch_connect_port=%(watchConnectPort)s, watch_connect_retries=%(watchConnectRetries)s, ' +
'watch_connect_timeout=%(watchConnectTimeout)s, watch_connect_interval=%(watchConnectInterval)s') % s)
return s
def _set_watch_settings(s):
s.setdefault('watchLink', False)
s.setdefault('watchLinkTimeout', 20)
s.setdefault('watchConnect', False)
s.setdefault('watchConnectHost', 'www.google.com')
s.setdefault('watchConnectPort', 80)
s.setdefault('watchConnectRetries', 3)
s.setdefault('watchConnectTimeout', 5)
s.setdefault('watchConnectInterval', 20)
logging.debug('writing watch settings to %s: ' % WATCH_CONF +
('watch_link=%(watchLink)s, watch_link_timeout=%(watchLinkTimeout)s, ' +
'watch_connect=%(watchConnect)s, watch_connect_host=%(watchConnectHost)s, ' +
'watch_connect_port=%(watchConnectPort)s, watch_connect_retries=%(watchConnectRetries)s, ' +
'watch_connect_timeout=%(watchConnectTimeout)s, watch_connect_interval=%(watchConnectInterval)s') % s)
with open(WATCH_CONF, 'w') as f:
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' % ['"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']))
f.write('netwatch_port=%s\n' % s['watchConnectPort'])
f.write('netwatch_retries=%s\n' % s['watchConnectRetries'])
f.write('netwatch_timeout=%s\n' % s['watchConnectTimeout'])
f.write('netwatch_interval=%s\n' % s['watchConnectInterval'])
@additional_section
def expertSettings():
return {
'label': 'Expert Settings',
'description': 'system tweaks and board-specific options',
'advanced': True
}
@additional_config
def watchLink():
return {
'label': 'Network Link Watch',
'description': 'enable this if you want the system to reboot upon detecting network link issues',
'type': 'bool',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_watch_settings,
'set': _set_watch_settings,
'get_set_dict': True
}
@additional_config
def watchLinkTimeout():
return {
'label': 'Network Link Timeout',
'description': 'sets the time after which the network link is considered down',
'type': 'number',
'min': 1,
'max': 3600,
'unit': 's',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'required': True,
'depends': ['watchLink'],
'get': _get_watch_settings,
'set': _set_watch_settings,
'get_set_dict': True
}
@additional_config
def watchConnect():
return {
'label': 'Connectivity Watch',
'description': 'enable this if you want the system to constantly try to connect to a certain host and reboot upon failure',
'type': 'bool',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'get': _get_watch_settings,
'set': _set_watch_settings,
'get_set_dict': True
}
@additional_config
def watchConnectHost():
return {
'label': 'Connectivity Watch Host',
'description': 'sets the hostname or IP address to which a TCP connection will be opened',
'type': 'str',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'required': True,
'depends': ['watchConnect'],
'get': _get_watch_settings,
'set': _set_watch_settings,
'get_set_dict': True
}
@additional_config
def watchConnectPort():
return {
'label': 'Connectivity Watch Port',
'description': 'sets the TCP port TO which the TCP connection will be opened',
'type': 'number',
'min': 1,
'max': 65535,
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'required': True,
'depends': ['watchConnect'],
'get': _get_watch_settings,
'set': _set_watch_settings,
'get_set_dict': True
}
@additional_config
def watchConnectRetries():
return {
'label': 'Connectivity Watch Retries',
'description': 'sets the number of times to retry to connect',
'type': 'number',
'min': 1,
'max': 100,
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'required': True,
'depends': ['watchConnect'],
'get': _get_watch_settings,
'set': _set_watch_settings,
'get_set_dict': True
}
@additional_config
def watchConnectTimeout():
return {
'label': 'Connectivity Watch Timeout',
'description': 'sets the time to wait for the connection to succeed',
'type': 'number',
'min': 1,
'max': 3600,
'unit': 's',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'required': True,
'depends': ['watchConnect'],
'get': _get_watch_settings,
'set': _set_watch_settings,
'get_set_dict': True
}
@additional_config
def watchConnectInterval():
return {
'label': 'Connectivity Watch Interval',
'description': 'sets the time to wait between connections',
'type': 'number',
'min': 1,
'max': 3600,
'unit': 's',
'section': 'expertSettings',
'advanced': True,
'reboot': True,
'required': True,
'depends': ['watchConnect'],
'get': _get_watch_settings,
'set': _set_watch_settings,
'get_set_dict': True
}

View File

@ -1,3 +0,0 @@
config BR2_PACKAGE_STREAMEYE
bool "streameye"

View File

@ -1,21 +0,0 @@
################################################################################
#
# streameye
#
################################################################################
STREAMEYE_VERSION = ffd6f28a094f70c70893f6e516610459faa15ea2
STREAMEYE_SITE = $(call github,ccrisan,streameye,$(STREAMEYE_VERSION))
STREAMEYE_LICENSE = GPLv3
define STREAMEYE_BUILD_CMDS
make CC="$(TARGET_CC)" -C "$(@D)"
endef
define STREAMEYE_INSTALL_TARGET_CMDS
cp $(@D)/streameye $(TARGET_DIR)/usr/bin/
cp $(@D)/extras/raspimjpeg.py $(TARGET_DIR)/usr/bin/
endef
$(eval $(generic-package))