def find_command(command):
- cmd = __file__
- cmd = sys.executable + ' ' + cmd
- cmd = cmd.replace('-b', '') # remove server-specific options
- cmd += ' %s ' % command
- cmd += ' '.join([pipes.quote(arg) for arg in sys.argv[2:]
- if arg not in ['-b']])
+ if command == 'relayevent':
+ relayevent_sh = os.path.join(os.path.dirname(__file__), 'scripts/relayevent.sh')
+
+ cmd = relayevent_sh + ' "%s"' % (settings._config_file or '')
+
+ else:
+ cmd = __file__
+ cmd = sys.executable + ' ' + cmd
+ cmd = cmd.replace('-b', '') # remove server-specific options
+ cmd += ' %s ' % command
+ cmd += ' '.join([pipes.quote(arg) for arg in sys.argv[2:]
+ if arg not in ['-b']])
return cmd
# use the config file directory as base path
# if not specified otherwise in the config file
base_dir = os.path.dirname(config_file)
+ settings._config_file = config_file
if not conf_path_given[0]:
settings.CONF_PATH = base_dir
--- /dev/null
+#!/bin/bash
+
+if [ -z "$3" ]; then
+ echo "Usage: $0 <motioneye.conf> <event> <thread_id> [filename]"
+ exit -1
+fi
+
+motioneye_conf=$1
+if [ -f "$motioneye_conf" ]; then
+ port=$(cat $motioneye_conf | grep -E '^port' | cut -d ' ' -f 2)
+ conf_path=$(cat $motioneye_conf | grep -E '^conf_path' | cut -d ' ' -f 2)
+ if [ -n "$conf_path" ]; then
+ motion_conf="$conf_path/motion.conf"
+ if [ -r "$motion_conf" ]; then
+ username=$(cat $motion_conf | grep 'admin_username' | cut -d ' ' -f 3)
+ password=$(cat $motion_conf | grep 'admin_password' | cut -d ' ' -f 3)
+ fi
+ fi
+fi
+
+test -z "$port" && port="8765"
+test -z "$username" && username="admin"
+
+event="$2"
+thread_id="$3"
+filename="$4"
+
+uri="/_relay_event/?_username=$username&event=$event&thread_id=$thread_id"
+data="{\"filename\": \"$filename\"}"
+signature=$(echo -n "POST:$uri:$data:$password" | sha1sum | cut -d ' ' -f 1)
+
+curl -H "Content-Type: application/json" -X POST "http://127.0.0.1:$port$uri&_signature=$signature" -d "$data" &>/dev/null
+
+