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
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/man/man8
LIBEXECDIR = $(PREFIX)/libexec/srczap
SHAREDIR = $(PREFIX)/share/srczap
LIBEXECDIR = $(PREFIX)/libexec/sourcezap
SHAREDIR = $(PREFIX)/share/sourcezap
install:
install -d $(BINDIR) $(LIBEXECDIR) $(SHAREDIR) $(MANDIR)
install -m 0755 bin/srczap $(BINDIR)
install -m 0755 bin/setup-srczap $(BINDIR)
install -m 0755 libexec/srczap/* $(LIBEXECDIR)
install -m 0644 share/srczap/* $(SHAREDIR)
install -m 0644 man/man8/srczap.8 $(MANDIR)
install -m 0755 bin/sourcezap $(BINDIR)
install -m 0755 bin/setup-sourcezap $(BINDIR)
install -m 0755 libexec/sourcezap/* $(LIBEXECDIR)
install -m 0644 share/sourcezap/* $(SHAREDIR)
install -m 0644 man/man8/sourcezap.8 $(MANDIR)
deinstall:
rm $(BINDIR)/srczap
rm $(BINDIR)/setup-srczap
rm $(MANDIR)/srczap.8
rm $(BINDIR)/sourcezap
rm $(BINDIR)/setup-sourcezap
rm $(MANDIR)/sourcezap.8
rm -rf $(LIBEXECDIR)
rm -rf $(SHAREDIR)
shellcheck:
shellcheck bin/srczap
shellcheck libexec/srczap/*
shellcheck bin/sourcezap
shellcheck libexec/sourcezap/*

View file

@ -15,38 +15,38 @@ the first time:
# Add the '_srczap' user, group and home directory
# This command requires root privileges
# setup-srczap
# setup-sourcezap
### CLI: srczap
### CLI: sourcezap
# Clone the HardenedBSD source tree into /home/_srczap/src/
# This command is delegated to the '_srczap' user
$ srczap clone
# Clone the HardenedBSD source tree into /home/_sourcezap/src/
# This command is delegated to the '_sourcezap' user
$ sourcezap clone
# Pull updates into /home/_srczap/src/
# This command is delegated to the '_srczap' user
$ srczap pull
# Pull updates into /home/_sourcezap/src/
# This command is delegated to the '_sourcezap' user
$ sourcezap pull
# Install /home/_srczap/src/ into /usr/src/
# Install /home/_sourcezap/src/ into /usr/src/
# 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
$ srczap erase
$ sourcezap erase
### ENVIRONMENT
* __$SRCZAP\_GITURL__ <br>
* __$SOURCEZAP\_GITURL__ <br>
The URL to a git repository. <br>
Default: https://git.HardenedBSD.org/HardenedBSD/HardenedBSD.git.
* __$SRCZAP\_BRANCH__ <br>
* __$SOURCEZAP\_BRANCH__ <br>
The git branch to clone and pull updates from. <br>
Default: hardened/14-stable/master.
* __$SRCZAP\_INSTALLDIR__ <br>
* __$SOURCEZAP\_INSTALLDIR__ <br>
The directory where the source tree will be installed. <br>
Default: /usr/src/.
@ -54,14 +54,14 @@ the first time:
**Source**
The most recent version of srczap can be installed directly
The most recent version of sourcezap can be installed directly
via git:
$ git clone https://github.com/0x1eef/srczap.git
$ cd srczap
$ git clone https://github.com/0x1eef/sourcezap.git
$ cd sourcezap
# make install
# setup-srczap
# pw groupmod -n _srczap -m <user>
# setup-sourcezap
# pw groupmod -n _sourcezap -m <user>
## Requirements
@ -70,9 +70,9 @@ via git:
## Sources
* [GitHub](https://github.com/0x1eef/srczap)
* [GitLab](https://gitlab.com/0x1eef/srczap)
* [git.HardenedBSD.org](https://git.HardenedBSD.org/0x1eef/srczap)
* [GitHub](https://github.com/0x1eef/sourcezap)
* [GitLab](https://gitlab.com/0x1eef/sourcezap)
* [git.HardenedBSD.org](https://git.HardenedBSD.org/0x1eef/sourcezap)
## 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
localbase="${LOCALBASE:-/usr/local}"
gitdir="/home/_srczap/src"
gitdir="/home/_sourcezap/src"
giturl="${SRCZAP_GITURL:-https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git}"
branch="${SRCZAP_BRANCH:-hardened/14-stable/master}"
installdir="${SRCZAP_INSTALLDIR:-/usr/src}"
revision="${installdir}"/.srczap
libexec="${localbase}"/libexec/srczap
revision="${installdir}"/.sourcezap
libexec="${localbase}"/libexec/sourcezap
##
# functions
@ -27,10 +27,10 @@ require_dependency() {
# main
i=1
while [ "${i}" -le "$#" ]; do
eval "_srczap_option=\$${i}"
eval "_sourcezap_option=\$${i}"
# shellcheck disable=SC2154
if [ "${_srczap_option}" = "-v" ]; then
cat "${localbase}"/share/srczap/VERSION
if [ "${_sourcezap_option}" = "-v" ]; then
cat "${localbase}"/share/sourcezap/VERSION
exit 0
fi
# shellcheck disable=SC2003
@ -40,26 +40,26 @@ done
case $1 in
"clone")
require_dependency "git doas"
"${libexec}"/srczap-clone "${giturl}" "${gitdir}" "${branch}"
"${libexec}"/sourcezap-clone "${giturl}" "${gitdir}" "${branch}"
;;
"pull")
require_dependency "git doas"
"${libexec}"/srczap-pull "${gitdir}" "${branch}"
"${libexec}"/sourcezap-pull "${gitdir}" "${branch}"
;;
"erase")
"${libexec}"/srczap-erase "${gitdir}" "${installdir}"
"${libexec}"/sourcezap-erase "${gitdir}" "${installdir}"
;;
"install")
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 "Commands:\n"
printf " clone Clone the HardenedBSD source tree\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"
;;
esac

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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