fix self_upgrade

This commit is contained in:
Kay0u 2020-12-22 15:29:02 +01:00
parent 896dea99dd
commit 4382aae5bd
No known key found for this signature in database
GPG key ID: AAFEEB16CFA2AE2D

View file

@ -203,11 +203,8 @@ function self_upgrade()
local check_version="$(git ls-remote $git_repository | cut -f 1 | head -n1)" local check_version="$(git ls-remote $git_repository | cut -f 1 | head -n1)"
# If the version file exist, check for an upgrade
if [ -e "$version_file" ]
then
# Check if the last commit on the repository match with the current version # Check if the last commit on the repository match with the current version
if [ "$check_version" != "$(cat "$version_file")" ] if [ ! -e "$version_file" ] || [ "$check_version" != "$(cat "$version_file")" ]
then then
# If the versions don't matches. Do an upgrade # If the versions don't matches. Do an upgrade
log_info "Upgrading Package check" log_info "Upgrading Package check"
@ -219,7 +216,7 @@ function self_upgrade()
# Clone in another directory # Clone in another directory
git clone --quiet $git_repository "./upgrade" git clone --quiet $git_repository "./upgrade"
cp -a "./upgrade/." "./." cp -a "./upgrade/." "./."
rm -r "./upgrade" rm -rf "./upgrade"
# Update the version file # Update the version file
echo "$check_version" > "$version_file" echo "$check_version" > "$version_file"
rm "./pcheck.lock" rm "./pcheck.lock"
@ -233,7 +230,6 @@ EOF
# Start the upgrade script by replacement of this process # Start the upgrade script by replacement of this process
exec "./upgrade_script.sh" exec "./upgrade_script.sh"
fi fi
fi
# Update the version file # Update the version file
echo "$check_version" > "$version_file" echo "$check_version" > "$version_file"