commit 6d60655f545df46a0930b908a3f0084bed0f574e
parent 7c803a417d1416ebdd7c947422089eadda89b537
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date:   Thu, 13 Jan 2022 19:22:37 +0100

Rename files for more convenience

Diffstat:
Aa | 25+++++++++++++++++++++++++
Daddkey | 24------------------------
Ae | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dedit | 74--------------------------------------------------------------------------
Mhelp | 8+++++++-
Ai | 21+++++++++++++++++++++
Dinit | 20--------------------
Rsubscripts/mirror-repository -> non-interactive/mirror-repository | 0
Rsubscripts/post-update-public-repos -> non-interactive/post-update-hook | 0
Ar | 2++
Drestart-web | 2--
11 files changed, 130 insertions(+), 121 deletions(-)

diff --git a/a b/a @@ -0,0 +1,25 @@ +#!/bin/sh +# add an ssh key to the list of authorized keys + +echo "Paste the key to be added:" +read key + +keyfile="$(mktemp)" +echo "$key" > "$keyfile" + +# check for errors +fingerprint="$(ssh-keygen -lf $keyfile)" +if [ "$(echo "$fingerprint" | egrep -c '\((R|D)SA|ED25519\)')" -ne "1" ]; then + echo "Error: $fingerprint" + rm "$keyfile" + exit 1 +fi + +mkdir -p .ssh && \ + echo -n "no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty " >> .ssh/authorized_keys && \ + cat "$keyfile" >> .ssh/authorized_keys + +rm "$keyfile" + +echo "Success! Added a key with the following fingerprint:" +echo "$fingerprint" diff --git a/addkey b/addkey @@ -1,24 +0,0 @@ -#!/bin/sh - -echo "Paste the key to be added:" -read key - -keyfile="$(mktemp)" -echo "$key" > "$keyfile" - -# check for errors -fingerprint="$(ssh-keygen -lf $keyfile)" -if [ "$(echo "$fingerprint" | egrep -c '\((R|D)SA|ED25519\)')" -ne "1" ]; then - echo "Error: $fingerprint" - rm "$keyfile" - exit 1 -fi - -mkdir -p .ssh && \ - echo -n "no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty " >> .ssh/authorized_keys && \ - cat "$keyfile" >> .ssh/authorized_keys - -rm "$keyfile" - -echo "Success! Added a key with the following fingerprint:" -echo "$fingerprint" diff --git a/e b/e @@ -0,0 +1,75 @@ +#!/bin/sh +# edit metadata of a repository + +# check number of params +[ $# -ne 1 ] && echo "Usage: e repo[.git]" && exit 1 + +# set the repository name, adding .git if necessary +p=$(echo "$1" | sed 's/\.git$\|$/.git/i') + +[ ! -d "$p" ] && echo "$p not found." && exit 1 + +get_category() { + if [ ! -f "$p/git-daemon-export-ok" ]; then + echo "Private repository" + elif [ ! -f "$p/category" ]; then + echo "Unlisted repository (public cloning but not listed on website)" + else + printf "Public repository, category: " + cat "$p/category" + fi +} + +modify_metadata() { + printf "Enter new $1: " + read answer + echo "$answer" > "$p/$1" +} + +modify_category() { + echo "Category options: + + [p]rivate repository + [u]nlisted repository (public cloning but not listed on website) + + [pr]ojects (public repository) + [pe]rsonal setup (public repository) + [m]iscellanea (public repository)" + + printf ">>> " + read answer + + case $answer in + p) rm -f "$p/git-daemon-export-ok"; rm -f "$p/category" ;; + u) touch "$p/git-daemon-export-ok"; rm -f "$p/category" ;; + pr) touch "$p/git-daemon-export-ok"; echo "Projects" > "$p/category" ;; + pe) touch "$p/git-daemon-export-ok"; echo "Personal setup" > "$p/category" ;; + m) touch "$p/git-daemon-export-ok"; echo "Miscellanea" > "$p/category" ;; + *) echo "Option unknown" ;; + esac +} + +while true; do + echo "Editing repository $p. What data do you want to modify? + + [u]rl: $(cat "$p/url") + [o]wner: $(cat "$p/owner") + [d]escription: $(cat "$p/description") + [c]ategory/visibility: $(get_category) + + [e]xit" + + printf "> " + read answer + + case $answer in + u) modify_metadata "url" ;; + o) modify_metadata "owner" ;; + d) modify_metadata "description" ;; + c) modify_category ;; + e) break ;; + *) echo "Option unknown" ;; + esac +done + +$HOME/git-shell-commands/r diff --git a/edit b/edit @@ -1,74 +0,0 @@ -#!/bin/sh - -# check number of params -[ $# -ne 1 ] && echo "Usage: edit repo[.git]" && exit 1 - -# set the repository name, adding .git if necessary -p=$(echo "$1" | sed 's/\.git$\|$/.git/i') - -[ ! -d "$p" ] && echo "$p not found." && exit 1 - -get_category() { - if [ ! -f "$p/git-daemon-export-ok" ]; then - echo "Private repository" - elif [ ! -f "$p/category" ]; then - echo "Unlisted repository (public cloning but not listed on website)" - else - printf "Public repository, category: " - cat "$p/category" - fi -} - -modify_metadata() { - printf "Enter new $1: " - read answer - echo "$answer" > "$p/$1" -} - -modify_category() { - echo "Category options: - - [p]rivate repository - [u]nlisted repository (public cloning but not listed on website) - - [pr]ojects (public repository) - [pe]rsonal setup (public repository) - [m]iscellanea (public repository)" - - printf ">>> " - read answer - - case $answer in - p) rm -f "$p/git-daemon-export-ok"; rm -f "$p/category" ;; - u) touch "$p/git-daemon-export-ok"; rm -f "$p/category" ;; - pr) touch "$p/git-daemon-export-ok"; echo "Projects" > "$p/category" ;; - pe) touch "$p/git-daemon-export-ok"; echo "Personal setup" > "$p/category" ;; - m) touch "$p/git-daemon-export-ok"; echo "Miscellanea" > "$p/category" ;; - *) echo "Option unknown" ;; - esac -} - -while true; do - echo "Editing repository $p. What data do you want to modify? - - [u]rl: $(cat "$p/url") - [o]wner: $(cat "$p/owner") - [d]escription: $(cat "$p/description") - [c]ategory/visibility: $(get_category) - - [e]xit" - - printf "> " - read answer - - case $answer in - u) modify_metadata "url" ;; - o) modify_metadata "owner" ;; - d) modify_metadata "description" ;; - c) modify_category ;; - e) break ;; - *) echo "Option unknown" ;; - esac -done - -$HOME/git-shell-commands/restart-web diff --git a/help b/help @@ -1,12 +1,18 @@ #!/bin/sh echo "Run 'help' for help, or 'exit' to leave. Available commands:" +echo +echo " a Add an ssh key" +echo " e <repo> Edit metadata of a repository" +echo " i <repo> Create a new repository (private by default)" +echo " r Re-create the stagit website" +echo cd "$(dirname "$0")" for cmd in *; do case "$cmd" in - help) ;; + a|e|i|r|help) ;; *) [ -f "$cmd" ] && [ -x "$cmd" ] && echo " $cmd" ;; esac done diff --git a/i b/i @@ -0,0 +1,21 @@ +#!/bin/sh +# create a new repository (private by default) + +# check number of params +[ $# -ne 1 ] && echo "Usage: i repo[.git]" && exit 1 + +# set the repository name, adding .git if necessary +p=$(echo "$1" | sed 's/\.git$\|$/.git/i') + +[ -e "$p" ] && echo "$p is already a file or directory." && exit 1 + +# create and initialise the repository +mkdir "$p" && \ + cd "$p" && \ + git --bare init +ln -sf "/usr/local/share/doc/stagit/example_post-receive.sh" "hooks/post-receive" +ln -sf "$(dirname "$(realpath "$0")")/non-interactive/post-update-hook" "hooks/post-update" + +echo "Oscar Benedito" > "owner" +echo "https://git.oscarbenedito.com/${p%.git}" > "url" +echo "${p%.git}" > "description" diff --git a/init b/init @@ -1,20 +0,0 @@ -#!/bin/sh - -# check number of params -[ $# -ne 1 ] && echo "Usage: init repo[.git]" && exit 1 - -# set the repository name, adding .git if necessary -p=$(echo "$1" | sed 's/\.git$\|$/.git/i') - -[ -e "$p" ] && echo "$p is already a file or directory." && exit 1 - -# create and initialise the repository -mkdir "$p" && \ - cd "$p" && \ - git --bare init -ln -sf "/usr/local/share/doc/stagit/example_post-receive.sh" "hooks/post-receive" -ln -sf "$(dirname "$(realpath "$0")")/subscripts/post-update-public-repos" "hooks/post-update" - -echo "Oscar Benedito" > "owner" -echo "https://git.oscarbenedito.com/${p%.git}" > "url" -echo "${p%.git}" > "description" diff --git a/subscripts/mirror-repository b/non-interactive/mirror-repository diff --git a/subscripts/post-update-public-repos b/non-interactive/post-update-hook diff --git a/r b/r @@ -0,0 +1 @@ +/usr/local/share/doc/stagit/example_create.sh +\ No newline at end of file diff --git a/restart-web b/restart-web @@ -1 +0,0 @@ -/usr/local/share/doc/stagit/example_create.sh -\ No newline at end of file