commit 639e61bf1380fdf4b21ddc28b7da11722d8a15bf
parent 3d7562715a71f26f08996bbaef296e9303344142
Author: Fred Großkopf <fred@kuandu.systems>
Date: Fri, 18 Sep 2026 12:49:54 +0200
Updates install/uninstall scripts
Diffstat:
4 files changed, 42 insertions(+), 64 deletions(-)
diff --git a/post-receive.hook b/gitpages.post-receive.hook
diff --git a/gitpages.sh b/gitpages.sh
@@ -13,7 +13,6 @@ gitpages - generate static Git web pages using stagit
Usage:
gitpages setup SRC
- gitpages queue REPO
gitpages process_queue
gitpages mirror SRC DST
gitpages generate [REPO]
@@ -295,7 +294,7 @@ setup_all() {
[ -d "$GIT_SRC" ] \
|| error "Directory '$GIT_SRC' not found"
- POST_RECEIVE="$SCRIPT_DIR/post-receive.hook"
+ POST_RECEIVE="$SCRIPT_DIR/gitpages.post-receive.hook"
[ -f "$POST_RECEIVE" ] \
|| error "post-receive helper not found in $SCRIPT_DIR"
diff --git a/install.sh b/install.sh
@@ -1,18 +1,4 @@
#!/bin/sh
-#
-# Copyright (c) 2026 Fred Großkopf
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
set -eu
@@ -51,7 +37,7 @@ setup_user() {
-d "$VAR_DIR" \
-c "Gitpages service user" \
-g "$GROUP_NAME" \
- -G "$GIT_USER" \
+ -G "$GIT_GROUP" \
"$USER_NAME"
log "Created user $USER_NAME (primary group: $GROUP_NAME)"
fi
@@ -62,27 +48,29 @@ setup_spool() {
}
install_scripts() {
- for script in gitpages.sh; do
- if [ -f "./$script" ]; then
- install -m 755 -o root -g wheel "./$script" "$BIN_DIR/$script"
- log "Installed $script to $BIN_DIR"
- else
- warn "$script not found, skipping."
- fi
- done
+ if [ -f "./gitpages.sh" ]; then
+ install -m 755 -o root -g wheel \
+ ./gitpages.sh "$BIN_DIR/gitpages"
+ log "Installed gitpages to $BIN_DIR/gitpages"
+ else
+ error "gitpages.sh not found"
+ fi
+
+ if [ -f "./gitpages.post-receive.hook" ]; then
+ install -m 755 -o root -g wheel \
+ ./gitpages.post-receive.hook "$BIN_DIR/gitpages.post-receive.hook"
+ log "Installed post-receive hook to $BIN_DIR/gitpages.post-receive.hook"
+ else
+ error "gitpages.post-receive.hook not found"
+ fi
}
setup_config() {
config="$ETC_DIR/gitpages.conf"
- backup="$config.bak"
if [ -f "$config" ]; then
- n=1
- while [ -f "$backup.$n" ]; do
- n=$((n + 1))
- done
- cp -p "$config" "$backup.$n"
- log "Backed up $config to $backup.$n"
+ warn "$config already exists; keeping existing configuration."
+ return 0
fi
tmp="$(mktemp "$ETC_DIR/gitpages.conf.XXXXXX")"
@@ -95,13 +83,14 @@ GIT_HTML=$GIT_HTML
ASSETS_DIR=$ASSETS_DIR
EOF
+ chmod 644 "$tmp"
mv "$tmp" "$config"
trap - EXIT INT TERM
log "Wrote config to $config"
}
setup_logrotation() {
- if ! grep -q "$LOG_DIR/updates.log" "$ETC_DIR"/newsyslog.conf; then
+ if ! grep -qF "$LOG_DIR/updates.log" "$ETC_DIR"/newsyslog.conf; then
echo "$LOG_DIR/updates.log ${USER_NAME}:${GROUP_NAME} 640 5 100 * J" >> "$ETC_DIR"/newsyslog.conf
log "Log rotation appended to $ETC_DIR/newsyslog.conf."
else
@@ -110,24 +99,24 @@ setup_logrotation() {
}
setup_cron() {
- cron_line="*/5 * * * * $BIN_DIR/gitpages-update.sh"
-
- if [ ! -f "$BIN_DIR/gitpages-update.sh" ]; then
- error "Cannot setup cron: $BIN_DIR/gitpages-update.sh not found."
- fi
+ cron_line="*/5 * * * * $BIN_DIR/gitpages process_queue"
- if crontab -u "$USER_NAME" -l 2> /dev/null | grep -qF "$cron_line"; then
+ if crontab -u "$USER_NAME" -l 2> /dev/null \
+ | grep -qF "$cron_line"; then
log "Cronjob already exists and is configured correctly."
else
- echo "$cron_line" | crontab -u "$USER_NAME" -
+ {
+ crontab -u "$USER_NAME" -l 2> /dev/null || true
+ printf '%s\n' "$cron_line"
+ } | crontab -u "$USER_NAME" -
log "Cronjob set for gitpages user."
fi
}
setup_webroot() {
install -d -m 755 -o "root" -g "wheel" "$WEB_ROOT"
- install -d -m 755 -o "$USER_NAME" -g "$GROUP_NAME" "$WEB_ROOT/git"
- install -d -m 755 -o "$USER_NAME" -g "$GROUP_NAME" "$WEB_ROOT/git-raw"
+ install -d -m 755 -o "$USER_NAME" -g "$GROUP_NAME" "$WEB_ROOT/$GIT_HTML"
+ install -d -m 755 -o "$USER_NAME" -g "$GROUP_NAME" "$WEB_ROOT/$GIT_RAW"
log "Created web root and subdirectories under $WEB_ROOT"
}
@@ -148,14 +137,19 @@ main() {
ETC_DIR="/etc"
VAR_DIR="/var/gitpages"
LOG_DIR="/var/log/gitpages"
- SPOOL_DIR="/var/spool"
- QUEUE_DIR="$SPOOL_DIR/gitpages/queue"
+ SPOOL_DIR="/var/spool/gitpages"
+ QUEUE_DIR="$SPOOL_DIR/queue"
# Validation
if ! id "$GIT_USER" > /dev/null 2>&1; then
error "User '$GIT_USER' does not exist."
fi
+ GIT_GROUP=$(id -gn "$GIT_USER") \
+ || error "Could not determine primary group of '$GIT_USER'."
+
+ log "Using Git user: $GIT_USER (group: $GIT_GROUP)"
+
case "$GIT_SRC" in
/*) : ;;
*) error "GIT_SRC must be an absolute path" ;;
@@ -175,8 +169,7 @@ main() {
log "Installing gitpages environment for git-user: $GIT_USER"
log "Using WEB_ROOT: $WEB_ROOT"
- # Determine and switch to where this script resides
- # so ./gitpages-*.sh work no matter where script is invoked from
+ # Switch to the directory containing the installation files.
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
cd "$SCRIPT_DIR" || error "cannot cd to $SCRIPT_DIR"
diff --git a/uninstall.sh b/uninstall.sh
@@ -1,18 +1,4 @@
#!/bin/sh
-#
-# Copyright (c) 2026 Fred Großkopf
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
set -e
@@ -31,14 +17,14 @@ WEB_ROOT=""
ASSETS_DIR="${VAR_DIR}/assets"
remove_files() {
- rm -f "$BIN_DIR/gitpages.sh"
+ rm -f "$BIN_DIR/gitpages"
+ rm -f "$BIN_DIR/gitpages.post-receive.hook"
log "Removed binaries."
warn "Configuration files were not removed:"
warn " $ETC_DIR/gitpages.conf"
- warn " $ETC_DIR/gitpages.conf.bak*"
warn "Remove them manually if no longer needed:"
- warn " rm -f $ETC_DIR/gitpages.conf $ETC_DIR/gitpages.conf.bak*"
+ warn " rm -f $ETC_DIR/gitpages.conf"
}
remove_logrotation() {
@@ -127,7 +113,7 @@ confirm_assets_removal() {
printf '\n' >&2
warn "The default assets directory will be removed:"
warn " $ASSETS_DIR"
- warn "This includes all files deployed to the web root from this directory."
+ warn "Any custom files stored in this directory will be deleted."
warn "If you customized ASSETS_DIR in /etc/gitpages.conf, you are responsible for that directory."
printf '\n' >&2