mirror of
https://github.com/aljazceru/cyphernode.git
synced 2026-01-03 04:55:46 +01:00
A lot of small fixes, improvements on startup tests, migration
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./trace.sh
|
||||
|
||||
trim() {
|
||||
echo -e "$1" | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//'
|
||||
}
|
||||
@@ -7,12 +9,12 @@ trim() {
|
||||
createCurlConfig() {
|
||||
|
||||
if [[ ''$1 == '' ]]; then
|
||||
echo "Missing file name: Check your *_BTC_NODE_RPC_CFG"
|
||||
trace "[startproxy] Missing file name: Check your *_BTC_NODE_RPC_CFG"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ ''$2 == '' ]]; then
|
||||
echo "Missing content: Check your *_BTC_NODE_RPC_USER"
|
||||
trace "[startproxy] Missing content: Check your *_BTC_NODE_RPC_USER"
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -21,17 +23,45 @@ createCurlConfig() {
|
||||
|
||||
}
|
||||
|
||||
if [ -e ${DB_PATH}/.dbfailed ]; then
|
||||
touch /container_monitor/proxy_dbfailed
|
||||
trace "[startproxy] A previous database creation/migration failed. Stopping."
|
||||
trace "[startproxy] A file called .dbfailed has been created. Fix the migration errors, remove .dbfailed and retry."
|
||||
trace "[startproxy] Exiting."
|
||||
sleep 30
|
||||
exit 1
|
||||
else
|
||||
rm -f /container_monitor/proxy_dbfailed
|
||||
fi
|
||||
|
||||
if [ ! -e ${DB_FILE} ]; then
|
||||
echo "DB not found, creating..."
|
||||
trace "[startproxy] DB not found, creating..."
|
||||
cat cyphernode.sql | sqlite3 $DB_FILE
|
||||
psql -h postgres -f cyphernode.postgresql -U cyphernode
|
||||
returncode=$?
|
||||
trace_rc ${returncode}
|
||||
else
|
||||
echo "DB found, migrating..."
|
||||
trace "[startproxy] DB found, migrating..."
|
||||
for script in sqlmigrate*.sh; do
|
||||
sh $script
|
||||
returncode=$?
|
||||
trace_rc ${returncode}
|
||||
if [ "${returncode}" -ne "0" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "${returncode}" -ne "0" ]; then
|
||||
touch ${DB_PATH}/.dbfailed
|
||||
touch /container_monitor/proxy_dbfailed
|
||||
trace "[startproxy] Database creation/migration failed. Stopping."
|
||||
trace "[startproxy] A file called .dbfailed has been created in your proxy datapath. Fix the migration errors, remove .dbfailed and retry."
|
||||
trace "[startproxy] Exiting."
|
||||
sleep 30
|
||||
exit ${returncode}
|
||||
fi
|
||||
|
||||
chmod 0600 $DB_FILE
|
||||
|
||||
createCurlConfig ${WATCHER_BTC_NODE_RPC_CFG} ${WATCHER_BTC_NODE_RPC_USER}
|
||||
|
||||
Reference in New Issue
Block a user