77 lines
1.7 KiB
Plaintext
77 lines
1.7 KiB
Plaintext
|
#! /bin/bash
|
||
|
|
||
|
### BEGIN INIT INFO
|
||
|
# Provides: tokenbridge-monitor
|
||
|
# Required-Start: $remote_fs $syslog
|
||
|
# Required-Stop: $remote_fs $syslog
|
||
|
# Default-Start: 2 3 4 5
|
||
|
# Default-Stop: 0 1 6
|
||
|
# Short-Description: Start daemon at boot time
|
||
|
# Description: Enable service provided by daemon.
|
||
|
### END INIT INFO
|
||
|
|
||
|
WORKDIR="{{ '/home/' + compose_service_user | default('poadocker') + '/' + bridge_path + '/monitor' if bridge_path[:1] != "/" else bridge_path + '/monitor' }}"
|
||
|
|
||
|
start(){
|
||
|
echo "Starting TokenBridge Monitor.."
|
||
|
cd $WORKDIR
|
||
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose down -v
|
||
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose rm -fv
|
||
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose up --detach
|
||
|
}
|
||
|
|
||
|
stop(){
|
||
|
echo "Stopping TokenBridge Monitor.."
|
||
|
cd $WORKDIR
|
||
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose down -v
|
||
|
sleep 2
|
||
|
}
|
||
|
|
||
|
status(){
|
||
|
echo "TokenBridge Monitor status:"
|
||
|
cd $WORKDIR
|
||
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose ps
|
||
|
}
|
||
|
|
||
|
rebuild(){
|
||
|
echo "Rebuild TokenBridge Monitor.."
|
||
|
cd $WORKDIR
|
||
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose down -v
|
||
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose rm -fv
|
||
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose up --detach --force-recreate --no-deps --build
|
||
|
}
|
||
|
|
||
|
|
||
|
case "$1" in
|
||
|
|
||
|
start)
|
||
|
start
|
||
|
;;
|
||
|
|
||
|
stop)
|
||
|
stop
|
||
|
;;
|
||
|
|
||
|
status)
|
||
|
status
|
||
|
;;
|
||
|
|
||
|
restart)
|
||
|
echo "Restarting TokenBridge Monitor.."
|
||
|
stop
|
||
|
start
|
||
|
;;
|
||
|
|
||
|
rebuild)
|
||
|
rebuild
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
echo $"Usage: $0 {start|stop|restart|rebuild|status}"
|
||
|
exit 1
|
||
|
;;
|
||
|
|
||
|
esac
|
||
|
|
||
|
exit 0
|