From 40b6bc968a5b6d1d12d2cddefeeb472fa8462f9a Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 15 Jul 2014 12:26:49 +0200 Subject: Reaktor nag: s/superfluous/obsolete/g --- Reaktor/commands/nag | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Reaktor/commands/nag') diff --git a/Reaktor/commands/nag b/Reaktor/commands/nag index 68035831..c07ed5b8 100755 --- a/Reaktor/commands/nag +++ b/Reaktor/commands/nag @@ -16,7 +16,8 @@ trap 'rm -f nag.hosts nag.services nag.patch' EXIT INT QUIT diff -u nag.hosts nag.services > nag.patch || : missing_services=$(sed -n '1d;2d;s/^-\(.*\)/\1/p' nag.patch | tr '\n' ' ') -superfluous_services=$(sed -n '1d;2d;s/^+\(.*\)/\1/p' nag.patch | tr '\n' ' ') +obsolete_services=$(sed -n '1d;2d;s/^+\(.*\)/\1/p' nag.patch | tr '\n' ' ') + # # output @@ -24,9 +25,9 @@ superfluous_services=$(sed -n '1d;2d;s/^+\(.*\)/\1/p' nag.patch | tr '\n' ' ') if test -n "$missing_services"; then echo missing services: $missing_services fi -if test -n "$superfluous_services"; then - echo superfluous services: $superfluous_services +if test -n "$obsolete_services"; then + echo obsolete services: $obsolete_services fi -if test -z "$missing_services$superfluous_services"; then +if test -z "$missing_services$obsolete_services"; then echo hosts and services are in sync fi -- cgit v1.2.3 From e5d8e8f1b13af2b61d61288a50dcc0cd56097735 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 15 Jul 2014 12:28:45 +0200 Subject: Reaktor nag: don't cd $workdir Because Reaktor already does it... --- Reaktor/commands/nag | 2 -- 1 file changed, 2 deletions(-) (limited to 'Reaktor/commands/nag') diff --git a/Reaktor/commands/nag b/Reaktor/commands/nag index c07ed5b8..8454d84b 100755 --- a/Reaktor/commands/nag +++ b/Reaktor/commands/nag @@ -1,8 +1,6 @@ #! /bin/sh set -euf -cd "$workdir" - if test -e nag.hosts; then echo "nag seems to run already... if not, then delete $workdir/nag.*, please" exit 23 -- cgit v1.2.3 From 38769e12bfbc963e1bfd3226bdc0c907209bdb09 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 15 Jul 2014 12:36:30 +0200 Subject: Reaktor nag: don't nag when in-sync --- Reaktor/commands/nag | 3 --- 1 file changed, 3 deletions(-) (limited to 'Reaktor/commands/nag') diff --git a/Reaktor/commands/nag b/Reaktor/commands/nag index 8454d84b..56c34c01 100755 --- a/Reaktor/commands/nag +++ b/Reaktor/commands/nag @@ -26,6 +26,3 @@ fi if test -n "$obsolete_services"; then echo obsolete services: $obsolete_services fi -if test -z "$missing_services$obsolete_services"; then - echo hosts and services are in sync -fi -- cgit v1.2.3 From 0a39b3ecd80965002044cf7ba9d0a99c94ad1261 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 15 Jul 2014 12:37:34 +0200 Subject: Reaktor nag: maintain own copies of git repos --- Reaktor/commands/nag | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'Reaktor/commands/nag') diff --git a/Reaktor/commands/nag b/Reaktor/commands/nag index 56c34c01..e5380fc3 100755 --- a/Reaktor/commands/nag +++ b/Reaktor/commands/nag @@ -1,17 +1,30 @@ #! /bin/sh set -euf -if test -e nag.hosts; then +if test -e nag.hosts.ls; then echo "nag seems to run already... if not, then delete $workdir/nag.*, please" exit 23 fi -trap 'rm -f nag.hosts nag.services nag.patch' EXIT INT QUIT +trap 'rm -f nag.hosts.ls nag.services.ls nag.patch' EXIT INT QUIT -(cd "$hostsdir" && ls | sort) > nag.hosts -(cd "$servicesdir" && ls | sort) > nag.services +if ! test -d nag.hosts; then + git clone "$hosts_repo" nag.hosts | grep -v 'Alreay up-to-date.' +else + (cd nag.hosts && git pull) +fi + +if ! test -d nag.services; then + git clone "$services_repo" nag.services | grep -v 'Already up-to-date.' +else + (cd nag.services && git pull) +fi + + +(cd nag.hosts && ls | sort) > nag.hosts.ls +(cd nag.services && ls | sort) > nag.services.ls -diff -u nag.hosts nag.services > nag.patch || : +diff -u nag.hosts.ls nag.services.ls > nag.patch || : missing_services=$(sed -n '1d;2d;s/^-\(.*\)/\1/p' nag.patch | tr '\n' ' ') obsolete_services=$(sed -n '1d;2d;s/^+\(.*\)/\1/p' nag.patch | tr '\n' ' ') -- cgit v1.2.3 From 0bead921a24d9856c74ee8c1f296c2a45e634647 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 15 Jul 2014 12:42:25 +0200 Subject: Reaktor nag: git pull|grep -v 'Already up-to-date' --- Reaktor/commands/nag | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Reaktor/commands/nag') diff --git a/Reaktor/commands/nag b/Reaktor/commands/nag index e5380fc3..2b33d5e1 100755 --- a/Reaktor/commands/nag +++ b/Reaktor/commands/nag @@ -9,15 +9,15 @@ fi trap 'rm -f nag.hosts.ls nag.services.ls nag.patch' EXIT INT QUIT if ! test -d nag.hosts; then - git clone "$hosts_repo" nag.hosts | grep -v 'Alreay up-to-date.' + git clone "$hosts_repo" nag.hosts else - (cd nag.hosts && git pull) + (cd nag.hosts && git pull) | grep -v 'Already up-to-date.' fi if ! test -d nag.services; then - git clone "$services_repo" nag.services | grep -v 'Already up-to-date.' + git clone "$services_repo" nag.services else - (cd nag.services && git pull) + (cd nag.services && git pull) | grep -v 'Already up-to-date.' fi -- cgit v1.2.3 From 55ce96f905c2abd96346abc007d87b35a0074656 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 15 Jul 2014 12:46:42 +0200 Subject: Reaktor nag: s/grep/sed/ --- Reaktor/commands/nag | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Reaktor/commands/nag') diff --git a/Reaktor/commands/nag b/Reaktor/commands/nag index 2b33d5e1..7c4fd3c6 100755 --- a/Reaktor/commands/nag +++ b/Reaktor/commands/nag @@ -11,13 +11,13 @@ trap 'rm -f nag.hosts.ls nag.services.ls nag.patch' EXIT INT QUIT if ! test -d nag.hosts; then git clone "$hosts_repo" nag.hosts else - (cd nag.hosts && git pull) | grep -v 'Already up-to-date.' + (cd nag.hosts && git pull) | sed '/Already up-to-date/d' fi if ! test -d nag.services; then git clone "$services_repo" nag.services else - (cd nag.services && git pull) | grep -v 'Already up-to-date.' + (cd nag.services && git pull) | sed '/Already up-to-date/d' fi -- cgit v1.2.3 From 5d975cef395e8e52b1abbd5f8a897532c386b9d8 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 15 Jul 2014 12:57:01 +0200 Subject: Reaktor nag: factor out git_pull_output_filter --- Reaktor/commands/nag | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Reaktor/commands/nag') diff --git a/Reaktor/commands/nag b/Reaktor/commands/nag index 7c4fd3c6..338c083e 100755 --- a/Reaktor/commands/nag +++ b/Reaktor/commands/nag @@ -8,16 +8,22 @@ fi trap 'rm -f nag.hosts.ls nag.services.ls nag.patch' EXIT INT QUIT + +git_pull_output_filter() { + sed -n '/^ [0-9]\+ file change/p' +} + + if ! test -d nag.hosts; then git clone "$hosts_repo" nag.hosts else - (cd nag.hosts && git pull) | sed '/Already up-to-date/d' + (cd nag.hosts && git pull) | git_pull_output_filter fi if ! test -d nag.services; then git clone "$services_repo" nag.services else - (cd nag.services && git pull) | sed '/Already up-to-date/d' + (cd nag.services && git pull) | git_pull_output_filter fi -- cgit v1.2.3 From d4d6241b6b1e948bbc52fc8dab22f098d6130af6 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 15 Jul 2014 13:03:07 +0200 Subject: Reaktor nag: git_pull_output_filter REPO_NAME --- Reaktor/commands/nag | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Reaktor/commands/nag') diff --git a/Reaktor/commands/nag b/Reaktor/commands/nag index 338c083e..24414dd3 100755 --- a/Reaktor/commands/nag +++ b/Reaktor/commands/nag @@ -9,21 +9,22 @@ fi trap 'rm -f nag.hosts.ls nag.services.ls nag.patch' EXIT INT QUIT +# usage: git_pull_output_filter REPO_NAME git_pull_output_filter() { - sed -n '/^ [0-9]\+ file change/p' + sed -n 's/^ [0-9]\+ file change/'"$1"': &/p' } if ! test -d nag.hosts; then git clone "$hosts_repo" nag.hosts else - (cd nag.hosts && git pull) | git_pull_output_filter + (cd nag.hosts && git pull) | git_pull_output_filter hosts fi if ! test -d nag.services; then git clone "$services_repo" nag.services else - (cd nag.services && git pull) | git_pull_output_filter + (cd nag.services && git pull) | git_pull_output_filter services fi -- cgit v1.2.3