Add 'sourcezap [setup|teardown]' (#5)
Co-authored-by: 0x1eef <0x1eef@protonmail.com> Reviewed-on: http://git.bastion.home.network/0x1eef/sourcezap/pulls/5
This commit is contained in:
parent
b39c81584b
commit
81b163dd25
6 changed files with 65 additions and 7 deletions
12
README.md
12
README.md
|
@ -8,15 +8,19 @@ can be installed into `/usr/src/` by root.
|
||||||
|
|
||||||
## CLI
|
## CLI
|
||||||
|
|
||||||
### CLI: setup-sourcezap
|
### CLI: setup
|
||||||
|
|
||||||
`setup-sourcezap` should be run after installing sourcezap for
|
`sourcezap setup` should be run after installing sourcezap for
|
||||||
the first time. <br> There is no harm in running `setup-sourcezap`
|
the first time. <br> There is no harm in running `sourcezap setup`
|
||||||
multiple times:
|
multiple times:
|
||||||
|
|
||||||
# Add the '_sourcezap' user, group and home directory
|
# Add the '_sourcezap' user, group and home directory
|
||||||
# This command requires root privileges
|
# This command requires root privileges
|
||||||
root@localhost# setup-sourcezap
|
root@localhost# sourcezap setup
|
||||||
|
|
||||||
|
# Reverse the changes made by 'sourcezap setup'
|
||||||
|
# This command requires root privileges
|
||||||
|
root@localhost# sourcezap teardown
|
||||||
|
|
||||||
### CLI: group
|
### CLI: group
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,12 @@ while [ "${i}" -le "$#" ]; do
|
||||||
done
|
done
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
|
"setup")
|
||||||
|
"${libexec}"/commands/sourcezap-setup
|
||||||
|
;;
|
||||||
|
"teardown")
|
||||||
|
"${libexec}"/commands/sourcezap-teardown
|
||||||
|
;;
|
||||||
"clone")
|
"clone")
|
||||||
require_dependency "git doas"
|
require_dependency "git doas"
|
||||||
"${libexec}"/commands/sourcezap-clone "${giturl}" "${gitdir}" "${defaultbranch}"
|
"${libexec}"/commands/sourcezap-clone "${giturl}" "${gitdir}" "${defaultbranch}"
|
||||||
|
@ -68,7 +74,11 @@ case $1 in
|
||||||
*)
|
*)
|
||||||
printf "Usage: sourcezap COMMAND [OPTIONS]\n"
|
printf "Usage: sourcezap COMMAND [OPTIONS]\n"
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf "Commands:\n"
|
printf "Setup\n"
|
||||||
|
printf " setup Setup sourcezap for the first time\n"
|
||||||
|
printf " teardown Reverse the changes made by 'sourcezap setup'\n"
|
||||||
|
printf "\n"
|
||||||
|
printf "General\n"
|
||||||
printf " clone Clone the HardenedBSD source tree\n"
|
printf " clone Clone the HardenedBSD source tree\n"
|
||||||
printf " pull Pull source tree updates\n"
|
printf " pull Pull source tree updates\n"
|
||||||
printf " checkout Checkout a branch other than the default\n"
|
printf " checkout Checkout a branch other than the default\n"
|
||||||
|
|
|
@ -3,7 +3,7 @@ set -e
|
||||||
|
|
||||||
##
|
##
|
||||||
# variables
|
# variables
|
||||||
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/..)}
|
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
||||||
libexec="${localbase}"/libexec/sourcezap
|
libexec="${localbase}"/libexec/sourcezap
|
||||||
|
|
||||||
##
|
##
|
24
libexec/sourcezap/commands/sourcezap-teardown
Executable file
24
libexec/sourcezap/commands/sourcezap-teardown
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
##
|
||||||
|
# variables
|
||||||
|
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
|
||||||
|
libexec="${localbase}"/libexec/sourcezap
|
||||||
|
user=_sourcezap
|
||||||
|
|
||||||
|
##
|
||||||
|
# functions
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
. "${libexec}"/functions/print.sh
|
||||||
|
|
||||||
|
##
|
||||||
|
# main
|
||||||
|
if [ "$(id -u)" = "0" ]; then
|
||||||
|
pw userdel -n "${user}"
|
||||||
|
rm -rf /home/"${user}"/
|
||||||
|
printok "done"
|
||||||
|
else
|
||||||
|
printerr "you must be root"
|
||||||
|
exit 1
|
||||||
|
fi
|
|
@ -6,6 +6,8 @@
|
||||||
.Nd manages a copy of the HardenedBSD source tree
|
.Nd manages a copy of the HardenedBSD source tree
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.br
|
.br
|
||||||
|
.Nm sourcezap setup
|
||||||
|
.Nm sourcezap teardown
|
||||||
.Nm sourcezap clone
|
.Nm sourcezap clone
|
||||||
.Nm sourcezap pull
|
.Nm sourcezap pull
|
||||||
.Nm sourcezap checkout
|
.Nm sourcezap checkout
|
||||||
|
@ -17,7 +19,22 @@ manages a copy of the HardenedBSD source tree.
|
||||||
The copy of the source tree is maintained by members of
|
The copy of the source tree is maintained by members of
|
||||||
the '_sourcezap' group, and a copy of the source tree
|
the '_sourcezap' group, and a copy of the source tree
|
||||||
can be installed into /usr/src/ by root.
|
can be installed into /usr/src/ by root.
|
||||||
.Sh EXAMPLES
|
.Sh SETUP
|
||||||
|
.sp
|
||||||
|
.sp
|
||||||
|
.Nm sourcezap setup
|
||||||
|
.br
|
||||||
|
Setup sourcezap for the first time
|
||||||
|
.br
|
||||||
|
This command requires root privileges
|
||||||
|
.Pp
|
||||||
|
.Nm sourcezap teardown
|
||||||
|
.br
|
||||||
|
Reverses the changes made by 'sourcezap setup'
|
||||||
|
.br
|
||||||
|
This command requires root privileges
|
||||||
|
.Pp
|
||||||
|
.Sh COMMANDS
|
||||||
.sp
|
.sp
|
||||||
.sp
|
.sp
|
||||||
.Nm sourcezap clone
|
.Nm sourcezap clone
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
* vNEXT
|
* vNEXT
|
||||||
|
|
||||||
|
** Add 'sourcezap setup', 'sourcezap teardown'
|
||||||
|
Replaces and enhances 'setup-sourcezap'
|
||||||
|
|
||||||
** Add libexec/sourcezap/commands/sourcezap-sh
|
** Add libexec/sourcezap/commands/sourcezap-sh
|
||||||
Runs /bin/sh within /home/_sourcezap/src/ as the '_sourcezap' user
|
Runs /bin/sh within /home/_sourcezap/src/ as the '_sourcezap' user
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue