From f6e4e98965351a41aa85affb1640e2774b0d979b Mon Sep 17 00:00:00 2001 From: Fascinated Date: Wed, 12 Jul 2023 14:16:41 +0100 Subject: [PATCH] add basic download test --- start.sh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/start.sh b/start.sh index 8394c56..cf1f210 100644 --- a/start.sh +++ b/start.sh @@ -1,6 +1,25 @@ +workDir=/usr/src/app + +baseUrl=https://git.fascinated.cc/Fascinated/simple-links/raw/branch/master/public/ +toDownload=("avatar.webp" "background.jpg") + echo "Checking if files need to be downloaded" -if [ -z "$(ls -A /usr/src/app/public)" ]; then - echo "Directory is empty" +if [ -z "$(ls -A $workDir/public)" ]; then + echo "Some files are missing, downloading them" + if [ ! -w "$workDir" ]; then + echo "The directory \"$workDir\" is not writeable, unable to download files. Please check your docker compose for :ro and set it to :rw" + for item in "${toDownload[@]}" + do + dir=$workDir/public/$item + if [ -e "$dir" ]; then + echo "Downloading $item to directory $dir" + wget -P $dir $baseUrl$item + echo "Done" + fi + done + echo "Finished downloading files!" +else + echo "All files are already present, no need to download" fi echo "Starting Simple Links..."