cleaned up bashisms

This commit is contained in:
Luxferre
2026-07-27 20:33:44 +03:00
parent 3c952b7631
commit 9775b3edc4
9 changed files with 46 additions and 46 deletions
+14 -14
View File
@@ -62,7 +62,7 @@ case "$PARAM" in
help
;;
"newsrv") # set up Git user on the server
[[ -z "$USERHOST" ]] && echo "Error: no user and hostname!" && exit 1
[ -z "$USERHOST" ] && echo "Error: no user and hostname!" && exit 1
$SSHCMD "useradd ${GITUSR}; passwd ${GITUSR}; mkdir -p /home/${GITUSR}/.ssh; echo 'no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty' > /home/${GITUSR}/.ssh/authorized_keys; chown -R ${GITUSR} /home/${GITUSR}/.ssh"
echo "Now, you'll need to enter the newly created ${GITUSR} user password:"
ssh-copy-id ${GITUSR}@${THOST}
@@ -70,18 +70,18 @@ case "$PARAM" in
echo "Git user set up on ${THOST}. Now use $0 newrepo ${GITUSR}@${THOST} [name] to set up new Git repos"
;;
"newrepo") # set up a new Git repo
[[ -z "$USERHOST" ]] && echo "Error: no user and hostname!" && exit 1
[ -z "$USERHOST" ] && echo "Error: no user and hostname!" && exit 1
REPONAME="$3"
[[ -z "$REPONAME" ]] && echo "Error: no repository name!" && exit 1
[ -z "$REPONAME" ] && echo "Error: no repository name!" && exit 1
REPODIR="${REPONAME}.git"
FULLREPODIR="/home/${GITUSR}/$REPODIR"
$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
[ -z "$USERHOST" ] && echo "Error: no user and hostname!" && exit 1
REPONAME="$3"
[[ -z "$REPONAME" ]] && echo "Error: no repository name!" && exit 1
[ -z "$REPONAME" ] && echo "Error: no repository name!" && exit 1
VALUE="$4" # it may be empty
REPODIR="${REPONAME}.git"
FULLREPODIR="/home/${GITUSR}/$REPODIR"
@@ -89,9 +89,9 @@ case "$PARAM" in
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
[ -z "$USERHOST" ] && echo "Error: no user and hostname!" && exit 1
REPONAME="$3"
[[ -z "$REPONAME" ]] && echo "Error: no repository name!" && exit 1
[ -z "$REPONAME" ] && echo "Error: no repository name!" && exit 1
VALUE="$4" # it may be empty
REPODIR="${REPONAME}.git"
FULLREPODIR="/home/${GITUSR}/$REPODIR"
@@ -99,9 +99,9 @@ case "$PARAM" in
echo "Clone URL set for ${REPODIR}"
;;
"set-repo-owner") # set the repo owner name for some services
[[ -z "$USERHOST" ]] && echo "Error: no user and hostname!" && exit 1
[ -z "$USERHOST" ] && echo "Error: no user and hostname!" && exit 1
REPONAME="$3"
[[ -z "$REPONAME" ]] && echo "Error: no repository name!" && exit 1
[ -z "$REPONAME" ] && echo "Error: no repository name!" && exit 1
VALUE="$4" # it may be empty
REPODIR="${REPONAME}.git"
FULLREPODIR="/home/${GITUSR}/$REPODIR"
@@ -109,7 +109,7 @@ case "$PARAM" in
echo "Owner name set for ${REPODIR}"
;;
"gitd-sd") # set up the Git daemon using a systemd unit
[[ -z "$USERHOST" ]] && echo "Error: no user and hostname!" && exit 1
[ -z "$USERHOST" ] && echo "Error: no user and hostname!" && exit 1
TMPUNIT="/tmp/git-daemon.service"
cat << EOF > $TMPUNIT
[Unit]
@@ -134,18 +134,18 @@ EOF
rm -f $TMPUNIT
;;
"gitd-publish") # make a repository public via the Git daemon
[[ -z "$USERHOST" ]] && echo "Error: no user and hostname!" && exit 1
[ -z "$USERHOST" ] && echo "Error: no user and hostname!" && exit 1
REPONAME="$3"
[[ -z "$REPONAME" ]] && echo "Error: no repository name!" && exit 1
[ -z "$REPONAME" ] && echo "Error: no repository name!" && exit 1
REPODIR="${REPONAME}.git"
ACCFILE="/home/${GITUSR}/${REPODIR}/git-daemon-export-ok"
$SSHCMD "touch $ACCFILE; chown $GITUSR $ACCFILE"
echo "Repository git://${THOST}/$REPODIR made public"
;;
"gitd-unpublish") # revoke repository publishing via the Git daemon
[[ -z "$USERHOST" ]] && echo "Error: no user and hostname!" && exit 1
[ -z "$USERHOST" ] && echo "Error: no user and hostname!" && exit 1
REPONAME="$3"
[[ -z "$REPONAME" ]] && echo "Error: no repository name!" && exit 1
[ -z "$REPONAME" ] && echo "Error: no repository name!" && exit 1
REPODIR="${REPONAME}.git"
ACCFILE="/home/${GITUSR}/${REPODIR}/git-daemon-export-ok"
$SSHCMD "rm -f $ACCFILE"