Replace 'portzap setup' with 'setup-portzap'

This commit is contained in:
0x1eef 2024-04-19 05:49:49 -03:00
parent 61f3e3ae08
commit 2ab35924c8
5 changed files with 20 additions and 27 deletions

View file

@ -7,6 +7,7 @@ SHAREDIR = $(PREFIX)/share/portzap
install: install:
install -d $(BINDIR) $(LIBEXECDIR) $(SHAREDIR) $(MANDIR) install -d $(BINDIR) $(LIBEXECDIR) $(SHAREDIR) $(MANDIR)
install -m 0755 bin/portzap $(BINDIR) install -m 0755 bin/portzap $(BINDIR)
install -m 0755 bin/setup-portzap $(BINDIR)
install -m 0755 libexec/portzap/* $(LIBEXECDIR) install -m 0755 libexec/portzap/* $(LIBEXECDIR)
install -m 0644 share/portzap/* $(SHAREDIR) install -m 0644 share/portzap/* $(SHAREDIR)
install -m 0644 man/man8/portzap.8 $(MANDIR) install -m 0644 man/man8/portzap.8 $(MANDIR)

View file

@ -9,7 +9,17 @@ can be installed to `/usr/ports` by root.
## Examples ## Examples
**CLI** ### CLI: setup-portzap
This command should be run after installing portzap for
the first time.
# Add the portzap user, group and home directory.
# This command requires root privileges.
# setup-portzap
### CLI: portzap
# Clone the hardenedbsd ports tree into /home/_portzap/ports/. # Clone the hardenedbsd ports tree into /home/_portzap/ports/.
# This command is delegated to the '_portzap' user. # This command is delegated to the '_portzap' user.
@ -27,11 +37,8 @@ can be installed to `/usr/ports` by root.
# This command requires root privileges. # This command requires root privileges.
# portzap install # portzap install
# Add the portzap user, group and home directory.
# This command requires root privileges.
# portzap setup
**ENVIRONMENT** ### ENVIRONMENT
* __$PORTZAP\_GITURL__ <br> * __$PORTZAP\_GITURL__ <br>
The URL to a git repository. <br> The URL to a git repository. <br>

View file

@ -12,18 +12,10 @@ libexec="${localbase}"/libexec/portzap
## ##
# functions # functions
require_root() {
if [ "$(id -u)" != "0" ]; then
echo "This command requires root privileges."
exit 1
fi
}
require_membership_of() { require_membership_of() {
group=$1 group=$1
if ! id -Gn | tr ' ' '\n' | grep -e "^${group}$" > /dev/null 2>&1; then if ! id -Gn | tr ' ' '\n' | grep -e "^${group}$" > /dev/null 2>&1; then
echo "This command requires a user to be a member of ${group}." echo "[-] This command requires a user to be a member of ${group}."
exit 1 exit 1
fi fi
} }
@ -32,7 +24,7 @@ require_dependency() {
deps=$1 deps=$1
for dep in $deps; do for dep in $deps; do
if ! which -s "$dep"; then if ! which -s "$dep"; then
echo "This command requires ${dep}, but it was not found." echo "[-] This command requires ${dep}, but ${dep} wasn't found"
exit 1 exit 1
fi fi
done done
@ -72,10 +64,6 @@ case $1 in
require_dependency "git doas" require_dependency "git doas"
"${libexec}"/portzap-install "${gitdir}" "${installdir}" "${revision}" "${libexec}"/portzap-install "${gitdir}" "${installdir}" "${revision}"
;; ;;
"setup")
require_root
"${libexec}"/portzap-setup
;;
*) *)
printf "Usage: portzap COMMAND [OPTIONS]\n" printf "Usage: portzap COMMAND [OPTIONS]\n"
printf "\n" printf "\n"
@ -84,6 +72,5 @@ case $1 in
printf " pull Pull updates from the hardenedbsd ports tree.\n" printf " pull Pull updates from the hardenedbsd ports tree.\n"
printf " erase Erase /usr/ports/ and /home/_portzap/ports/.\n" printf " erase Erase /usr/ports/ and /home/_portzap/ports/.\n"
printf " install Install the ports tree into /usr/ports/.\n" printf " install Install the ports tree into /usr/ports/.\n"
printf " setup Add the _portzap user, group and home directory.\n"
;; ;;
esac esac

View file

@ -8,6 +8,11 @@ doas="${localbase}"/etc/doas.conf
## ##
# main # main
if [ "$(id -u)" != "0" ]; then
echo "[-] This command must be run as root"
exit 1
fi
if id -u _portzap > /dev/null 2>&1; then if id -u _portzap > /dev/null 2>&1; then
echo "[-] The _portzap user exists" echo "[-] The _portzap user exists"
echo "[-] Add user(s) to the _portzap group:" echo "[-] Add user(s) to the _portzap group:"

View file

@ -13,8 +13,6 @@ portzap pull
portzap erase portzap erase
.br .br
portzap install portzap install
.br
portzap setup
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm portzap .Nm portzap
manages a copy of the hardenedbsd ports tree. manages a copy of the hardenedbsd ports tree.
@ -49,11 +47,6 @@ Install /home/_portzap/ports/ into /usr/ports/.
.br .br
This command requires root privileges. This command requires root privileges.
.Pp .Pp
.Nm portzap setup
.br
Add the portzap user, group and home directory.
.br
This command requires root privileges.
.Sh ENVIRONMENT .Sh ENVIRONMENT
.sp .sp
.sp .sp