Rename project (srczap -> sourcezap)

This commit is contained in:
0x1eef 2024-05-11 20:19:45 -03:00
parent fe7ec40fc9
commit 4fe253da0f
17 changed files with 123 additions and 123 deletions

View file

@ -1,24 +1,24 @@
PREFIX = /usr/local PREFIX = /usr/local
BINDIR = $(PREFIX)/bin BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/man/man8 MANDIR = $(PREFIX)/man/man8
LIBEXECDIR = $(PREFIX)/libexec/srczap LIBEXECDIR = $(PREFIX)/libexec/sourcezap
SHAREDIR = $(PREFIX)/share/srczap SHAREDIR = $(PREFIX)/share/sourcezap
install: install:
install -d $(BINDIR) $(LIBEXECDIR) $(SHAREDIR) $(MANDIR) install -d $(BINDIR) $(LIBEXECDIR) $(SHAREDIR) $(MANDIR)
install -m 0755 bin/srczap $(BINDIR) install -m 0755 bin/sourcezap $(BINDIR)
install -m 0755 bin/setup-srczap $(BINDIR) install -m 0755 bin/setup-sourcezap $(BINDIR)
install -m 0755 libexec/srczap/* $(LIBEXECDIR) install -m 0755 libexec/sourcezap/* $(LIBEXECDIR)
install -m 0644 share/srczap/* $(SHAREDIR) install -m 0644 share/sourcezap/* $(SHAREDIR)
install -m 0644 man/man8/srczap.8 $(MANDIR) install -m 0644 man/man8/sourcezap.8 $(MANDIR)
deinstall: deinstall:
rm $(BINDIR)/srczap rm $(BINDIR)/sourcezap
rm $(BINDIR)/setup-srczap rm $(BINDIR)/setup-sourcezap
rm $(MANDIR)/srczap.8 rm $(MANDIR)/sourcezap.8
rm -rf $(LIBEXECDIR) rm -rf $(LIBEXECDIR)
rm -rf $(SHAREDIR) rm -rf $(SHAREDIR)
shellcheck: shellcheck:
shellcheck bin/srczap shellcheck bin/sourcezap
shellcheck libexec/srczap/* shellcheck libexec/sourcezap/*

View file

@ -15,38 +15,38 @@ the first time:
# Add the '_srczap' user, group and home directory # Add the '_srczap' user, group and home directory
# This command requires root privileges # This command requires root privileges
# setup-srczap # setup-sourcezap
### CLI: srczap ### CLI: sourcezap
# Clone the HardenedBSD source tree into /home/_srczap/src/ # Clone the HardenedBSD source tree into /home/_sourcezap/src/
# This command is delegated to the '_srczap' user # This command is delegated to the '_sourcezap' user
$ srczap clone $ sourcezap clone
# Pull updates into /home/_srczap/src/ # Pull updates into /home/_sourcezap/src/
# This command is delegated to the '_srczap' user # This command is delegated to the '_sourcezap' user
$ srczap pull $ sourcezap pull
# Install /home/_srczap/src/ into /usr/src/ # Install /home/_sourcezap/src/ into /usr/src/
# This command requires root privileges # This command requires root privileges
# srczap install # sourcezap install
# Start over: erase /usr/src/ and /home/_srczap/src/ # Start over: erase /usr/src/ and /home/_sourcezap/src/
# This command requires root privileges # This command requires root privileges
$ srczap erase $ sourcezap erase
### ENVIRONMENT ### ENVIRONMENT
* __$SRCZAP\_GITURL__ <br> * __$SOURCEZAP\_GITURL__ <br>
The URL to a git repository. <br> The URL to a git repository. <br>
Default: https://git.HardenedBSD.org/HardenedBSD/HardenedBSD.git. Default: https://git.HardenedBSD.org/HardenedBSD/HardenedBSD.git.
* __$SRCZAP\_BRANCH__ <br> * __$SOURCEZAP\_BRANCH__ <br>
The git branch to clone and pull updates from. <br> The git branch to clone and pull updates from. <br>
Default: hardened/14-stable/master. Default: hardened/14-stable/master.
* __$SRCZAP\_INSTALLDIR__ <br> * __$SOURCEZAP\_INSTALLDIR__ <br>
The directory where the source tree will be installed. <br> The directory where the source tree will be installed. <br>
Default: /usr/src/. Default: /usr/src/.
@ -54,14 +54,14 @@ the first time:
**Source** **Source**
The most recent version of srczap can be installed directly The most recent version of sourcezap can be installed directly
via git: via git:
$ git clone https://github.com/0x1eef/srczap.git $ git clone https://github.com/0x1eef/sourcezap.git
$ cd srczap $ cd sourcezap
# make install # make install
# setup-srczap # setup-sourcezap
# pw groupmod -n _srczap -m <user> # pw groupmod -n _sourcezap -m <user>
## Requirements ## Requirements
@ -70,9 +70,9 @@ via git:
## Sources ## Sources
* [GitHub](https://github.com/0x1eef/srczap) * [GitHub](https://github.com/0x1eef/sourcezap)
* [GitLab](https://gitlab.com/0x1eef/srczap) * [GitLab](https://gitlab.com/0x1eef/sourcezap)
* [git.HardenedBSD.org](https://git.HardenedBSD.org/0x1eef/srczap) * [git.HardenedBSD.org](https://git.HardenedBSD.org/0x1eef/sourcezap)
## License ## License

37
bin/setup-sourcezap Executable file
View file

@ -0,0 +1,37 @@
#!/bin/sh
set -e
##
# variables
localbase="${LOCALBASE:-/usr/local}"
conf=$(cat "${localbase}"/share/sourcezap/doas.conf)
doas="${localbase}"/etc/doas.conf
##
# main
if [ "$(id -u)" != "0" ]; then
echo "[x] This command must be run by root"
exit 1
fi
if id -u _sourcezap > /dev/null 2>&1; then
echo "[-] The _sourcezap user exists"
echo "[-] Add user(s) to the _sourcezap group:"
echo "root# pw groupmod -n _sourcezap -m user1,user2"
else
pw useradd -n _sourcezap \
-c "sourcezap user" \
-m \
-s /sbin/nologin
chmod u=rwX,g=rX,o= /home/_sourcezap/
echo "[-] The _sourcezap user, group and home directory have been created."
echo "[-] Add user(s) to the _sourcezap group:"
echo "root# pw groupmod -n _sourcezap -m user1,user2"
fi
if grep -F "^${conf}$" "${doas}" > /dev/null 2>&1; then
echo "[-] No changes made to ${doas}"
else
echo "$conf" >> "$doas"
echo "[-] ${doas} has been changed. Please review the changes"
fi

View file

@ -1,37 +0,0 @@
#!/bin/sh
set -e
##
# variables
localbase="${LOCALBASE:-/usr/local}"
conf=$(cat "${localbase}"/share/srczap/doas.conf)
doas="${localbase}"/etc/doas.conf
##
# main
if [ "$(id -u)" != "0" ]; then
echo "[x] This command must be run by root"
exit 1
fi
if id -u _srczap > /dev/null 2>&1; then
echo "[-] The _srczap user exists"
echo "[-] Add user(s) to the _srczap group:"
echo "root# pw groupmod -n _srczap -m user1,user2"
else
pw useradd -n _srczap \
-c "srczap user" \
-m \
-s /sbin/nologin
chmod u=rwX,g=rX,o= /home/_srczap/
echo "[-] The _srczap user, group and home directory have been created."
echo "[-] Add user(s) to the _srczap group:"
echo "root# pw groupmod -n _srczap -m user1,user2"
fi
if grep -F "^${conf}$" "${doas}" > /dev/null 2>&1; then
echo "[-] No changes made to ${doas}"
else
echo "$conf" >> "$doas"
echo "[-] ${doas} has been changed. Please review the changes"
fi

View file

@ -4,12 +4,12 @@ set -e
## ##
# variables # variables
localbase="${LOCALBASE:-/usr/local}" localbase="${LOCALBASE:-/usr/local}"
gitdir="/home/_srczap/src" gitdir="/home/_sourcezap/src"
giturl="${SRCZAP_GITURL:-https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git}" giturl="${SRCZAP_GITURL:-https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git}"
branch="${SRCZAP_BRANCH:-hardened/14-stable/master}" branch="${SRCZAP_BRANCH:-hardened/14-stable/master}"
installdir="${SRCZAP_INSTALLDIR:-/usr/src}" installdir="${SRCZAP_INSTALLDIR:-/usr/src}"
revision="${installdir}"/.srczap revision="${installdir}"/.sourcezap
libexec="${localbase}"/libexec/srczap libexec="${localbase}"/libexec/sourcezap
## ##
# functions # functions
@ -27,10 +27,10 @@ require_dependency() {
# main # main
i=1 i=1
while [ "${i}" -le "$#" ]; do while [ "${i}" -le "$#" ]; do
eval "_srczap_option=\$${i}" eval "_sourcezap_option=\$${i}"
# shellcheck disable=SC2154 # shellcheck disable=SC2154
if [ "${_srczap_option}" = "-v" ]; then if [ "${_sourcezap_option}" = "-v" ]; then
cat "${localbase}"/share/srczap/VERSION cat "${localbase}"/share/sourcezap/VERSION
exit 0 exit 0
fi fi
# shellcheck disable=SC2003 # shellcheck disable=SC2003
@ -40,26 +40,26 @@ done
case $1 in case $1 in
"clone") "clone")
require_dependency "git doas" require_dependency "git doas"
"${libexec}"/srczap-clone "${giturl}" "${gitdir}" "${branch}" "${libexec}"/sourcezap-clone "${giturl}" "${gitdir}" "${branch}"
;; ;;
"pull") "pull")
require_dependency "git doas" require_dependency "git doas"
"${libexec}"/srczap-pull "${gitdir}" "${branch}" "${libexec}"/sourcezap-pull "${gitdir}" "${branch}"
;; ;;
"erase") "erase")
"${libexec}"/srczap-erase "${gitdir}" "${installdir}" "${libexec}"/sourcezap-erase "${gitdir}" "${installdir}"
;; ;;
"install") "install")
require_dependency "git doas" require_dependency "git doas"
"${libexec}"/srczap-install "${gitdir}" "${installdir}" "${revision}" "${libexec}"/sourcezap-install "${gitdir}" "${installdir}" "${revision}"
;; ;;
*) *)
printf "Usage: srczap COMMAND [OPTIONS]\n" printf "Usage: sourcezap COMMAND [OPTIONS]\n"
printf "\n" printf "\n"
printf "Commands:\n" printf "Commands:\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 " erase Erase /usr/src/ and /home/_srczap/src/\n" printf " erase Erase /usr/src/ and /home/_sourcezap/src/\n"
printf " install Install the source tree into /usr/src/\n" printf " install Install the source tree into /usr/src/\n"
;; ;;
esac esac

View file

@ -13,7 +13,7 @@ mode=u=rwX,g=rX,o=
# functions # functions
gitexec() gitexec()
{ {
doas -n -u _srczap \ doas -n -u _sourcezap \
/bin/sh -c "umask ${mode}; ${git} ${1}" /bin/sh -c "umask ${mode}; ${git} ${1}"
} }

View file

@ -13,7 +13,7 @@ mode=u=rwX,g=rX,o=
# functions # functions
gitexec() gitexec()
{ {
doas -n -u _srczap \ doas -n -u _sourcezap \
/bin/sh -c "umask ${mode}; ${git} ${1}" /bin/sh -c "umask ${mode}; ${git} ${1}"
} }

View file

@ -11,7 +11,7 @@ mode=u=rwX,g=rX,o=
# functions # functions
gitexec() gitexec()
{ {
doas -n -u _srczap \ doas -n -u _sourcezap \
/bin/sh -c "umask ${mode}; ${git} ${1}" /bin/sh -c "umask ${mode}; ${git} ${1}"
} }

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
set -e set -e
group="_srczap" group="_sourcezap"
if id -Gn | \ if id -Gn | \
tr ' ' '\n' | \ tr ' ' '\n' | \
grep -e "^${group}$" \ grep -e "^${group}$" \

View file

@ -15,20 +15,20 @@ mode=u=rwX,g=rX,o=
# functions # functions
gitexec() gitexec()
{ {
doas -n -u _srczap \ doas -n -u _sourcezap \
/bin/sh -c "umask ${mode}; ${git} ${1}" /bin/sh -c "umask ${mode}; ${git} ${1}"
} }
## ##
# main # main
if ! "${libexec}"/issrczap-member; then if ! "${libexec}"/issourcezap-member; then
echo "[x] This command must be run by a member of the '_srczap' group" echo "[x] This command must be run by a member of the '_sourcezap' group"
exit 1 exit 1
fi fi
if [ -e "${gitdir}/.git" ]; then if [ -e "${gitdir}/.git" ]; then
echo "[x] ${gitdir} exists." echo "[x] ${gitdir} exists."
echo "[x] Try 'srczap pull'" echo "[x] Try 'sourcezap pull'"
exit 1 exit 1
fi fi

View file

@ -60,7 +60,7 @@ perform_install()
run_install() run_install()
{ {
install -o root -g _srczap -m "${mode}" -v "$@" install -o root -g _sourcezap -m "${mode}" -v "$@"
} }
## ##

View file

@ -14,7 +14,7 @@ mode="u=rwX,g=rX,o="
# functions # functions
gitexec() gitexec()
{ {
doas -n -u _srczap \ doas -n -u _sourcezap \
/bin/sh -c "umask ${mode}; ${git} ${1}" /bin/sh -c "umask ${mode}; ${git} ${1}"
} }
@ -38,15 +38,15 @@ change_branch()
## ##
# main # main
if ! "${libexec}"/issrczap-member; then if ! "${libexec}"/issourcezap-member; then
echo "[x] This command must be run by a member of the '_srczap' group" echo "[x] This command must be run by a member of the '_sourcezap' group"
exit 1 exit 1
fi fi
if [ ! -e "${gitdir}/.git" ]; then if [ ! -e "${gitdir}/.git" ]; then
set +x set +x
echo "[x] ${gitdir} is not a valid git repository." echo "[x] ${gitdir} is not a valid git repository."
echo "[x] Try 'srczap clone'" echo "[x] Try 'sourcezap clone'"
exit 1 exit 1
fi fi

View file

@ -1,68 +1,68 @@
.Dd May 2023 .Dd May 2023
.Dt SRCZAP 8 .Dt SOURCEZAP 8
.Os .Os
.Sh NAME .Sh NAME
.Nm srczap .Nm sourcezap
.Nd manages a copy of the HardenedBSD source tree .Nd manages a copy of the HardenedBSD source tree
.Sh SYNOPSIS .Sh SYNOPSIS
.br .br
srczap clone sourcezap clone
.br .br
srczap pull sourcezap pull
.br .br
srczap install sourcezap install
.br .br
srczap erase sourcezap erase
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm srczap .Nm sourcezap
manages a copy of the HardenedBSD source tree. 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 '_srczap' 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 EXAMPLES
.sp .sp
.sp .sp
.Nm srczap clone .Nm sourcezap clone
.br .br
Clone the HardenedBSD source tree into /home/_srczap/src/. Clone the HardenedBSD source tree into /home/_sourcezap/src/.
.br .br
This command is delegated to the '_srczap' user. This command is delegated to the '_sourcezap' user.
.Pp .Pp
.Nm srczap pull .Nm sourcezap pull
.br .br
Pull updates into /home/_srczap/src/. Pull updates into /home/_sourcezap/src/.
.br .br
This command is delegated to the '_srczap' user. This command is delegated to the '_sourcezap' user.
.Pp .Pp
.Nm srczap install .Nm sourcezap install
.br .br
Install /home/_srczap/src/ into /usr/src/. Install /home/_sourcezap/src/ into /usr/src/.
.br .br
This command requires root privileges. This command requires root privileges.
.Pp .Pp
.Nm srczap erase .Nm sourcezap erase
.br .br
Start over: erase /usr/src/ and /home/_srczap/src/. Start over: erase /usr/src/ and /home/_sourcezap/src/.
.br .br
This command requires root privileges. This command requires root privileges.
.br .br
.Sh ENVIRONMENT .Sh ENVIRONMENT
.sp .sp
.sp .sp
.Nm SRCZAP_GITURL .Nm SOURCEZAP_GITURL
.br .br
The URL to a git repository. The URL to a git repository.
.br .br
Default: https://git.HardenedBSD.org/HardenedBSD/HardenedBSD.git/ Default: https://git.HardenedBSD.org/HardenedBSD/HardenedBSD.git/
.sp .sp
.Nm SRCZAP_BRANCH .Nm SOURCEZAP_BRANCH
.br .br
The git branch to clone and pull updates from. The git branch to clone and pull updates from.
.br .br
Default: hardened/14-stable/master Default: hardened/14-stable/master
.br .br
.sp .sp
.Nm SRCZAP_INSTALLDIR .Nm SOURCEZAP_INSTALLDIR
.br .br
The directory where the ports collection will be installed. The directory where the ports collection will be installed.
.br .br
@ -70,6 +70,6 @@ Default: /usr/src/
.sp .sp
.Sh AUTHORS .Sh AUTHORS
The The
.Nm srczap .Nm sourcezap
utility and this manual page were written by utility and this manual page were written by
0x1eef <0x1eef@protonmail.com>. 0x1eef <0x1eef@protonmail.com>.

View file

@ -0,0 +1,4 @@
##
# sourcezap
permit nopass root as _sourcezap cmd /bin/sh
permit nopass :_sourcezap as _sourcezap cmd /bin/sh

View file

@ -1,4 +0,0 @@
##
# srczap
permit nopass root as _srczap cmd /bin/sh
permit nopass :_srczap as _srczap cmd /bin/sh