#!/bin/bash #================================================= # GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= ynh_abort_if_errors # Stop script if an error is detected #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= # Retrieve app id app=$YNH_APP_INSTANCE_NAME # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_app_setting_set $app domain "$domain" ynh_app_setting_set $app path_url "$path_url" #================================================= # STANDARD MODIFICATIONS #================================================= #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_app_setting_set $app final_path "$final_path" # Create tmp directory and fetch app inside TMPDIR=$(mktemp -d) extract_sources "$TMPDIR" #================================================= # CREATE DEDICATED USER #================================================= ynh_system_user_create $app # Create a dedicated system user #================================================= # SPECIFIC SETUP #================================================= # Install files and set permissions mv "$TMPDIR" "$final_path" # Set rights on directory chown -R root: $final_path chown -R $app: $final_path/cache chmod 755 $final_path # Enable every bridge for i in $final_path/bridges/*.php ; do echo $(basename $i) | sed "s|Bridge.php$||g" | tee -a $final_path/whitelist.txt done #================================================= # NGINX CONFIGURATION #================================================= # Create a dedicated nginx config ynh_add_nginx_config # Copy and set php-fpm configuration phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf" ynh_replace_string "{POOLNAME}" "${app}" "$PKGDIR/conf/php-fpm.conf" ynh_replace_string "{DESTDIR}" "${final_path}" "$PKGDIR/conf/php-fpm.conf" ynh_replace_string "{USER}" "${app}" "$PKGDIR/conf/php-fpm.conf" cp $PKGDIR/conf/php-fpm.conf "$phpfpm_conf" # Set SSOwat rules ynh_app_setting_set "$app" skipped_uris "/" #================================================= # RELOAD NGINX #================================================= systemctl restart php5-fpm systemctl reload nginx