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

119 lines
3.6 KiB
Text
Raw Normal View History

#!/bin/bash
2015-03-01 23:51:00 +01:00
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# IMPORT GENERIC HELPERS
2020-07-05 19:14:29 +02:00
source _common.sh
source /usr/share/yunohost/helpers
2015-03-01 23:51:00 +01:00
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
2020-12-18 22:56:28 +01:00
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)
2015-05-31 12:40:22 +02:00
2020-07-05 19:14:29 +02:00
ynh_clean_setup() {
ynh_clean_check_starting
}
ynh_abort_if_errors
2015-03-01 23:51:00 +01:00
#=================================================
# Check upgrade type
#=================================================
ynh_script_progression --message="Check upgrade type..."
2020-12-18 22:56:28 +01:00
upgrade_type=$(ynh_check_app_version_changed)
2020-07-05 19:14:29 +02:00
#=================================================
# Stop services
#=================================================
ynh_script_progression --message="Stop services..."
2020-12-18 22:56:28 +01:00
2020-07-05 19:14:29 +02:00
systemctl stop $app.target
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..."
2020-12-18 22:56:28 +01:00
2020-07-05 19:14:29 +02:00
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
2020-07-05 19:14:29 +02:00
# 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
2020-07-05 19:14:29 +02:00
2020-12-18 22:56:28 +01:00
#=================================================
# 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)"
2020-07-05 19:14:29 +02:00
#=================================================
# restart services
#=================================================
ynh_script_progression --message="Recreate and start services..."
2020-12-18 22:56:28 +01:00
2020-07-05 19:14:29 +02:00
source ./create_services
#=================================================
# NGINX CONFIGURATION
#=================================================
# Create a dedicated nginx config
ynh_script_progression --message="configure nginx..." --weight=1
2020-12-18 22:56:28 +01:00
2020-07-05 19:14:29 +02:00
ynh_add_nginx_config