-
Notifications
You must be signed in to change notification settings - Fork 6
/
rsub.1
96 lines (96 loc) · 2.46 KB
/
rsub.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
.\"
.\" Copyright (c) 2018 Eric Radman <ericshane@eradman.com>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd September 24, 2024
.Dt RSUB 1
.Os
.Sh NAME
.Nm rsub
.Nd substitute lines or block of text
.Sh SYNOPSIS
.Nm rsub
.Op Fl A
.Fl r Ar line_regex
.Fl l Ar line_text
.Ar target
.Nm rsub
.Ar target
.Ar < block_content
.Sh DESCRIPTION
.Nm
is shipped to remote machines by
.Xr rset 1
to provide a standard method of modifying configuration parameters within a
file.
Two modes of operation are supported: line substitution and block replacement.
.Pp
Single line replacements are defined by the flags
.Fl r
and
.Fl l ,
while the content for a text block is provided on STDIN.
.Pp
The arguments for line substitution are as follows:
.Bl -tag -width Ds
.It Fl A
Append line if the pattern is not found.
.It Fl r
A regular expression matching the line to replace.
.It Fl l
The replacement text for a matching line.
Newlines are not permitted as part of the replacement string.
.El
.Sh ENVIRONMENT
.Bl -tag -width Ds
.It Ev RSUB_DIFF_ARGS
Arguments for
.Xr diff 1
tool.
The default is
.Qq -U 2 .
.It Ev RSUB_START RSUB_END
Define the beginning and ending markers when updating a block of text.
.El
.Sh EXIT STATUS
The
.Nm
utility exits with one of the following values:
.Pp
.Bl -tag -width Ds -offset indent -compact
.It Li 0
Target file was updated
.It Li 1
No changes were made, or an error occurred
.It Li 2
Incorrect parameters
.It Li 3
File not found
.El
.Sh EXAMPLES
Ensure a single configuration parameter is set
.Bd -literal -offset indent
$SD/rsub -r '^AllowTcpForwarding .+' -l 'AllowTcpForwarding yes' \e
/etc/ssh/sshd_config
.Ed
.Pp
Update a managed block of text
.Bd -literal -offset indent
$SD/rsub /etc/fstab <<-CONF
/dev/ada0p1 /vm ufs rw 0 0
.Ed
.Dl CONF
.Sh SEE ALSO
.Xr awk 1 ,
.Xr rinstall 1