Add "portzap rmtree"
This commit is contained in:
parent
2307b3ee2b
commit
79c59c3634
2 changed files with 27 additions and 3 deletions
|
@ -23,6 +23,9 @@ is maintained as a git repository, and portzap allows the repository to be clone
|
||||||
* **portzap unpack** <br>
|
* **portzap unpack** <br>
|
||||||
This command should be run as root. It copies `/tmp/ports` to `/usr/ports`.
|
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
|
## Sources
|
||||||
|
|
||||||
* [Source code (GitHub)](https://github.com/0x1eef/portzap)
|
* [Source code (GitHub)](https://github.com/0x1eef/portzap)
|
||||||
|
|
27
bin/portzap
27
bin/portzap
|
@ -36,7 +36,7 @@ user_is_not_root() {
|
||||||
# Commands
|
# Commands
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
echo Usage: portzap "clone|pull|unpack"
|
echo "Usage: portzap clone|pull|unpack|rmtree"
|
||||||
}
|
}
|
||||||
|
|
||||||
clone() {
|
clone() {
|
||||||
|
@ -45,7 +45,12 @@ clone() {
|
||||||
echo "The clone command should not be run as root."
|
echo "The clone command should not be run as root."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
git clone --depth 1 $source $stage_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +65,7 @@ pull() {
|
||||||
cd $stage_dir
|
cd $stage_dir
|
||||||
git pull --rebase origin hardenedbsd/main
|
git pull --rebase origin hardenedbsd/main
|
||||||
else
|
else
|
||||||
echo "Run 'portzap clone' first"
|
echo "Run 'portzap clone' first."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -74,6 +79,18 @@ unpack() {
|
||||||
cp -Rfv /tmp/ports /usr/
|
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
|
case $1 in
|
||||||
"clone")
|
"clone")
|
||||||
exit_on_missing_deps
|
exit_on_missing_deps
|
||||||
|
@ -89,6 +106,10 @@ case $1 in
|
||||||
unpack
|
unpack
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
"rmtree")
|
||||||
|
rmtree
|
||||||
|
break
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
help
|
help
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue