#!/bin/bash source _common.sh source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression "Stopping $app's systemd service..." ynh_systemctl --service=$app --action="stop" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression "Ensuring downward compatibility..." if ynh_compare_current_package_version -c le -v "3.11.0~ynh1" then extension_service_url=$(ynh_app_setting_get --key="extension_service_url") extension_item_url=$(ynh_app_setting_get --key="extension_item_url") if [ "$extension_service_url" ] && [ "$extension_item_url" ] then extensions_gallery="{\"serviceUrl\": \"$extension_service_url\",\"itemUrl\": \"$extension_item_url\"}" ynh_app_setting_set --key="extensions_gallery" --value="$extensions_gallery" ynh_app_setting_delete --key="extension_service_url" ynh_app_setting_delete --key="extension_item_url" fi if [ "$enable_proposed_api" ] then ynh_print_warn "Custom enable-proposed-api. You have to enable again them through application config panel." ynh_print_warn "enable-proposed-api was set to: $enable_proposed_api" ynh_app_setting_delete --key="enable_proposed_api" fi if [ "$hashed_password" ] then auth="password" else auth="none" fi ynh_app_setting_set --key="auth" --value=$auth ynh_config_remove_fail2ban ynh_safe_rm $install_dir mkdir -p $install_dir fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= # FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed if ynh_app_upstream_version_changed then ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --full_replace fi #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir" #REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R root:$admin "$install_dir" chmod +x "$install_dir/bin/code-server" #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression "Updating configuration..." ynh_config_add --template="config.yaml" --destination="$install_dir/config.yaml" ynh_config_add --template="code-server.env" --destination="$install_dir/code-server.env" if [ "$auth" == "password" ] then echo "hashed-password: $hashed_password" >> "$install_dir/config.yaml" fi #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 440 "$install_dir/config.yaml" "$install_dir/code-server.env" #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $admin:$admin "$install_dir/config.yaml" "$install_dir/code-server.env" #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression "Upgrading systemd configuration..." # Create a dedicated NGINX config ynh_config_add_nginx # Create a dedicated systemd config ynh_config_add_systemd # Use logrotate to manage app-specific logfile(s) ynh_config_add_logrotate yunohost service add $app --description="VS Code Server" --log="/var/log/$app/$app.log" #================================================= # SET PERMISSION FOR THE USER #================================================= ynh_permission_update --permission="main" --add="$admin" chown -R $admin:$admin "$data_dir" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression "Starting $app's systemd service..." ynh_systemctl --service=$app --action="start" #================================================= # END OF SCRIPT #================================================= ynh_script_progression "Upgrade of $app completed"