Skip to content
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

{PRE|POST}_{UP|DOWN}_COMMAND directives for single command execution #665

Open
MikhailKasimov opened this issue Sep 8, 2016 · 4 comments
Labels

Comments

@MikhailKasimov
Copy link
Contributor

MikhailKasimov commented Sep 8, 2016

Hello!

Due to man ifcfg we have PRE_UP_SCRIPT, POST_UP_SCRIPT, PRE_DOWN_SCRIPT and POST_DOWN_SCRIPT schemes to specify systemd-service, wicked-script and user-script on network interface up|down is. But there is no way to specify a single command execution explicitly (or I can't see it personally). In Debian-based distros there is the kiss-principal pre-up sleep 5 command in /etc/network/interfaces, for example. Ok, in wicked framework we can create something like #!/bin/bash sleep 5 script, put it in /some/directory/ and then call it by {PRE|POST}_{UP|DOWN}_SCRIPT="compat:suse:/some/directory", but this is rather long way, as for me.

Can we have the simple {PRE|POST}_{UP|DOWN}_COMMAND directives for _single _command _execution (I've marked the baseline idea)?

Syntax is similar to {PRE|POST}_{UP|DOWN}_SCRIPT, for example: {PRE|POST}_{UP|DOWN}_COMMAND="compat:suse:sleep 5"

In case if there are two or more commands to be executed -- welcome to {PRE|POST}_{UP|DOWN}_SCRIPT way.

Thank you!

@mtomaschewski
Copy link
Member

mtomaschewski commented Sep 11, 2016

This is not possible with {PRE|POST}_{UP|DOWN}_SCRIPT variable as it contains a list of "schema:script".
Implementing {PRE|POST}_{UP|DOWN}_COMMAND[SUFFIX] (.._COMMAND="foo", ..._COMMAND_2="bar") would be possible... The device name (and action [post-up,post-down,pre-up,pre-down]) context have to be passed in command arguments as needed then.

@MikhailKasimov
Copy link
Contributor Author

MikhailKasimov commented Sep 11, 2016

Implementing {PRE|POST}_{UP|DOWN}_COMMAND[SUFFIX] (.._COMMAND="foo", ..._COMMAND_2="bar") would be possible...

I think about such scheme:
{PRE|POST}_{UP|DOWN}_COMMAND="foo [args for foo]" ,"bar [args for bar]",...,"someting [args for somethnig] which means: do foo [args for foo] first, then "bar [args for bar]", then... someting [args for somethnig].

In case of some command duplication, e.g. {PRE|POST}_{UP|DOWN}_COMMAND="foo [args for foo]",""foo [args for foo]",...,"foo [args for foo]"" to execute it all, because this is user's (sysadmin's) responsibility, which command should be executed with(-out) any argument(-s) and how many times on network interface up|down is.

Your opinion?

@MikhailKasimov MikhailKasimov changed the title [Feature Request] {PRE|POST}_{UP|DOWN}_COMMAND directives for single command execution {PRE|POST}_{UP|DOWN}_COMMAND directives for single command execution Sep 11, 2016
@mtomaschewski
Copy link
Member

A {PRE|POST}_{UP|DOWN}_COMMAND="foo [args for foo]" ,"bar [args for bar]" is not parsable
(sourcable) by the shell, so it can't be used. It would be required to use a shell array like:
{PRE|POST}_{UP|DOWN}_COMMAND=("foo [args for foo]" "bar [args for bar]")
and this would require a significant care about quotes of the list values and trigger a feature e.g. in
yast2 (-network, -sysconfig) to understand it (-> next major release with some luck).
A {PRE|POST}_{UP|DOWN}_COMMAND[SUFFIX]="value ...", that is:
{PRE|POST}_{UP|DOWN}_COMMAND_1="foo ..."
{PRE|POST}_{UP|DOWN}_COMMAND_2="bar ..."
is already well know format since ages .... (IPADDR and many other variables). Sorry that I didn't wrote what I mean exactly with [SUFFIX] in my previous comment, what probably caused the confusion.

@MikhailKasimov
Copy link
Contributor Author

Ok, thanks for explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants