Skip to content

Commit 532fc2d

Browse files
authored
Merge pull request #101 from jestabro/vyconf-cli
T7374: allow use of exisiting vyconf replacements for my_* commands
2 parents 7f3f67a + 7b23855 commit 532fc2d

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

functions/interpreter/vyatta-cfg-run

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,17 @@ vyatta_config_show ()
103103

104104
vyatta_config_commit ()
105105
{
106-
if ! vyatta_cli_shell_api sessionChanged; then
107-
echo "No configuration changes to commit"
108-
return 1;
106+
if test -f "/var/run/vyconf_backend"; then
107+
echo $$
108+
if ! /usr/libexec/vyos/vyconf/bin/vy_session_changed; then
109+
echo "No configuration changes to commit"
110+
return 1;
111+
fi
112+
else
113+
if ! vyatta_cli_shell_api sessionChanged; then
114+
echo "No configuration changes to commit"
115+
return 1;
116+
fi
109117
fi
110118
local comment="commit"
111119
local next=0
@@ -126,16 +134,28 @@ vyatta_config_commit ()
126134

127135
export COMMIT_COMMENT="$comment"
128136
export COMMIT_VIA=cli
129-
/opt/vyatta/sbin/my_commit "${args[@]}" 2>&1
137+
if test -f "/var/run/vyconf_backend"; then
138+
/usr/libexec/vyos/vyconf/bin/vy_commit "${args[@]}" 2>&1
139+
else
140+
/opt/vyatta/sbin/my_commit "${args[@]}" 2>&1
141+
fi
130142
unset COMMIT_VIA
131143
unset COMMIT_COMMENT
132144
}
133145

134146
vyatta_config_commit-confirm ()
135147
{
136-
if ! vyatta_cli_shell_api sessionChanged; then
137-
echo "No configuration changes to commit"
138-
return 1;
148+
if test -f "/var/run/vyconf_backend"; then
149+
echo $$
150+
if ! /usr/libexec/vyos/vyconf/bin/vy_session_changed; then
151+
echo "No configuration changes to commit"
152+
return 1;
153+
fi
154+
else
155+
if ! vyatta_cli_shell_api sessionChanged; then
156+
echo "No configuration changes to commit"
157+
return 1;
158+
fi
139159
fi
140160
local -a args=()
141161
local first=1
@@ -358,7 +378,11 @@ vyatta_cfg_cmd_run ()
358378
elif [[ "$cmd" == "show" ]]; then
359379
vyatta_config_show "${@:2}"
360380
else
361-
cmd="/opt/vyatta/sbin/my_$cmd"
381+
if test -f "/var/run/vyconf_backend"; then
382+
cmd="${vyconf_bin_dir}/vy_$cmd"
383+
else
384+
cmd="/opt/vyatta/sbin/my_$cmd"
385+
fi
362386
output=$($cmd "${@:2}")
363387
fi
364388
vyatta_cfg_print_output "$output"

0 commit comments

Comments
 (0)