1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/diaspora_ynh.git synced 2024-09-03 18:26:13 +02:00
diaspora_ynh/scripts/upgrade
2020-12-18 22:56:28 +01:00

118 lines
3.6 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# IMPORT GENERIC HELPERS
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments
domain=$(ynh_app_setting_get --app $app --key domain)
admin=$(ynh_app_setting_get --app $app --key admin)
final_path=$(ynh_app_setting_get --app $app --key final_path)
ynh_clean_setup() {
ynh_clean_check_starting
}
ynh_abort_if_errors
#=================================================
# Check upgrade type
#=================================================
ynh_script_progression --message="Check upgrade type..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# Stop services
#=================================================
ynh_script_progression --message="Stop services..."
systemctl stop $app.target
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies $ruby_build_dependencies
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
# migrate from rvm to rbenv
ynh_script_progression --message="Remove rvm..."
if [ -e "$final_path/.rvm" ]; then
sudo -u $app --login << EOF
rvm implode --force
EOF
fi
source ./install_ruby
# remove old gpg keys for rvm
ynh_script_progression --message="Remove old rvm keys..."
if gpg --list-keys mpapis@gmail.com >/dev/null 2>&1; then
ynh_print_info --message="Found mpapis key: deleting"
sudo -u $app gpg --delete-keys mpapis@gmail.com
ynh_secure_remove "$final_path/mpapis@gmail.com.pgp"
fi
if gpg --list-keys piotr.kuczynski@gmail.com >/dev/null 2>&1; then
ynh_print_info --message="Found piotr.kuczynski: deleting"
sudo -u $app gpg --delete-keys piotr.kuczynski@gmail.com
ynh_secure_remove "$final_path/piotr.kuczynski@gmail.com.pgp"
fi
if [ "$upgrade_type" == "UPGRADE_APP" ];
then
upgrade_message="Upgrading this app and upstream to $current_tag"
else
upgrade_message="Shallow upgrade of yunohost app"
fi
ynh_script_progression --message=$upgrade_message
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
# revert local change to .ruby-version
pushd $final_path/diaspora
git checkout -- .ruby-version
git fetch
git checkout $current_tag
popd
source ./bundle_app
fi
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add $app.target \
--log $final_path/diaspora/log/production.log \
$final_path/diaspora/log/unicorn-stderr.log\
$final_path/diaspora/log/unicorn-stdout.log\
$final_path/diaspora/log/sidekiq.log\
--description "Diaspora service (unicorn web and sidekiq)"
#=================================================
# restart services
#=================================================
ynh_script_progression --message="Recreate and start services..."
source ./create_services
#=================================================
# NGINX CONFIGURATION
#=================================================
# Create a dedicated nginx config
ynh_script_progression --message="configure nginx..." --weight=1
ynh_add_nginx_config