Skip to content

Commit

Permalink
Merge pull request #61 from toklinke/feature/fix_update_mainline
Browse files Browse the repository at this point in the history
 Various fixes for update via web frontend
  • Loading branch information
toklinke authored Jun 28, 2022
2 parents 5193228 + ee28c72 commit c0e19e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
7 changes: 3 additions & 4 deletions start_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PYTHON_PARAMETERS="-X utf8"
SCRIPT_PARAMETERS=""
INTERPRETER=python3

DEBUG=1
DEBUG=0

if [ $DEBUG != 0 ];
then
Expand All @@ -33,11 +33,10 @@ cd $SCRIPT_DIR/webserver
if [ $DEBUG != 0 ];
then
echo "Starting server"
$INTERPRETER $PYTHON_PARAMETERS $EXECUTABLE $SCRIPT_PARAMETERS >/var/log/hucon.log 2>/var/log/hucon_err.log &
else
$INTERPRETER $PYTHON_PARAMETERS $EXECUTABLE $SCRIPT_PARAMETERS &
fi

$INTERPRETER $PYTHON_PARAMETERS $EXECUTABLE $SCRIPT_PARAMETERS >/var/log/hucon.log 2>/var/log/hucon_err.log &

HUCON_PID=$!

echo $HUCON_PID > /var/run/hucon.pid
Expand Down
19 changes: 13 additions & 6 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,30 @@ if [ $do_check ]; then
echo "Your version is: $currentVersion"
echo "The latest version is: $latestVersion"

result=$(/bin/bash /opt/hucon/version_compare.sh "${currentVersion}" "${latestVersion}")
result=$(/bin/bash ${SCRIPT_DIR}/version_compare.sh "${currentVersion}" "${latestVersion}")

if [ "${result}" -eq 0 ]; then
echo "There is no new version!"
exit 0
elif [ "${result}" -eq 1 ]; then
echo "Your version is newer than the available version!"
echo "Your version is newer than the available version!"
exit 0
elif [ "${result}" -eq 2 ]; then
echo "There is a new stable version!"
exit 1
elif [ "${result}" -eq 3 ]; then
echo "You have an unstable version, but hey it's the newest one"
exit 0
elif [ "${result}" -eq 4 ]; then
echo "Your unstable version is newer than the available version!"
exit 0
elif [ "${result}" -eq 5 ]; then
echo "There is a new unstable (alpha/beta/rc) version! It is highly experimental and discouraged to be installed!"
exit 1
fi
else
echo "Could not read the version from github."
exit 0
fi
fi

Expand All @@ -92,15 +99,15 @@ if [ $do_update ]; then
echo "Update the system from $currentVersion to $latestVersion"

# remove the old package if needed.
if [ -f hucon.run ]; then
rm hucon.run
if [ -f ${SCRIPT_DIR}/hucon.run ]; then
rm ${SCRIPT_DIR}/hucon.run
fi

# download the new package
downloadUrl="https://github.com/$UPDATE_SOURCE_REPO/releases/download/$latestVersion/hucon-$latestVersion.run"

# Download the new package
wget $downloadUrl -O hucon.run
wget $downloadUrl -O ${SCRIPT_DIR}/hucon.run

echo "Check if existing code can be moved to /root/hucon/code..."
if [[ ! -e /root/hucon/code ]]; then
Expand All @@ -114,7 +121,7 @@ if [ $do_update ]; then
fi

# and install it.
sh hucon.run
sh ${SCRIPT_DIR}/hucon.run
else
echo "You are using the up to date version."
fi
Expand Down

0 comments on commit c0e19e8

Please sign in to comment.