dot

packages and services management
Log | Files | Refs | README

commit ac3117f4f15cd314135848afb4c14afef216371f
parent 760ea0d0f5d18fa15662105adb6f4f485275df80
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Sat, 19 Aug 2017 19:48:00 +0200

git: sync with remote

Diffstat:
Mgit/bin/git-index | 11++++-------
Agit/bin/git-sync | 6++++++
Dgit/configure | 18------------------
Agit/cron | 1+
Mpkg/bin/pkg-configure | 1+
Mpkg/bin/pkg-service | 3++-
Aquark/config.h | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mquark/configure | 2+-
Mquark/run | 2+-
9 files changed, 74 insertions(+), 28 deletions(-)

diff --git a/git/bin/git-index b/git/bin/git-index @@ -17,16 +17,15 @@ FOOTER=' export LC_COLLATE=C -mkdir -p "git/$NAME/commit" "git/$NAME/file" -cd "git/$NAME" || exit 1 - +mkdir -p "$NAME/commit" "$NAME/file" +cd "$NAME" || exit 1 # --- ./index.html --------------------------------------------------------------- { printf '%s\n' "$HEADER" - git -C "$1" ls-files | sort | awk '{ + git -C "$1" ls-tree -r --name-only master | sort | awk '{ gsub("&", "\&amp;"); gsub("<", "\&lt;") do { print } while (sub("/[^/]*$", "")) }' | sort -u | awk '{ @@ -78,10 +77,9 @@ cd "git/$NAME" || exit 1 } > index.html - # --- ./file/ ------------------------------------------------------------------ -git -C "$1" ls-files | while IFS='' read -r file +git -C "$1" ls-tree -r --name-only master | while IFS='' read -r file do [ "$1/$file" -ot "file/$file" ] && continue echo "file $file" @@ -89,7 +87,6 @@ do git -C "$1" show master:"$file" > "file/$file" done - # --- ./commit/ ------------------------------------------------------------------- for commit in $(git -C "$1" log --format='%H') diff --git a/git/bin/git-sync b/git/bin/git-sync @@ -0,0 +1,6 @@ +find "$HOME/srv/git" -mindepth 1 -maxdepth 1 -type d | +while IFS='' read -r repo +do + git -C "$repo" fetch --all + git -C "$repo" push --all +done diff --git a/git/configure b/git/configure @@ -1,18 +0,0 @@ -cd /home/git || exit - -mkdir -p .ssh && chmod 700 .ssh -touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys -touch git-shell-commands && chmod 500 git-shell-commands - -git clone --bare http://github.com/josuah/pkg -git clone --bare http://github.com/josuah/www -git clone --bare http://github.com/josuah/cgr -git clone --bare http://github.com/josuah/notes -git clone --bare http://github.com/josuah/iode -git clone --bare http://github.com/josuah/iomenu -git clone --bare http://github.com/josuah/drawille -git clone --bare http://github.com/josuah/miniwi -git clone --bare http://github.com/josuah/alphabet - -chown -R git . -chgrp -R git . diff --git a/git/cron b/git/cron @@ -0,0 +1 @@ +* * * * * git-sync diff --git a/pkg/bin/pkg-configure b/pkg/bin/pkg-configure @@ -14,6 +14,7 @@ find -L "$ROOT" -type l -exec rm {} + 2> /dev/null # --- crontab ------------------------------------------------------------------ +mkdir -p "$ROOT/etc" [ -f "$ROOT/pkg/$1/cron" ] && tee -a "$ROOT/etc/crontab" < "$ROOT/pkg/$1/cron" sort -u "$ROOT/etc/crontab" -o "$ROOT/etc/crontab" diff --git a/pkg/bin/pkg-service b/pkg/bin/pkg-service @@ -39,7 +39,7 @@ case "$1" in if ! "$0" status "$srv" "$@" then mkdir -p "$ROOT/run/pid/$srv" - . "$ROOT/pkg/$srv/run" "$@" >> "$ROOT/var/log/$srv" 2>&1 <&- + . "$ROOT/pkg/$srv/run" "$@" >> "$ROOT/var/log/$srv" 2>&1 if cp "/proc/$PID/cmdline" "$ROOT/run/pid/$srv/$PID" 2> /dev/null then @@ -49,6 +49,7 @@ case "$1" in touch "$ROOT/run/pid/$srv/$PID" fi fi + "$0" status "$srv" ;; (update) find "$ROOT/run/pid" -type f | while IFS='' read path diff --git a/quark/config.h b/quark/config.h @@ -0,0 +1,58 @@ +static const char *host = "localhost"; +static const char *port = "80"; +static const char *servedir = "."; +static const char *docindex = "index.html"; +static const char *user = "nobody"; +static const char *group = "nogroup"; + +static int listdirs = 1; +static int vhosts = 0; + +static const int maxnprocs = 512; +#define HEADER_MAX 4096 +#define FIELD_MAX 200 + +/* virtual hosts */ +static struct { + const char *name; + const char *regex; + const char *dir; + regex_t re; +} vhost[] = { + /* canonical host host regex directory */ + { "josuah.net", "^josuah\\.net$", "josuah.net" }, + { "git.josuah.net", "^git\\.josuah\\.net$", "git.josuah.net" }, + { "cyberia.systems", "^cyberia\\.systems", "cyberia.systems" }, +}; + +/* mime-types */ +static const struct { + char *ext; + char *type; +} mimes[] = { + { "xml", "application/xml" }, + { "xhtml", "application/xhtml+xml" }, + { "html", "text/html; charset=UTF-8" }, + { "htm", "text/html; charset=UTF-8" }, + { "css", "text/css" }, + { "txt", "text/plain" }, + { "md", "text/plain" }, + { "c", "text/plain" }, + { "h", "text/plain" }, + { "gz", "application/x-gtar" }, + { "tar", "application/tar" }, + { "pdf", "application/x-pdf" }, + { "png", "image/png" }, + { "gif", "image/gif" }, + { "jpeg", "image/jpg" }, + { "jpg", "image/jpg" }, + { "iso", "application/x-iso9660-image" }, + { "webp", "image/webp" }, + { "svg", "image/svg+xml" }, + { "flac", "audio/flac" }, + { "mp3", "audio/mpeg" }, + { "ogg", "audio/ogg" }, + { "mp4", "video/mp4" }, + { "ogv", "video/ogg" }, + { "webm", "video/webm" }, +}; diff --git a/quark/configure b/quark/configure @@ -1 +1 @@ -setcap 'CAP_NET_BIND_SERVICE+ep' "$ROOT/opt/bin/quark" +setcap 'CAP_NET_BIND_SERVICE+ep' "$ROOT/opt/quark/bin/quark" diff --git a/quark/run b/quark/run @@ -1 +1 @@ -quark -L -Vd "$ROOT/srv/http" -p 80 -h 0.0.0.0 & PID=$! +quark -h 0.0.0.0 -d "$HOME/srv/http" -V & PID=$!