InvenTree/contrib/container/execute.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/sh
# File to check existence
db_version_old="${INVENTREE_HOME}/db_version.old"
2024-08-20 10:53:20 +00:00
new_version="$(python3 ${INVENTREE_HOME}/.github/scripts/version_check.py only_version)"
# Check if the file exists
if [ ! -e "$db_version_old" ]; then
echo "New Installation DB is getting initialised"
# Run setup command
invoke update || exit 2
echo "Setup command completed."
2024-08-20 07:59:28 +00:00
echo "$new_version" > "$db_version_old"
fi
old_version=$(cat "$db_version_old")
echo "old version $old_version"
echo "new version $new_version"
# Number to compare (replace with your actual value)
# Check if the stored version is smaller than new one
if [ "$(awk -v num1=$new_version -v num2=$old_version 'BEGIN { print (num1 < num2) }')" -eq 1 ]; then
echo "Error: Downgrade of version is not allowed."
echo "Old DB version was $old_version, and the new version is $new_version"
exit 1
fi
if [ "$(awk -v num1=$old_version -v num2=$new_version 'BEGIN { print (num1 < num2) }')" -eq 1 ]; then
echo "DB upgrade available: Version was $old_version, new version is $new_version"
# Run update command
invoke update || exit 2
echo "Update successful"
2024-08-20 07:04:30 +00:00
# Write the the new version to the old version file after update
2024-08-20 07:59:28 +00:00
echo "$new_version" > "$db_version_old"
fi
2024-02-19 23:32:24 +00:00
echo "Database migration/update checks completed."