Skip to content

Instantly share code, notes, and snippets.

@John-Gee
Last active June 5, 2020 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save John-Gee/fc1678d97d03620ae411127274acc1fb to your computer and use it in GitHub Desktop.
Save John-Gee/fc1678d97d03620ae411127274acc1fb to your computer and use it in GitHub Desktop.
#!/bin/bash
usage() {
echo "Usage:"
echo "$0 on"
echo "or"
echo "$0 off"
exit
}
check_for_process() {
count=`ps -ef | grep lhctrl.py | grep -v grep | wc -l`
echo $count
}
mode=$1
force=$2
B_ID=""
B_MAC=""
if [[ -z "$mode" ]]; then
usage
elif [[ "on" == "$mode" ]]; then
count=$(check_for_process)
if [ $count -ne 1 ]; then
echo "Turning LHs on"
~/scripts/lhctrl.py -b $B_ID --lh_b_mac $B_MAC -g 0 &
else
echo "LHs should already be on"
fi
elif [[ "off" == "$mode" ]]; then
check_for_process
count=$(check_for_process)
if [ $count -ne 0 ]; then
echo "Turning LHs off"
killall lhctrl.py
else
echo "LHs should already be off"
fi
if [[ $force == "--force" ]] ; then
~/scripts/lhctrl.py -b $B_ID --lh_b_mac $B_MAC -g 1 --lh_timeout 2 -p 1
fi
else
usage
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment