aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2020-09-13 16:40:54 -0400
committerMitch Riedstra <mitch@riedstra.us>2020-09-13 16:40:54 -0400
commit5debb8c4b7afeb531b1584595343390e4f07b113 (patch)
tree962a4046ad9436c0c5aa838ba075ea472fb1090e
parent578b04e3f380cfd674cd545f6a4d673b4e046bf5 (diff)
downloadalpine-cgit-5debb8c4b7afeb531b1584595343390e4f07b113.tar.gz
alpine-cgit-5debb8c4b7afeb531b1584595343390e4f07b113.tar.xz
Do not run setup multiple times in a container's life. Also update scripts
-rw-r--r--docker-compose.yml3
-rwxr-xr-xentrypoint.sh7
-rwxr-xr-xhome/list.sh9
-rwxr-xr-xhome/repack.sh15
-rwxr-xr-xhome/update.sh16
-rw-r--r--readme.md2
6 files changed, 30 insertions, 22 deletions
diff --git a/docker-compose.yml b/docker-compose.yml
index 3a26619..5ea6959 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -7,6 +7,9 @@ services:
volumes:
- ./homedir:/var/git
- ./hostkeys:/var/hostkeys
+ environment:
+ - CGIT_UID=1000
+ - CGIT_GID=1000
ports:
- '127.0.0.1:8080:8080'
- '0.0.0.0:8022:8022'
diff --git a/entrypoint.sh b/entrypoint.sh
index 11c2a7e..1072ba6 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -23,12 +23,14 @@ NGINX_WORKER_CONNECTIONS="${NGINX_WORKER_CONNECTIONS:-1024}"
printf "\033[0m"
setup() {
+if [ -e /setup ] ; then return ; fi
if [ "$(find /var/git -type f | wc -l)" -eq 0 ] ; then
cp -r /var/default/git/* /var/git/
fi
-addgroup -g "${CGIT_GID}" git
+addgroup -g "${CGIT_GID}" git
adduser -h /var/git --gecos "$FULL_NAME" -D -s "${CGIT_SHELL}" -u "${CGIT_UID}" -G git git
+
chown -R git:git /var/git
passwd -u git
@@ -38,6 +40,8 @@ if [ -n "$AUTHORIZED_KEYS" ] ; then
mkdir -p /etc/ssh/keys
echo "$AUTHORIZED_KEYS" | tee /etc/ssh/keys/git
fi
+
+touch /setup
}
# exec runsvdir /var/service
@@ -165,7 +169,6 @@ run_nginx
run_cgit
run_sshd
-
set +x
# Bail out if a service stops, poll it every 30 seconds
watchServices 30
diff --git a/home/list.sh b/home/list.sh
new file mode 100755
index 0000000..c1cba62
--- /dev/null
+++ b/home/list.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+#shellcheck disable=SC2038
+find . -type d -name branches \
+ | xargs -n1 dirname \
+ | while read -r repo ; do
+ if ! [ "$(basename "$repo")" = ".git" ] ; then
+ echo "$repo";
+ fi
+ done
diff --git a/home/repack.sh b/home/repack.sh
index 25419ea..e494390 100755
--- a/home/repack.sh
+++ b/home/repack.sh
@@ -2,12 +2,9 @@
set -e
set -x
-repos="$(find "$HOME" -type d -iname '*.git')"
-
-IFS="
-"
-
-for repo in $repos ; do
- cd "$repo"
- git repack
-done
+#shellcheck disable=SC2086
+$HOME/list.sh \
+ | while read -r repo ; do
+ cd "$repo"
+ git repack
+ done
diff --git a/home/update.sh b/home/update.sh
index b6a0412..e494390 100755
--- a/home/update.sh
+++ b/home/update.sh
@@ -2,13 +2,9 @@
set -e
set -x
-repos="$(find $HOME -type d -iname '*.git')"
-
-IFS="
-"
-
-for repo in $repos ; do
- cd $repo
- git update-server-info
-done
-
+#shellcheck disable=SC2086
+$HOME/list.sh \
+ | while read -r repo ; do
+ cd "$repo"
+ git repack
+ done
diff --git a/readme.md b/readme.md
index 172112e..063f15f 100644
--- a/readme.md
+++ b/readme.md
@@ -3,7 +3,7 @@
Docker image for running a cgit instance.
Primarily designed for a single user though it wouldn't be too hard to alter
-the [`entrypoint.sh`](entrypoint.sh) to add and support multiple users with
+the [`entrypoint.sh`](../tree/entrypoint.sh) to add and support multiple users with
separate keys, permissions and such.
This runs fastcgiwrap, nginx and a SSH server for a self hosted private