Commit Diff


commit - 9bc314e5b2b2a30ab2fce10168f3ceb9f6a1b8f2
commit + 688c9bfdd4186b11f46855ff989a3f556438e233
blob - d4af1cf9a03eebca09eff59415b38e7246dc7f7d
blob + d9d7b278f84e59567f787f5691f9061cf1b582b1
--- Makefile
+++ Makefile
@@ -9,14 +9,20 @@ SSH_TEST_NODES=tools0
 
 all: tests
 
-website: index.md documentation.html
+release: r7.1
+	rm -fr _release/r7-$(UTILITY_VERSION)
+	mkdir -p _release/r7-$(UTILITY_VERSION)
+	cp r7 r7.1 Makefile README.md _release/r7-$(UTILITY_VERSION)
+	cd _release && tar cfv r7-$(UTILITY_VERSION).tar r7-$(UTILITY_VERSION)
+	gzip -9 _release/r7-$(UTILITY_VERSION).tar
+	cp _release/r7-$(UTILITY_VERSION).tar.gz _release/r7-latest.tar.gz
+
+html: index.md documentation.html
 	pandoc --template=./r7doc.html \
-	   	-s --toc=true \
+	   	-s --toc=false \
 		--metadata title='R7' \
 		--from markdown+smart \
 		-t html -o index.html index.md
-	scp index.html root@campfire:/var/www/inda.re/r7/
-	ssh root@campfire chmod 644 /var/www/inda.re/r7/index.html
 
 documentation.html: README.md ./r7
 	pandoc --template=./r7doc.html \
@@ -24,20 +30,20 @@ documentation.html: README.md ./r7
 		--metadata title='R7 Documentation' \
 		--from markdown+smart \
 		-t html -o documentation.html README.md
-	scp documentation.html root@campfire:/var/www/inda.re/r7/
-	ssh root@campfire chmod 644 /var/www/inda.re/r7/documentation\*
 
 r7.1: README.md
 	pandoc --from markdown+smart \
-		-t man -o r7.1 README.md
+		-s -t man -o r7.1 README.md
 
 r7.1.pdf: README.md
 	pandoc --from markdown+smart \
-		-t pdf -o r7.1.pdf README.md
+		-s -t pdf -o r7.1.pdf README.md
 
 install:
 	cp ./r7 $(PREFIX)/bin/
 	chmod 755 $(PREFIX)/bin/r7
+	cp ./r7.1 $(PREFIX)/man/man1/
+	chmod 644 $(PREFIX)/man/man1/r7.1
 
 # Test suite for r7
 R=${SHELL} ${UTILITY}
blob - 8dbd3b9815d76f2022abea37a0d7440075f1efd6
blob + bf26401ae46dcef585cea64e5ac07022e3900f9f
--- README.md
+++ README.md
@@ -1,28 +1,38 @@
 ---
-title: "R7 Documentation"
-man_manual: "r7(1)"
+title: R7
 section: 1
+header: User Manual
+footer: v0.0.1
+date: Tue Jun 3 2025
 ---
 
