Compare commits

...

4 commits

Author SHA1 Message Date
f8bcf60ae1 Add setup/setup-user
Some checks are pending
sourcezap / shellcheck (push) Waiting to run
2024-07-26 11:32:27 -03:00
36cb7591ee Add libexec/sourcezap/setup/ 2024-07-25 07:22:30 -03:00
c97b48bc0d Continue script execution when "git checkout" fails 2024-07-24 14:34:23 -03:00
0b029b5124 Update RELNOTES 2024-07-20 17:25:54 -03:00
6 changed files with 86 additions and 38 deletions

View file

@ -10,8 +10,9 @@ can be installed into `/usr/src/` by root.
#### CLI: setup-sourcezap
This command should be run after installing sourcezap for
the first time:
`setup-sourcezap` should be run after installing
sourcezap for the first time. <br> There is no harm in
running `setup-sourcezap` multiple times:
# Add the '_sourcezap' user, group and home directory
# This command requires root privileges

View file

@ -5,8 +5,6 @@ set -e
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/..)}
libexec="${localbase}"/libexec/sourcezap
conf=$(cat "${localbase}"/share/sourcezap/doas.conf)
doas="${localbase}"/etc/doas.conf
##
# functions
@ -14,25 +12,10 @@ doas="${localbase}"/etc/doas.conf
##
# main
if [ "$(id -u)" != "0" ]; then
if [ "$(id -u)" = "0" ]; then
"${libexec}"/setup/setup-user
"${libexec}"/setup/setup-doas
else
printerr "you must be root"
exit 1
fi
if id -u _sourcezap > /dev/null 2>&1; then
printok "_sourcezap user exists"
else
pw useradd -n _sourcezap \
-c "sourcezap user" \
-m \
-s /sbin/nologin
chmod u=rwX,g=rX,o= /home/_sourcezap/
printok "create _sourcezap user"
fi
if grep -F "^${conf}$" "${doas}" > /dev/null 2>&1; then
printok "${doas} is up to date"
else
echo "$conf" >> "$doas"
printok "update ${doas} (note: review the update)"
fi

View file

@ -34,5 +34,5 @@ fi
"${git}" clone "${giturl}" "${gitdir}"
cd "${gitdir}"
"${git}" config core.filemode off
"${git}" checkout -t origin/"${branch}"
"${git}" checkout -t origin/"${branch}" || true
printok "clone complete"

View file

@ -0,0 +1,28 @@
#!/bin/sh
set -e
##
# variables
localbase=$(realpath "$(dirname "$0")"/../../..)
libexec="${localbase}"/libexec/sourcezap
sharedir="${localbase}"/share/sourcezap
##
# functions
. "${libexec}"/functions/print.sh
install_doasconf()
{
src="${sharedir}"/doas.conf
dest="${localbase}"/etc/doas.conf
if grep -Fq "$(cat "${src}")" "${dest}"; then
printok "doas.conf is up to date"
else
cat "${src}" >> "${dest}"
printok "${dest} updated"
fi
}
##
# main
install_doasconf

View file

@ -0,0 +1,26 @@
#!/bin/sh
set -e
##
# variables
localbase=${LOCALBASE:-$(realpath "$(dirname "$0")"/../../..)}
libexec="${localbase}"/libexec/sourcezap
user="_sourcezap"
##
# functions
. "${libexec}"/functions/print.sh
##
# main
if id -u "${user}" > /dev/null 2>&1; then
printok "${user} user exists"
else
pw useradd
-n "${user}" \
-c "sourcezap user" \
-m \
-s /sbin/nologin
chmod u=rwX,g=rX,o= /home/"${user}"/
printok "${user} user created"
fi

View file

@ -1,28 +1,38 @@
= v0.2.1
v?.?.?
~ Fix Makefile
| Add libexec/sourcezap/setup/setup-user
Move the code that handles the creation of the '_sourcezap'
user from bin/setup-sourcezap to the libexec/sourcezap/setup/
directory
| Recover from "git checkout" failure
After this change, "git checkout" exiting unsuccessfully
towards the end of "sourcezap clone" no longer causes
sourcezap to exit as well
v0.2.1
| Fix Makefile
The mandoc directory wasn't created properly.
It became obvious when building the port
It only became obvious when building the port
into a temporary staging directory
= v0.2.0
v0.2.0
~ Set "diff.renameLimit" to unlimited
After this change, sourcezap always
forwards "-l0" to "git diff"
| Set "diff.renameLimit" to unlimited
After this change, sourcezap forwards "-l0" to "git diff"
~ Replace utils/gitexec with utils/git/run
| Replace utils/gitexec with utils/git/run
After this change, we talk to git via utils/git/run
~ Add utils/git
| Add utils/git
A dedicated directory for git-related scripts
~ Remove "set -x"
| Remove "set -x"
After this change, sourcezap emits less output
~ Remove scripts
Remove "utils/printok", "utils/printerr", and
"utils/git-rev"
| Remove scripts
Remove "utils/printok", "utils/printerr", and "utils/git-rev"
~ Add documentation
| Add documentation
Covers README.md and sourcezap.8