dot

packages and services management
Log | Files | Refs | README

commit a3a392f1321164389e90fc92b6f72e6d3b937037
parent fe82e417ae559f9a02798111ca5d542d9c7d7550
Author: Josuah Demangeon <mail@josuah.net>
Date:   Tue, 11 Dec 2018 20:43:02 +0100

ltree to convert existing directory listing as a tree

Diffstat:
Mbin/ltree | 79++++++++++++++++++++++++++++++++++---------------------------------------------
Mconf/s6 | 12+++---------
Aetc | 2++
Ainit/openbsd | 8++++++++
As6/tinydns/h-o.st/zone/alias/h-o.st/@ | 2++
As6/tinydns/h-o.st/zone/alias/h-o.st/g | 2++
As6/tinydns/h-o.st/zone/alias/h-o.st/git | 2++
As6/tinydns/h-o.st/zone/alias/h-o.st/mac/54e1ad43a3a4 | 2++
As6/tinydns/h-o.st/zone/alias/himalaya-solaire.org/@ | 2++
As6/tinydns/h-o.st/zone/alias/josuah.net/@ | 2++
As6/tinydns/h-o.st/zone/alias/josuah.net/git | 2++
As6/tinydns/h-o.st/zone/alias/josuah.net/irc | 2++
As6/tinydns/h-o.st/zone/host/h-o.st/glaphyrae | 2++
As6/tinydns/h-o.st/zone/ns/h-o.st | 2++
As6/tinydns/h-o.st/zone/ns/himalaya-solaire.org | 2++
As6/tinydns/h-o.st/zone/ns/josuah.net | 2++
As6/tinydns/h-o.st/zone/txt/h-o.st | 1+
As6/tinydns/h-o.st/zone/txt/himalaya-solaire.org | 1+
As6/tinydns/h-o.st/zone/txt/josuah.net | 1+
19 files changed, 74 insertions(+), 54 deletions(-)

