#!/bin/bash # Exit on command errors and treat unset variables as an error set -eu app=$YNH_APP_INSTANCE_NAME # Source YunoHost helpers source /usr/share/yunohost/helpers # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN path=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC # Correct path if [ "${path:0:1}" != "/" ]; then path="/$path" fi if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then path="${path:0:${#path}-1}" fi # Save app settings ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set "$app" path "$path" ynh_app_setting_set "$app" is_public "$is_public" # Check domain/path availability sudo yunohost app checkurl "${domain}${path}" -a "$app" \ || ynh_die "Path not available: ${domain}${path}" # Download source sudo wget -q https://raw.githubusercontent.com/keeweb/keeweb/gh-pages/index.html sudo wget -q https://raw.githubusercontent.com/keeweb/keeweb/gh-pages/manifest.appcache sudo sed -i.bak 's/(no-config)/config.json/g' index.html # Copy source files src_path=/var/www/$app sudo mkdir -p $src_path sudo cp -a index.html manifest.appcache ../conf/config.json $src_path # Set permissions to app files sudo chown -R root: $src_path # Modify Nginx configuration file and copy it to Nginx conf directory sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf sed -i "s@YNH_WWW_ALIAS@$src_path/@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf # If app is public, add url to SSOWat conf as skipped_uris if [[ $is_public -eq 1 ]]; then ynh_app_setting_set "$app" unprotected_uris "/" fi # Restart services sudo service nginx reload