summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rwxr-xr-xscripts/vyatta-exists14
-rw-r--r--src/cli_shell_api.cpp26
3 files changed, 26 insertions, 15 deletions
diff --git a/Makefile.am b/Makefile.am
index 7c93743..a424d2f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -78,7 +78,6 @@ sbin_SCRIPTS += scripts/vyatta-cfg-notify
sbin_SCRIPTS += scripts/vyatta-irqaffin
sbin_SCRIPTS += scripts/vyatta-auto-irqaffin.pl
sbin_SCRIPTS += scripts/vyatta-check-typeless-node.pl
-sbin_SCRIPTS += scripts/vyatta-exists
sbin_SCRIPTS += scripts/vyatta-strip-migration-comments.pl
share_perl5_DATA = lib/Vyatta/Config.pm
diff --git a/scripts/vyatta-exists b/scripts/vyatta-exists
deleted file mode 100755
index ef2dea3..0000000
--- a/scripts/vyatta-exists
+++ /dev/null
@@ -1,14 +0,0 @@
-#! /bin/bash
-
-# Test if given node exists in Vyatta config hierarchy
-#
-# if vyatta-exists interfaces wireless
-
-if [ -z "$VYATTA_TEMP_CONFIG_DIR" ]; then
- echo "$0: not in configuration mode" 1>&2;
- exit 1;
-fi
-IFS=/
-node=$*
-IFS=
-exec test -d $VYATTA_TEMP_CONFIG_DIR/$node
diff --git a/src/cli_shell_api.cpp b/src/cli_shell_api.cpp
index 22a5cad..d863025 100644
--- a/src/cli_shell_api.cpp
+++ b/src/cli_shell_api.cpp
@@ -41,6 +41,8 @@ static const char *op_name[] = {
"teardownSession",
"setupSession",
"inSession",
+ "exists",
+ "existsActive",
NULL
};
static const int op_exact_args[] = {
@@ -58,6 +60,8 @@ static const int op_exact_args[] = {
0,
0,
0,
+ -1,
+ -1,
-1
};
static const char *op_exact_error[] = {
@@ -75,6 +79,8 @@ static const char *op_exact_error[] = {
"No argument expected",
"No argument expected",
"No argument expected",
+ NULL,
+ NULL,
NULL
};
static const int op_min_args[] = {
@@ -92,6 +98,8 @@ static const int op_min_args[] = {
-1,
-1,
-1,
+ 1,
+ 1,
-1
};
static const char *op_min_error[] = {
@@ -109,6 +117,8 @@ static const char *op_min_error[] = {
NULL,
NULL,
NULL,
+ "Must specify config path",
+ "Must specify config path",
NULL
};
#define OP_exact_args op_exact_args[op_idx]
@@ -254,6 +264,20 @@ doInSession(const vector<string>& args)
}
}
+static void
+doExists(const vector<string>& args)
+{
+ UnionfsCstore cstore(true);
+ exit(cstore.cfgPathExists(args, false) ? 0 : 1);
+}
+
+static void
+doExistsActive(const vector<string>& args)
+{
+ UnionfsCstore cstore(true);
+ exit(cstore.cfgPathExists(args, true) ? 0 : 1);
+}
+
typedef void (*OpFuncT)(const vector<string>& args);
OpFuncT OpFunc[] = {
&doGetSessionEnv,
@@ -270,6 +294,8 @@ OpFuncT OpFunc[] = {
&doTeardownSession,
&doSetupSession,
&doInSession,
+ &doExists,
+ &doExistsActive,
NULL
};