mirror of
https://github.com/YunoHost-Apps/vikunja_ynh.git
synced 2024-09-03 18:06:26 +02:00
137 lines
4.5 KiB
Bash
137 lines
4.5 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
|
|
timezone="$(cat /etc/timezone)"
|
|
secret=$(ynh_string_random --length=32)
|
|
redis_db=$(ynh_redis_get_free_db)
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
if [ -z "${set_motd:-}" ]; then
|
|
set_motd=""
|
|
ynh_app_setting_set --app="$app" --key="set_motd" --value="$set_motd"
|
|
fi
|
|
|
|
if [ -z "${enable_registration:-}" ]; then
|
|
enable_registration="true"
|
|
ynh_app_setting_set --app="$app" --key="enable_registration" --value="$enable_registration"
|
|
fi
|
|
|
|
if [ -z "${enable_linksharing:-}" ]; then
|
|
enable_linksharing="true"
|
|
ynh_app_setting_set --app="$app" --key="enable_linksharing" --value="$enable_linksharing"
|
|
fi
|
|
|
|
if [ -z "${enable_taskattachments:-}" ]; then
|
|
enable_taskattachments="true"
|
|
ynh_app_setting_set --app="$app" --key="enable_taskattachments" --value="$enable_taskattachments"
|
|
fi
|
|
|
|
if [ -z "${enable_taskcomments:-}" ]; then
|
|
enable_taskcomments="true"
|
|
ynh_app_setting_set --app="$app" --key="enable_taskcomments" --value="$enable_taskcomments"
|
|
fi
|
|
|
|
if [ -z "${enable_emailreminders:-}" ]; then
|
|
enable_emailreminders="true"
|
|
ynh_app_setting_set --app="$app" --key="enable_emailreminders" --value="$enable_emailreminders"
|
|
fi
|
|
|
|
if [ -z "${enable_userdeletion:-}" ]; then
|
|
enable_userdeletion="true"
|
|
ynh_app_setting_set --app="$app" --key="enable_userdeletion" --value="$enable_userdeletion"
|
|
fi
|
|
|
|
if [ -z "${maxavatarsize:-}" ]; then
|
|
maxavatarsize=1024
|
|
ynh_app_setting_set --app="$app" --key="maxavatarsize" --value="$maxavatarsize"
|
|
fi
|
|
|
|
if [ -z "${maxitemsperpage:-}" ]; then
|
|
maxitemsperpage=50
|
|
ynh_app_setting_set --app="$app" --key="maxitemsperpage" --value="$maxitemsperpage"
|
|
fi
|
|
|
|
if [ -z "${language:-}" ]; then
|
|
language="en"
|
|
ynh_app_setting_set --app="$app" --key="language" --value="$language"
|
|
fi
|
|
|
|
if ynh_compare_current_package_version --comparison lt --version "0.23.0~ynh1"; then
|
|
mv "$backend_path/config.yml" "$install_dir/config.yml"
|
|
ynh_secure_remove "$backend_path"
|
|
ynh_app_setting_delete --app="$app" --key="backend_path"
|
|
fi
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# STOP SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name=$app --action=stop --log_path=systemd
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading source files..." --weight=5
|
|
|
|
# Frontend
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
executable="$(find $tempdir -name "vikunja-*" \! -name "*.sha256")"
|
|
ln -s "$executable" "$install_dir/vikunja"
|
|
|
|
chmod +x "$install_dir/vikunja"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# UPGRADE A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading a configuration file..." --weight=1
|
|
|
|
ynh_add_config --template="config.yml" --destination="$install_dir/config.yml"
|
|
|
|
chmod 400 "$install_dir/config.yml"
|
|
chown $app:$app "$install_dir/config.yml"
|
|
|
|
#=================================================
|
|
# NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
|
|
|
|
ynh_add_nginx_config
|
|
|
|
ynh_add_systemd_config
|
|
|
|
yunohost service add $app --description="Self-hosted To-Do list application" --log="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# START SYSTEMD SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
|
|
|
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="server started on"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|