45 lines
493 B
Bash
45 lines
493 B
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
|
||
|
|
## consts
|
||
|
|
|
||
|
|
pidfile="/var/mautrix-telegram/run.pid"
|
||
|
|
|
||
|
|
|
||
|
|
## functions
|
||
|
|
|
||
|
|
function start
|
||
|
|
{
|
||
|
|
cd {{var_synapse_bridge_mautrix_telegram_directory}}
|
||
|
|
source ./bin/activate
|
||
|
|
python -m mautrix_telegram &
|
||
|
|
pid=$!
|
||
|
|
echo ${pid} > ${pidfile}
|
||
|
|
}
|
||
|
|
|
||
|
|
function stop
|
||
|
|
{
|
||
|
|
pid=$(cat ${pidfile})
|
||
|
|
kill ${pid}
|
||
|
|
}
|
||
|
|
|
||
|
|
function toggle
|
||
|
|
{
|
||
|
|
if $(test ! -e ${pidfile})
|
||
|
|
then
|
||
|
|
start
|
||
|
|
else
|
||
|
|
stop
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
## args
|
||
|
|
|
||
|
|
if $(test $# -ge 1) ; then command=$1 && shift ; else command="toggle" ; fi
|
||
|
|
|
||
|
|
|
||
|
|
## exec
|
||
|
|
|
||
|
|
${command}
|
||
|
|
|