mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 12:33:02 +02:00
cli: fix copy to missing startup-config file
Fixes #981 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+20
-4
@@ -286,10 +286,18 @@ static int copy(const char *src, const char *dst, const char *remote_user)
|
|||||||
} else {
|
} else {
|
||||||
/* Direct copy for other datastores (no callbacks needed) */
|
/* Direct copy for other datastores (no callbacks needed) */
|
||||||
rc = sr_copy_config(sess, NULL, srcds->datastore, timeout * 1000);
|
rc = sr_copy_config(sess, NULL, srcds->datastore, timeout * 1000);
|
||||||
if (rc)
|
if (rc) {
|
||||||
emsg(sess, ERRMSG "unable to copy configuration, err %d: %s\n", rc, sr_strerror(rc));
|
emsg(sess, ERRMSG "unable to copy configuration, err %d: %s\n", rc, sr_strerror(rc));
|
||||||
else
|
} else {
|
||||||
set_owner(dstds->path, user);
|
/* Export datastore to backing file if it has one */
|
||||||
|
if (dstds->path) {
|
||||||
|
rc = systemf("sysrepocfg -d %s -X%s -f json", dstds->sysrepocfg, dstds->path);
|
||||||
|
if (rc)
|
||||||
|
fprintf(stderr, ERRMSG "failed saving %s to %s\n", srcds->name, dstds->path);
|
||||||
|
else
|
||||||
|
set_owner(dstds->path, user);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rc = sr_disconnect(conn);
|
rc = sr_disconnect(conn);
|
||||||
@@ -397,7 +405,15 @@ static int copy(const char *src, const char *dst, const char *remote_user)
|
|||||||
} else {
|
} else {
|
||||||
rc = systemf("sysrepocfg -d %s -I%s -f json", dstds->sysrepocfg, fn);
|
rc = systemf("sysrepocfg -d %s -I%s -f json", dstds->sysrepocfg, fn);
|
||||||
if (rc)
|
if (rc)
|
||||||
fprintf(stderr, ERRMSG "failed loading %s from %s", dst, src);
|
fprintf(stderr, ERRMSG "failed loading %s from %s\n", dst, src);
|
||||||
|
else if (dstds->path) {
|
||||||
|
rc = systemf("sysrepocfg -d %s -X%s -f json", dstds->sysrepocfg, dstds->path);
|
||||||
|
if (rc)
|
||||||
|
fprintf(stderr, ERRMSG "failed saving %s\n", dstds->path);
|
||||||
|
else
|
||||||
|
set_owner(dstds->path, user);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user