Add 'portzap init'

This commit is contained in:
0x1eef 2023-01-15 18:29:09 -03:00 committed by Robert
parent a5e6eb4f0f
commit 56a73ed635

View file

@ -5,7 +5,11 @@
# the HardenedBSD ports collection.
source="https://git.hardenedbsd.org/hardenedbsd/ports.git"
stage_dir="/tmp/ports/"
stage_dir="/home/_portzap/ports"
clone_mode=007
pull_mode=007
init_mode=707
##
# Utils
@ -36,16 +40,22 @@ user_is_not_root() {
# Commands
help() {
echo "Usage: portzap clone|pull|unpack|rmtree"
echo "Usage: portzap init|clone|pull|unpack|rmtree"
}
init() {
if user_is_not_root;
then
echo "The init command should be run as root."
exit
fi;
umask $init_mode
pw userdel _portzap -r
pw useradd _portzap -m -s /sbin/nologin
}
clone() {
if user_is_root
then
echo "The clone command should not be run as root."
exit 1
fi
if [ -e "$stage_dir/.git" ];
if has_portzap_access
then
echo "$stage_dir has already been cloned."
echo "Run 'portzap pull', or 'portzap rmtree' instead."
@ -79,19 +89,11 @@ 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
"init")
init
break
;;
"clone")
exit_on_missing_deps
clone