pile

Not quite a web "stack"; more orderly than a web "heap", hopefully?
git clone https://git.kevinlegouguec.net/pile
Log | Files | Refs

add-repo.sh (1179B)


      1 #!/bin/bash
      2 
      3 set -eu
      4 test "${DEBUG:-}" && set -x
      5 
      6 declare -r SCRIPTS_DIR=$(dirname "$(realpath "$0")")
      7 . "${SCRIPTS_DIR}"/settings
      8 
      9 declare -r REPO_DIR=$(realpath "$1")
     10 declare -r REPO_NAME=$(basename "${REPO_DIR}")
     11 
     12 repo-owner ()
     13 {
     14     test -f "${REPO_DIR}"/owner && {
     15         cat "${REPO_DIR}"/owner
     16         return
     17     }
     18     # Sure hope someone ran 'chfn -f'.
     19     getent passwd ${USER} | cut -d: -f5 | cut -d, -f1
     20 }
     21 
     22 declare -r REPO_DESCRIPTION="${REPO_DIR}"/description
     23 declare -r REPO_OWNER=$(repo-owner)
     24 declare -r REPO_URL=https://${DOMAIN}/${REPO_NAME}
     25 
     26 (
     27     cd "${WWW_DIR}"
     28     git init --bare "${REPO_NAME}"
     29 
     30     cd "${REPO_NAME}"
     31 
     32     ln -s ../*.{css,png} .
     33 
     34     # stagit puts a clickable link on every page's 'git clone' blurb;
     35     # make sure there is a browser-friendly page for users to land on,
     36     # instead of a 40x.
     37     # Use log.html: that aligns with stagit-index's repo links.
     38     ln -s log.html index.html
     39 
     40     ln -sf "${REPO_DESCRIPTION}" .
     41     echo "${REPO_OWNER}" > owner
     42     echo "${REPO_URL}" > url
     43 )
     44 
     45 (
     46     cd "${REPO_DIR}"
     47     git remote add www "${WWW_DIR}"/"${REPO_NAME}"
     48     ln -s "${SCRIPTS_DIR}"/post-receive hooks/
     49 
     50     ./hooks/post-receive
     51 )