sourcezap/libexec/srczap/srczap-erase
0x1eef ea06f0dfbc First commit
A modified copy of portzap repurposed for management of the
hardenedbsd source tree.
2024-05-11 16:03:00 -03:00

43 lines
861 B
Bash

#!/bin/sh -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"