Compare commits
No commits in common. "prod" and "master" have entirely different histories.
81
run
81
run
@ -1,81 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
dev=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A500DA2H-if00-port0
|
|
||||||
rundir=$(realpath $(dirname $0))
|
|
||||||
session="tic2mqtt"
|
|
||||||
|
|
||||||
cmd=""
|
|
||||||
quiet=""
|
|
||||||
|
|
||||||
cd $rundir
|
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
|
||||||
case "$1" in
|
|
||||||
start) cmd=$1;;
|
|
||||||
stop) cmd=$1;;
|
|
||||||
restart) cmd=$1;;
|
|
||||||
status) cmd=$1;;
|
|
||||||
log) cmd=$1;;
|
|
||||||
-q) quiet=$1;;
|
|
||||||
--quiet) quiet=$1;;
|
|
||||||
*) echo "usage: $0 [start|stop|restart|status|log] [-q|--quiet]"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
is_running=$(tmux has -t $session 2> /dev/null && echo yes)
|
|
||||||
|
|
||||||
case "$cmd" in
|
|
||||||
start)
|
|
||||||
if [ -n "$is_running" ]; then
|
|
||||||
echo "tic2mqtt already running. aborting"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
make -s
|
|
||||||
test -z $quiet && echo "starting tic2mqtt"
|
|
||||||
tmux new -s $session -d "./tic2mqtt -a -t $dev -h doctor -v"
|
|
||||||
test -z $quiet && tmux ls
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
if [ ! -n "$is_running" ]; then
|
|
||||||
test -z $quiet && echo "no tic2mqtt running. nothing to stop"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
test -z $quiet && echo "killing tic2mqtt"
|
|
||||||
tmux kill-session -t $session
|
|
||||||
;;
|
|
||||||
restart)
|
|
||||||
$0 $quiet stop
|
|
||||||
$0 $quiet start
|
|
||||||
;;
|
|
||||||
status)
|
|
||||||
if [ -n "$is_running" ]; then
|
|
||||||
tmux ls | grep $session
|
|
||||||
else
|
|
||||||
echo "no tic2mqtt running"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
log)
|
|
||||||
if [ -n "$is_running" ]; then
|
|
||||||
tmp=$(mktemp)
|
|
||||||
tmux capture -t $session -p -S - >$tmp
|
|
||||||
if [ $(cat $tmp |wc -l) -gt 30 ]; then
|
|
||||||
head -10 $tmp
|
|
||||||
echo
|
|
||||||
echo "[...]"
|
|
||||||
echo
|
|
||||||
tail -20 $tmp
|
|
||||||
else
|
|
||||||
cat $tmp
|
|
||||||
fi
|
|
||||||
rm -f $tmp
|
|
||||||
else
|
|
||||||
echo "no tic2mqtt running"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "usage: $0 [start|stop]"
|
|
||||||
;;
|
|
||||||
esac
|
|
Loading…
Reference in New Issue
Block a user