forked from gcoop-libre/freeipa-sssd-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipa-src-cfg
executable file
·114 lines (88 loc) · 1.8 KB
/
ipa-src-cfg
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
# This script comes with ABSOLUTELY NO WARRANTY, use at own risk
# Copyright (C) 2021 Osiris Alejandro Gomez <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# shellcheck disable=SC2046
BIN="$(basename "$0")"
IPA_CONFIG="$HOME/.ipa-config"
function cfg_usage()
{
cat << EOF
## \`$BIN\` Common functions and variables
### Usage
\`\`\`bash
$BIN
\`\`\`
### Description
Common functions and variables for FreeIPA SSSD Tools scripts.
EOF
}
if [[ "$1" =~ ^[-]+(h|help) ]]
then
[[ "$BIN" = "$(basename "${BASH_SOURCE[0]}")" ]] && cfg_usage
fi
stderror ()
{
echo >&2 "$1"
}
function die()
{
stderror "ERROR: $1"
exit 1
}
function success ()
{
echo "OK: $1"
exit 0
}
function cfg()
{
die "$EMPTY $1 TRY DEFINE IN $IPA_CONFIG"
}
markdown()
{
cat << EOF
---
fontsize: 8pt
code-block-font-size: 8pt
classoption: landscape
---
EOF
}
code()
{
printf "\\n\\n%s\\n\\n" '```'
}
title1()
{
printf "\\n# %s\\n\\n" "$1"
}
title2()
{
printf "\\n## %s\\n\\n" "$1"
}
title3()
{
printf "\\n### %s\\n\\n" "$1"
}
function config()
{
[[ ! -e "$IPA_CONFIG" ]] && die "NOT FOUND FILE: $IPA_CONFIG"
eval $(sed '/:/!d;/^ *#/d;s/:/ /;' < "$IPA_CONFIG" | while read -r k v
do
str="$k='$v'"
echo "$str"
done)
}