From 17b5dc39b098fb9ad30e99320ec35ca400231afe Mon Sep 17 00:00:00 2001 From: acidvegas Date: Sun, 5 Nov 2023 01:50:22 -0500 Subject: [PATCH] Fixed mistakes in helper script, repo script, css, and more --- assets/deploy-git | 12 +++++-- assets/helper | 78 +++++++++++++++++++++------------------------- assets/repo | 8 +++-- assets/sshd_config | 5 +-- assets/style.css | 2 +- 5 files changed, 52 insertions(+), 53 deletions(-) diff --git a/assets/deploy-git b/assets/deploy-git index c7a36c2..64aba51 100755 --- a/assets/deploy-git +++ b/assets/deploy-git @@ -1,5 +1,4 @@ #!/bin/sh -# git deployment for stagit - developed by acidvegas (https://git.acid.vegas/stagit) [ ! $(grep -q /usr/bin/git-shell /etc/shells) ] && echo "/usr/bin/git-shell" >> /etc/shells [ ! $(getent passwd git) ] && userdel -f git useradd -d /srv/git -k /dev/null -m -s /usr/bin/git-shell -U git @@ -10,4 +9,13 @@ usermod -p '*' git echo -e "[Unit]\nDescription=Start Git Daemon\n\n[Service]\nExecStart=/usr/bin/git daemon --reuseaddr --base-path=/srv/git/ /srv/git/\n\nRestart=always\nRestartSec=500ms\nUser=git\nGroup=git\n\n[Install]\nWantedBy=multi-user.target" > /etc/systemd/system/git-daemon.service systemctl start git-daemon && systemctl enable git-daemon echo "Be sure to use 'AuthorizedKeysFile /etc/ssh/authorized_keys/%u' in your /etc/ssh/sshd_config" -echo "Add your public key to /etc/ssh/authorized_keys/git prefixed with 'no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty'" \ No newline at end of file +echo "Add your public key to /etc/ssh/authorized_keys/git prefixed with 'no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty'" +sudo apt-get install libmd4c-dev libmd4c-html0 libmd4c-html0-dev libmd4c0 +sudo apt-get install libgit2-dev +#STAGIT_CFLAGS += -DGIT_OPT_SET_OWNER_VALIDATION=-1 +Makefile uncomment +sudo certbot --nginx -d example.com -d www.example.com + + +sudo git config --system init.defaultBranch main +^^^^^^ THIS MOTHER FGCKER diff --git a/assets/helper b/assets/helper index ce86d35..028f0a8 100755 --- a/assets/helper +++ b/assets/helper @@ -7,65 +7,57 @@ URL="git.acid.vegas" PROTO="https" CLONE_URL="git://$URL" COMMIT_LIMIT=100 -HTML_DIR="$HOME/dev/git/acidvegas/git.acid.vegas" -REPOS_DIR="$HOME/dev/git" -REPOS_EXCLUDE="git.acid.vegas mirror readme" - -find_repos() { - args="" - for dir in $REPOS_EXCLUDE; do - args="$args -type d -name $dir -prune -o" - done - echo "$(find $1 $args -type d -name .git -printf "%h\\n " | sort | xargs echo)" -} +HTML_DIR="/srv/http" +REPOS_DIR="/srv/git" prepair() { [ -d $HTML_DIR ] && rm -rf $HTML_DIR/* mkdir -p $HTML_DIR/assets echo "[~] populating custom assets..." cp acidvegas.png favicon.png logo.png mostdangerous.png style.css $HTML_DIR/assets - echo $URL > $HTML_DIR/CNAME } make_index() { echo "[~] creating index..." - args="" - for dir in $(ls $REPOS_DIR | grep -v 'mirror'); do - echo "[~] indexing '$dir' repositories..." - DIR_REPOS="$(find_repos $REPOS_DIR/$dir)" - args="$args -c \"$dir\" $DIR_REPOS" - done + args="" + for category in $(cat /srv/git/*/owner | xargs -n1 | sort -u | xargs); do + echo "[~] indexing '$category' repositories..." + REPOS=$(grep -rl "$category" /srv/git/*/owner | xargs -I{} dirname {} | sort -f | tr '\n' ' ') + args="$args -c \"$category\" $REPOS" + done echo "$args" | xargs stagit-index > $HTML_DIR/index.html - echo "[+] finished" } -make_repos() { - for dir in $(find_repos $REPOS_DIR); do - USER=$(basename $(dirname $dir)) - REPO=$(basename $dir) - if [ -f $dir/.git/description ]; then - if [ "$(cat $dir/.git/description)" = "Unnamed repository; edit this file 'description' to name the repository." ]; then - read -p "description for '$USER/$REPO':" desc - echo "$desc" > $dir/.git/description - echo "[+] updated default 'description' file for '$REPO'" - fi - else - read -p "description for '$USER/$REPO':" desc - echo "$desc" > $dir/.git/description - echo "[+] added missing 'description' file for '$REPO'" +make_repo() { + REPO=$(basename "$(echo "$1" | sed 's/\.git$//')") + if [ -f $1/description ]; then + if [ "$(cat $1/description)" = "Unnamed repository; edit this file 'description' to name the repository." ]; then + read -p "description for '$REPO':" desc + echo "$desc" > $1/description + echo "[+] updated default 'description' file for '$REPO'" fi - if [ ! -f $dir/.git/url ]; then - echo "$CLONE_URL/$REPO.git" > $dir/.git/url - echo "[+] added missing 'url' file for '$REPO'" - fi - echo "[~] processing '$REPO' repository..." - mkdir -p $HTML_DIR/$REPO && cd $HTML_DIR/$REPO && stagit -l $COMMIT_LIMIT -u "$PROTO://$URL/$REPO" $dir - ln -sf log.html index.html - git --git-dir $dir/.git archive --format=tar.gz -o "$HTML_DIR/$REPO/archive.tar.gz" --prefix="$REPO/" HEAD + else + read -p "description for '$REPO':" desc + echo "$desc" > $1/description + echo "[+] added missing 'description' file for '$REPO'" + fi + if [ ! -f $1/url ]; then + echo "$CLONE_URL/$REPO.git" > $1/url + echo "[+] added missing 'url' file for '$REPO'" + fi + echo "[~] processing '$REPO' repository..." + mkdir -p $HTML_DIR/$REPO && cd $HTML_DIR/$REPO && stagit -l $COMMIT_LIMIT -u "$PROTO://$URL/$REPO" $1 + ln -sf log.html index.html + git --git-dir $1 archive --format=tar.gz -o "$HTML_DIR/$REPO/archive.tar.gz" --prefix="$REPO/" HEAD +} + +make_all_repos() { + for dir in $(find $REPOS_DIR -type d -name "*.git" | sort); do + make_repo $dir done } # Main prepair -make_repos -make_index \ No newline at end of file +make_all_repos +make_index diff --git a/assets/repo b/assets/repo index bb585fe..cc9f41e 100755 --- a/assets/repo +++ b/assets/repo @@ -6,9 +6,11 @@ if [ $1 = '-c' ]; then [ ! -f post-receive ] && "missing post-receive script" && exit 1 mkdir $2.git && git init --bare $2.git touch $2.git/git-daemon-export-ok - ln post-recieve $2.git/hooks/post-recieve - echo "git://git.acid.vegas/$1.git" > $2.git/url + ln /srv/git/git-shell-commands/post-receive $2.git/hooks/post-receive + echo "git://git.acid.vegas/$2.git" > $2.git/url elif [ $1 = '-d' ]; then [ ! -d $2.git ] && echo "repository does not exist" && exit 1 rm -rf $2.git -fi \ No newline at end of file +else + echo "invlid arguments (use -c or -d)" && exit 1 +fi diff --git a/assets/sshd_config b/assets/sshd_config index 24dd67f..30e1ac5 100644 --- a/assets/sshd_config +++ b/assets/sshd_config @@ -1,15 +1,12 @@ AuthenticationMethods publickey AuthorizedKeysFile /etc/ssh/authorized_keys/%u Banner /etc/issue -ChallengeResponseAuthentication no ClientAliveInterval 0 DisableForwarding yes -PasswordAuthentication no PermitRootLogin no -Port CHANGEME Port 22 +Port CHANGEME PrintLastLog no -Protocol 2 Match LocalPort 22 AllowUsers git diff --git a/assets/style.css b/assets/style.css index 79022cb..3ad4b7c 100644 --- a/assets/style.css +++ b/assets/style.css @@ -28,7 +28,7 @@ td.num{text-align:right;} a.d, a.h, a.i, a.line {text-decoration:none;} h1, h2, h3, h4, h5, h6{font-size:1em;margin:0;} -img, h1, h2{vertical-align middle;} +img, h1, h2{vertical-align: middle;} #branches tr td:nth-child(3), #branches tr:hover td, #tags tr:hover td{background-color:#111;} #tags tr td:nth-child(3){white-space:normal;}