Use ${VAR} syntax

This commit is contained in:
Calin Crisan 2019-01-12 17:34:21 +02:00
parent 8642911d60
commit 484d7c23be
11 changed files with 129 additions and 124 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
mkdir -p /var/lib/samba/private mkdir -p /var/lib/samba/private
echo -e "$PASSWORD\n$PASSWORD\n" | /usr/bin/smbpasswd -a admin -s > /dev/null echo -e "${PASSWORD}\n${PASSWORD}\n" | /usr/bin/smbpasswd -a admin -s > /dev/null

View File

@ -2,10 +2,10 @@
test -f /etc/proftpd.conf || exit 0 test -f /etc/proftpd.conf || exit 0
test -n "$OS_VERSION" || source /etc/init.d/base test -n "${OS_VERSION}" || source /etc/init.d/base
test -n "$OS_DEBUG" || source /etc/init.d/conf test -n "${OS_DEBUG}" || source /etc/init.d/conf
test "$OS_NETWORKLESS" == "true" && exit 0 test "${OS_NETWORKLESS}" == "true" && exit 0
start() { start() {
msg_begin "Starting proftpd" msg_begin "Starting proftpd"

View File

@ -2,10 +2,10 @@
test -f /etc/samba/smb.conf || exit 0 test -f /etc/samba/smb.conf || exit 0
test -n "$OS_VERSION" || source /etc/init.d/base test -n "${OS_VERSION}" || source /etc/init.d/base
test -n "$OS_DEBUG" || source /etc/init.d/conf test -n "${OS_DEBUG}" || source /etc/init.d/conf
test "$OS_NETWORKLESS" == "true" && exit 0 test "${OS_NETWORKLESS}" == "true" && exit 0
start() { start() {
mkdir -p /var/log/samba mkdir -p /var/log/samba

View File

@ -11,20 +11,20 @@ MEYEWATCH_DISABLE="false"
DEV_V4L_BY_ID="/dev/v4l/by-id/" DEV_V4L_BY_ID="/dev/v4l/by-id/"
MEDIA_DIR="/data/output" MEDIA_DIR="/data/output"
test -n "$OS_VERSION" || source /etc/init.d/base test -n "${OS_VERSION}" || source /etc/init.d/base
prepare_conf $CONF $SYS_CONF $BOOT_CONF prepare_conf ${CONF} ${SYS_CONF} ${BOOT_CONF}
test -f "$CONF" || exit 0 test -f "${CONF}" || exit 0
test -r $WATCH_CONF && source $WATCH_CONF test -r ${WATCH_CONF} && source ${WATCH_CONF}
opts=$(cat "$CONF" | while read line; do echo "--$line"; done) opts=$(cat "${CONF}" | while read line; do echo "--${line}"; done)
port=$(echo "$opts" | grep -oE 'port [[:digit:]]+' | cut -d ' ' -f 2) port=$(echo "${opts}" | grep -oE 'port [[:digit:]]+' | cut -d ' ' -f 2)
responsive() { responsive() {
curl -m 2 --head http://127.0.0.1:$port &>/dev/null && return 0 || return 1 curl -m 2 --head http://127.0.0.1:${port} &>/dev/null && return 0 || return 1
} }
watch() { watch() {
@ -34,10 +34,10 @@ watch() {
if responsive; then if responsive; then
count=0 count=0
else else
if [ $count -lt $MEYEWATCH_TIMEOUT ]; then if [ ${count} -lt ${MEYEWATCH_TIMEOUT} ]; then
count=$(($count + 5)) count=$((${count} + 5))
else else
logger -t motioneye -s "not responding for $MEYEWATCH_TIMEOUT seconds, rebooting" logger -t motioneye -s "not responding for ${MEYEWATCH_TIMEOUT} seconds, rebooting"
reboot reboot
fi fi
fi fi
@ -47,39 +47,39 @@ watch() {
find_persistent_device() { find_persistent_device() {
device=$1 device=$1
if ! [ -d $DEV_V4L_BY_ID ]; then if ! [ -d ${DEV_V4L_BY_ID} ]; then
echo $device echo ${device}
return return
fi fi
for p in $DEV_V4L_BY_ID/*; do for p in ${DEV_V4L_BY_ID}/*; do
if [ $(realpath "$p") == $device ]; then if [ $(realpath "${p}") == ${device} ]; then
echo $p | sed 's#//*#/#g' echo ${p} | sed 's#//*#/#g'
return return
fi fi
done done
echo $device echo ${device}
} }
add_mmal_cameras() { add_mmal_cameras() {
vcgencmd=$(which vcgencmd) vcgencmd=$(which vcgencmd)
if [ -z "$vcgencmd" ]; then if [ -z "${vcgencmd}" ]; then
return 1 return 1
fi fi
camera=$($vcgencmd get_camera 2>/dev/null) camera=$(${vcgencmd} get_camera 2>/dev/null)
if [ "$camera" != "supported=1 detected=1" ]; then if [ "${camera}" != "supported=1 detected=1" ]; then
return 1 return 1
fi fi
output_dir="/data/output/camera1/" output_dir="/data/output/camera1/"
loc="/config/add/?_username=admin" loc="/config/add/?_username=admin"
device="vc.ril.camera" device="vc.ril.camera"
body="{\"path\": \"$device\", \"proto\": \"mmal\"}" body="{\"path\": \"${device}\", \"proto\": \"mmal\"}"
signature=$(echo -n "POST:$loc:$body:" | sha1sum | cut -d ' ' -f 1) 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 curl -s -m 60 --data "${body}" "http://127.0.0.1:${port}${loc}&_signature=${signature}" > /dev/null
return 0 return 0
} }
@ -88,20 +88,20 @@ add_v4l2_cameras() {
index=1 index=1
for device in $(ls /dev/video* 2>/dev/null); do for device in $(ls /dev/video* 2>/dev/null); do
# filter out devices that don't look like cameras # filter out devices that don't look like cameras
if ! v4l2-ctl -d $device --list-formats-ext 2>/dev/null | grep -oE '[[:digit:]]+x[[:digit:]]+' &>/dev/null; then if ! v4l2-ctl -d ${device} --list-formats-ext 2>/dev/null | grep -oE '[[:digit:]]+x[[:digit:]]+' &>/dev/null; then
continue continue
fi fi
output_dir="/data/output/camera$index/" output_dir="/data/output/camera${index}/"
loc="/config/add/?_username=admin" loc="/config/add/?_username=admin"
device=$(find_persistent_device $device) device=$(find_persistent_device ${device})
body="{\"path\": \"$device\", \"proto\": \"v4l2\"}" body="{\"path\": \"${device}\", \"proto\": \"v4l2\"}"
signature=$(echo -n "POST:$loc:$body:" | sha1sum | cut -d ' ' -f 1) 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 curl -s -m 60 --data "${body}" "http://127.0.0.1:${port}${loc}&_signature=${signature}" > /dev/null
index=$(($index + 1)) index=$((${index} + 1))
done done
if [ $index -gt 1 ]; then if [ ${index} -gt 1 ]; then
return 0 return 0
else else
return 1 return 1
@ -111,8 +111,8 @@ add_v4l2_cameras() {
start() { start() {
msg_begin "Starting motioneye" msg_begin "Starting motioneye"
mkdir -p $MEDIA_DIR mkdir -p ${MEDIA_DIR}
meyectl startserver -b -c $CONF -l meyectl startserver -b -c ${CONF} -l
count=0 count=0
while true; do while true; do
@ -122,22 +122,22 @@ start() {
break break
fi fi
if [ $count -gt $MEYEWATCH_TIMEOUT ]; then if [ ${count} -gt ${MEYEWATCH_TIMEOUT} ]; then
msg_fail msg_fail
test "$MEYEWATCH_DISABLE" == "false" && reboot test "${MEYEWATCH_DISABLE}" == "false" && reboot
return 1 return 1
fi fi
count=$(($count + 1)) count=$((${count} + 1))
done done
# add connected camera(s) with default settings # add connected camera(s) with default settings
if responsive && ! [ -f $MOTION_CONF ]; then if responsive && ! [ -f ${MOTION_CONF} ]; then
add_mmal_cameras || add_v4l2_cameras add_mmal_cameras || add_v4l2_cameras
sync sync
fi fi
if [ "$MEYEWATCH_DISABLE" == "false" ]; then if [ "${MEYEWATCH_DISABLE}" == "false" ]; then
watch & watch &
fi fi
@ -146,7 +146,7 @@ start() {
stop() { stop() {
msg_begin "Stopping motioneye" msg_begin "Stopping motioneye"
meyectl stopserver -c $CONF &>/dev/null meyectl stopserver -c ${CONF} &>/dev/null
test $? == 0 && msg_done || msg_fail 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 ps | grep motioneye | grep -v $$ | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1 | xargs -r kill
} }

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
test "$MEYE_USERNAME" == "admin" || exit 0 test "${MEYE_USERNAME}" == "admin" || exit 0
PASSWORD="$MEYE_PASSWORD" /usr/sbin/adminpasswd PASSWORD="${MEYE_PASSWORD}" /usr/sbin/adminpasswd

View File

@ -3,14 +3,14 @@
MOTIONEYE_CONF_DIR="/data/etc/" MOTIONEYE_CONF_DIR="/data/etc/"
test -n "$OS_VERSION" || source /etc/init.d/base test -n "${OS_VERSION}" || source /etc/init.d/base
enabled() { enabled() {
test $(ls -1 $MOTIONEYE_CONF_DIR/thread-*.conf 2>/dev/null| wc -l) == 1 || return 1 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 '# @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 grep -E '# @url http://(.*)127.0.0.1:' ${MOTIONEYE_CONF_DIR}/thread-1.conf &>/dev/null || return 1
return 0 return 0
} }

View File

@ -6,8 +6,9 @@ MOTIONEYE_CONF=/data/etc/motioneye.conf
STREAMEYE_CONF=/data/etc/streameye.conf STREAMEYE_CONF=/data/etc/streameye.conf
STREAMEYE_LOG=/var/log/streameye.log STREAMEYE_LOG=/var/log/streameye.log
test -r $RASPIMJPEG_CONF || exit 1
test -r $STREAMEYE_CONF || exit 1 test -r ${RASPIMJPEG_CONF} || exit 1
test -r ${STREAMEYE_CONF} || exit 1
watch() { watch() {
count=0 count=0
@ -22,33 +23,33 @@ watch() {
function start() { function start() {
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1) pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -n "$pid" ]; then if [ -n "${pid}" ]; then
return return
fi fi
raspimjpeg_opts="" raspimjpeg_opts=""
while read line; do while read line; do
if echo "$line" | grep false &>/dev/null; then if echo "${line}" | grep false &>/dev/null; then
continue continue
fi fi
if echo "$line" | grep true &>/dev/null; then if echo "${line}" | grep true &>/dev/null; then
line=$(echo $line | cut -d ' ' -f 1) line=$(echo ${line} | cut -d ' ' -f 1)
fi fi
raspimjpeg_opts="$raspimjpeg_opts --$line" raspimjpeg_opts="${raspimjpeg_opts} --${line}"
done < $RASPIMJPEG_CONF done < ${RASPIMJPEG_CONF}
source $STREAMEYE_CONF source ${STREAMEYE_CONF}
streameye_opts="-p $PORT" streameye_opts="-p ${PORT}"
if [ -n "$CREDENTIALS" ] && [ "$AUTH" = "basic" ]; then if [ -n "${CREDENTIALS}" ] && [ "${AUTH}" = "basic" ]; then
streameye_opts="$streameye_opts -a basic -c $CREDENTIALS" streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}"
fi fi
if [ -r $MOTIONEYE_CONF ] && grep 'log-level debug' $MOTIONEYE_CONF >/dev/null; then if [ -r ${MOTIONEYE_CONF} ] && grep 'log-level debug' ${MOTIONEYE_CONF} >/dev/null; then
raspimjpeg_opts="$raspimjpeg_opts -d" raspimjpeg_opts="${raspimjpeg_opts} -d"
streameye_opts="$streameye_opts -d" streameye_opts="${streameye_opts} -d"
fi fi
raspimjpeg.py $raspimjpeg_opts 2>$RASPIMJPEG_LOG | streameye $streameye_opts &>$STREAMEYE_LOG & raspimjpeg.py ${raspimjpeg_opts} 2>${RASPIMJPEG_LOG} | streameye ${streameye_opts} &>${STREAMEYE_LOG} &
} }
function stop() { function stop() {
@ -57,17 +58,17 @@ function stop() {
# stop the raspimjpeg process # stop the raspimjpeg process
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1) pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -z "$pid" ]; then if [ -z "${pid}" ]; then
return return
fi fi
kill -HUP "$pid" &>/dev/null kill -HUP "${pid}" &>/dev/null
count=0 count=0
while kill -0 "$pid" &>/dev/null && [ $count -lt 5 ]; do while kill -0 "${pid}" &>/dev/null && [ ${count} -lt 5 ]; do
sleep 1 sleep 1
count=$(($count + 1)) count=$((${count} + 1))
done done
kill -KILL "$pid" &>/dev/null || true kill -KILL "${pid}" &>/dev/null || true
} }
case "$1" in case "$1" in

View File

@ -1,15 +1,16 @@
#!/bin/sh #!/bin/sh
motioneye_conf_dir="/data/etc/" MOTIONEYE_CONF_DIR="/data/etc/"
test -n "$OS_VERSION" || source /etc/init.d/base
test -n "${OS_VERSION}" || source /etc/init.d/base
enabled() { enabled() {
test $(ls -1 $motioneye_conf_dir/thread-*.conf 2>/dev/null| wc -l) == 1 || return 1 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 '# @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 grep -E '# @url http://(.*)127.0.0.1:' ${MOTIONEYE_CONF_DIR}/thread-1.conf &>/dev/null || return 1
return 0 return 0
} }

View File

@ -6,8 +6,9 @@ MOTIONEYE_CONF=/data/etc/motioneye.conf
STREAMEYE_CONF=/data/etc/streameye.conf STREAMEYE_CONF=/data/etc/streameye.conf
STREAMEYE_LOG=/var/log/streameye.log STREAMEYE_LOG=/var/log/streameye.log
test -r $RASPIMJPEG_CONF || exit 1
test -r $STREAMEYE_CONF || exit 1 test -r ${RASPIMJPEG_CONF} || exit 1
test -r ${STREAMEYE_CONF} || exit 1
watch() { watch() {
count=0 count=0
@ -22,33 +23,33 @@ watch() {
function start() { function start() {
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1) pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -n "$pid" ]; then if [ -n "${pid}" ]; then
return return
fi fi
raspimjpeg_opts="" raspimjpeg_opts=""
while read line; do while read line; do
if echo "$line" | grep false &>/dev/null; then if echo "${line}" | grep false &>/dev/null; then
continue continue
fi fi
if echo "$line" | grep true &>/dev/null; then if echo "${line}" | grep true &>/dev/null; then
line=$(echo $line | cut -d ' ' -f 1) line=$(echo ${line} | cut -d ' ' -f 1)
fi fi
raspimjpeg_opts="$raspimjpeg_opts --$line" raspimjpeg_opts="${raspimjpeg_opts} --${line}"
done < $RASPIMJPEG_CONF done < ${RASPIMJPEG_CONF}
source $STREAMEYE_CONF source ${STREAMEYE_CONF}
streameye_opts="-p $PORT" streameye_opts="-p ${PORT}"
if [ -n "$CREDENTIALS" ] && [ "$AUTH" = "basic" ]; then if [ -n "${CREDENTIALS}" ] && [ "${AUTH}" = "basic" ]; then
streameye_opts="$streameye_opts -a basic -c $CREDENTIALS" streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}"
fi fi
if [ -r $MOTIONEYE_CONF ] && grep 'log-level debug' $MOTIONEYE_CONF >/dev/null; then if [ -r ${MOTIONEYE_CONF} ] && grep 'log-level debug' ${MOTIONEYE_CONF} >/dev/null; then
raspimjpeg_opts="$raspimjpeg_opts -d" raspimjpeg_opts="${raspimjpeg_opts} -d"
streameye_opts="$streameye_opts -d" streameye_opts="${streameye_opts} -d"
fi fi
raspimjpeg.py $raspimjpeg_opts 2>$RASPIMJPEG_LOG | streameye $streameye_opts &>$STREAMEYE_LOG & raspimjpeg.py ${raspimjpeg_opts} 2>${RASPIMJPEG_LOG} | streameye ${streameye_opts} &>${STREAMEYE_LOG} &
} }
function stop() { function stop() {
@ -57,17 +58,17 @@ function stop() {
# stop the raspimjpeg process # stop the raspimjpeg process
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1) pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -z "$pid" ]; then if [ -z "${pid}" ]; then
return return
fi fi
kill -HUP "$pid" &>/dev/null kill -HUP "${pid}" &>/dev/null
count=0 count=0
while kill -0 "$pid" &>/dev/null && [ $count -lt 5 ]; do while kill -0 "${pid}" &>/dev/null && [ ${count} -lt 5 ]; do
sleep 1 sleep 1
count=$(($count + 1)) count=$((${count} + 1))
done done
kill -KILL "$pid" &>/dev/null || true kill -KILL "${pid}" &>/dev/null || true
} }
case "$1" in case "$1" in

View File

@ -1,15 +1,16 @@
#!/bin/sh #!/bin/sh
motioneye_conf_dir="/data/etc/" MOTIONEYE_CONF_DIR="/data/etc/"
test -n "$OS_VERSION" || source /etc/init.d/base
test -n "${OS_VERSION}" || source /etc/init.d/base
enabled() { enabled() {
test $(ls -1 $motioneye_conf_dir/thread-*.conf 2>/dev/null| wc -l) == 1 || return 1 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 '# @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 grep -E '# @url http://(.*)127.0.0.1:' ${MOTIONEYE_CONF_DIR}/thread-1.conf &>/dev/null || return 1
return 0 return 0
} }

View File

@ -6,8 +6,9 @@ MOTIONEYE_CONF=/data/etc/motioneye.conf
STREAMEYE_CONF=/data/etc/streameye.conf STREAMEYE_CONF=/data/etc/streameye.conf
STREAMEYE_LOG=/var/log/streameye.log STREAMEYE_LOG=/var/log/streameye.log
test -r $RASPIMJPEG_CONF || exit 1
test -r $STREAMEYE_CONF || exit 1 test -r ${RASPIMJPEG_CONF} || exit 1
test -r ${STREAMEYE_CONF} || exit 1
watch() { watch() {
count=0 count=0
@ -22,33 +23,33 @@ watch() {
function start() { function start() {
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1) pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -n "$pid" ]; then if [ -n "${pid}" ]; then
return return
fi fi
raspimjpeg_opts="" raspimjpeg_opts=""
while read line; do while read line; do
if echo "$line" | grep false &>/dev/null; then if echo "${line}" | grep false &>/dev/null; then
continue continue
fi fi
if echo "$line" | grep true &>/dev/null; then if echo "${line}" | grep true &>/dev/null; then
line=$(echo $line | cut -d ' ' -f 1) line=$(echo ${line} | cut -d ' ' -f 1)
fi fi
raspimjpeg_opts="$raspimjpeg_opts --$line" raspimjpeg_opts="${raspimjpeg_opts} --${line}"
done < $RASPIMJPEG_CONF done < ${RASPIMJPEG_CONF}
source $STREAMEYE_CONF source ${STREAMEYE_CONF}
streameye_opts="-p $PORT" streameye_opts="-p ${PORT}"
if [ -n "$CREDENTIALS" ] && [ "$AUTH" = "basic" ]; then if [ -n "${CREDENTIALS}" ] && [ "${AUTH}" = "basic" ]; then
streameye_opts="$streameye_opts -a basic -c $CREDENTIALS" streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}"
fi fi
if [ -r $MOTIONEYE_CONF ] && grep 'log-level debug' $MOTIONEYE_CONF >/dev/null; then if [ -r ${MOTIONEYE_CONF} ] && grep 'log-level debug' ${MOTIONEYE_CONF} >/dev/null; then
raspimjpeg_opts="$raspimjpeg_opts -d" raspimjpeg_opts="${raspimjpeg_opts} -d"
streameye_opts="$streameye_opts -d" streameye_opts="${streameye_opts} -d"
fi fi
raspimjpeg.py $raspimjpeg_opts 2>$RASPIMJPEG_LOG | streameye $streameye_opts &>$STREAMEYE_LOG & raspimjpeg.py ${raspimjpeg_opts} 2>${RASPIMJPEG_LOG} | streameye ${streameye_opts} &>${STREAMEYE_LOG} &
} }
function stop() { function stop() {
@ -57,17 +58,17 @@ function stop() {
# stop the raspimjpeg process # stop the raspimjpeg process
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1) pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
if [ -z "$pid" ]; then if [ -z "${pid}" ]; then
return return
fi fi
kill -HUP "$pid" &>/dev/null kill -HUP "${pid}" &>/dev/null
count=0 count=0
while kill -0 "$pid" &>/dev/null && [ $count -lt 5 ]; do while kill -0 "${pid}" &>/dev/null && [ ${count} -lt 5 ]; do
sleep 1 sleep 1
count=$(($count + 1)) count=$((${count} + 1))
done done
kill -KILL "$pid" &>/dev/null || true kill -KILL "${pid}" &>/dev/null || true
} }
case "$1" in case "$1" in