summaryrefslogtreecommitdiff
path: root/man/generate-man
blob: 538588a952f71b0e25a8a1cbf8ba8d82813ebb5c (plain)
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
#!/bin/bash

set -eu

export PYTHONPATH=..
export PATH="../bin:$PATH"

f2bversion=$(fail2ban-client -V)
echo "Generating man for $f2bversion ..."

# fail2ban-client
echo -n "Generating fail2ban-client "
help2man --section=1 --no-info --include=fail2ban-client.h2m --output fail2ban-client.1 fail2ban-client
echo "[done]"
echo -n "Patching fail2ban-client   "
# Changes the title.
sed -i -e 's/.SS "Command:"/.SH COMMAND/' fail2ban-client.1
# Sets bold font for commands.
IFS="
"
NEXT=0
FOUND=0
LINES=$( cat fail2ban-client.1 )
echo -n "" > fail2ban-client.1
for LINE in $LINES; do
	if [ "$LINE" = ".SH COMMAND" ]; then
		FOUND=1
	fi
	if [ $NEXT -eq 1 ] && [ $FOUND -eq 1 ]; then
		echo "\fB$LINE\fR" >> fail2ban-client.1
	else
		echo "$LINE" >> fail2ban-client.1
	fi
	if [ "$LINE" = ".TP" ]; then
		NEXT=1
	else
		NEXT=0
	fi
done
echo "[done]"

# fail2ban-python
echo -n "Generating fail2ban-python "
help2man --version-string=$f2bversion --section=1 --no-info --include=fail2ban-python.h2m --output fail2ban-python.1 fail2ban-python
echo "[done]"

# fail2ban-server
echo -n "Generating fail2ban-server "
help2man --section=1 --no-info --include=fail2ban-server.h2m --output fail2ban-server.1 fail2ban-server
echo "[done]"

# fail2ban-testcases
echo -n "Generating fail2ban-testcases "
help2man --section=1 --no-info --include=fail2ban-testcases.h2m --output fail2ban-testcases.1 fail2ban-testcases
echo "[done]"

# fail2ban-regex
echo -n "Generating fail2ban-regex  "
help2man --section=1 --no-info --include=fail2ban-regex.h2m --output fail2ban-regex.1 fail2ban-regex
echo "[done]"
echo -n "Patching fail2ban-regex    "
# Changes the title.
sed -i -e 's/.SS "Log:"/.SH LOG/' fail2ban-regex.1
sed -i -e 's/.SS "Regex:"/.SH REGEX/' fail2ban-regex.1
# Sets bold font for commands.
IFS="
"
NEXT=0
FOUND=0
LINES=$( cat fail2ban-regex.1 )
echo -n "" > fail2ban-regex.1
for LINE in $LINES; do
	if [ "$LINE" = ".SH LOG" ]; then
		FOUND=1
	fi
	if [ $NEXT -eq 1 ] && [ $FOUND -eq 1 ]; then
		echo "\fB$LINE\fR" >> fail2ban-regex.1
	else
		echo "$LINE" >> fail2ban-regex.1
	fi
	if [ "$LINE" = ".TP" ]; then
		NEXT=1
	else
		NEXT=0
	fi
done
echo "[done]"