12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #!/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)
- isp_zone=$(ynh_app_setting_get "$app" isp_zone)
- latitude=$(ynh_app_setting_get "$app" latitude)
- longitude=$(ynh_app_setting_get "$app" longitude)
- zoom=$(ynh_app_setting_get "$app" zoom)
- cnil_link=$(ynh_app_setting_get "$app" cnil_link)
- cnil_number=$(ynh_app_setting_get "$app" cnil_number)
- url_contact=$(ynh_app_setting_get "$app" url_contact)
- 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
- # 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
- 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
|