diff --git a/bin/ltree b/bin/ltree @@ -1,6 +1,6 @@ #!/usr/bin/awk -f -# list paths in a tree with some stat infos +# Usage: ltree [-h html-prefix] path... # Use find(1) walk the entire tree and then call ls -ld with all the # result (ls sort the list itself) with the paths displayed as a tree: @@ -19,19 +19,16 @@ BEGIN { TAIL = "└─ "; VOID = " "; - num = list(entries, ARGC == 1 ? "." : ARGV[1]); - tree(entries, num); - - for (l = 1; l <= num; l++) { - for (i = 1; entries[l":"i] != ""; i++) - printf("%s", entries[l":"i]); - printf("%s\n", entries[l"name"]); + if (ARGV[1] == "-h") { + HTML = ARGV[2]; + for (i = 1; i < ARGC - 2; ++i) ARGV[i] = ARGV[i + 2]; + ARGC -= 2; } } -# Get a recursive list of all entries into entries[] with entries[i:j] +# Get a recursive list of all list into list[] with list[i:j] # holding the component j of the path i, and 0 has all the -l details, -# then return the number of entries in entries[]. +# then return the number of list in list[]. # # [ 1:[ 0:"-rw-r--r-- 1 root root 341 Mar 13 10:50", # 1:"etc" ], @@ -47,52 +44,44 @@ BEGIN { # # [ 1:[ 1:LINE, 2:LINE, 3:LINE, 4:LINE, 5:NODE, 6:"filename" ] ] -function list(entries, path) { - cmd = "cd '" path "' && exec find ." \ - " -name '*.git' -prune -o" \ - " -name 'CVS' -prune -o" \ - " -exec ls -ld {} +"; - - for (num = 0; cmd | getline; num++) { - sub(" \\.$", "", $0); - sub(" -> .*", "", $0); - infos = $0; - sub(" \\./.*", "", infos); - sub(".* \\./", "./", $0); - - entries[num"path"] = $0; - count = split($0, path_v, "/"); - for (i = 2; i < count; i++) - entries[num":"i] = LINE; - - entries[num":"count] = NODE; - entries[num":"1] = infos " "; - entries[num"name"] = path_v[count]; - } - close(cmd); + sub(" \\.$", "", $0); + sub(" -> .*", "", $0); + infos = $0; + sub(" \\./.*", "", infos); + sub(".* \\./", "", $0); + LIST[NR"path"] = $0; + count = split($0, paths, "/"); + for (i = 2; i < count; i++) LIST[NR":"i] = LINE; - return num - 1; + LIST[NR":"count] = NODE; + LIST[NR":"1] = infos " "; + LIST[NR"name"] = paths[count]; } -# Transform entries into a tree by replacing some LINE by VOID when needed. -# The tree is walked from the bottom to the top, and column by column -# toward the right until an empty column is met. +END { + # Transform list into a tree by replacing some LINE by VOID when needed. + # The tree is walked from the bottom to the top, and column by column + # toward the right until an empty column is met. -function tree(entries, num) -{ for (i = 2; !stop; i++) { stop = tail = 1; - for (l = num; l > 0; l--) { - if (entries[l":"i] == LINE && tail) { - entries[l":"i] = VOID; + for (l = NR; l > 0; l--) { + if (LIST[l":"i] == LINE && tail) { + LIST[l":"i] = VOID; stop = 0; - } else if (entries[l":"i] == NODE && tail) { - entries[l":"i] = TAIL; + } else if (LIST[l":"i] == NODE && tail) { + LIST[l":"i] = TAIL; tail = stop = 0; - } else if (!entries[l":"i]) { + } else if (!LIST[l":"i]) { tail = 1; } } } + + for (nr = 1; nr <= NR; nr++) { + for (nf = 1; LIST[nr":"nf] != ""; nf++) printf("%s", LIST[nr":"nf]); + if (!HTML) print(LIST[nr"name"]); + else print("<a href=\"" HTML "/" LIST[nr"path"] "\">" LIST[nr"name"] "</a>"); + } } diff --git a/conf/s6 b/conf/s6 @@ -1,18 +1,12 @@ #!/usr/bin/env execlineb elgetpositionals -backtick -n x { dirname ${0}/.. } importas rootdir x +backtick -n x { dirname ${0} } importas confdir x +backtick -n x { cd ${confdir}/.. pwd } importas rootdir cd ${rootdir} -backtick -n x { pwd } importas pwd x backtick -n x { uname } importas uname x if { cp dot/profile /etc } if { cp -r profile.d /etc } -if { ln -sf ${pwd}/s6 /etc } - -ifelse { ${uname} = OpenBSD } { - cp ../init/openbsd /etc/rc.d/service -} - -echo OS not supported +if { ln -sf ${rootdir}/s6 /etc } diff --git a/etc b/etc @@ -0,0 +1 @@ +/etc+ \ No newline at end of file diff --git a/init/openbsd b/init/openbsd @@ -0,0 +1,8 @@ +#!/usr/bin/env execlineb +elgetpositionals + +ifelse { test $1 = start } { background { service-init } } +ifelse { test $1 = stop } { service-halt } +ifelse { test $1 = restart } { if { $0 stop } $0 start } +ifelse { test $1 = reload } { pkill -HUP service-init } +echo "usage: service {start,stop,restart,reload,check}" diff --git a/s6/tinydns/h-o.st/zone/alias/h-o.st/@ b/s6/tinydns/h-o.st/zone/alias/h-o.st/@ @@ -0,0 +1 @@ +../../host/h-o.st/glaphyrae+ \ No newline at end of file diff --git a/s6/tinydns/h-o.st/zone/alias/h-o.st/g b/s6/tinydns/h-o.st/zone/alias/h-o.st/g @@ -0,0 +1 @@ +../../host/h-o.st/glaphyrae+ \ No newline at end of file diff --git a/s6/tinydns/h-o.st/zone/alias/h-o.st/git b/s6/tinydns/h-o.st/zone/alias/h-o.st/git @@ -0,0 +1 @@ +../../host/h-o.st/glaphyrae+ \ No newline at end of file diff --git a/s6/tinydns/h-o.st/zone/alias/h-o.st/mac/54e1ad43a3a4 b/s6/tinydns/h-o.st/zone/alias/h-o.st/mac/54e1ad43a3a4 @@ -0,0 +1 @@ +../../../host/h-o.st/glaphyrae+ \ No newline at end of file diff --git a/s6/tinydns/h-o.st/zone/alias/himalaya-solaire.org/@ b/s6/tinydns/h-o.st/zone/alias/himalaya-solaire.org/@ @@ -0,0 +1 @@ +../../host/h-o.st/glaphyrae+ \ No newline at end of file diff --git a/s6/tinydns/h-o.st/zone/alias/josuah.net/@ b/s6/tinydns/h-o.st/zone/alias/josuah.net/@ @@ -0,0 +1 @@ +../../host/h-o.st/glaphyrae+ \ No newline at end of file diff --git a/s6/tinydns/h-o.st/zone/alias/josuah.net/git b/s6/tinydns/h-o.st/zone/alias/josuah.net/git @@ -0,0 +1 @@ +../../host/h-o.st/glaphyrae+ \ No newline at end of file diff --git a/s6/tinydns/h-o.st/zone/alias/josuah.net/irc b/s6/tinydns/h-o.st/zone/alias/josuah.net/irc @@ -0,0 +1 @@ +../../host/h-o.st/glaphyrae+ \ No newline at end of file diff --git a/s6/tinydns/h-o.st/zone/host/h-o.st/glaphyrae b/s6/tinydns/h-o.st/zone/host/h-o.st/glaphyrae @@ -0,0 +1,2 @@ +199.247.28.162 +2001:19f0:5001:7ac:5400:01ff:fe90:7c33 diff --git a/s6/tinydns/h-o.st/zone/ns/h-o.st b/s6/tinydns/h-o.st/zone/ns/h-o.st @@ -0,0 +1 @@ +../host/h-o.st/glaphyrae+ \ No newline at end of file diff --git a/s6/tinydns/h-o.st/zone/ns/himalaya-solaire.org b/s6/tinydns/h-o.st/zone/ns/himalaya-solaire.org @@ -0,0 +1 @@ +../host/h-o.st/glaphyrae+ \ No newline at end of file diff --git a/s6/tinydns/h-o.st/zone/ns/josuah.net b/s6/tinydns/h-o.st/zone/ns/josuah.net @@ -0,0 +1 @@ +../host/h-o.st/glaphyrae+ \ No newline at end of file diff --git a/s6/tinydns/h-o.st/zone/txt/h-o.st b/s6/tinydns/h-o.st/zone/txt/h-o.st @@ -0,0 +1 @@ +v=spf1 mx -all diff --git a/s6/tinydns/h-o.st/zone/txt/himalaya-solaire.org b/s6/tinydns/h-o.st/zone/txt/himalaya-solaire.org @@ -0,0 +1 @@ +v=spf1 include:_mailcust.gandi.net ?all diff --git a/s6/tinydns/h-o.st/zone/txt/josuah.net b/s6/tinydns/h-o.st/zone/txt/josuah.net @@ -0,0 +1 @@ +v=spf1 mx -all