From 734f57c776a8788fcd4f211fe37260f7e76170f6 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:09:06 +0100 Subject: [PATCH] Update 02-init_steps.sh --- .../rootfs/etc/cont-init.d/02-init_steps.sh | 55 +++++++++---------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/nextcloud/rootfs/etc/cont-init.d/02-init_steps.sh b/nextcloud/rootfs/etc/cont-init.d/02-init_steps.sh index 3bfccc3e5..92a898959 100755 --- a/nextcloud/rootfs/etc/cont-init.d/02-init_steps.sh +++ b/nextcloud/rootfs/etc/cont-init.d/02-init_steps.sh @@ -112,7 +112,7 @@ echo "... Disabling check_data_directory_permissions" for files in /defaults/config.php /data/config/www/nextcloud/config/config.php; do if [ -f "$files" ]; then sed -i "/check_data_directory_permissions/d" "$files" - sed -i "/datadirectory/a 'check_data_directory_permissions' => false," "$files" + sed -i "/datadirectory/a\ \ 'check_data_directory_permissions' => false," "$files" fi done timeout 10 sudo -u abc php /app/www/public/occ config:system:set check_data_directory_permissions --value=false --type=bool || echo "Please install nextcloud first" @@ -141,34 +141,33 @@ if bashio::config.true "Enable_thumbnails"; then # Clean variables sed -i "/preview_ffmpeg_path/d" "$files" sed -i "/enable_previews/d" "$files" - sed -i "/'installed'/a 'preview_ffmpeg_path' => '/usr/bin/ffmpeg'," "$files" - sed -i "/'installed'/a 'enable_previews' => true," "$files" + sed -i "/enabledPreviewProviders/,/),/d" "$files" - # Prepare text - if ! grep -q "enabledPreviewProviders" "$files"; then - insert_text=$(cat < - array ( - 0 => 'OC\\Preview\\TXT', - 1 => 'OC\\Preview\\MarkDown', - 2 => 'OC\\Preview\\OpenDocument', - 3 => 'OC\\Preview\\PDF', - 4 => 'OC\\Preview\\Image', - 5 => 'OC\\Preview\\TIFF', - 6 => 'OC\\Preview\\SVG', - 7 => 'OC\\Preview\\Font', - 8 => 'OC\\Preview\\MP3', - 9 => 'OC\\Preview\\Movie', - 10 => 'OC\\Preview\\MKV', - 11 => 'OC\\Preview\\MP4', - 12 => 'OC\\Preview\\AVI', - ), - EOL - ) - - # Use sed to insert the text after a specific pattern (you can adjust the pattern as needed) - sed -i "/'installed'/a $insert_text" "$files" - fi + # Add variables + echo "'preview_ffmpeg_path' => '/usr/bin/ffmpeg', + 'enable_previews' => true, + 'enabledPreviewProviders' => + array ( + 0 => 'OC\Preview\TXT', + 1 => 'OC\Preview\MarkDown', + 2 => 'OC\Preview\OpenDocument', + 3 => 'OC\Preview\PDF', + 4 => 'OC\Preview\Image', + 5 => 'OC\Preview\TIFF', + 6 => 'OC\Preview\SVG', + 7 => 'OC\Preview\Font', + 8 => 'OC\Preview\MP3', + 9 => 'OC\Preview\Movie', + 10 => 'OC\Preview\MKV', + 11 => 'OC\Preview\MP4', + 12 => 'OC\Preview\AVI', + )," > lines_to_add + + # Iterate through each line in the lines_to_add_file + while IFS= read -r line; do + # Use sed to insert the line after the match "installed" in the config_file + sed -i "/installed/i\ \ ${line//[[:space:]]/}" config.php + done < "$lines_to_add" fi done fi