-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'postup'/'predown': Quotation marks are not handled correctly. #153
Comments
It looks like regular shell commands are not supported in general (e.g. |
Thanks, the xshell suggestion is good, I'll try to take a look at it sometime - it'd also help to clearly highlight which parts still shell out. As for the POSTUP/PREDOWN, they come from this issue - #71 There the aim was just to support bash scripts as files - i.e. the argument is the path to the bash script. |
Yes, I think It also would make adding environ variables easier, and it's easy to make the variables usable as arguments of scripts/applications (which I described in my last PR): use xshell::{cmd, Shell};
fn main() {
let sh = Shell::new().unwrap();
let cmd = r#"echo "=> 'VPN is ready. The NS IP is: $IP'""#;
cmd!(sh, "bash -c {cmd}")
.env("IP", "127.0. 0.1")
.run()
.unwrap();
} Output:
And Another advantage is/might be that Interpolation of |
However, I'm not sure if I've seen warnings to not use |
I've found the cause of the following error (mentioned in another issue):
The following post-up callback reproduces it:
cargo run -- exec --custom /tmp/openvpn_test.ovpn --protocol openvpn --postup "echo '=> VPN is ready'" --firewall NfTables 'ls'
Using
--postup 'echo "=> VPN is ready!"'
fails as well.So it looks like, that quotation marks are not handled properly.
Have you seen the xshell crate?
It can handle cases like that:
Output:
Printing out the executed command can be deactivated via .quiet().
I highly recommend this crate for any "shell scripting" via Rust. It has many useful features for that.
I guess, Vopono would have at least 15 to 30% less lines of code, if
xshell
was used.This change is a bit to large for me to implement (I have no clue about most things that happen in Vopono), but I definitely would use
xshell
for something like Vopono.Maybe using
xshell
forpostup
,predown
and the executed command would be enough, at the beginning.The text was updated successfully, but these errors were encountered: