-
-
Save John-Gee/fc1678d97d03620ae411127274acc1fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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