mirror of
https://github.com/YunoHost-Apps/rocketchat_ynh.git
synced 2024-09-03 20:16:25 +02:00
3493b1fd52
Adds working upgrade
77 lines
2.3 KiB
Bash
77 lines
2.3 KiB
Bash
#!/bin/bash
|
|
set -eu
|
|
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
# Exit on command errors and treat access to unset variables as an error
|
|
ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
path=$(ynh_app_setting_get $app path)
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
|
serviceuser=$(ynh_app_setting_get $app serviceuser)
|
|
|
|
# Check domain/path availability
|
|
sudo yunohost app checkurl "${domain}${path}" -a "$app" || ynh_die
|
|
|
|
# Check destination directory
|
|
[[ -d $final_path ]] && ynh_die \
|
|
"The destination directory '$final_path' already exists.\
|
|
You should safely delete it before restoring this app."
|
|
|
|
# Create destination
|
|
sudo mkdir -p $final_path
|
|
|
|
# Create user
|
|
sudo useradd -d "$final_path" -M $serviceuser
|
|
|
|
#=================================================
|
|
# STANDARD RESTORATION STEPS
|
|
#=================================================
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
#=================================================
|
|
|
|
sudo cp -a "conf/nginx" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
sudo systemctl reload nginx
|
|
|
|
#=================================================
|
|
# RESTORE THE SYSTEMD CONFIGURATION
|
|
#=================================================
|
|
sudo cp -a "conf/service" "/etc/systemd/system/rocketchat.service"
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable rocketchat
|
|
|
|
#=================================================
|
|
# RESTORE THE APP MAIN DIR
|
|
#=================================================
|
|
|
|
sudo tar -xzf ./rocket.chat.gtar -C $final_path
|
|
sudo chown -R $serviceuser: $final_path
|
|
|
|
#=================================================
|
|
# RESTORE THE MONGODB
|
|
#=================================================
|
|
|
|
sudo mongorestore ./dump
|
|
|
|
#=================================================
|
|
# START APP RELATED SERVICES
|
|
#=================================================
|
|
|
|
sudo systemctl start rocketchat
|