#!/bin/bash #================================================= # GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE FAILURE OF THE SCRIPT #================================================= ynh_clean_setup () { # Nettoyage des résidus d'installation non pris en charge par le script remove. # Pas de nettoyage supplémentaire nécessaire ici... echo "" } ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée. #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH admin_user=$YNH_APP_ARG_ADMIN_USER upload_password=$YNH_APP_ARG_UPLOAD_PASSWORD is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS #================================================= path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path. CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine. CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé. #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app admin $admin_user ynh_app_setting_set $app is_public $is_public #================================================= # STANDARD MODIFICATIONS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_app_setting_set $app final_path $final_path ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path #================================================= # NGINX CONFIGURATION #================================================= ynh_nginx_config #================================================= # CREATE DEDICATED USER #================================================= ynh_system_user_create $app # Créer un utilisateur système dédié à l'app #================================================= # PHP-FPM CONFIGURATION #================================================= ynh_fpm_config # Créer le fichier de configuration du pool php-fpm et le configure. #================================================= # SPECIFIC SETUP #================================================= # SET AND SAVE THE UPLOAD PASSWORD #================================================= jirafeauconfigfile="$final_path/lib/config.local.php" sudo cp "../conf/config.local.php" "$jirafeauconfigfile" # Set and save upload password, allowing an empty one if [ -z "$upload_password" ] then ynh_replace_string "YNH_UPLOAD_PASSWORD" "" "$jirafeauconfigfile" ynh_app_setting_set $app upload_password "" else ynh_replace_string "YNH_UPLOAD_PASSWORD" "$upload_password" "$jirafeauconfigfile" ynh_app_setting_set $app upload_password "$upload_password" fi #================================================= # CONFIGURE JIRAFEAU #================================================= var_root=/home/yunohost.app/$app ynh_replace_string "YNH_DOMAIN" "$domain" "$jirafeauconfigfile" ynh_replace_string "YNH_WWW_PATH" "$path_url" "$jirafeauconfigfile" ynh_replace_string "YNH_VAR_ROOT" "$var_root" "$jirafeauconfigfile" ynh_replace_string "YNH_ADMIN_USER" "$admin_user" "$jirafeauconfigfile" ynh_store_checksum_config "$jirafeauconfigfile" # Enregistre la somme de contrôle du fichier de config # Remove the install.php sudo rm $final_path/install.php #================================================= # GENERIC FINALISATION #================================================= # SECURING FILES AND DIRECTORIES #================================================= # Les fichiers appartiennent à root sudo chown -R root: $final_path sudo mkdir -p $var_root/{files,links,async,block} sudo chown -R $app:root $var_root sudo chmod -R 700 $var_root #================================================= # SETUP SSOWAT #================================================= ynh_app_setting_set $app skipped_uris "/" if [ $is_public -eq 0 ] then ynh_app_setting_set $app protected_regex "jirafeau/$" fi #================================================= # RELOAD NGINX #================================================= sudo systemctl reload nginx