2019-05-08 14:51:56 +03:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: poabridge
|
|
|
|
# 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
|
|
|
|
|
2019-05-31 15:54:32 +03:00
|
|
|
WORKDIR="{{ '/home/' + compose_service_user | default('poadocker') + '/' + bridge_path + '/oracle' if bridge_path[:1] != "/" else bridge_path + '/oracle' }}"
|
2019-05-08 14:51:56 +03:00
|
|
|
|
|
|
|
#Getting path to private key file and variable name for parsing key file
|
|
|
|
keyfile="{{ keyfile_path }}"
|
2019-09-13 10:11:38 +03:00
|
|
|
vaddr="ORACLE_VALIDATOR_ADDRESS="
|
|
|
|
vkey="ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY="
|
2019-10-29 17:55:47 +03:00
|
|
|
composefileoverride="{{ composefileoverride | default('') }}"
|
2019-05-08 14:51:56 +03:00
|
|
|
|
|
|
|
#Parsing file content and add key to variable
|
|
|
|
while read -r line
|
|
|
|
do
|
|
|
|
case $line in
|
|
|
|
$vaddr*)
|
|
|
|
vaddr=${line#$vaddr}
|
|
|
|
;;
|
|
|
|
$vkey*)
|
|
|
|
vkey=${line#$vkey}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < $keyfile
|
|
|
|
|
|
|
|
start(){
|
|
|
|
echo "Starting bridge.."
|
|
|
|
cd $WORKDIR
|
2019-10-29 17:55:47 +03:00
|
|
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose $composefileoverride down -v
|
|
|
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose $composefileoverride rm -fv
|
|
|
|
sudo -u "{{ compose_service_user }}" ORACLE_VALIDATOR_ADDRESS=$vaddr ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=$vkey /usr/local/bin/docker-compose $composefileoverride up --detach
|
2019-05-08 14:51:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
stop(){
|
|
|
|
echo "Stopping bridge.."
|
|
|
|
cd $WORKDIR
|
2019-10-29 17:55:47 +03:00
|
|
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose $composefileoverride down -v
|
2019-05-08 14:51:56 +03:00
|
|
|
sleep 2
|
|
|
|
}
|
|
|
|
|
|
|
|
status(){
|
|
|
|
echo "Bridge status:"
|
|
|
|
cd $WORKDIR
|
2019-10-29 17:55:47 +03:00
|
|
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose $composefileoverride ps
|
2019-05-08 14:51:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
rebuild(){
|
|
|
|
echo "Rebuild bridge.."
|
|
|
|
cd $WORKDIR
|
2019-10-29 17:55:47 +03:00
|
|
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose $composefileoverride down -v
|
|
|
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose $composefileoverride rm -fv
|
|
|
|
sudo -u "{{ compose_service_user }}" ORACLE_VALIDATOR_ADDRESS=$vaddr ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY=$vkey /usr/local/bin/docker-compose $composefileoverride up --detach --force-recreate --no-deps --build
|
2019-05-08 14:51:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
|
|
|
|
status)
|
|
|
|
status
|
|
|
|
;;
|
|
|
|
|
|
|
|
restart)
|
|
|
|
echo "Restarting bridge.."
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
|
|
|
|
rebuild)
|
|
|
|
rebuild
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo $"Usage: $0 {start|stop|restart|rebuild|status}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|