updated start script
This commit is contained in:
parent
729923fe63
commit
4fff689cfe
189
start-qortal.sh
189
start-qortal.sh
@ -1,102 +1,123 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
QORTAL_RUNNING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
|
# Check if Qortal is running
|
||||||
GUI_START="~/.config/autostart/start-qortal.desktop"
|
QORTAL_RUNNING=$(pgrep -f 'java.*qortal' > /dev/null && echo 1 || echo 0)
|
||||||
|
GUI_START="${HOME}/.config/autostart/start-qortal.desktop"
|
||||||
|
|
||||||
if [ -f "${GUI_START}" ]; then
|
if [[ -f "$GUI_START" ]]; then
|
||||||
echo "Qortal is set up to start via GUI, waiting 2 minutes for Qortal to start..."
|
echo "Qortal is set to start via GUI. Checking if it is running..."
|
||||||
sleep 120
|
|
||||||
echo "Checking if Qortal is running..."
|
if [[ "$QORTAL_RUNNING" -eq 1 ]]; then
|
||||||
QORTAL_RUNNING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
|
echo "Qortal is already running. Checking if it's responding..."
|
||||||
if [ -n "${QORTAL_RUNNING}" ]; then
|
sleep 60
|
||||||
echo "Qortal is already running...not starting Qortal..."
|
QORTAL_RESPONDING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
|
||||||
exit
|
|
||||||
|
if [[ -n "$QORTAL_RESPONDING" ]]; then
|
||||||
|
echo "Qortal is running and responding. Exiting..."
|
||||||
|
exit 0
|
||||||
else
|
else
|
||||||
echo "Qortal did not start after 2 minutes...waiting another 90 seconds..."
|
echo "Qortal is running but not responding. Restarting..."
|
||||||
sleep 90
|
killall -9 java
|
||||||
echo "Attempting to start Qortal again..."
|
sleep 5
|
||||||
bash ~/qortal/start.sh
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Qortal is not running. Starting Qortal..."
|
||||||
|
cd "${HOME}/qortal" || exit
|
||||||
|
./start.sh
|
||||||
echo "Waiting 120 seconds..."
|
echo "Waiting 120 seconds..."
|
||||||
sleep 120
|
sleep 120
|
||||||
QORTAL_RUNNING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
|
|
||||||
if [ -n "${QORTAL_RUNNING}" ]; then
|
QORTAL_RUNNING=$(pgrep -f 'java.*qortal' > /dev/null && echo 1 || echo 0)
|
||||||
echo "Qortal running, exiting..."
|
QORTAL_RESPONDING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
|
||||||
exit
|
|
||||||
else
|
if [[ "$QORTAL_RUNNING" -eq 1 ]]; then
|
||||||
echo "Qortal is still not running... checking for auto-fix-visible GUI..."
|
echo "Qortal started successfully. Verifying response after 60 seconds..."
|
||||||
if [ -f ~/.config/autostart/auto-fix-visible* ]; then
|
sleep 60
|
||||||
echo "auto-fix-visible exists, waiting for auto-fix script to run..."
|
if [[ -n "$QORTAL_RESPONDING" ]]; then
|
||||||
|
echo "Qortal is responding! All good! Exiting..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Qortal is still not running. Checking for auto-fix-visible script..."
|
||||||
|
if [[ -f "${HOME}/.config/autostart/auto-fix-visible*" ]]; then
|
||||||
|
echo "Auto-fix script exists. Waiting for it to run..."
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "auto-fix-visible doesn't exist... running auto-fix script manually..."
|
echo "Auto-fix script not found. Downloading and executing manually..."
|
||||||
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-qortal.sh
|
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-qortal.sh
|
||||||
chmod +x auto-fix-qortal.sh
|
chmod +x auto-fix-qortal.sh
|
||||||
echo "Executing auto-fix-qortal.sh..."
|
|
||||||
./auto-fix-qortal.sh
|
./auto-fix-qortal.sh
|
||||||
exit
|
exit 0
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "Qortal is not set to start via GUI. Checking if it is running..."
|
||||||
|
|
||||||
|
if [[ "$QORTAL_RUNNING" -eq 1 ]]; then
|
||||||
|
echo "Qortal is running. Checking response after 60 seconds..."
|
||||||
|
sleep 60
|
||||||
|
QORTAL_RESPONDING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
|
||||||
|
|
||||||
|
if [[ -n "$QORTAL_RESPONDING" ]]; then
|
||||||
|
echo "Qortal is responding. Exiting..."
|
||||||
|
exit 0
|
||||||
else
|
else
|
||||||
echo "Qortal is not set up to start via GUI...Checking if Qortal is running after a 90-second wait..."
|
echo "Qortal is running but unresponsive. Restarting..."
|
||||||
sleep 90
|
|
||||||
QORTAL_RUNNING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
|
|
||||||
if [ -z "${QORTAL_RUNNING}" ]; then
|
|
||||||
echo "Qortal is not running..."
|
|
||||||
echo "Attempting to start Qortal..."
|
|
||||||
bash ~/qortal/start.sh
|
|
||||||
echo "Start script has executed, awaiting Qortal start..."
|
|
||||||
sleep 90
|
|
||||||
echo "Checking if Qortal is running..."
|
|
||||||
QORTAL_RUNNING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
|
|
||||||
if [ -n "${QORTAL_RUNNING}" ]; then
|
|
||||||
echo "Qortal has started successfully! Exiting script..."
|
|
||||||
exit
|
|
||||||
else
|
|
||||||
echo "Qortal did not start...force-killing Java and starting again..."
|
|
||||||
killall -9 java
|
killall -9 java
|
||||||
bash ~/qortal/start.sh
|
sleep 5
|
||||||
echo "Qortal start script has been executed..."
|
fi
|
||||||
if crontab -l | grep -q '#.*auto-fix-qortal.sh'; then
|
fi
|
||||||
echo "'auto-fix-qortal.sh' is commented out in crontab. Manually executing auto-fix script..."
|
|
||||||
echo "Grabbing the newest version of auto-fix script..."
|
echo "Qortal is not running. Attempting to start..."
|
||||||
cd
|
cd "${HOME}/qortal" || exit
|
||||||
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-qortal.sh
|
./start.sh
|
||||||
chmod +x auto-fix-qortal.sh
|
echo "Start script executed. Waiting 90 seconds..."
|
||||||
echo "Executing auto-fix-qortal.sh..."
|
sleep 90
|
||||||
./auto-fix-qortal.sh
|
|
||||||
exit
|
QORTAL_RUNNING=$(pgrep -f 'java.*qortal' > /dev/null && echo 1 || echo 0)
|
||||||
elif crontab -l | grep -q '[^#]*auto-fix-qortal.sh'; then
|
QORTAL_RESPONDING=$(curl -sS --connect-timeout 10 "localhost:12391/admin/status")
|
||||||
echo "'auto-fix-qortal.sh' is active in crontab...auto-fix script should run automatically within 7 min from reboot..."
|
|
||||||
echo "Checking if machine has just booted..."
|
if [[ "$QORTAL_RUNNING" -eq 1 ]]; then
|
||||||
UPTIME=$(awk '{print int($1)}' /proc/uptime)
|
echo "Qortal started successfully. Checking response..."
|
||||||
if [ "${UPTIME}" -ge 420 ]; then
|
if [[ -n "$QORTAL_RESPONDING" ]]; then
|
||||||
echo "Machine has been online longer than 7 min, assuming auto-fix script would have run if it were supposed to..."
|
echo "Qortal is running and responding! Exiting..."
|
||||||
echo "Running auto-fix script manually..."
|
exit 0
|
||||||
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-qortal.sh
|
fi
|
||||||
chmod +x auto-fix-qortal.sh
|
fi
|
||||||
echo "Executing auto-fix-qortal.sh..."
|
|
||||||
./auto-fix-qortal.sh
|
echo "Qortal did not start. Killing Java processes and retrying..."
|
||||||
exit
|
killall -9 java
|
||||||
else
|
cd "${HOME}/qortal"
|
||||||
echo "Machine has been online less than 7 min, allowing auto-fix script to run on its own..."
|
./start.sh
|
||||||
exit
|
|
||||||
fi
|
echo "Checking crontab for auto-fix script..."
|
||||||
else
|
if crontab -l | grep -q '#.*auto-fix-qortal.sh'; then
|
||||||
echo "'auto-fix-qortal.sh' does not exist in crontab."
|
echo "Auto-fix script is commented out. Running manually..."
|
||||||
echo "Assuming it was removed accidentally..."
|
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-qortal.sh
|
||||||
echo "Running auto-fix script manually, and setting it up to run automatically..."
|
chmod +x auto-fix-qortal.sh
|
||||||
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-qortal.sh
|
./auto-fix-qortal.sh
|
||||||
chmod +x auto-fix-qortal.sh
|
exit 0
|
||||||
echo "Executing auto-fix-qortal.sh..."
|
elif crontab -l | grep -q '[^#]*auto-fix-qortal.sh'; then
|
||||||
./auto-fix-qortal.sh
|
echo "Auto-fix script is in crontab. Checking machine uptime..."
|
||||||
exit
|
UPTIME=$(awk '{print int($1)}' /proc/uptime)
|
||||||
fi
|
|
||||||
fi
|
if [[ "$UPTIME" -ge 420 ]]; then
|
||||||
else
|
echo "Machine has been online for over 7 minutes. Running auto-fix manually..."
|
||||||
echo "Qortal is running, exiting script..."
|
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-qortal.sh
|
||||||
exit
|
chmod +x auto-fix-qortal.sh
|
||||||
|
./auto-fix-qortal.sh
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Machine has been online less than 7 minutes. Allowing auto-fix script to run automatically..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Auto-fix script not found in crontab. Running manually and setting up auto-run..."
|
||||||
|
curl -L -O https://raw.githubusercontent.com/crowetic/QORTector-scripts/main/auto-fix-qortal.sh
|
||||||
|
chmod +x auto-fix-qortal.sh
|
||||||
|
./auto-fix-qortal.sh
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user