dot

packages and services management
Log | Files | Refs | README

commit ffe2a63516d3857f825a16cd1af3d57a28855fa8
parent 10df53fd0b6c9bd7335bbf134a643ad1c65f81e9
Author: Josuah Demangeon <mail@josuah.net>
Date:   Fri, 10 Nov 2017 10:43:46 +0100

service -> daemon

Diffstat:
Abin/daemon | 27+++++++++++++++++++++++++++
Mbin/git-index | 15++++++++-------
Mbin/git-repos | 27+++++++++++++++++----------
Mbin/pree | 4++--
Dbin/service | 33---------------------------------
Rservice/.gitignore -> daemon/.gitignore | 0
Rservice/crond -> daemon/crond | 0
Rservice/git -> daemon/git | 0
Rservice/ii -> daemon/ii | 0
Rservice/monitor -> daemon/monitor | 0
Rservice/ngircd -> daemon/ngircd | 0
Rservice/opentracker -> daemon/opentracker | 0
Rservice/quark -> daemon/quark | 0
Rservice/ratox -> daemon/ratox | 0
Ddot/gitignore | 1-
Mman/git-index.1 | 25-------------------------
Mman/www.1 | 23-----------------------
17 files changed, 54 insertions(+), 101 deletions(-)

diff --git a/bin/daemon b/bin/daemon @@ -0,0 +1,27 @@ +#!/bin/sh + +: ${1:?usage: ${0##*/} list | [start stop] daemon} + +mkdir -p "$HOME/var/log" + +[ $# = 0 ] && exec "$0" help +cmd=$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 + ;; +(start) + s=$1 + shift + sh "$HOME/etc/daemon/$s" "$@" >> "$HOME/var/log/$s" 2>&1 + printf '%-14s: %s\n' "$s" "$(pgrep -x "$s" | tr '\n' ' ')" + ;; +(stop) + pkill -x "$1" + printf '%-14s: %s\n' "$1" "$(pgrep -x "$1" | tr '\n' ' ')" + ;; +esac diff --git a/bin/git-index b/bin/git-index @@ -3,8 +3,8 @@ type pree > /dev/null && PREE=pree || PREE=tee -NAME=${1%/} -NAME=${NAME##*/} +PATH=$(cd "$1/.." && pwd) +NAME=${PATH##*/} HEADER='<!doctype html> <title>'$NAME'</title> @@ -21,7 +21,7 @@ export LC_COLLATE=C git -C "$1" ls-tree -r --name-only master | sort | $PREE printf '</pre><pre>\n' - git -C "$1" log --graph --date=short --format='%H %cd %cn <%ce>%n%s%n' | + git -C "$1" log --graph --format='%H %cd %cn <%ce>%n%s%n' | 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>|' @@ -37,14 +37,15 @@ do printf '%s\n' "$1/commit $commit" printf '%s\n' "$HEADER" > "$1/commit/$commit.html" git -C "$1" show -U3 "$commit" | - sed -e 's|&|\&amp;|g' \ + sed >> "$1/commit/$commit.html" \ + -e 's|&|\&amp;|g' \ -e 's|<|\&lt;|g' \ -e 's|^[A-Z][a-z]*:|<b>&</b>|' \ -e '/^commit/ s|.*|<b>&</b>|' \ -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>|' - >> "$1/commit/$commit.html" - printf '</pre>\n' >> "$1/commit/$commit.html" + -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 @@ -2,14 +2,21 @@ while read repo do - git clone --mirror "$repo" && - printf '\n' >> "${repo##*/}.git" -done << 'EOF' -http://github.com/josuah/alphabet -http://github.com/josuah/cgr -http://github.com/josuah/etc -http://github.com/josuah/fungus-pathogen -http://github.com/josuah/http -http://github.com/josuah/iomenu -http://github.com/josuah/notes + git clone --mirror "$repo" + path=$(cd "$PWD/${repo##*/}" && pwd) + cat > "$path/hooks/post-receive" << EOF +#!/bin/sh +git update-server-info +git-index $path +EOF + chmod +x "$path/hooks/post-receive" +done << EOF +http://github.com/josuah/alphabet.git EOF + +#http://github.com/josuah/cgr.git +#http://github.com/josuah/etc.git +#http://github.com/josuah/fungus-pathogen.git +#http://github.com/josuah/http.git +#http://github.com/josuah/iomenu.git +#http://github.com/josuah/notes.git diff --git a/bin/pree b/bin/pree @@ -1,5 +1,5 @@ #!/bin/sh -# convert find(1)-style input to a tree(1)-style +# convert find(1)-style input to a tree(1)-style output LC_COLLATE=C @@ -42,7 +42,7 @@ END { name = lines[l":"0]; sub(".*/", "", name); for (i = 1; lines[l":"i]; i++) - printf("%s", name); + printf("%s", lines[l":"i]); if (HTML) printf("<a href=\"%s\"></a>\n", lines[l":"0], name); else diff --git a/bin/service b/bin/service @@ -1,33 +0,0 @@ -#!/bin/sh - -: ${1:?usage: ${0##*/} list | [start stop] service} - -err() -{ - printf '%-14s: %s\n' "$1" "$2" - exit 1 -} - -mkdir -p "$HOME/var/log" - -[ $# = 0 ] && exec "$0" help -cmd=$1 -shift - -case $cmd in -(list) - ls -1 "$HOME/etc/service" | while IFS='' read -r svc - do printf '%-14s: %s\n' "$svc" "$(pgrep "$svc" | tr '\n' ' ')" - done - ;; -(start) - s=$1 - shift - sh "$HOME/etc/service/$s" "$@" >> "$HOME/var/log/$s" 2>&1 - printf '%-14s: %s\n' "$s" "$(pgrep -x "$s" | tr '\n' ' ')" - ;; -(stop) - pkill -x "$1" || err "$1" 'could not stop' - printf '%-14s: %s\n' "$1" "$(pgrep -x "$1" | tr '\n' ' ')" - ;; -esac diff --git a/service/.gitignore b/daemon/.gitignore diff --git a/service/crond b/daemon/crond diff --git a/service/git b/daemon/git diff --git a/service/ii b/daemon/ii diff --git a/service/monitor b/daemon/monitor diff --git a/service/ngircd b/daemon/ngircd diff --git a/service/opentracker b/daemon/opentracker diff --git a/service/quark b/daemon/quark diff --git a/service/ratox b/daemon/ratox diff --git a/dot/gitignore b/dot/gitignore @@ -1 +0,0 @@ -*/supervise diff --git a/man/git-index.1 b/man/git-index.1 @@ -1,67 +1,42 @@ .Dd mar 23, 2017 .Dt GIT-INDEX .Os -. -. .Sh NAME -. .Nm git-index .Nd generate static website with the git command -. -. .Sh SYNOPSIS -. .Nm .Ar repository .Op Ar description -. -. .Sh DESCRIPTION -. The .Nm script creates a static website presenting the files and commits of a git repository. The build is incremential so that it can be triggered at every commit without large overhead. -. .Pp -. It only requires .Xr 1 git command to produce the output, and the various. -. .Pp -. The first argument is treated as a path to a repository. -. -. .Sh FILES -. .Bl -tag -width indent -. .It Pa ./style.css Ns , Pa ./favicon.png These ressources will be used in the html .Li <head> element. -. -. .It Pa ./repository/index.html An .Pa index.html file will be created in the repository directory, containing a list of the files and the commits. -. .It Pa ./repository/commit/4279dbc3735e1e38bf33120c9234640d99fee650.html One html page per commit is created. -. .It Pa ./repository/file/path/to/the/file The file content of the -. .El -. -. .Sh EXAMPLES -. A script generating an index of multiple repositories might look like this: .Bd -literal -offset indent printf '<!doctype html>\\n<html>\\n<body>\\n<ul>\\n' > ./index.html diff --git a/man/www.1 b/man/www.1 @@ -2,18 +2,13 @@ .Dt WWW-TREE 1 .Os .Sh NAME -. .Nm www-tree .Nd simple, recursive static website generator -. .Sh SYNOPSIS -. .Li cd .Pa path .Li && www -. .Sh DESCRIPTION -. .Pp The only thing this script does is building one index.html for each directory, including @@ -25,21 +20,16 @@ Each index.html has the content of a file in the top .Pa path directory, after being parsed. -. .Sh FILES -. Some files are treated particularly. -. .Bl -tag .It dir/layout.html File containing the index.html pages layout. -. .It dir/*/README The "README" files content can be displayed on the pages if the layout contains a .Li {{ content }} keyword. -. .It dir/.* All .Sy directories @@ -49,47 +39,34 @@ will be ignored. .El .Pp All other directories are ignored and let unchanged. -. .Sh LAYOUT FORMAT -. Within a layout.html, some templating permit to insert dynamic content into the index files, by using the following keywords. -. .Bl -tag .It {{ content }} Content of the README file in the current directory, if any. -. .It {{ list }} List of links to subpages for the current directory (including dotfiles). -. .It {{ nav }} List of top level directories, for use as a <nav> element. -. .It {{ root }} Relative path to the root of the website, for relative links. -. .It {{ title }} Page title, given by the path, with "/" replaced by " > ". .El -. .Sh ENVIRONMENT -. .Bl -tag .It PWD Source directory from which generate the website. It is also where the website will be generated. .El -. .Sh SEE ALSO -. .Pa http://marmaro.de the website that gave me the idea. .Pp .Xr werc 1 .Xr swerc 1 -. .Sh AUTHORS -. .Nm www is made by .An Josuah Demangeon Aq mail@josuah.net