dot

packages and services management
Log | Files | Refs | README

commit 80f4cd4b15d9d8fca2aca1d62d24f7c6f5faf645
parent ffe2a63516d3857f825a16cd1af3d57a28855fa8
Author: Josuah Demangeon <mail@josuah.net>
Date:   Fri, 10 Nov 2017 11:19:47 +0100

simplified daemon and updated git-index and git-repo

Diffstat:
Mbin/daemon | 11++++++-----
Mbin/git-index | 26++++++++------------------
Mbin/git-repos | 1+
3 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/bin/daemon b/bin/daemon @@ -1,15 +1,12 @@ #!/bin/sh -: ${1:?usage: ${0##*/} list | [start stop] daemon} - mkdir -p "$HOME/var/log" -[ $# = 0 ] && exec "$0" help cmd=$1 -shift +[ $# -gt 1 ] && shift case $cmd in -(list) +('') ls -1 "$HOME/etc/daemon" | while IFS='' read -r svc do printf '%-14s: %s\n' "$svc" "$(pgrep "$svc" | tr '\n' ' ')" done @@ -17,6 +14,7 @@ case $cmd in (start) s=$1 shift + [ -f "$HOME/etc/daemon/$s" ] || exec printf '%s: no script found\n' "$s" sh "$HOME/etc/daemon/$s" "$@" >> "$HOME/var/log/$s" 2>&1 printf '%-14s: %s\n' "$s" "$(pgrep -x "$s" | tr '\n' ' ')" ;; @@ -24,4 +22,7 @@ case $cmd in pkill -x "$1" printf '%-14s: %s\n' "$1" "$(pgrep -x "$1" | tr '\n' ' ')" ;; +(*) + printf 'usage: %s [start|stop service]\n' "${0##*/}" + ;; esac diff --git a/bin/git-index b/bin/git-index @@ -1,43 +1,34 @@ #!/bin/sh # add index.html and commit/%H.html inside of a git bare repository + #git #pree -type pree > /dev/null && PREE=pree || PREE=tee - -PATH=$(cd "$1/.." && pwd) -NAME=${PATH##*/} - +NAME=$(cd "$1" && pwd | sed 's|.*/||') HEADER='<!doctype html> <title>'$NAME'</title> <meta charset="utf-8"/> <style> pre { float: left; margin: 4em 0 4em 4em; } </style> <pre> <h1><a href="..">&lt;</a> '$NAME'</h1>' - export LC_COLLATE=C { printf '%s\n' "$HEADER" - - git -C "$1" ls-tree -r --name-only master | sort | $PREE + git -C "$1" ls-tree -r --name-only master | sort | pree printf '</pre><pre>\n' - git -C "$1" log --graph --format='%H %cd %cn <%ce>%n%s%n' | - sed -r -e 's|&|\&amp;|g' \ - -e 's|<|\&lt;|g' \ + sed -r -e 's|&|\&amp;|g' \ + -e 's|<|\&lt;|g' \ -e 's|([0-9a-f]{8})[0-9a-f]{32}|<a href="commit/&.html">\1</a>|' printf '</pre>\n' - } > "$1/index.html" mkdir -p "$1/commit" - for commit in $(git -C "$1" log --format='%H') do [ -f "$1/commit/$commit.html" ] && continue - printf '%s\n' "$1/commit $commit" + printf '%s\n' "$commit" printf '%s\n' "$HEADER" > "$1/commit/$commit.html" - git -C "$1" show -U3 "$commit" | - sed >> "$1/commit/$commit.html" \ + git -C "$1" show -U3 "$commit" | sed >> "$1/commit/$commit.html" \ -e 's|&|\&amp;|g' \ -e 's|<|\&lt;|g' \ -e 's|^[A-Z][a-z]*:|<b>&</b>|' \ @@ -45,7 +36,6 @@ do -e '/^diff/ s|.*|<b>&</b>|' \ -e '/^+/ s|.*|<span style="color: green;">&</span>|' \ -e '/^-/ s|.*|<span style="color: red ;">&</span>|' \ - -e '/^@/ s|.*|<span style="color: blue ;">&</span>|' \ - + -e '/^@/ s|.*|<span style="color: blue ;">&</span>|' printf '</pre>\n' >> "$1/commit/$commit.html" done diff --git a/bin/git-repos b/bin/git-repos @@ -10,6 +10,7 @@ git update-server-info git-index $path EOF chmod +x "$path/hooks/post-receive" + git-index "$path" done << EOF http://github.com/josuah/alphabet.git EOF