aboutsummaryrefslogtreecommitdiffstats
path: root/terminaldweller.com/cgit/bootstrap
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2022-09-13 17:32:12 +0000
committerterminaldweller <thabogre@gmail.com>2022-09-13 17:32:12 +0000
commit68e3be1f591e40925b4c5c3f57aee8d4e260ebbf (patch)
treef07a55bbb82c23c688d104ff24d61084f5f5b72b /terminaldweller.com/cgit/bootstrap
parentupdates (diff)
downloadscripts-68e3be1f591e40925b4c5c3f57aee8d4e260ebbf.tar.gz
scripts-68e3be1f591e40925b4c5c3f57aee8d4e260ebbf.zip
update
Diffstat (limited to 'terminaldweller.com/cgit/bootstrap')
-rw-r--r--terminaldweller.com/cgit/bootstrap/Dockerfile7
-rwxr-xr-xterminaldweller.com/cgit/bootstrap/bootstrap.sh64
-rw-r--r--terminaldweller.com/cgit/bootstrap/crontab1
-rwxr-xr-xterminaldweller.com/cgit/bootstrap/docker-entrypoint.sh6
4 files changed, 78 insertions, 0 deletions
diff --git a/terminaldweller.com/cgit/bootstrap/Dockerfile b/terminaldweller.com/cgit/bootstrap/Dockerfile
new file mode 100644
index 0000000..73e757a
--- /dev/null
+++ b/terminaldweller.com/cgit/bootstrap/Dockerfile
@@ -0,0 +1,7 @@
+FROM alpine:3.16
+RUN apk update && apk add --no-cache git cronie busybox-initscripts
+RUN rc-service crond start && rc-update add crond
+COPY ./bootstrap.sh /bootstrap.sh
+COPY ./docker-entrypoint.sh /docker-entrypoint.sh
+COPY ./crontab /etc/crontabs/root
+ENTRYPOINT ["/bootstrap.sh"]
diff --git a/terminaldweller.com/cgit/bootstrap/bootstrap.sh b/terminaldweller.com/cgit/bootstrap/bootstrap.sh
new file mode 100755
index 0000000..a943ffb
--- /dev/null
+++ b/terminaldweller.com/cgit/bootstrap/bootstrap.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+set -e
+
+GIT_REPO_DIR=/etc/gitrepos
+ORIGIN_HTTPS=https://github.com/terminaldweller
+ORIGIN_SSH=git@github.com:terminaldweller
+REPOS="cgrep \
+ mutator \
+ delf \
+ dwasm \
+ colo \
+ blog \
+ devourer \
+ hived \
+ mdrtl \
+ simplex \
+ scripts \
+ vagrantboxes \
+ dockerimages \
+ st \
+ dmenu \
+ tabbed \
+ dwm \
+ w3m \
+ leetcode \
+ irssi-scripts \
+ jupyter-notebook-docker-compose \
+ seer \
+ devi-githooks \
+ kaminokumo \
+ wikis \
+ grpc \
+ faultreiber \
+ luatablegen \
+ cfe-extra"
+
+bootstrap() {
+ for REPO in ${REPOS}; do
+ (cd "${GIT_REPO_DIR}" && git clone --bare "${ORIGIN_HTTPS}/${REPO}")
+ done
+}
+
+update_repos() {
+ for REPO in ${REPOS}; do
+ (cd "${GIT_REPO_DIR}/${REPO}" && git fetch)
+ done
+}
+
+on_startup() {
+ dir_list=$(ls -A == "$1")
+ if [ -z "$dir_list" ]; then
+ bootstrap
+ else
+ update_repos
+ fi
+}
+
+if [ "$1" = "--startup" ]; then
+ on_startup "$@"
+elif [ "$1" = "--update" ]; then
+ update_repos
+elif [ "$1" = "--bootstrap" ]; then
+ bootstrap
+fi
diff --git a/terminaldweller.com/cgit/bootstrap/crontab b/terminaldweller.com/cgit/bootstrap/crontab
new file mode 100644
index 0000000..2346740
--- /dev/null
+++ b/terminaldweller.com/cgit/bootstrap/crontab
@@ -0,0 +1 @@
+0 */6 * * * /bootstrap.sh --update
diff --git a/terminaldweller.com/cgit/bootstrap/docker-entrypoint.sh b/terminaldweller.com/cgit/bootstrap/docker-entrypoint.sh
new file mode 100755
index 0000000..a6ea4d5
--- /dev/null
+++ b/terminaldweller.com/cgit/bootstrap/docker-entrypoint.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+
+. /bootstrap.sh
+on_startup
+crond -s -P -f