Add 'portzap init'
This commit is contained in:
parent
a5e6eb4f0f
commit
56a73ed635
1 changed files with 23 additions and 21 deletions
44
bin/portzap
44
bin/portzap
|
@ -5,7 +5,11 @@
|
||||||
# the HardenedBSD ports collection.
|
# the HardenedBSD ports collection.
|
||||||
|
|
||||||
source="https://git.hardenedbsd.org/hardenedbsd/ports.git"
|
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
|
# Utils
|
||||||
|
@ -36,16 +40,22 @@ user_is_not_root() {
|
||||||
# Commands
|
# Commands
|
||||||
|
|
||||||
help() {
|
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() {
|
clone() {
|
||||||
if user_is_root
|
if has_portzap_access
|
||||||
then
|
|
||||||
echo "The clone command should not be run as root."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -e "$stage_dir/.git" ];
|
|
||||||
then
|
then
|
||||||
echo "$stage_dir has already been cloned."
|
echo "$stage_dir has already been cloned."
|
||||||
echo "Run 'portzap pull', or 'portzap rmtree' instead."
|
echo "Run 'portzap pull', or 'portzap rmtree' instead."
|
||||||
|
@ -79,19 +89,11 @@ 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
|
||||||
|
"init")
|
||||||
|
init
|
||||||
|
break
|
||||||
|
;;
|
||||||
"clone")
|
"clone")
|
||||||
exit_on_missing_deps
|
exit_on_missing_deps
|
||||||
clone
|
clone
|
||||||
|
@ -114,4 +116,4 @@ case $1 in
|
||||||
help
|
help
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue