1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gogs_ynh.git synced 2024-09-03 20:36:23 +02:00
gogs_ynh/scripts/restore

57 lines
1.4 KiB
Text
Raw Normal View History

2016-08-15 15:38:50 +02:00
#!/bin/bash
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Load common variables and helpers
source ./experimental_helper.sh
source ./_common.sh
2016-08-15 15:38:50 +02:00
# Set app specific variables
app=${APPNAME:-gogs}
2016-08-15 15:38:50 +02:00
dbname=$app
dbuser=$app
# Retrieve old app settings
domain=$(ynh_app_setting_get "$app" domain)
path_url=$(ynh_app_setting_get "$app" path)
2016-08-15 15:38:50 +02:00
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
admin=$(ynh_app_setting_get "$app" adminusername)
# Check domain/path availability with app helper
ynh_webpath_available $domain $path_url || ynh_die "$domain is not available as domain, please use an other domain."
2016-08-15 15:38:50 +02:00
# Check user parameter
ynh_user_exists "$admin" \
|| ynh_die "The chosen admin user does not exist."
# Check Final Path availability
test ! -e "$final_path" || ynh_die "This path already contains a folder"
2016-08-15 15:38:50 +02:00
# Add users
ynh_system_user_create $app
2016-08-15 15:38:50 +02:00
# Restore all files
ynh_restore
2016-08-15 15:38:50 +02:00
# Create and restore the database
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
# Restore configuration files
systemctl daemon-reload
systemctl enable "$app".service
# Configure logrotate
ynh_use_logrotate "/var/log/$app"
2016-08-15 15:38:50 +02:00
# Add Gogs to YunoHost's monitored services
yunohost service add "$app" --log /var/log/"$app"/"$app".log
2016-08-15 15:38:50 +02:00
# Reload services
systemctl reload nginx.service
systemctl restart "$app".service