50 lines
1.3 KiB
Bash
Executable File
50 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
names_container=("lucas" "multimedia" "mimi")
|
|
clean_versions() {
|
|
VERSION_DIRS=("Music" "Pictures" "Stuff" "SW")
|
|
for dir in ${VERSION_DIRS[@]}; do
|
|
if [ -d /nextcloud/nextcloud-data/lucas/files_versions/${dir} ]; then
|
|
echo "Delete /nextcloud/nextcloud-data/lucas/files_versions/${dir}? (y/*)"
|
|
read -n 4 choice
|
|
if [[ "${choice}" == "y" ]]; then
|
|
echo "Delete"
|
|
rm -dr /nextcloud/nextcloud-data/lucas/files_versions/${dir}
|
|
else
|
|
echo "Skip"
|
|
fi
|
|
else
|
|
echo "${dir} not present - skipping"
|
|
fi
|
|
done
|
|
}
|
|
|
|
clean_trashbin() {
|
|
container=("avi" "mkv" "mp4" "m4v" "srt")
|
|
IFS=$'\n'; set -f
|
|
find /nextcloud/nextcloud-data/multimedia/files_trashbin/files/ -name *\.* -delete
|
|
for name in ${names_container[@]}; do
|
|
for cont in ${container[@]}; do
|
|
FILE_ARR=("${FILE_ARR[@]}" $(find /nextcloud/nextcloud-data/${name}/files_trashbin/files/ -type f -name "*${cont}*"))
|
|
done
|
|
done
|
|
if [ ${#FILE_ARR[@]} -eq 0 ]; then
|
|
echo "No Media Containers Present"
|
|
return
|
|
fi
|
|
for file in ${FILE_ARR[@]}; do
|
|
echo "Delete $( echo $file | rev | cut -f1 -d'/' | rev)"
|
|
rm "${file}"
|
|
done
|
|
}
|
|
check_root(){
|
|
if [ $(id -u) -ne 0 ]; then
|
|
echo "Execute as root: $(id)"
|
|
exit
|
|
fi
|
|
}
|
|
check_root
|
|
service apache2 stop
|
|
clean_versions
|
|
clean_trashbin
|
|
service apache2 start
|