diff options
author | SanJacobs | 2022-10-09 05:27:31 +0200 |
---|---|---|
committer | SanJacobs | 2022-10-09 05:27:31 +0200 |
commit | fda0ca04aab0a84f8d2c6e699162014071b66451 (patch) | |
tree | 73387c26c0e69af9b7fcdbb228ad0c47a4b5f8a3 /send-refresh.sh | |
parent | 31f388f4989b520bf50d5c766af19d6982e77759 (diff) | |
download | send-fda0ca04aab0a84f8d2c6e699162014071b66451.tar.gz send-fda0ca04aab0a84f8d2c6e699162014071b66451.tar.bz2 send-fda0ca04aab0a84f8d2c6e699162014071b66451.zip |
It works!!!
Diffstat (limited to 'send-refresh.sh')
-rwxr-xr-x | send-refresh.sh | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/send-refresh.sh b/send-refresh.sh index 388571c..422f787 100755 --- a/send-refresh.sh +++ b/send-refresh.sh @@ -4,29 +4,54 @@ #find /path/to/base/dir/ -mindepth 1 -maxdepth 1 -type d -ctime +14 -exec rm -rf {} \; -# Recursively discover files in the user's home directory, older than 14 days, and delete them +# Discover files in the user's home directory, older than 14 days, and delete them #find /path/to/home/dir/ -mindepth 1 -maxdepth 1 -type f -ctime +14 -exec rm -rf {} \; -# Recursively discover files in the user's home directory, younger than 14 days +# Discover files in the user's home directory, younger than 14 days #find /path/to/home/dir/ -mindepth 1 -maxdepth 1 -type f -ctime -14 # command for getting the filename out of a full path #basename /path/to/file.zip -# Creating an array of homedirectory files younger than 14 days: +# Creating an arrays of home directory files: -webdir="/path/to/public/webdir/" +webdir="testdir/website/" +homedir="testdir/home/" young_files=() - while IFS= read -r -d $'\0'; do young_files+=("$REPLY") -done < <(find /home/san/ -mindepth 1 -maxdepth 1 -type f -ctime -14 -name "*.zip" -print0) +done < <(find $homedir -mindepth 1 -maxdepth 1 -type f -ctime -14 -name "*.zip" -print0) + +old_files=() +while IFS= read -r -d $'\0'; do + old_files+=("$REPLY") +done < <(find $webdir* -mindepth 1 -maxdepth 1 -type f -ctime +14 -name "*.zip" -print0) +# +14 this should say # Looping over said array: +echo " --- Young files ---" for file in "${young_files[@]}"; do filename=$(basename "$file") checksum=$(md5sum "$file" | awk '{print $1;}') + filesite=$webdir$checksum + + if mkdir "$filesite" ; then + echo "Made directory, and it worked!" + + webpage=$filesite/index.html + cat html/1.part >> $webpage + echo \<h2\>\<a href="$filename"\>$filename\</a\>\</h2\> >> $webpage + cat html/2.part >> $webpage + stat $file >> $webpage + zipinfo -1 $file | tree --fromfile . >> $webpage + cat html/3.part >> $webpage + + mv "$file" "$filesite/$filename" + + else + echo "Already done." + fi echo "file: $file" echo "filename: $filename" @@ -34,3 +59,16 @@ for file in "${young_files[@]}"; do done + +echo " --- Old files ---" +for file in "${old_files[@]}"; do + filename=$(basename "$file") + checksum=$(md5sum "$file" | awk '{print $1;}') + + echo "file: $file" + echo "filename: $filename" + echo "checksum: $checksum" + + rm -rf $(dirname "$file") + +done |