diff options
| author | Akshay Nair <phenax5@gmail.com> | 2026-07-04 18:12:10 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2026-07-04 18:46:35 +0530 |
| commit | 2cd9a4039c0c5f524df0a33605c9baef1f57917e (patch) | |
| tree | 5e17ce2f0c78d663cf6f2f7be5abe769dc7a3f71 | |
| parent | ef34b26068c4e25f929a584edda63b8878c063b3 (diff) | |
| download | bacchus-remote-2cd9a4039c0c5f524df0a33605c9baef1f57917e.tar.gz bacchus-remote-2cd9a4039c0c5f524df0a33605c9baef1f57917e.zip | |
Add git shell commands
Diffstat (limited to '')
| -rwxr-xr-x | cgit/ssh/git-shell-commands/list | 13 | ||||
| -rwxr-xr-x | cgit/ssh/git-shell-commands/new | 33 | ||||
| -rw-r--r-- | docker-compose.yml | 2 | ||||
| -rwxr-xr-x | setup.sh | 15 |
4 files changed, 58 insertions, 5 deletions
diff --git a/cgit/ssh/git-shell-commands/list b/cgit/ssh/git-shell-commands/list new file mode 100755 index 0000000..804a488 --- /dev/null +++ b/cgit/ssh/git-shell-commands/list @@ -0,0 +1,13 @@ +#!/usr/bin/env sh + +ls -1 /git | while IPS="" read name; do + echo "$name" + printf " description: " + if [ -f "/git/${name}/description" ]; then + cat "/git/${name}/description" + else + echo "<no description>" + fi + echo "" +done + diff --git a/cgit/ssh/git-shell-commands/new b/cgit/ssh/git-shell-commands/new new file mode 100755 index 0000000..ec2d8ca --- /dev/null +++ b/cgit/ssh/git-shell-commands/new @@ -0,0 +1,33 @@ +#!/usr/bin/env sh + +set -eu + +remote_host="git.ediblemonad.dev" +owner_info="Akshay Nair <phenax5@gmail.com>" + +if [ $# -lt 2 ]; then + echo "Usage: new <name> <...description>" 1>&2 + exit 1 +fi + +repo_name="$1"; shift 1; +[ -z "$repo_name" ] && echo "Error: empty repo name" 1>&2 && exit 1 + +# Stupid cmdline parsing means I can't do $1 here for space separated stuff +description="$*" +[ -z "$description" ] && echo "Error: empty description" 1>&2 && exit 1 + +repo_dir="/git/${repo_name}.git" + +if [ -d "$repo_dir" ]; then + echo "Error: $repo_name already exists" 1>&2 + exit 1; +fi + +git --bare init "$repo_dir" + +cd "$repo_dir" +echo "$description" > description +echo "$owner_info" > owner_info + +echo "git@${remote_host}:${repo_dir}" diff --git a/docker-compose.yml b/docker-compose.yml index 646cb11..33051ad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -74,7 +74,7 @@ services: - DEFAULT_EMAIL=ediblemonad@gmail.com - NGINX_PROXY_CONTAINER=nginx-proxy - NGINX_DOCKER_GEN_CONTAINER=nginx-proxy - # - ACME_CA_URI=https://acme-staging-v02.api.letsencrypt.org/directory + - ACME_CA_URI=https://acme-staging-v02.api.letsencrypt.org/directory volumes: - /var/run/docker.sock:/var/run/docker.sock:ro - proxy-certs:/etc/nginx/certs @@ -5,7 +5,7 @@ set -eu ROOT_DIR=${ROOT_DIR:-"/opt/project"} configure() { - configure_user && configure_fs && configure_packages && configure_firewall + configure_user && configure_fs && configure_packages && configure_git && configure_firewall } services() { cd "$ROOT_DIR"; docker compose --profile services "$@"; } @@ -22,7 +22,14 @@ stop() { services down; } configure_packages() { apt install \ docker.io docker-buildx docker-compose-v2 \ - ufw + git ufw +} + +configure_git() { + sudo -u git git config --global init.defaultBranch main + # kept explicit shell setup + chsh -s "$(which git-shell)" git + cp -rf "$ROOT_DIR/cgit/ssh/git-shell-commands" /home/git/ } configure_firewall() { @@ -34,7 +41,7 @@ configure_firewall() { configure_user() { groupadd -f -g 1001 git - useradd --shell /usr/sbin/nologin --no-create-home git --uid 1001 --gid 1001 || true + useradd --shell /usr/sbin/nologin git --uid 1001 --gid 1001 || true groupadd -f -g 1002 send useradd --shell /usr/sbin/nologin --no-create-home send --uid 1002 --gid 1002 || true } @@ -54,6 +61,6 @@ update() { cmd="$1"; shift; case "$cmd" in update|start|startfg|stop|services|core) "$cmd" "$@" ;; - configure|configure_firewall|configure_user|configure_fs|configure_packages) "$cmd" "$@" ;; + configure|configure_firewall|configure_user|configure_fs|configure_packages|configure_git) "$cmd" "$@" ;; *) echo "Invalid command: $cmd"; exit 1 ;; esac |
