summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src/mobile/vty_interface.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-11-08 14:59:06 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-12-03 12:58:53 +0000
commit4080e622b7661c0f2305c3d4d84021a456a76ceb (patch)
treee4217e1c22b42af4fbc90c00e56b49272122deae /src/host/layer23/src/mobile/vty_interface.c
parent32dec4236e5bf3753bd84715d5e099272ea5d481 (diff)
mobile: Add initial support for scripting support
Right now the script will be executed once it is loaded. Make sure to write it into the config file last. Expose various log commands for logging. Jump through some hoops and get the filename and line number from lua. Change-Id: I456f6b6b5e1a14ed6c8cb0dcc5140093d3c61ef6
Diffstat (limited to 'src/host/layer23/src/mobile/vty_interface.c')
-rw-r--r--src/host/layer23/src/mobile/vty_interface.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c
index 81c20fe9..87679855 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -1531,6 +1531,8 @@ static void config_write_ms(struct vty *vty, struct osmocom_ms *ms)
/* no shutdown must be written to config, because shutdown is default */
vty_out(vty, " %sshutdown%s", (ms->shutdown != MS_SHUTDOWN_NONE) ? "" : "no ",
VTY_NEWLINE);
+ if (ms->lua_script)
+ vty_out(vty, " lua-script %s%s", ms->lua_script, VTY_NEWLINE);
vty_out(vty, "!%s", VTY_NEWLINE);
}
@@ -2740,6 +2742,30 @@ DEFUN(cfg_shutdown_force, cfg_ms_shutdown_force_cmd, "shutdown force",
return CMD_SUCCESS;
}
+DEFUN(cfg_ms_script_load_run, cfg_ms_script_load_run_cmd, "lua-script FILENAME",
+ "Load and execute a LUA script\nFilename for lua script")
+{
+ struct osmocom_ms *ms = vty->index;
+
+ osmo_talloc_replace_string(ms, &ms->lua_script, argv[0]);
+ if (!ms->lua_script)
+ return CMD_WARNING;
+
+ script_lua_load(vty, ms, ms->lua_script);
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_ms_no_script_load_run, cfg_ms_no_script_load_run_cmd, "no lua-script",
+ NO_STR "Load and execute LUA script")
+{
+ struct osmocom_ms *ms = vty->index;
+
+ script_lua_close(ms);
+ talloc_free(ms->lua_script);
+ ms->lua_script = NULL;
+ return CMD_SUCCESS;
+}
+
int ms_vty_go_parent(struct vty *vty)
{
switch (vty->node) {
@@ -2931,6 +2957,8 @@ int ms_vty_init(void)
install_element(MS_NODE, &cfg_ms_shutdown_cmd);
install_element(MS_NODE, &cfg_ms_shutdown_force_cmd);
install_element(MS_NODE, &cfg_ms_no_shutdown_cmd);
+ install_element(MS_NODE, &cfg_ms_script_load_run_cmd);
+ install_element(MS_NODE, &cfg_ms_no_script_load_run_cmd);
/* Register the talloc context introspection command */
osmo_talloc_vty_add_cmds();