-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FreeBSD support #1616
base: dev
Are you sure you want to change the base?
FreeBSD support #1616
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/sh | ||
|
||
# $FreeBSD$ | ||
# | ||
# PROVIDE: motioneye | ||
# REQUIRE: LOGIN | ||
# KEYWORD: shutdown | ||
# | ||
# Add the following line(s) to /etc/rc.conf to enable motioneye: | ||
# | ||
# motioneye_enable="YES" | ||
# # optional | ||
# motioneye_flags="-l startserver -c $motioneye_config" | ||
# motioneye_user="root" | ||
# motioneye_config="/usr/local/etc/motioneye/motioneye.conf" | ||
|
||
. /etc/rc.subr | ||
|
||
name=motioneye | ||
rcvar=motioneye_enable | ||
load_rc_config $name | ||
|
||
# Set defaults | ||
motioneye_enable=${motioneye_enable:-"NO"} | ||
motioneye_config=${motioneye_config:-"/usr/local/etc/motioneye/motioneye.conf"} | ||
motioneye_flags=${motioneye_flags:-"startserver -l -c $motioneye_config"} | ||
motioneye_user=${motioneye_user:-"root"} | ||
|
||
pidfile=/var/run/motioneye.pid | ||
command_interpreter=/usr/local/bin/python2.7 | ||
command=/usr/local/bin/meyectl | ||
|
||
start_cmd=motioneye_start | ||
stop_postcmd=motioneye_cleanup | ||
|
||
motioneye_start() { | ||
echo "Starting motioneye." | ||
/usr/sbin/daemon -cf -p ${pidfile} -u ${motioneye_user} ${command} ${motioneye_flags} | ||
} | ||
|
||
motioneye_cleanup() { | ||
[ -f ${pidfile} ] && rm ${pidfile} | ||
} | ||
|
||
run_rc_command "$1" | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -29,7 +29,9 @@ filename="$4" | |||||
|
||||||
uri="/_relay_event/?_username=$username&event=$event&motion_camera_id=$motion_camera_id" | ||||||
data="{\"filename\": \"$filename\"}" | ||||||
signature=$(echo -n "POST:$uri:$data:$password" | sha1sum | cut -d ' ' -f 1) | ||||||
# allow for sha1 usage as well as sha1sum | ||||||
sha1=$(which sha1sum sha1) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Problematic if both commands exist. Also, please use
Suggested change
|
||||||
signature=$(echo -n "POST:$uri:$data:$password" | $sha1 | cut -d ' ' -f 1) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To assure compatibility with any kind of shell:
Suggested change
|
||||||
|
||||||
curl -s -S -m $timeout -H "Content-Type: application/json" -X POST "http://127.0.0.1:$port$uri&_signature=$signature" -d "$data" >/dev/null | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,17 +34,23 @@ def get_os_version(): | |
|
||
|
||
def _get_os_version_lsb_release(): | ||
try: | ||
output = subprocess.check_output('lsb_release -sri', shell=True) | ||
lines = output.strip().split() | ||
name, version = lines | ||
if version.lower() == 'rolling': | ||
version = '' | ||
# check if it exists before calling to avoid log spam | ||
rc = subprocess.call(['which', 'lsb_release']) | ||
|
||
if rc == 0: | ||
try: | ||
output = subprocess.check_output('lsb_release -sri', shell=True) | ||
lines = output.strip().split() | ||
name, version = lines | ||
if version.lower() == 'rolling': | ||
version = '' | ||
|
||
return name, version | ||
return name, version | ||
|
||
except: | ||
return _get_os_version_uname() | ||
except: | ||
return _get_os_version_uname() | ||
else: | ||
return _get_os_version_uname() | ||
Comment on lines
+37
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong indentation? Simpler may be: # check if it exists before calling to avoid log spam
if subprocess.call(['which', 'lsb_release']):
try:
output = subprocess.check_output('lsb_release -sri', shell=True)
lines = output.strip().split()
name, version = lines
if version.lower() == 'rolling':
version = ''
return name, version
except:
pass
return _get_os_version_uname() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we please lose the bare except as discussed in PEP8 and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also see annotations on this in CodeFactor. What is the exception type in case of a failing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
except subprocess.CalledProcessError as e:
logging.warning(f'Running lsb_release failed with: {e.output}') Or something like that? |
||
|
||
|
||
def _get_os_version_uname(): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here is something wrong since you return an empty array? Isn't it intended to return
output
and make it an empty array only onexcept
?