#!/bin/bash # Source app helpers and functions source _common.sh source /usr/share/yunohost/helpers # Exit on command errors and treat unset variables as an error set -eu # Retrieve arguments app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN path=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC author=$YNH_APP_ARG_AUTHOR # Check domain/path availability sudo yunohost app checkurl "${domain}${path}" -a "$app" \ || exit 1 DESTDIR="/var/www/${app}" [[ -d "$DESTDIR" ]] && ynh_die \ "The destination directory '${DESTDIR}' already exists.\ You should safely delete it before installing this app." # Store settings from manifest ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app author $author # Install python dependencies sudo apt-get install -y python-pip python-virtualenv python-dev libldap2-dev libsasl2-dev libssl-dev # Create the virtualenv virtualenv ${DESTDIR} cd ${DESTDIR} source bin/activate # Install pelican pip install pelican markdown # Configure Nginx nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf" sed -i "s@{PATH}@${path}@g" ../conf/nginx.conf sed -i "s@{LOCATION}@${path:-/}@g" ../conf/nginx.conf sed -i "s@{DESTDIR}@${DESTDIR}@g" ../conf/nginx.conf sed -i "s@{POOLNAME}@${app}@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf "$nginx_conf" sudo nginx -t && sudo service nginx reload [[ $is_public -eq 1 ]] \ && ynh_app_setting_set "$app" unprotected_uris "/"