diff --git a/conf/1.1.1.src b/conf/1.1.1.src new file mode 100644 index 0000000..6630157 --- /dev/null +++ b/conf/1.1.1.src @@ -0,0 +1,5 @@ +SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-1.1.1.tar.bz2 +SOURCE_SUM=a5bf599320e256e9adaba2ccc0a91a1116ad4efcc04c701fdbe3c05c0fc2f2f5 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.bz2 +SOURCE_IN_SUBDIR=true \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 59f33d0..8235971 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -27,6 +27,8 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) if ynh_compare_current_package_version --comparison lt --version 0.9.8.1~ynh1; then upgrade_type="0.9.8" +elif ynh_compare_current_package_version --comparison lt --version 1.0.7~ynh2; then + upgrade_type="1.1.1" else upgrade_type=$(ynh_check_app_version_changed) fi @@ -87,7 +89,7 @@ if [ "$upgrade_type" == "0.9.8" ] then ynh_script_progression --message="Upgrading upgrade to 0.9.8" --weight=5 # Download, check integrity, uncompress and patch the source from 0.9.8.src - ynh_setup_source --dest_dir="$final_path" --source_id="0.9.8" + ynh_setup_source --keep="config.local.php" --dest_dir="$final_path" --source_id="0.9.8" # Set permissions on app files ynh_system_user_create --username=$app ynh_add_nginx_config @@ -101,25 +103,63 @@ then if [ -d "$backup_squelettes" ] then cp -ar $backup_squelettes $final_path/www/squelettes - ynh_secure_remove $backup_squelettes - fi + fi if [ -e "$backup_bdd" ] then cp -a $backup_bdd $final_path/association.sqlite - ynh_secure_remove $backup_squelettes fi chown -R $app:$app $final_path + chmod 755 $final_path - key=$(ynh_string_random --length=50) - cp -a $final_path/config.dist.php $final_path/config.local.php - ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" - if [ "$path_url" == "/" ]; then - ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" - else - ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" + # Create the visitors permission if needed + visitors_enabled=$(ynh_permission_has_user "main" "visitors" && echo 0 || echo 1) + if [[ $visitors_enabled -eq 0 ]]; then + ynh_permission_update --permission "main" --add "visitors" fi + + ynh_systemd_action --service_name=nginx --action=reload + # Finalize the upgrade + ynh_local_curl "/index.php" + sleep 5 + ynh_local_curl "/index.php" + upgrade_type="UPGRADE_APP" + + if [[ $visitors_enabled -eq 0 ]]; then + ynh_permission_update --permission "main" --remove "visitors" + fi +fi +#================================================= +# UPGRADE TO 1.1.1 if necessary +#================================================= + +if [ "$upgrade_type" == "1.1.1" ] +then + ynh_script_progression --message="Upgrading upgrade to 1.1.1" --weight=5 + # Download, check integrity, uncompress and patch the source from 0.9.8.src + ynh_setup_source --keep="config.local.php" --dest_dir="$final_path" --source_id="1.1.1" + # Set permissions on app files + ynh_system_user_create --username=$app + ynh_add_nginx_config + ynh_add_fpm_config --package="$extra_php_dependencies" + phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + ynh_script_progression --message="restore data..." --weight=10 + + backup_bdd=/tmp/association.sqlite + backup_squelettes=/tmp/squelettes + + if [ -d "$backup_squelettes" ] + then + cp -ar $backup_squelettes $final_path/www/squelettes + fi + + if [ -e "$backup_bdd" ] + then + cp -a $backup_bdd $final_path/association.sqlite + fi + + chown -R $app:$app $final_path chmod 755 $final_path # Create the visitors permission if needed @@ -156,7 +196,7 @@ ynh_script_progression --message="Upgrading source files..." --weight=5 if [ "$upgrade_type" == "UPGRADE_APP" ] then # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --keep="config.local.php" --dest_dir="$final_path" fi #================================================= @@ -200,15 +240,6 @@ fi #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=5 -key=$(ynh_string_random --length=50) -cp -a $final_path/config.dist.php $final_path/config.local.php -ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" -if [ "$path_url" == "/" ]; then -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" -else -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" -fi - # Permissions on files and directories chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path"