commit e4944d09120a2c7ec98ca8aafc98e860351e0966
parent 71d1b3b43b730b37f938549145ad92457a8b3132
Author: Luxferre <lux@ferre>
Date: Thu, 11 Jan 2024 22:20:08 +0200
Updated ghmd
Diffstat:
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
@@ -9,7 +9,7 @@ This is a set of (mostly Linux-specific unless stated otherwise) various useful
- `nnstatus.sh`: output useful status information to dzen2 panel (Xorg-specific but can be rewritten to use any other panel of your choice, depends on `nawk` or other AWK command, `iw` for WLAN stats, `amixer` for volume controls and xkb-switch for keyboard layout controls)
- `nnstatus-stdout.sh`: same as `nnstatus.sh` but without interactivity and keyboard layout functionality, suitable for use in dvtm, a4 and other terminal-based tools with configurable status bar, as it just outputs the information line into the stdout
- `nnkeys.sh`: shell-based multimedia keys manager daemon with a separate configuration file (see `nnkeys.conf` for an example), depends on `evtest`, `pkill` and AWK
-- `ghmd.sh`: single-script solution for basic self-hosted Git repository management including setting up the Git server, private and public-readable repos (see `ghmd.sh help` for all information)
+- `ghmd.sh`: single-script solution for basic self-hosted Git repository management including setting up the Git server, private and public-readable repos and their metadata (see `ghmd.sh help` for all information)
## Credits
diff --git a/ghmd.sh b/ghmd.sh
@@ -5,6 +5,7 @@
# 3) a public Git repo using git:// protocol on the remote instance (if it uses systemd)
# 4) Git daemon (serving git:// protocol) on the remote instance
# 5) access via the Git daemon to individual repositories
+# 6) repository description and clone URL for some services like stagit
# Usage: ghmd.sh [newsrv | newrepo | gitd-sd | gitd-publish | gitd-unpublish] user@host [name]
# regardless of the actions, the user must have root permissions
# prerequisite: git package must be already installed on the server
@@ -40,6 +41,14 @@ Unpublish an existing Git repository on the daemon:
$0 gitd-unpublish root@hostname myrepo
+Set the (displayed) description of an existing Git repository:
+
+$0 set-repo-desc root@hostname myrepo "This is a cool repo"
+
+Set the (displayed) clone URL of an existing Git repository:
+
+$0 set-repo-url root@hostname myrepo git://hostname/myrepo.git
+
Created by Luxferre in 2024, released into public domain
EOF
}
@@ -65,6 +74,26 @@ case "$PARAM" in
$SSHCMD "mkdir -p $FULLREPODIR;cd $FULLREPODIR;git init --bare --shared;chown -R ${GITUSR}:${GITUSR} ."
echo "Empty repository created at ${USERHOST}:${REPODIR}"
;;
+ "set-repo-desc") # set the repo description for some services
+ [[ -z "$USERHOST" ]] && echo "Error: no user and hostname!" && exit 1
+ REPONAME="$3"
+ [[ -z "$REPONAME" ]] && echo "Error: no repository name!" && exit 1
+ VALUE="$4" # it may be empty
+ REPODIR="${REPONAME}.git"
+ FULLREPODIR="/home/${GITUSR}/$REPODIR"
+ $SSHCMD "cd $FULLREPODIR;echo \"$VALUE\" > description;chown -R ${GITUSR}:${GITUSR} description"
+ echo "Description set for ${REPODIR}"
+ ;;
+ "set-repo-url") # set the repo clone URL for some services
+ [[ -z "$USERHOST" ]] && echo "Error: no user and hostname!" && exit 1
+ REPONAME="$3"
+ [[ -z "$REPONAME" ]] && echo "Error: no repository name!" && exit 1
+ VALUE="$4" # it may be empty
+ REPODIR="${REPONAME}.git"
+ FULLREPODIR="/home/${GITUSR}/$REPODIR"
+ $SSHCMD "cd $FULLREPODIR;echo \"$VALUE\" > url;chown -R ${GITUSR}:${GITUSR} url"
+ echo "Clone URL set for ${REPODIR}"
+ ;;
"gitd-sd") # set up the Git daemon using a systemd unit
[[ -z "$USERHOST" ]] && echo "Error: no user and hostname!" && exit 1
TMPUNIT="/tmp/git-daemon.service"