Update 02-init_steps.sh

This commit is contained in:
Alexandre
2023-11-29 11:09:06 +01:00
committed by GitHub
parent 427f555883
commit 734f57c776

View File

@@ -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 <<EOL
'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',
),
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