2019-05-08 13:51:56 +02: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 14:54:32 +02:00
|
|
|
WORKDIR="{{ '/home/' + compose_service_user | default('poadocker') + '/' + bridge_path + '/oracle' if bridge_path[:1] != "/" else bridge_path + '/oracle' }}"
|
2019-05-08 13:51:56 +02:00
|
|
|
|
|
|
|
#Getting path to private key file and variable name for parsing key file
|
|
|
|
keyfile="{{ keyfile_path }}"
|
2019-09-13 09:11:38 +02:00
|
|
|
vaddr="ORACLE_VALIDATOR_ADDRESS="
|
|
|
|
vkey="ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY="
|
2019-10-29 11:55:47 -03:00
|
|
|
composefileoverride="{{ composefileoverride | default('') }}"
|
2019-05-08 13:51:56 +02: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 11: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 13:51:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
stop(){
|
|
|
|
echo "Stopping bridge.."
|
|
|
|
cd $WORKDIR
|
2019-10-29 11:55:47 -03:00
|
|
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose $composefileoverride down -v
|
2019-05-08 13:51:56 +02:00
|
|
|
sleep 2
|
|
|
|
}
|
|
|
|
|
|
|
|
status(){
|
|
|
|
echo "Bridge status:"
|
|
|
|
cd $WORKDIR
|
2019-10-29 11:55:47 -03:00
|
|
|
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose $composefileoverride ps
|
2019-05-08 13:51:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
|
|
|
|
status)
|
|
|
|
status
|
|
|
|
;;
|
|
|
|
|
|
|
|
restart)
|
|
|
|
echo "Restarting bridge.."
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2020-02-03 18:48:28 -03:00
|
|
|
echo $"Usage: $0 {start|stop|restart|status}"
|
2019-05-08 13:51:56 +02:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|