wireguard-install icon indicating copy to clipboard operation
wireguard-install copied to clipboard

Accept environment variables as answers.

Open Leopere opened this issue 5 years ago • 11 comments

Would it be unreasonable to imagine a world where your Q&A system could be automated with the addition of bash environment variables? I think this would be incredibly useful if you already know the answers you want to give.

Otherwise, you could even have an option like $WIREGUARD-INSTALL-RECOMMENDS=True and it would just pick whatever you recommend by default and skip all other questions.

Leopere avatar Jun 05 '19 14:06 Leopere

Something like https://github.com/angristan/openvpn-install/issues/261

angristan avatar Jun 06 '19 09:06 angristan

https://github.com/angristan/wireguard-install/pull/46 if you want have possibility to make this but have add a good system -install or -remove next is for add more clients

liberodark avatar Dec 18 '19 14:12 liberodark

Something like angristan/openvpn-install#261

https://github.com/angristan/openvpn-install/pull/592 should be considered too

randshell avatar Jul 01 '20 18:07 randshell

It really wouldn't be big trouble to add a function for checking the state of a variable, if the variable.

https://www.cyberciti.biz/faq/unix-linux-bash-script-check-if-variable-is-empty/ that can be fairly easily inserted in near the beginning and then the rest of the script can function basically the same. This way you could use this in headless deployments.

Leopere avatar Jul 05 '20 18:07 Leopere

It really wouldn't be big trouble to add a function for checking the state of a variable, if the variable.

I can't really work on it until my refactoring PRs are reviewed and eventually merged as they conflict with each other and working on master isn't an option. After if you like you can open a PR for this too, the codebase will be similar to the openvpn-install repo.

randshell avatar Jul 06 '20 18:07 randshell

Hey I’m in zero rush in the meantime I’ll just keep using that complexorganizations script.

On Mon, Jul 6, 2020 at 2:49 PM randomshell [email protected] wrote:

It really wouldn't be big trouble to add a function for checking the state of a variable, if the variable.

I can't really work on it until my refactoring PRs are reviewed and eventually merged as they conflict with each other and working on master isn't an option. After if you like you can open a PR for this too, the codebase will be similar to the openvpn-install repo.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/angristan/wireguard-install/issues/21#issuecomment-654405929, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIE2VSDKGCPVORZPES6CTDR2IMDRANCNFSM4HTZ4GHQ .

Leopere avatar Jul 06 '20 19:07 Leopere

This is actually way easier than using if's and should not require any major code changes. Ignore everything you see in that cyberciti.biz link. You can simply use bash variable substitution. For example:

$ cat things.sh
echo ${lolwat:-things}
$ bash things.sh 
things
$ 

vs

$ lolwat=omgursh bash things.sh 
omgursh
$ 

AndreiG6 avatar Jul 07 '20 00:07 AndreiG6

Makes sense to me but it might be keen to call a check as a function.

On Mon, Jul 6, 2020 at 8:36 PM Andrei D. [email protected] wrote:

This is actually way easier than using if's and should not require any major code changes. Ignore everything you see in that cyberciti.biz http://cyberciti.biz link. You can simply use bash variable substitution. For example:

$ cat things.sh echo ${lolwat:-things} $ bash things.sh things $

vs

$ lolwat=omgursh bash things.sh omgursh $

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/angristan/wireguard-install/issues/21#issuecomment-654531665, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIE2VQOWMUYPVIGYZVC2N3R2JUXVANCNFSM4HTZ4GHQ .

Leopere avatar Jul 07 '20 01:07 Leopere

Why have a function check for a variable and replace the default value vs just allowing substitution on the default var. Bash variable substitution is there to avoid extra checks and have a viable default fallback

On Tue, Jul 7, 2020, 04:14 Leopere [email protected] wrote:

Makes sense to me but it might be keen to call a check as a function.

On Mon, Jul 6, 2020 at 8:36 PM Andrei D. [email protected] wrote:

This is actually way easier than using if's and should not require any major code changes. Ignore everything you see in that cyberciti.biz http://cyberciti.biz link. You can simply use bash variable substitution. For example:

$ cat things.sh echo ${lolwat:-things} $ bash things.sh things $

vs

$ lolwat=omgursh bash things.sh omgursh $

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/angristan/wireguard-install/issues/21#issuecomment-654531665 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAIE2VQOWMUYPVIGYZVC2N3R2JUXVANCNFSM4HTZ4GHQ

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angristan/wireguard-install/issues/21#issuecomment-654541785, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE6DR6CNXRJKFUZGMZHKC6TR2JZHLANCNFSM4HTZ4GHQ .

AndreiG6 avatar Jul 07 '20 04:07 AndreiG6

We aren't going to use functions but variable substitution like it was already done in the openvpn-install repo https://github.com/angristan/openvpn-install/blob/eca5be8aacc54a570bb3c5306d8764e1be3cab79/openvpn-install.sh#L603-L605

randshell avatar Jul 07 '20 15:07 randshell

Eh that could be fine i do like that solution but just feels brutish like there’s a lot of potential failure modes where if there’s a good system for capturing bad inputs in a callable bash function. Just making suggestions I’m not able to spend time doing it.

If my suggestions get in the way obviously just do it there faster way.

On Tue, Jul 7, 2020 at 12:07 AM Andrei D. [email protected] wrote:

Why have a function check for a variable and replace the default value vs just allowing substitution on the default var. Bash variable substitution is there to avoid extra checks and have a viable default fallback

On Tue, Jul 7, 2020, 04:14 Leopere [email protected] wrote:

Makes sense to me but it might be keen to call a check as a function.

On Mon, Jul 6, 2020 at 8:36 PM Andrei D. [email protected] wrote:

This is actually way easier than using if's and should not require any major code changes. Ignore everything you see in that cyberciti.biz http://cyberciti.biz link. You can simply use bash variable substitution. For example:

$ cat things.sh echo ${lolwat:-things} $ bash things.sh things $

vs

$ lolwat=omgursh bash things.sh omgursh $

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <

https://github.com/angristan/wireguard-install/issues/21#issuecomment-654531665

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AAIE2VQOWMUYPVIGYZVC2N3R2JUXVANCNFSM4HTZ4GHQ

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/angristan/wireguard-install/issues/21#issuecomment-654541785 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AE6DR6CNXRJKFUZGMZHKC6TR2JZHLANCNFSM4HTZ4GHQ

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/angristan/wireguard-install/issues/21#issuecomment-654586460, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIE2VWVNCZJFIJSDBBFHITR2KNQJANCNFSM4HTZ4GHQ .

Leopere avatar Jul 07 '20 18:07 Leopere