1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/coin_ynh.git synced 2024-09-03 18:16:26 +02:00
coin_ynh/scripts/restore

78 lines
1.9 KiB
Text
Raw Normal View History

2017-04-09 11:05:39 +02:00
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
. /usr/share/yunohost/helpers
# Retrieve old app settings
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
admin=$(ynh_app_setting_get "$app" admin)
email=$(ynh_app_setting_get "$app" email)
isp_name=$(ynh_app_setting_get "$app" isp_name)
isp_site=$(ynh_app_setting_get "$app" isp_site)
secret=$(ynh_app_setting_get "$app" secret)
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app \
|| ynh_die "Path not available: ${domain}${path}"
final_path=/opt/$app
if [ -d $final_path ]; then
ynh_die "There is already a directory: $final_path "
fi
conf=/etc/nginx/conf.d/$domain.d/$app.conf
if [ -f $conf ]; then
ynh_die "There is already a nginx conf file at this path: $conf "
fi
gunicorn_path=/etc/systemd/system/$app.service
if [ -f $gunicorn_path ]; then
ynh_die "There is already a gunicorn service file at this path: $gunicorn_path "
fi
# Dependences
ynh_package_install python3-pip python3-virtualenv
# Restore sources & data
sudo cp -a ./sources $final_path
2018-12-20 19:58:44 +01:00
# Create user
useradd $app -d $final_path || echo "User already exists"
2017-04-09 11:05:39 +02:00
# Set permissions
sudo chown -R www-data:www-data $final_path
# Restore conf files
sudo cp -a ./nginx.conf $conf
sudo cp -a ./gunicorn.service $gunicorn_path
sudo chown root: $gunicorn_path
sudo chmod 644 $gunicorn_path
# Set Administrator
if ynh_user_exists $admin; then
sudo yunohost app addaccess $app -u $admin
fi
# Log folder
sudo mkdir -p /var/log/$app
sudo chown -R $app /var/log/$app
sudo chgrp -R www-data /var/log/$app
# Reload Nginx
sudo service nginx reload
2018-12-20 19:58:44 +01:00
systemctl daemon-reload
2017-04-09 11:05:39 +02:00
sudo systemctl start $app
sudo systemctl enable $app
sudo yunohost service add $app -l /var/log/gunicorn/$app.log
ynh_app_setting_set "$app" skipped_uris "/"
sudo yunohost app ssowatconf