sourcezap/libexec/srczap/srczap-erase

45 lines
865 B
Text
Raw Normal View History

2024-05-11 21:43:59 +02:00
#!/bin/sh
set -e
##
# variables
gitdir=$1
installdir=$2
##
# main
if [ "$(id -u)" != "0" ]; then
echo "[-] This command must be run by root"
exit 1
fi
printf "[-] Are you sure ? \n"
printf "[-] These directories will be erased:\n"
printf " [*] %s \n" "${gitdir}"
printf " [*] %s \n" "${installdir}"
printf "[y|n] "
while true; do
read -r r
if [ "${r}" = "y" ]; then
break
elif [ "${r}" = "n" ]; then
printf "[-] Nothing to do\n"
exit
else
printf "[-] '%s' is not a valid option.\n" "${r}"
printf "[y|n] "
fi
done
for dir in "${gitdir}" "${installdir}"; do
printf "%s " "${dir}"
find "${dir}" \
-maxdepth 1 \
\! -name "." \
\! -name ".." \
\! -name "src" \
-exec printf . \; \
-exec rm -rf "{}" \;
echo
done
printf "[-] Done\n"