mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 04:33:00 +02:00
committed by
Joachim Wiberg
parent
d66740250c
commit
f224d0d03d
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
Q=$@
|
||||
|
||||
echo "$Q, are you sure? (y/N)"
|
||||
read -n1 yorn
|
||||
|
||||
if [ x$yorn != "xy" ]; then
|
||||
echo "Ok, aborting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
@@ -28,6 +28,7 @@ confd_plugin_la_SOURCES = \
|
||||
dagger.c dagger.h \
|
||||
ietf-interfaces.c \
|
||||
ietf-system.c \
|
||||
ietf-factory-default.c \
|
||||
infix-dhcp.c \
|
||||
infix-services.c \
|
||||
infix-factory.c \
|
||||
|
||||
@@ -116,6 +116,9 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **priv)
|
||||
rc = infix_factory_init(&confd);
|
||||
if (rc)
|
||||
goto err;
|
||||
rc = ietf_factory_default_init(&confd);
|
||||
if(rc)
|
||||
goto err;
|
||||
rc = infix_system_sw_init(&confd);
|
||||
if (rc)
|
||||
goto err;
|
||||
|
||||
@@ -132,6 +132,9 @@ int ietf_system_init(struct confd *confd);
|
||||
/* infix-dhcp.c */
|
||||
int infix_dhcp_init(struct confd *confd);
|
||||
|
||||
/* ietf-factory-default */
|
||||
int ietf_factory_default_init(struct confd *confd);
|
||||
|
||||
/* infix-factory.c */
|
||||
int infix_factory_init(struct confd *confd);
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include "core.h"
|
||||
|
||||
static int factory_reset(sr_session_ctx_t *session, uint32_t sub_id, const char *xpath,
|
||||
const sr_val_t *input, const size_t input_cnt, sr_event_t event,
|
||||
unsigned request_id, sr_val_t **output, size_t *output_cnt, void *priv)
|
||||
{
|
||||
DEBUG("%s", xpath);
|
||||
return systemf("factory -y");
|
||||
}
|
||||
|
||||
int ietf_factory_default_init(struct confd *confd)
|
||||
{
|
||||
int rc;
|
||||
|
||||
REGISTER_RPC(confd->session, "/ietf-factory-default:factory-reset", factory_reset, NULL, &confd->fsub);
|
||||
return SR_ERR_OK;
|
||||
fail:
|
||||
ERROR("failed: %s", sr_strerror(rc));
|
||||
return rc;
|
||||
}
|
||||
@@ -305,6 +305,11 @@
|
||||
<ACTION sym="script">jq -C . /cfg/startup-config.cfg</ACTION>
|
||||
</COMMAND>
|
||||
</COMMAND>
|
||||
<COMMAND name="factory-reset" help="Restore the system to factory state">
|
||||
<ACTION sym="script" interactive="true">/bin/yorn "This will restore the device to factory state"</ACTION>
|
||||
<ACTION sym="rpc@infix">/ietf-factory-default:factory-reset</ACTION>
|
||||
</COMMAND>
|
||||
|
||||
|
||||
<COMMAND name="follow" help="Monitor a log file, use Ctrl-C to abort">
|
||||
<PARAM name="fn" ptype="/LOGFILES" help="Optional log file to monitor, default: syslog"/>
|
||||
|
||||
Reference in New Issue
Block a user