diff --git a/manifest.json b/manifest.json index 3e46591..bb35489 100644 --- a/manifest.json +++ b/manifest.json @@ -25,8 +25,7 @@ "install" : [ { "name": "domain", - "type": "domain", - "example": "domain.org" + "type": "domain" }, { "name": "path", diff --git a/scripts/change_url b/scripts/change_url index 532750e..594268b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -88,8 +88,8 @@ if [ $change_path -eq 1 ] && [ "$new_path" == "/" ]; then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" elif [ $change_path -eq 1 ] && [ "$old_path" == "/" ]; then ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" -else [ $change_path -eq 1 ] - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" +elif [ $change_path -eq 1 ]; then + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi # Change the domain for NGINX diff --git a/scripts/install b/scripts/install index 5f8d061..b7447b9 100644 --- a/scripts/install +++ b/scripts/install @@ -34,8 +34,6 @@ ynh_script_progression --message="Validating installation parameters..." --weigh final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -64,8 +62,6 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" -chown -R $app:$app $final_path - #================================================= # NGINX CONFIGURATION #================================================= @@ -81,8 +77,6 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=5 # Create a dedicated PHP-FPM config ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependencies" -#phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - #================================================= # ADD A CONFIGURATION @@ -101,19 +95,14 @@ else ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" fi -# permissions on files and directories -chmod 400 $final_path/config.dist.php $final_path/index.php $final_path/sous-domaine.html $final_path/VERSION -chmod 644 $final_path/config.local.php -find $final_path/scripts -type d -exec chmod 500 {} + -find $final_path/scripts -type f -exec chmod 400 {} + -find $final_path/templates -type d -exec chmod 500 {} + -find $final_path/templates -type f -exec chmod 400 {} + -find $final_path/include -type d -exec chmod 500 {} + -find $final_path/include -type f -exec chmod 400 {} + -find $final_path/data -type d -exec chmod 700 {} + -find $final_path/data -type f -exec chmod 600 {} + -find /var/www/garradin/www -type d -exec chmod 505 {} + -find /var/www/garradin/www -type f -exec chmod 644 {} + +# Permissions on files and directories +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +find "$final_path" -type d -exec chmod 550 {} + +find "$final_path" -type f -exec chmod 440 {} + +find "$final_path/data" -type d -exec chmod 770 {} + +find "$final_path/data" -type f -exec chmod 660 {} + +chmod 660 "$final_path/config.local.php" #================================================= # SETUP SSOWAT diff --git a/scripts/restore b/scripts/restore index f23b8ad..4ba8ebe 100644 --- a/scripts/restore +++ b/scripts/restore @@ -34,8 +34,6 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=4 -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" test ! -d $final_path \ || ynh_die "There is already a directory: $final_path " @@ -67,7 +65,13 @@ ynh_system_user_create --username=$app #================================================= # Restore permissions on app files -chown -R $app:$app $final_path +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +find "$final_path" -type d -exec chmod 550 {} + +find "$final_path" -type f -exec chmod 440 {} + +find "$final_path/data" -type d -exec chmod 770 {} + +find "$final_path/data" -type f -exec chmod 660 {} + +chmod 660 "$final_path/config.local.php" #================================================= # RESTORE THE PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index d251201..8b5a911 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -193,8 +193,6 @@ then ynh_secure_remove $backup_bdd fi -chown -R $app:$app $final_path - #================================================= # ADD A CONFIGURATION #================================================= @@ -209,19 +207,14 @@ else ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" fi -# Set permissions on app files -chmod 400 $final_path/config.dist.php $final_path/index.php $final_path/sous-domaine.html $final_path/VERSION -chmod 644 $final_path/config.local.php -find $final_path/scripts -type d -exec chmod 500 {} + -find $final_path/scripts -type f -exec chmod 400 {} + -find $final_path/templates -type d -exec chmod 500 {} + -find $final_path/templates -type f -exec chmod 400 {} + -find $final_path/include -type d -exec chmod 500 {} + -find $final_path/include -type f -exec chmod 400 {} + -find $final_path/data -type d -exec chmod 700 {} + -find $final_path/data -type f -exec chmod 600 {} + -find /var/www/garradin/www -type d -exec chmod 505 {} + -find /var/www/garradin/www -type f -exec chmod 644 {} + +# Permissions on files and directories +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +find "$final_path" -type d -exec chmod 550 {} + +find "$final_path" -type f -exec chmod 440 {} + +find "$final_path/data" -type d -exec chmod 770 {} + +find "$final_path/data" -type f -exec chmod 660 {} + +chmod 660 "$final_path/config.local.php" #================================================= # RELOAD NGINX @@ -236,6 +229,7 @@ ynh_systemd_action --service_name=nginx --action=reload ynh_script_progression --message="Finalise upgrade" --weight=1 ynh_local_curl "/admin/index.php" +chmod 440 "$final_path/config.local.php" #================================================= # END OF SCRIPT