2015-08-11 12:26:57 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2016-07-10 16:24:09 +02:00
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
2016-07-10 16:24:09 +02:00
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2016-07-10 16:24:09 +02:00
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2016-07-11 18:41:22 +02:00
|
|
|
|
2016-07-10 16:24:09 +02:00
|
|
|
# Retrieve app settings
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
2018-08-10 15:55:41 +02:00
|
|
|
path_url=$(ynh_app_setting_get "$app" path)
|
2016-07-10 16:24:09 +02:00
|
|
|
port=$(ynh_app_setting_get "$app" port)
|
|
|
|
ssoenabled=$(ynh_app_setting_get "$app" ssoenabled)
|
|
|
|
public_site=$(ynh_app_setting_get "$app" public_site)
|
2018-08-10 15:55:41 +02:00
|
|
|
timezone=$(cat /etc/timezone)
|
2018-08-10 16:36:04 +02:00
|
|
|
final_path=$(ynh_app_setting_get "$app" final_path)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# If final_path doesn't exist, create it
|
|
|
|
if [ -z "$final_path" ]; then
|
|
|
|
final_path="/var/www/$app"
|
|
|
|
ynh_app_setting_set "$app" final_path "$final_path"
|
|
|
|
fi
|
2018-08-10 15:55:41 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ACTIVE TRAP
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# TODO: activate backup
|
|
|
|
# Backup the current version of the app
|
|
|
|
# ynh_backup_before_upgrade
|
|
|
|
# ynh_clean_setup () {
|
|
|
|
# restore it if the upgrade fails
|
|
|
|
# ynh_restore_upgradebackup
|
|
|
|
# }
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK THE PATH
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Normalize the URL path syntax
|
|
|
|
path_url=$(ynh_normalize_url_path $path_url)
|
2015-08-11 12:26:57 +02:00
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# UPGRADE DEPENDENCIES
|
|
|
|
#=================================================
|
2015-08-31 16:39:08 +02:00
|
|
|
|
2017-12-29 14:33:28 +01:00
|
|
|
# Since Movim 0.13, zmq is required
|
2018-08-10 15:00:05 +02:00
|
|
|
ynh_install_app_dependencies php5-zmq
|
2017-12-29 14:33:28 +01:00
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
2018-08-10 17:27:41 +02:00
|
|
|
ynh_setup_source "$final_path"
|
|
|
|
|
|
|
|
chown -R movim:www-data "$final_path"
|
2016-07-10 20:36:22 +02:00
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
## TODO: consider installation in a subpath
|
2018-08-10 17:27:41 +02:00
|
|
|
ynh_replace_string "'/ws/'" "'${path_url%/}/ws/'" \
|
2018-08-10 16:36:04 +02:00
|
|
|
"${final_path}/app/assets/js/movim_websocket.js"
|
2015-08-21 18:12:22 +02:00
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
|
2015-08-21 18:12:22 +02:00
|
|
|
# Create movim user if not exists and set permissions
|
2016-07-10 16:24:09 +02:00
|
|
|
ynh_system_user_exists movim \
|
2018-08-10 16:46:40 +02:00
|
|
|
|| useradd -d /var/www/movim -s /bin/sh movim
|
2018-08-10 15:55:41 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SET PERMISSIONS
|
|
|
|
#=================================================
|
|
|
|
|
2018-08-10 16:46:40 +02:00
|
|
|
chown -R movim:www-data "$final_path"
|
|
|
|
find "${final_path}/" -type f -print0 | xargs -0 chmod 0644
|
|
|
|
find "${final_path}/" -type d -print0 | xargs -0 chmod 0755
|
|
|
|
chmod 400 "${final_path}/config/db.inc.php"
|
2015-08-11 12:26:57 +02:00
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
#=================================================
|
|
|
|
# install PHP dependencies
|
|
|
|
#=================================================
|
|
|
|
|
2018-08-10 17:27:41 +02:00
|
|
|
curl -sS https://getcomposer.org/installer \
|
|
|
|
| exec_cmd php -- --install-dir="$final_path"
|
|
|
|
|
2016-07-10 17:34:37 +02:00
|
|
|
# Update PHP dependencies using composer
|
|
|
|
(exec_cmd php composer.phar config --global discard-changes true \
|
2016-07-11 18:41:22 +02:00
|
|
|
&& exec_cmd php composer.phar install --no-interaction) \
|
2016-07-10 17:34:37 +02:00
|
|
|
|| ynh_die "Unable to update Movim dependencies."
|
2015-08-11 12:26:57 +02:00
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
#=================================================
|
|
|
|
# Upgrade Movim Databas
|
|
|
|
#=================================================
|
|
|
|
|
2016-07-10 17:34:37 +02:00
|
|
|
# Upgrade Movim database as needed
|
|
|
|
exec_cmd php mud.php db --set
|
2015-11-13 15:44:16 +01:00
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
|
2015-12-16 13:53:46 +01:00
|
|
|
# Reset SSO parameters
|
2016-07-10 16:24:09 +02:00
|
|
|
ynh_app_setting_delete "$app" protected_uris
|
|
|
|
ynh_app_setting_delete "$app" skipped_uris
|
2018-08-10 16:46:40 +02:00
|
|
|
yunohost app clearaccess movim
|
2015-12-16 13:53:46 +01:00
|
|
|
|
2015-12-16 17:24:02 +01:00
|
|
|
# Replace old public_site variable (if exists) by ssoenabled
|
2016-07-10 17:56:37 +02:00
|
|
|
if [ ! -z "$public_site" ]; then
|
|
|
|
[[ $public_site = "Yes" ]] \
|
2016-07-11 18:41:22 +02:00
|
|
|
&& ssoenabled="No" \
|
|
|
|
|| ssoenabled="Yes"
|
2016-07-10 17:56:37 +02:00
|
|
|
ynh_app_setting_delete "$app" public_site
|
|
|
|
ynh_app_setting_set "$app" ssoenabled "$ssoenabled"
|
2015-12-16 17:24:02 +01:00
|
|
|
fi
|
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
|
|
|
|
2016-07-10 17:56:37 +02:00
|
|
|
# SSOwat configuration
|
2016-07-11 18:41:22 +02:00
|
|
|
if [[ "$ssoenabled" = "No" ]]; then
|
2016-07-10 17:56:37 +02:00
|
|
|
ynh_app_setting_set "$app" skipped_uris "/"
|
|
|
|
exec_cmd php mud.php config --xmppwhitelist=$domain
|
2018-08-10 16:46:40 +02:00
|
|
|
yunohost app ssowatconf
|
2018-08-10 17:27:41 +02:00
|
|
|
undo_sso_patch
|
2015-12-16 13:53:46 +01:00
|
|
|
else
|
2016-07-10 17:56:37 +02:00
|
|
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
2015-08-21 18:12:22 +02:00
|
|
|
fi
|
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
|
|
|
|
2018-08-10 16:52:22 +02:00
|
|
|
ynh_replace_string "YHURL" "${domain}${path_url}" ../conf/movim.service
|
|
|
|
ynh_replace_string "YHDIR" "${final_path}" ../conf/movim.service
|
|
|
|
ynh_replace_string "YHPORT" "${port}" ../conf/movim.service
|
|
|
|
|
|
|
|
ynh_secure_remove /lib/systemd/system/movim.service
|
|
|
|
cp ../conf/movim.service /etc/systemd/system/
|
|
|
|
systemctl daemon-reload
|
2015-08-19 11:25:29 +02:00
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
2015-08-21 18:12:22 +02:00
|
|
|
# Update php-fpm configuration
|
2018-08-10 16:46:40 +02:00
|
|
|
ynh_replace_string "YHTZ" "$timezone" ../conf/php-fpm.conf
|
|
|
|
cp ../conf/php-fpm.conf /etc/php5/fpm/pool.d/movim.conf
|
2015-08-21 18:12:22 +02:00
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
2015-08-21 18:12:22 +02:00
|
|
|
# Nginx configuration
|
2018-08-10 16:46:40 +02:00
|
|
|
ynh_replace_string "PATHTOCHANGE" "$path_url" ../conf/nginx.conf
|
|
|
|
ynh_replace_string "ALIASTOCHANGE" "$final_path/" ../conf/nginx.conf
|
|
|
|
ynh_replace_string "YHPORT" "$port" ../conf/nginx.conf
|
|
|
|
ynh_replace_string "//ws/" "/ws/" ../conf/nginx.conf # Avoid duplicate /
|
|
|
|
cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/movim.conf
|
2015-08-21 18:12:22 +02:00
|
|
|
|
2018-08-10 15:55:41 +02:00
|
|
|
#=================================================
|
|
|
|
# RELOAD SERVICES
|
|
|
|
#=================================================
|
|
|
|
|
2016-07-10 18:31:45 +02:00
|
|
|
# Reload services
|
2018-08-10 16:46:40 +02:00
|
|
|
service movim restart
|
|
|
|
service php5-fpm restart
|
|
|
|
service nginx reload
|