#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source ynh_install_go source /usr/share/yunohost/helpers #================================================= # CHECK VERSION #================================================= upgrade_type=$(ynh_check_app_version_changed) #================================================= # STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 if [ -z "${name:-}" ]; then name=$oidc_name ynh_app_setting_set --app=$app --key=name --value=$name ynh_app_setting_delete --app=$app --key=oidc_name fi if [ -z "${secret:-}" ]; then secret=$oidc_secret ynh_app_setting_set --app=$app --key=secret --value=$secret ynh_app_setting_delete --app=$app --key=oidc_secret fi if [ -z "${callback:-}" ]; then callback=$oidc_callback ynh_app_setting_set --app=$app --key=callback --value=$callback ynh_app_setting_delete --app=$app --key=oidc_callback fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --keep="config.yaml" fi chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= # SPECIFIC UPGRADE #================================================= # BUILDING SOURCES AND SETTING UP THE SERVER #================================================= ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6 ynh_exec_warn_less ynh_install_go --go_version=$GO_VERSION pushd "$install_dir" # Setup go exe and environnement ynh_use_go export GOPATH="$install_dir/go" export GOCACHE="$install_dir/go/.cache" # Build server from source make build 2>&1 ynh_secure_remove --file="$install_dir/go" popd ynh_remove_go # Setup a nice Yunohost logo cp ../sources/logo_dark.png "$install_dir/web/themes/dark/logo.png" cp ../sources/logo_light.png "$install_dir/web/themes/light/logo.png" #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_add_config --template="config.yaml" --destination="$install_dir/config.yaml" chmod 400 "$install_dir/config.yaml" chown $app:$app "$install_dir/config.yaml" #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append yunohost service add $app --description="OpenID Connect Provider" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed" --last