-## Description
-
-R7 is a shell remote configuration management framework designed to:
-
-- work within site specific repositories organized with groups and nodes
-- group functions and execute them in parallel on a list of nodes (hosts)
-- map the executions (`_run/`) to a tree structure (`_output/`)
-- trace the executions of functions and report issues or changes
-
-R7 is inspired by the amazing work made by the [rset](https://scriptedconfiguration.org/) tool.
-
-_Supported shells are ksh93, oksh and yash. Supported platforms are OpenBSD, FreeBSD, NetBSD and GNU/Linux. Busybox support is planned._
-
-_Optional dependencies are openrsync, rsync, column, graphviz and pandoc_
-
 ## Tutorial
 
 ### Introduction
 
+R7 is a configuration management framework made to configure nodes with
+configuration files and related operations versionned in a central repository.
+To remain code versionning system agnostic, manual or automated versionning is
+left to the user, via makefiles or triggered from r7 `site-config` configuration
+file _(See below)_.
+
+The idea is to store hosts configurations in `nodes/hostname` directories that
+maps each hosts `/etc` and to assign those hosts to configuration groups
+containing the directives to install the configuration and requirements.
+
+_Nodes sub-directories are hostnames understood by the ssh client and
+configuration._
+
+_Currently, r7 requires valid ssh configuration and keyfiles in the repository
+`.ssh/` directory._
+
+_Repositories can be initialized with `rset init` or `rset -w
+path/to/new-repository init`, the user will then have to provide valid
+configurations and keys for `.ssh/` in the newly created directory._
+
+_See [Technical Notes](#technical-notes) for dependencies and supported
+platforms._
+
 There is an example of r7 repository:
 
     ./nodes/
@@ -40,16 +50,6 @@ There is an example of r7 repository:
     ./.ssh/id_ed25519_r7.pub
     ./site-config
 
-_Nodes sub-directories are hostnames understood by the ssh client and
-configuration._
-
-_Currently, r7 requires valid ssh configuration and keyfiles in the repository
-`.ssh/` directory._
-
-_Repositories can be initialized with `rset init` or `rset -w
-path/to/new-repository init`, the user will then have to provide valid
-configurations and keys for `.ssh/` in the newly created directory._
-
 There is an example of r7 site configuration (`site-config` file):
 
 ```sh
@@ -383,7 +383,7 @@ This will produce something like the following:
 - (error 127) - in tools0 example2 service_A (1748791986)
 
     /bin/sh: <stdin>[155]: service: not found
-        :: 1748791986 tools0 ERROR unable to setup service A
+    :: 1748791986 tools0 ERROR unable to setup service A
 
 ```
 
@@ -510,8 +510,8 @@ Here we add new users:
 
 ```sh
 setup_users() {
-    useradd user1
-    useradd user2
+    useradd user1 2>/dev/null || :
+    useradd user2 2>/dev/null || :
 }
 ```
 
@@ -528,7 +528,7 @@ install_myscript() {
     crontab -u _myscript - <<-/
         MAILTO=$mail_admins
         */5 * * * *     myscript
-/
+    /
 }
 ```
 
@@ -635,7 +635,7 @@ r7 [options] [command [arguments...]]
 | **info** | Default command showing active nodes and summary |
 | **init** | Initialize a new work directory |
 
-### Environment
+## Environment
 
 | Name | Default value | Description |
 | ---- | ------------- | ------------|
@@ -657,9 +657,23 @@ r7 [options] [command [arguments...]]
 | SSH_KNOWN_HOSTS | R7_WORKDIR/.ssh/known_hosts | Set the SSH known hosts file |
 | SSH_CONNECT_TIMEOUT | 3 | Set the SSH connect timeout |
 
+
+## Group variables
+
+Those variables are available during the execution of th group file's functions.
+
+| Name | Description |
+| ---- | ----------- |
+| trace_id | Current run trace ID |
+| groupname | Current group name being executed |
+| exitonerror | Cause the error function to exit if equals `yes` |
+| nodename | Contains the output of `nodename` |
+| nodedir | Contains the output of `nodedir` |
+| groupdir | Contains the output of `groupdir` |
+
+
 ## Group functions
 
-
 Those functions are accessible during the execution of the group file's functions.
 
 1. [trace](#trace)
@@ -687,8 +701,6 @@ Append a trace containing the current node name and `t
 trace [string...]
 ```
 
----
-
 ### error
 
 ***Description:***
@@ -700,8 +712,6 @@ output, exit the group execution if `-e` is set
 error [string...]
 ```
 
----
-
 ### node
 
 ***Description:***
@@ -712,8 +722,6 @@ Returns true if the argument is an existing file or di
 node [filename|dirname]
 ```
 
----
-
 ### nodename
 
 ***Description:***
@@ -724,8 +732,6 @@ Returns the small hostname of the current host
 nodename
 ```
 
----
-
 ### nodedir
 
 ***Description:***
@@ -736,8 +742,6 @@ Returns `/tmp/r7/$(nodename)`
 nodename
 ```
 
----
-
 ### groupdir
 
 ***Description:***
@@ -748,8 +752,6 @@ Returns `/tmp/r7/$groupname.dir`
 groupdir
 ```
 
----
-
 ### install
 
 ***Description:***
@@ -761,8 +763,6 @@ owner, returns true if the file changed, otherwise ret
 install [-o owner] [-m mode] source destintaion
 ```
 
----
-
 ### groupinstall
 
 ***Description:***
@@ -774,8 +774,6 @@ performs like `install`
 groupinstall [-o owner] [-m mode] source destintaion
 ```
 
----
-
 ### nodeinstall
 
 ***Description:***
@@ -786,7 +784,6 @@ performs like `install`
 ```sh
 nodeinstall [-o owner] [-m mode] source destintaion
 ```
----
 
 ### source
 
@@ -820,10 +817,21 @@ name as argument without producing an error if the fil
 nodesource filename
 ```
 
-
-
 # r7 library
 
+Usable from the r7 `site-config` file or sourced in the current shell using:
+
+```sh
+. $(command -v r7)
+```
+
+Each functions are declared with underscore names and aliased with dashes.
+Shorter aliases are also available, list all declared aliases with:
+
+```sh
+alias
+```
+
 ## Interface
 
 1. [info](#info)
@@ -841,8 +849,6 @@ Default command showing active nodes and summary, ran 
 info
 ```
 
----
-
 ### usage
 
 ***Description:***
@@ -880,8 +886,6 @@ Resets the SSH agent environment and issues ssh-add fo
 unlock
 ```
 
----
-
 ### copy
 
 ***Description:***
@@ -892,8 +896,6 @@ r7 openrsync, rsync, scp wrapper; selected in order of
 copy SRC DST
 ```
 
----
-
 ### ssh
 
 ***Description:***
@@ -904,8 +906,6 @@ r7 SSH wrapper; behaves like the standard OpenSSH comm
 ssh OPTION HOST
 ```
 
----
-
 ### ssh-debug
 
 ***Description:***
@@ -916,8 +916,6 @@ r7 SSH with debug connection mode for a specific HOST
 ssh-debug HOST
 ```
 
----
-
 ### ssh-known-hosts
 
 ***Description:***
@@ -928,8 +926,6 @@ Calls ssh-keygen to dump the SSH known_hosts file
 ssh-known-hosts
 ```
 
----
-
 ### ssh-authorized-keys-reset
 
 ***Description:***
@@ -940,8 +936,6 @@ Resets SSH authorized_keys on the specified HOST
 ssh-authorized-keys-reset HOST
 ```
 
----
-
 ### ssh-accept-new
 
 ***Description:***
@@ -951,7 +945,6 @@ Adds a new host entry in the SSH known_hosts file
 ```sh
 ssh-accept-new HOST
 ```
----
 
 ### ssh-control-master-clean
 
@@ -962,7 +955,6 @@ Cleans the SSH control master directory
 ```sh
 ssh-control-master-clean
 ```
----
 
 ### ssh-users
 
@@ -973,7 +965,6 @@ Searches nodes for authorized_keys_* and returns a lis
 ```sh
 ssh-users
 ```
----
 
 ### ssh-ids
 
@@ -984,7 +975,6 @@ Returns sorted SSH IDs
 ```sh
 ssh-ids
 ```
----
 
 ### ssh-authorized-keys
 
@@ -995,7 +985,6 @@ Returns the list of authorized_keys from nodes
 ```sh
 ssh-authorized-keys
 ```
----
 
 ### ssh-ids-hosts
 
@@ -1006,7 +995,6 @@ Returns SSH IDs along with matching keyfile and hostna
 ```sh
 ssh-ids-hosts
 ```
----
 
 ## Deployment functions
 
@@ -1030,8 +1018,6 @@ Returns a list of available nodes
 nodes
 ```
 
----
-
 ### nodes-active
 
 ***Description:***
@@ -1042,8 +1028,6 @@ Returns a list of active nodes by detecting SSH availa
 nodes-active
 ```
 
----
-
 ### run-config
 
 ***Description:***
@@ -1054,8 +1038,6 @@ Executes `R7_SITE_CONFIG` in the loaded environment
 run-config
 ```
 
----
-
 ### members
 
 ***Description:***
@@ -1065,7 +1047,6 @@ Returns a list of active nodes matching a list of grep
 ```sh
 members REGEXES
 ```
----
 
 ### group
 
@@ -1076,7 +1057,6 @@ Applies GROUPNAME functions (in prefix order) to the p
 ```sh
 group GROUPNAME MEMBERS
 ```
----
 
 ### group-functions
 
@@ -1088,8 +1068,6 @@ Returns a list of functions found in the specified GRO
 group-functions GROUPNAME
 ```
 
----
-
 ### prefix
 
 ***Description:***
@@ -1125,8 +1103,6 @@ Dumps R7_RUNDIR to R7_OUTPUTDIR
 output-dump
 ```
 
----
-
 ### output-latest
 
 ***Description:***
@@ -1137,8 +1113,6 @@ Returns a list of outputs from the latest run
 output-latest
 ```
 
----
-
 ### output-status
 
 ***Description:***
@@ -1149,8 +1123,6 @@ Returns a list of current dumped functions exit status
 output-status
 ```
 
----
-
 ### output-duration
 
 ***Description:***
@@ -1161,8 +1133,6 @@ Returns a list of durations of executed groups
 output-duration
 ```
 
----
-
 ### output
 
 ***Description:***
@@ -1173,8 +1143,6 @@ Shows the dumped output matching HOST, GROUPNAME, and 
 output HOST GROUPNAME FUNCTION
 ```
 
----
-
 ### trace-id-last
 
 ***Description:***
@@ -1185,8 +1153,6 @@ Returns the latest execution trace_id
 trace-id-last
 ```
 
----
-
 ### output-diffs
 
 ***Description:***
@@ -1197,8 +1163,6 @@ Returns the diffs from the latest execution
 output-diffs
 ```
 
----
-
 ### output-permissions
 
 ***Description:***
@@ -1209,8 +1173,6 @@ Returns the latest permission changes
 output-permissions
 ```
 
----
-
 ### output-errors
 
 ***Description:***
@@ -1221,8 +1183,6 @@ Returns the latest errors detected
 output-errors
 ```
 
----
-
 ### summary
 
 ***Description:***
@@ -1233,8 +1193,6 @@ Produces a summary of errors, diffs, and permission ou
 summary
 ```
 
----
-
 ## Digraph output
 
 1. [digraph-host](#digraph-host)
@@ -1252,8 +1210,6 @@ Returns a directed graph (in DOT format) showing relat
 digraph-host
 ```
 
----
-
 ### digraph-ssh-id-hosts
 
 ***Description:***
@@ -1264,14 +1220,10 @@ Returns a directed graph (in DOT format) of relations 
 digraph-ssh-id-hosts
 ```
 
----
-
 ## HTML output
 
 1. [html](#html)
 
----
-
 ### html
 
 ***Description:***
@@ -1281,3 +1233,15 @@ Retunrs a report page with the content of `README.md` 
 ```sh
 html
 ```
+
+## Technical notes
+
+- Supported shells are ksh93, oksh, yash and bash.
+
+- Supported platforms are OpenBSD, FreeBSD, NetBSD and GNU/Linux.
+
+- Busybox support is planned.
+
+- Optional dependencies are openrsync, rsync, column, graphviz and pandoc.
+
+- The HTML output is a work in progress.
blob - 0416c70f82e6f6858332b02be354c29caf543764
blob + 16bfe794ae310ea59756004ea9f47fa4a0aaf5a8
--- r7
+++ r7
@@ -209,7 +209,10 @@ _main() {
 		fi
 		;;
 	info) info ;;
-	import) import "$@" ;;
+	import)
+		shift
+		import "$@"
+		;;
 	out | output)
 		shift
 		output "$@"
@@ -776,6 +779,7 @@ _collect() (
 			function=$5
 			status=$6
 			endcode=$7
+			# Traces from _call
 			case $status in
 			START)
 				save_group=$group save_function=$function
@@ -1133,75 +1137,75 @@ md() {
 }
 
 html() {
-	cat <<eof
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<meta charset="UTF-8">
-		<meta name="viewport" content="width=device-width, initial-scale=1.0">
-		<title>inda.re report</title>
-		<style type="text/css" media="screen">
-			html { margin: 4%; }
-			body {
-				margin: 0 auto;
-				max-width: 40em;
-				padding-left: 50px;
-				padding-right: 50px;
-				padding-top: 50px;
-				padding-bottom: 50px;
-				hyphens: auto;
-				overflow-wrap: break-word;
-				text-rendering: optimizeLegibility;
-				font-kerning: normal;
-			}
-			p {
-				text-align: justify;
-				text-justify: inter-word;
-			}
-			@media screen and (min-width: 1000px) {
-				html {
-					max-width:1300px;
-					margin: auto;
-				}
-			}
-			@media (prefers-color-scheme: dark) {
-				:root {
-					--red:   #E05434;
-					--green: #20B700;
-					--blue:  #A7C1E5;
-					--buildhead: #474749;
-				}
-				:link {
-					color: #BAD7FF;
-				}
-				:visited {
-					color: #F6BAFF;
-				}
-				body {
-					background-color: #1E1F21;
-					color: #EEEFF1;
-				}
-			}
-		</style>
-	</head>
-	<body>
-		<h1>$PWD</h1>
-		<nav>
-			<ul>
-				<li><a href="#Documentation">Documentation</a></li>
-			</ul>
-		</nav>
-		<main>
-			<section id="Documentation">
-				$(md README.md)
-			</section>
-		</main>
-		<footer>
-			<p>r7</p>
-		</footer>
-	</body>
-</html>
-eof
+	cat <<-eof
+		<!DOCTYPE html>
+		<html lang="en">
+			<head>
+				<meta charset="UTF-8">
+				<meta name="viewport" content="width=device-width, initial-scale=1.0">
+				<title>inda.re report</title>
+				<style type="text/css" media="screen">
+					html { margin: 4%; }
+					body {
+						margin: 0 auto;
+						max-width: 40em;
+						padding-left: 50px;
+						padding-right: 50px;
+						padding-top: 50px;
+						padding-bottom: 50px;
+						hyphens: auto;
+						overflow-wrap: break-word;
+						text-rendering: optimizeLegibility;
+						font-kerning: normal;
+					}
+					p {
+						text-align: justify;
+						text-justify: inter-word;
+					}
+					@media screen and (min-width: 1000px) {
+						html {
+							max-width:1300px;
+							margin: auto;
+						}
+					}
+					@media (prefers-color-scheme: dark) {
+						:root {
+							--red:   #E05434;
+							--green: #20B700;
+							--blue:  #A7C1E5;
+							--buildhead: #474749;
+						}
+						:link {
+							color: #BAD7FF;
+						}
+						:visited {
+							color: #F6BAFF;
+						}
+						body {
+							background-color: #1E1F21;
+							color: #EEEFF1;
+						}
+					}
+				</style>
+			</head>
+			<body>
+				<h1>$PWD</h1>
+				<nav>
+					<ul>
+						<li><a href="#Documentation">Documentation</a></li>
+					</ul>
+				</nav>
+				<main>
+					<section id="Documentation">
+						$(md README.md)
+					</section>
+				</main>
+				<footer>
+					<p>r7</p>
+				</footer>
+			</body>
+		</html>
+	eof
 	exit 0
 }