2020-04-19 15:28:43 +02:00
|
|
|
#!/bin/bash
|
2015-03-01 23:51:00 +01:00
|
|
|
|
2020-04-19 15:28:43 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# IMPORT GENERIC HELPERS
|
2020-07-05 19:14:29 +02:00
|
|
|
source _common.sh
|
2020-04-19 15:28:43 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2015-03-01 23:51:00 +01:00
|
|
|
|
2020-04-19 15:28:43 +02:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2020-05-03 14:38:50 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..."
|
2020-12-18 22:56:28 +01:00
|
|
|
|
2020-04-19 15:28:43 +02: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
|
|
|
|
}
|
2020-04-19 15:28:43 +02:00
|
|
|
ynh_abort_if_errors
|
2015-03-01 23:51:00 +01:00
|
|
|
|
2021-03-15 00:25:46 +01:00
|
|
|
#=================================================
|
|
|
|
# Migrate legacy permissions to new system
|
|
|
|
#=================================================
|
|
|
|
if ynh_legacy_permissions_exists
|
|
|
|
then
|
|
|
|
ynh_legacy_permissions_delete_all
|
|
|
|
|
|
|
|
ynh_app_setting_delete --app=$app --key=is_public
|
|
|
|
fi
|
|
|
|
|
2020-05-03 14:38:50 +02:00
|
|
|
#=================================================
|
|
|
|
# Check upgrade type
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Check upgrade type..."
|
2020-12-18 22:56:28 +01:00
|
|
|
|
2020-04-22 15:31:52 +02: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
|
2020-04-22 15:31:52 +02:00
|
|
|
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
|
2020-04-22 15:31:52 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|