mirror of
https://github.com/YunoHost-Apps/hedgedoc_ynh.git
synced 2024-09-03 19:25:52 +02:00
305be90bbf
* Small fixes
* 1.7.0 (#4)
* Upgrde to v.1.7.0
* Set requirements to 3.8.1
* Update README.md
* Upgrade to 1.7.1 (#6)
* Add limitations
* Avoid to buid frontend bundle
* Remove PostegrSQL warning
* Update README.md
Add you should reload service for changes in config to be registered.
* Add restart systemd tuto
* Change version
* Finding an available port
* Upgrade to version 1.7.2 (#12)
* Patch (#17)
* Cleaning up
* Update manifest.json
* Cleaning up
* Secure config file
* Remove yarn
* Update change_url
* Update change_url
* Revert "Remove yarn"
This reverts commit a8cabf0c0a
.
* Update change_url
* Update systemd.service
* Update systemd.service
* Cleaning up
* Fix
* fix badges
* Upgrade to version 1.8.0 (#21)
* Upgrade to version 1.8.0
* Upgrade to 1.8.0
* Upgrade to 1.8.0
* Upgrade to version 1.8.1
* [autopatch] Update issue and PR templates (#25)
Co-authored-by: Yunohost-Bot <>
* Add templates
* Upgrade to 1.8.2
* Update check_process
* Add templates
* Auto-update README
* Set new requirements (#28)
* Fix
* Simplify config
* Auto-update README
Co-authored-by: Yunohost-Bot <>
* Update manifest.json
* Auto-update README
* 1.9.0 (#31)
* 1.9.0
* Update manifest.json
* Auto-update README
* Systemd hardening (#33)
* Update systemd.service
* Update app.src
* Update manifest.json
* 1.9.1 (#34)
* Upgrade to 1.9.1
* 1.9.2 (#36)
* Remove replace_string
* Fix (#39)
* Update manifest.json
* Auto-update README
* Update config.json.example
* Update config.json.example
* 1.9.3
* Auto-update README
* 1.9.4 (#42)
* 1.9.4
* Auto-update README
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
* Auto-update README
* Update manifest.json
* Update _common.sh
* set relative path for --keep opt
* Update manifest.json
* Auto-update README
* 1.9.5
* Auto-update README
* 1.9.6
* Auto-update README
* Add more security as default (#47)
* Add more security as default
* Auto-update README
* Update config.json.example
* Update change_url
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
* Update manifest.json
* Auto-update README
* Update install
Co-authored-by: Eauchat <34686393+eauchat@users.noreply.github.com>
Co-authored-by: Alexandre Aubin <alex.aubin@mailoo.org>
Co-authored-by: YunoHost Bot <yunohost-bot@users.noreply.github.com>
Co-authored-by: Yunohost-Bot <>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: yalh76 <yalh@yahoo.com>
147 lines
4.7 KiB
Bash
147 lines
4.7 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC STARTING
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS
|
|
#=================================================
|
|
|
|
old_domain=$YNH_APP_OLD_DOMAIN
|
|
old_path=$YNH_APP_OLD_PATH
|
|
|
|
new_domain=$YNH_APP_NEW_DOMAIN
|
|
new_path=$YNH_APP_NEW_PATH
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
|
|
# Needed for helper "ynh_add_nginx_config"
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
|
db_user=$db_name
|
|
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
|
|
|
allow_anonymous=$(ynh_app_setting_get --app=$app --key=allow_anonymous)
|
|
allow_email_registration=$(ynh_app_setting_get --app=$app --key=allow_email_registration)
|
|
|
|
#=================================================
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
#=================================================
|
|
ynh_script_progression --message="Backing up HedgeDoc before changing its URL (may take a while)..." --weight=1
|
|
|
|
# Backup the current version of the app
|
|
ynh_backup_before_upgrade
|
|
ynh_clean_setup () {
|
|
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
|
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
|
|
|
# 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 WHICH PARTS SHOULD BE CHANGED
|
|
#=================================================
|
|
|
|
change_domain=0
|
|
if [ "$old_domain" != "$new_domain" ]
|
|
then
|
|
change_domain=1
|
|
fi
|
|
|
|
change_path=0
|
|
if [ "$old_path" != "$new_path" ]
|
|
then
|
|
change_path=1
|
|
fi
|
|
|
|
#=================================================
|
|
# STANDARD MODIFICATIONS
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name=$app --action=stop --log_path=systemd
|
|
|
|
#=================================================
|
|
# MODIFY URL IN NGINX CONF
|
|
#=================================================
|
|
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
|
|
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
|
|
|
# Change the path in the NGINX config file
|
|
if [ $change_path -eq 1 ]
|
|
then
|
|
# Make a backup of the original NGINX config file if modified
|
|
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
|
# Set global variables for NGINX helper
|
|
domain="$old_domain"
|
|
path_url="$new_path"
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
fi
|
|
|
|
# Change the domain for NGINX
|
|
if [ $change_domain -eq 1 ]
|
|
then
|
|
# Delete file checksum for the old conf file location
|
|
ynh_delete_file_checksum --file="$nginx_conf_path"
|
|
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
|
# Store file checksum for the new config file location
|
|
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
|
fi
|
|
|
|
#=================================================
|
|
# SPECIFIC MODIFICATIONS
|
|
#=================================================
|
|
# CONFIGURE HEDGEDOC
|
|
#=================================================
|
|
|
|
ynh_backup_if_checksum_is_different --file="$final_path/config.json"
|
|
|
|
domain=$new_domain
|
|
url_path=${new_path#/}
|
|
|
|
ynh_add_config --template="../conf/config.json.example" --destination="$final_path/config.json"
|
|
|
|
chmod 400 "$final_path/config.json"
|
|
chown $app:$app "$final_path/config.json"
|
|
|
|
#=================================================
|
|
# GENERIC FINALISATION
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
# Start a systemd service
|
|
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="HTTP Server listening"
|
|
|
|
#=================================================
|
|
# RELOAD NGINX
|
|
#=================================================
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Change of URL completed for $app" --last
|