From b411f13aa5b60ca0ab19d7261a857696b6c281dd Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 8 Feb 2024 20:16:13 +0100 Subject: [PATCH] feat: added pic command --- pic | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 pic diff --git a/pic b/pic new file mode 100755 index 0000000..00e1302 --- /dev/null +++ b/pic @@ -0,0 +1,30 @@ +#!/bin/bash +if [ $# -eq 0 ]; then + echo "[!] no repository name specified" + exit +fi + +REPOSITORY="$1" # with .git +REPONAME="$1" # without .git + +if [[ ! "$REPOSITORY" == *.git ]]; then + REPOSITORY="$REPOSITORY.git" +fi + +if [[ "$REPONAME" == *.git ]]; then + REPONAME=$(echo "$REPONAME" | sed 's/\.git$//') +fi + +if [ ! -d "/srv/git/$REPOSITORY" ]; then + echo "[!] repository doesn't exist" + exit +fi + +if [ $# -eq 1 ]; then + git config -f "/srv/git/$REPOSITORY/config" --unset cgit.logo + echo "[ ] unset homepage from $REPONAME" +else + git config -f "/srv/git/$REPOSITORY/config" cgit.logo "$2" + echo "[@] set '$2' as $REPONAME homepage" +fi +