From 558698e10ea114ac64a2ef3a2def64b85bdacf0a Mon Sep 17 00:00:00 2001 From: Eric Belhomme Date: Tue, 30 Aug 2022 08:13:19 +0200 Subject: [PATCH 1/3] save connection settings to rc-file --- README.md | 5 +++++ freeipa-sam.sh | 27 +++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 79550db..d6e4b81 100644 --- a/README.md +++ b/README.md @@ -33,5 +33,10 @@ 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` finally sends a prefilled ldapmodify to the server. +### `rcfile` +`rcfile` saves current directory connection settings (excepted `bindpass`) into a RC-file (stored into `${HOME}/.ipa/freeipa-sam.rc`) +If the file exists, variable are automatically read at script startup. +RC-file is also automatically written at normal exit (using `exit` command action) + PRs and issues welcome, but support cannot be promised. Cheers! diff --git a/freeipa-sam.sh b/freeipa-sam.sh index 5631b81..283a4d1 100755 --- a/freeipa-sam.sh +++ b/freeipa-sam.sh @@ -1,10 +1,30 @@ #!/usr/bin/env bash +rcfile="${HOME}/.ipa/freeipa-sam.rc" +if [ -e "$rcfile" ]; then + source "$rcfile" +fi ssleval=true prefix=ldaps passeval() { [ -z $bindpass ] && passeval="UNSET!" || passeval="SET!"; } ssleval() { [ "$prefix" == "ldaps" ] && ssleval="true" || ssleval="false"; } actionseval() { [ "$ldapserver" ] && [ "$binduser" ] && [ "$domain" ] && [ "$passeval" == "SET!" ] && actionseval="ready" || actionseval="conditions not yet met" && return 1; } +savercfile() { + test -d "${HOME}/.ipa" || mkdir -p "${HOME}/.ipa" + cat > "${HOME}/.ipa/freeipa-sam.rc" < Date: Wed, 31 Aug 2022 09:06:00 +0000 Subject: [PATCH 2/3] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d6e4b81..3dcc46f 100644 --- a/README.md +++ b/README.md @@ -33,10 +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` finally sends a prefilled ldapmodify to the server. -### `rcfile` -`rcfile` saves current directory connection settings (excepted `bindpass`) into a RC-file (stored into `${HOME}/.ipa/freeipa-sam.rc`) -If the file exists, variable are automatically read at script startup. -RC-file is also automatically written at normal exit (using `exit` command action) +### `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. Cheers! From 19bdd4387813224b5843e2769c38e96b1f8e8e3d Mon Sep 17 00:00:00 2001 From: Noah Bliss Date: Wed, 31 Aug 2022 09:12:01 +0000 Subject: [PATCH 3/3] Update freeipa-sam.sh --- freeipa-sam.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/freeipa-sam.sh b/freeipa-sam.sh index 283a4d1..c9597a6 100755 --- a/freeipa-sam.sh +++ b/freeipa-sam.sh @@ -2,6 +2,7 @@ rcfile="${HOME}/.ipa/freeipa-sam.rc" if [ -e "$rcfile" ]; then source "$rcfile" + rcfile_on=true fi ssleval=true prefix=ldaps @@ -9,7 +10,7 @@ passeval() { [ -z $bindpass ] && passeval="UNSET!" || passeval="SET!"; } ssleval() { [ "$prefix" == "ldaps" ] && ssleval="true" || ssleval="false"; } actionseval() { [ "$ldapserver" ] && [ "$binduser" ] && [ "$domain" ] && [ "$passeval" == "SET!" ] && actionseval="ready" || actionseval="conditions not yet met" && return 1; } -savercfile() { +save() { test -d "${HOME}/.ipa" || mkdir -p "${HOME}/.ipa" cat > "${HOME}/.ipa/freeipa-sam.rc" <