123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #!/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)
- # 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
- # 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
- # Reload Nginx
- sudo service nginx reload
- 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
|