bec/bec_server
2022-07-06 13:24:06 +02:00

30 lines
664 B
Bash
Executable File

#!/bin/sh
if [ "$#" -eq 0 ]; then
echo "bec_server <start/restart/stop> <config>"; exit 1
fi
if [[ "$1" == "start" ]]; then
if [[ "$#" -le 1 ]]; then
echo "Please specify a config file. bec_server start <config_file>"; exit 1
fi
tmux has-session -t bec 2>/dev/null
if [[ $? != 0 ]]; then
echo "Starting the BEC server"
./start_tmux_session.sh $2
else
echo "Session already exists."; exit 1
fi
elif [[ "$1" == "restart" ]]; then
./bec_server stop
./bec_server start $2
elif [[ "$1" == "stop" ]]; then
tmux has-session -t bec 2>/dev/null
if [[ $? != 0 ]]; then
echo "Session does not exist"; exit 1
else
tmux kill-session -t bec
fi
fi