Merge pull request #6 from eric-belhomme/master
save connection settings to rc-file
This commit is contained in:
commit
671df16db3
@ -33,5 +33,11 @@ Usage is pretty straightforward, it is highly-recommended that you leave SSL ena
|
|||||||
`passwd` interactively prompts for the new password and password expiration date.
|
`passwd` interactively prompts for the new password and password expiration date.
|
||||||
`passwd` finally sends a prefilled ldapmodify to the server.
|
`passwd` finally sends a prefilled ldapmodify to the server.
|
||||||
|
|
||||||
|
### `save`
|
||||||
|
`save` saves current directory connection settings (excepted `bindpass`) into an RC-file (`${HOME}/.ipa/freeipa-sam.rc`)
|
||||||
|
If the file exists, variable are automatically read at script startup, and updated in the file on script exit.
|
||||||
|
If the file does not exist when the script is started, nothing will be saved unless `save` is run manually.
|
||||||
|
|
||||||
|
|
||||||
PRs and issues welcome, but support cannot be promised.
|
PRs and issues welcome, but support cannot be promised.
|
||||||
Cheers!
|
Cheers!
|
||||||
|
|||||||
@ -1,10 +1,28 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
rcfile="${HOME}/.ipa/freeipa-sam.rc"
|
||||||
|
if [ -e "$rcfile" ]; then
|
||||||
|
source "$rcfile"
|
||||||
|
rcfile_on=true
|
||||||
|
fi
|
||||||
ssleval=true
|
ssleval=true
|
||||||
prefix=ldaps
|
prefix=ldaps
|
||||||
passeval() { [ -z $bindpass ] && passeval="UNSET!" || passeval="SET!"; }
|
passeval() { [ -z $bindpass ] && passeval="UNSET!" || passeval="SET!"; }
|
||||||
ssleval() { [ "$prefix" == "ldaps" ] && ssleval="true" || ssleval="false"; }
|
ssleval() { [ "$prefix" == "ldaps" ] && ssleval="true" || ssleval="false"; }
|
||||||
actionseval() { [ "$ldapserver" ] && [ "$binduser" ] && [ "$domain" ] && [ "$passeval" == "SET!" ] && actionseval="ready" || actionseval="conditions not yet met" && return 1; }
|
actionseval() { [ "$ldapserver" ] && [ "$binduser" ] && [ "$domain" ] && [ "$passeval" == "SET!" ] && actionseval="ready" || actionseval="conditions not yet met" && return 1; }
|
||||||
|
|
||||||
|
save() {
|
||||||
|
test -d "${HOME}/.ipa" || mkdir -p "${HOME}/.ipa"
|
||||||
|
cat > "${HOME}/.ipa/freeipa-sam.rc" <<EOF
|
||||||
|
# freeipa-sam rc-file
|
||||||
|
ldapserver="$ldapserver"
|
||||||
|
binduser="$binduser"
|
||||||
|
domain="$domain"
|
||||||
|
ldapdomain="$ldapdomain"
|
||||||
|
ssleval=$ssleval
|
||||||
|
prefix="$prefix"
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
menu() {
|
menu() {
|
||||||
passeval
|
passeval
|
||||||
ssleval
|
ssleval
|
||||||
@ -19,7 +37,7 @@ menu() {
|
|||||||
5.) ssl=$ssleval
|
5.) ssl=$ssleval
|
||||||
|
|
||||||
Actions ($actionseval):
|
Actions ($actionseval):
|
||||||
add | rm | ls | info | passwd
|
add | rm | ls | info | passwd | save
|
||||||
|
|
||||||
--- Results ---
|
--- Results ---
|
||||||
$results
|
$results
|
||||||
@ -110,7 +128,11 @@ userPassword: $password
|
|||||||
replace: passwordExpirationTime
|
replace: passwordExpirationTime
|
||||||
passwordExpirationTime: ${expire}031407Z" | ldapmodify -H "$prefix""://""$ldapserver" -D "$binduser" -w "$bindpass" && results="Submitted." || results="Error."
|
passwordExpirationTime: ${expire}031407Z" | ldapmodify -H "$prefix""://""$ldapserver" -D "$binduser" -w "$bindpass" && results="Submitted." || results="Error."
|
||||||
;;
|
;;
|
||||||
|
save)
|
||||||
|
save
|
||||||
|
;;
|
||||||
exit)
|
exit)
|
||||||
|
if [ $rcfile_on == "true" ]; then save; fi
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
"")
|
"")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user