#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh 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" if $(ynh_compare_current_package_version --comparison gt --version "0.2.0~ynh1") then pushd $install_dir redis-cli --rdb "/tmp/redis-$app.rdb" -p $port_redis popd ynh_systemd_action --service_name=redis-$app --action="stop" --log_path="/var/log/$app/redis-$app.log" fi #================================================= # INSTALL NODEJS #================================================= ynh_script_progression --message="Installing dependencies..." --weight=5 ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_secure_remove --file="$install_dir" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" # restore db backup if $(ynh_compare_current_package_version --comparison gt --version "0.2.0~ynh1") then mv /tmp/redis-$app.rdb $install_dir/redis-$app.rdb fi fi if [ "$upgrade_type" == "UPGRADE_APP" ] then pushd $install_dir ynh_use_nodejs ynh_exec_warn_less $ynh_npm install popd fi #================================================= # MIGRATE DATABASE #================================================= ynh_script_progression --message="migrating database... $(ynh_package_version --package=scrumblr)" --weight=1 echo "$(ynh_package_version --package=srumblr)" if $(ynh_compare_current_package_version --comparison lt --version "0.2.0~ynh2") then pushd $install_dir redis-cli --rdb "redis-$app.rdb" popd fi #================================================= # REDIS CONFIGURATION #================================================= ynh_add_config --template="redis.conf" --destination="$install_dir/redis.conf" redis_service="redis-$app" ynh_add_systemd_config --service $redis_service --template "scrumblr_redis.service" chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config ynh_add_systemd_config # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append #fix log directory owner chown -R $app:$app /var/log/$app yunohost service add $app --description="Software for notes" --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="systemd" --line_match="Server running at" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed" --last