Rewrite commands to use '/home/_portzap'
This commit is contained in:
parent
56a73ed635
commit
54124d2d9f
1 changed files with 34 additions and 18 deletions
52
bin/portzap
52
bin/portzap
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
source="https://git.hardenedbsd.org/hardenedbsd/ports.git"
|
source="https://git.hardenedbsd.org/hardenedbsd/ports.git"
|
||||||
stage_dir="/home/_portzap/ports"
|
stage_dir="/home/_portzap/ports"
|
||||||
|
clone_mode=007
|
||||||
|
pull_mode=007
|
||||||
|
|
||||||
clone_mode=007
|
clone_mode=007
|
||||||
pull_mode=007
|
pull_mode=007
|
||||||
|
@ -25,15 +27,21 @@ exit_on_missing_deps() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
user_is_root() {
|
has_portzap_access() {
|
||||||
user_id=$(id -u $(whoami))
|
groups=$(id -Gn)
|
||||||
return $user_id = "0"
|
in_group=1
|
||||||
|
for g in $groups; do
|
||||||
|
if [ $g="_portzap" ];
|
||||||
|
then
|
||||||
|
in_group=0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return $in_group
|
||||||
}
|
}
|
||||||
|
|
||||||
user_is_not_root() {
|
user_is_not_root() {
|
||||||
user_id=$(id -u $(whoami))
|
user_id=$(id -u $(whoami))
|
||||||
result=$(test $user_id -ne "0")
|
return $(test $user_id -ne "0")
|
||||||
return $result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -57,25 +65,33 @@ init() {
|
||||||
clone() {
|
clone() {
|
||||||
if has_portzap_access
|
if has_portzap_access
|
||||||
then
|
then
|
||||||
echo "$stage_dir has already been cloned."
|
if [ -e "$stage_dir/.git" ];
|
||||||
echo "Run 'portzap pull', or 'portzap rmtree' instead."
|
then
|
||||||
exit 1
|
echo "$stage_dir has already been cloned."
|
||||||
|
echo "Run 'portzap pull', or 'portzap rmtree' instead."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
umask $clone_mode
|
||||||
|
git clone --depth 1 $source $stage_dir
|
||||||
|
else
|
||||||
|
echo "Permission denied"
|
||||||
fi
|
fi
|
||||||
git clone --depth 1 $source $stage_dir
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pull() {
|
pull() {
|
||||||
if user_is_root
|
if has_portzap_access
|
||||||
then
|
then
|
||||||
echo "The pull command should not be run as root."
|
if [ -e "$stage_dir/.git" ];
|
||||||
exit 1
|
then
|
||||||
fi
|
umask $pull_mode
|
||||||
if [ -e "$stage_dir/.git" ];
|
cd $stage_dir
|
||||||
then
|
git pull --rebase origin hardenedbsd/main
|
||||||
cd $stage_dir
|
else
|
||||||
git pull --rebase origin hardenedbsd/main
|
echo "Run 'portzap clone' first."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Run 'portzap clone' first."
|
echo "Permission denied."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue