Add portzap-install-port
Add a new script that is responsible for installing a new port to /usr/ports with the correct permissions.
This commit is contained in:
parent
dd70ed38a7
commit
f08ad32c90
2 changed files with 32 additions and 12 deletions
29
bin/portzap
29
bin/portzap
|
@ -4,16 +4,19 @@
|
||||||
|
|
||||||
##
|
##
|
||||||
# Configuration
|
# Configuration
|
||||||
source="https://git.hardenedbsd.org/hardenedbsd/ports.git"
|
source_url="https://git.hardenedbsd.org/hardenedbsd/ports.git"
|
||||||
transient_dir="/home/_portzap/ports"
|
transient_dir="/home/_portzap/ports"
|
||||||
final_dir="/usr/ports/"
|
rest_dir="/usr/ports/"
|
||||||
|
|
||||||
|
##
|
||||||
|
# Default masks
|
||||||
|
init_mask=707
|
||||||
|
clone_mask=007
|
||||||
|
pull_mask=007
|
||||||
|
|
||||||
##
|
##
|
||||||
# Default modes
|
# Default modes
|
||||||
init_mode=707
|
unpack_mode="u=rwX,g=rX,o=rX"
|
||||||
clone_mode=007
|
|
||||||
pull_mode=007
|
|
||||||
unpack_mode=022
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Utils
|
# Utils
|
||||||
|
@ -58,7 +61,7 @@ init() {
|
||||||
echo "The init command should be run as root."
|
echo "The init command should be run as root."
|
||||||
exit 1
|
exit 1
|
||||||
fi;
|
fi;
|
||||||
umask $init_mode
|
umask $init_mask
|
||||||
pw userdel _portzap -r
|
pw userdel _portzap -r
|
||||||
pw useradd _portzap -m -s /sbin/nologin
|
pw useradd _portzap -m -s /sbin/nologin
|
||||||
}
|
}
|
||||||
|
@ -72,8 +75,8 @@ clone() {
|
||||||
echo "Run 'portzap pull' instead."
|
echo "Run 'portzap pull' instead."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
umask $clone_mode
|
umask $clone_mask
|
||||||
git clone --depth 1 $source $transient_dir
|
git clone --depth 1 $source_url $transient_dir
|
||||||
else
|
else
|
||||||
echo "Permission denied."
|
echo "Permission denied."
|
||||||
fi
|
fi
|
||||||
|
@ -84,7 +87,7 @@ pull() {
|
||||||
then
|
then
|
||||||
if [ -e "$transient_dir/.git" ];
|
if [ -e "$transient_dir/.git" ];
|
||||||
then
|
then
|
||||||
umask $pull_mode
|
umask $pull_mask
|
||||||
cd $transient_dir
|
cd $transient_dir
|
||||||
git pull --rebase origin hardenedbsd/main
|
git pull --rebase origin hardenedbsd/main
|
||||||
else
|
else
|
||||||
|
@ -103,8 +106,10 @@ unpack() {
|
||||||
echo "The unpack command should be run as root."
|
echo "The unpack command should be run as root."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
umask $unpack_mode
|
cd $transient_dir
|
||||||
cp -Rfv "$transient_dir/." $final_dir
|
find . -maxdepth 1 -type f -exec install -m=$unpack_mode {} $rest_dir \;
|
||||||
|
find . -maxdepth 1 -type d -exec mkdir -p -m $unpack_mode $rest_dir/{} \;
|
||||||
|
find . -depth 2 -type d -exec portzap-install-port {} $rest_dir $unpack_mode \;
|
||||||
}
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
|
|
15
bin/portzap-install-port
Executable file
15
bin/portzap-install-port
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/sh
|
||||||
|
src=$1
|
||||||
|
dest=$2/${src}
|
||||||
|
mode=$3
|
||||||
|
group=_portzap
|
||||||
|
install_args="-m $mode"
|
||||||
|
|
||||||
|
mkdir -m $mode -p $dest
|
||||||
|
find $src -maxdepth 1 -type f -execdir install $install_args {} $dest/{} \;
|
||||||
|
if [ -d "$src/files" ];
|
||||||
|
then
|
||||||
|
mkdir -m $mode -p $dest/files
|
||||||
|
find $src/files -maxdepth 1 -type f -execdir install $install_args {} $dest/files \;
|
||||||
|
fi
|
||||||
|
echo Install $(realpath $dest)
|
Loading…
Reference in a new issue