scripts

Assortment of various scripts and helpers.
git clone git://bsandro.tech/scripts
Log | Files | Refs | README | LICENSE

commit 72b254c7f51fcc78b25d00e343dbcc4657423c5c
parent 4c80e1f33311596b787a3f8d640d6b165ac65221
Author: bsandro <brian.drosan@gmail.com>
Date:   Mon,  7 Feb 2022 00:24:17 +0200

Git repositories managing scripts

Diffstat:
Arepos/create_new_pub.sh | 27+++++++++++++++++++++++++++
Arepos/post-receive | 29+++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/repos/create_new_pub.sh b/repos/create_new_pub.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +REPO_NAME=$1 +REPO_PATH="${REPO_NAME}.git" +CUR_PATH=$(pwd) +BASE_URL="git://bsandro.tech/${REPO_NAME}" + +if test -d $REPO_PATH; then + echo "Repository ${REPO_PATH} already exists, exiting" + exit +fi + +echo "creating new public repo ${REPO_NAME}" + +echo -n "Description: " +read DESCRIPTION + +echo -n "Owner: " +read OWNER + +git init --bare "${REPO_PATH}" +echo "${BASE_URL}" > "${REPO_PATH}/url" +echo "${DESCRIPTION}" > "${REPO_PATH}/description" +echo "${OWNER}" > "${REPO_PATH}/owner" +echo "${REPO_PATH}" >> pub.txt +touch "${REPO_PATH}/git-daemon-export-ok" +ln -s ${CUR_PATH}/post-receive "${REPO_PATH}/hooks/post-receive" diff --git a/repos/post-receive b/repos/post-receive @@ -0,0 +1,29 @@ +#!/bin/sh + +path_repos=/home/git/repos +path_html=/var/www/htdocs/git +site_url="https://bsandro.tech/git" +pub_repos="${path_repos}/pub.txt" + +cd "${path_repos}" +stagit-index $(cat "${pub_repos}") > "${path_html}/index.html" + +cd "${path_html}" +for repo in $(cat "${pub_repos}"); do + r=$(basename "${repo}") + d=$(basename "${repo}" ".git") + cd "${path_html}" + printf "%s: " "${d}" + if [ ! -d "./${d}" ]; then + mkdir "./${d}" + fi + cd "./${d}" || continue + stagit -u "${site_url}/${d}/" "${path_repos}/${r}" + ln -sf ../style.css + ln -sf ../logo.png + ln -sf ../favicon.ico + ln -sf ../favicon.ico favicon.png + ln -sf log.html index.html + + echo "ok" +done