Add "portzap rmtree"

This commit is contained in:
0x1eef 2023-01-14 19:48:30 -03:00 committed by Robert
parent 2307b3ee2b
commit 79c59c3634
2 changed files with 27 additions and 3 deletions

View file

@ -23,6 +23,9 @@ is maintained as a git repository, and portzap allows the repository to be clone
* **portzap unpack** <br>
This command should be run as root. It copies `/tmp/ports` to `/usr/ports`.
* **portzap rmtree** <br>
This command can be run as root, or a regular user. It removes `/tmp/ports`.
## Sources
* [Source code (GitHub)](https://github.com/0x1eef/portzap)

View file

@ -36,7 +36,7 @@ user_is_not_root() {
# Commands
help() {
echo Usage: portzap "clone|pull|unpack"
echo "Usage: portzap clone|pull|unpack|rmtree"
}
clone() {
@ -45,7 +45,12 @@ clone() {
echo "The clone command should not be run as root."
exit 1
fi
rm -rf $stage_dir
if [ -e "$stage_dir/.git" ];
then
echo "$stage_dir has already been cloned."
echo "Run 'portzap pull', or 'portzap rmtree' instead."
exit 1
fi
git clone --depth 1 $source $stage_dir
}
@ -60,7 +65,7 @@ pull() {
cd $stage_dir
git pull --rebase origin hardenedbsd/main
else
echo "Run 'portzap clone' first"
echo "Run 'portzap clone' first."
exit 1
fi
}
@ -74,6 +79,18 @@ unpack() {
cp -Rfv /tmp/ports /usr/
}
rmtree() {
if [ -e $stage_dir ];
then
echo "Please wait."
rm -rf $stage_dir
echo "OK: removed $stage_dir"
else
echo "$stage_dir does not exist."
exit 1
fi
}
case $1 in
"clone")
exit_on_missing_deps
@ -89,6 +106,10 @@ case $1 in
unpack
break
;;
"rmtree")
rmtree
break
;;
*)
help
break