diff --git a/scripts/install b/scripts/install index 6591840..28232f8 100644 --- a/scripts/install +++ b/scripts/install @@ -64,6 +64,8 @@ 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 #================================================= @@ -83,19 +85,10 @@ ynh_add_fpm_config --phpversion=$YNH_PHP_VERSION --package="$extra_php_dependenc #================================================= -# SETUP SSOWAT +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=8 +ynh_script_progression --message="Adding a configuration file..." --weight=5 -# Make app public if necessary -if [ $is_public -eq 1 ] -then - ynh_permission_update --permission "main" --add "visitors" -fi - -#================================================= -# MODIFY A CONFIG FILE -#================================================= # copy config.dist.php creating config.local.php cp -a $final_path/config.dist.php $final_path/config.local.php # create a key for the secret key CSFR; @@ -108,11 +101,7 @@ 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 -#================================================= -# Files owned by user app -#================================================= - -chown -R $app:$app $final_path +# 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 {} + @@ -126,6 +115,17 @@ find $final_path/data -type f -exec chmod 600 {} + find /var/www/garradin/www -type d -exec chmod 755 {} + find /var/www/garradin/www -type f -exec chmod 644 {} + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Configuring permissions..." --weight=8 + +# Make app public if necessary +if [ $is_public -eq 1 ] +then + ynh_permission_update --permission "main" --add "visitors" +fi + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 01f363b..0341ddf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -111,6 +111,8 @@ then ynh_secure_remove $backup_bdd fi + chown -R $app:$app $final_path + key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" @@ -119,12 +121,11 @@ then 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 - chown -R $app:$app $final_path chmod 755 $final_path # Create the visitors permission if needed if [ $is_public -eq 1 ] then - ynh_permission_update --permission="main" --add="visitors" + ynh_permission_update --permission "main" --add "visitors" fi ynh_systemd_action --service_name=nginx --action=reload @@ -192,6 +193,13 @@ then ynh_secure_remove $backup_bdd fi +chown -R $app:$app $final_path + +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=5 + key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" @@ -201,12 +209,7 @@ 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 -#================================================= -# Files owned by user app -#================================================= - # Set permissions on app files -chown -R $app:$app $final_path 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 {} +