1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cjdns_ynh.git synced 2024-09-03 18:16:29 +02:00
This commit is contained in:
dkoukoul 2023-12-21 16:50:38 +02:00
parent 0d2bc5924b
commit 005d50ab39

View file

@ -9,51 +9,11 @@
source _common.sh
source /usr/share/yunohost/helpers
# Settings are automatically loaded as bash variables
# in every app script context, therefore typically these will exist:
# - $domain
# - $path
# - $language
# - $install_dir
# - $port
# ...
# In the context of upgrade,
# - resources are automatically provisioned / updated / deleted (depending on existing resources)
# - a safety backup is automatically created by the core and will be restored if the upgrade fails
### This helper will compare the version of the currently installed app and the version of the upstream package.
### $upgrade_type can have 2 different values
### - UPGRADE_APP if the upstream app version has changed
### - UPGRADE_PACKAGE if only the YunoHost package has changed
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
#ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
#
# N.B. : the following setting migration snippets are provided as *EXAMPLES*
# of what you may want to do in some cases (e.g. a setting was not defined on
# some legacy installs and you therefore want to initiaze stuff during upgrade)
#
# If db_name doesn't exist, create it
#if [ -z "$db_name" ]; then
# db_name=$(ynh_sanitize_dbid --db_name=$app)
# ynh_app_setting_set --app=$app --key=db_name --value=$db_name
#fi
# If install_dir doesn't exist, create it
#if [ -z "$install_dir" ]; then
# install_dir=/var/www/$app
# ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
#fi
#=================================================
# STOP SYSTEMD SERVICE
@ -70,26 +30,8 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Checking for latest version..." --weight=1
current_version=$($install_dir/cjdroute --version | grep "Cjdns version:" | cut -d'-' -f2,3)
latest_version=$(curl --silent "https://api.github.com/repos/dkoukoul/cjdns/releases/latest" | jq -r ".tag_name")
# Extract release and subversion from current_version and latest_version
current_release=$(echo $current_version | cut -d'-' -f1 | tr -d 'v')
current_subversion=$(echo $current_version | cut -d'-' -f2)
latest_release=$(echo $latest_version | cut -d'-' -f1 | tr -d 'v')
latest_subversion=$(echo $latest_version | cut -d'-' -f2)
# Compare release and subversion
if [ $latest_release -gt $current_release ] || [ $latest_release -eq $current_release ] && [ $latest_subversion -gt $current_subversion ]
then
ynh_script_progression --message="New version $latest_version available" --weight=1
# Download, check integrity, uncompress and patch the source from manifest.toml
ynh_setup_source --dest_dir="$install_dir"
ynh_script_progression --message="Installing latest version..." --weight=1
else
ynh_script_progression --message="You have the latest version: $latest_version" --weight=1
fi
ynh_script_progression --message="Installing latest version..." --weight=1
ynh_setup_source --dest_dir="$install_dir"
fi
chmod -R o-rwx "$install_dir"