From 13ea0c85cfe0c7b9880d5ddf2abe6409cedf9f22 Mon Sep 17 00:00:00 2001 From: kx Date: Wed, 28 Sep 2022 19:18:07 +0300 Subject: Poweroff command for admin user --- src/main.c | 1 + src/shell.c | 9 +++++++++ src/shell.h | 1 + 3 files changed, 11 insertions(+) diff --git a/src/main.c b/src/main.c index d00230e..19474de 100644 --- a/src/main.c +++ b/src/main.c @@ -71,6 +71,7 @@ COMMAND shell_admin_list[] = { { "stat", com_stat, "Print out statistics on FILE" }, { "more", com_more, "View the contents of FILE" }, { "vi", com_vi, "Edit the contents of text FILE" }, + { "poweroff", com_poweroff, "Turn off the BMC power" }, { "..", com_top, "Return to top menu" }, { (char *)NULL, (rl_icpfunc_t *)NULL, (char *)NULL } }; diff --git a/src/shell.c b/src/shell.c index ade4d53..c5b8332 100644 --- a/src/shell.c +++ b/src/shell.c @@ -150,3 +150,12 @@ int com_ping( char *arg ) sprintf( syscom, "ping %s", arg ); return( system( syscom ) ); } + +int com_poweroff( char *arg ) +{ + if( !arg ) + arg = ""; + + sprintf( syscom, "poweroff %s", arg ); + return( system( syscom ) ); +} diff --git a/src/shell.h b/src/shell.h index 15b4278..c43f8bb 100644 --- a/src/shell.h +++ b/src/shell.h @@ -18,6 +18,7 @@ extern int com_delete( char *arg ); extern int com_cd( char *arg ); extern int com_ping( char *arg ); extern int com_pwd( char *ignore ); +extern int com_poweroff( char *arg ); -- cgit v1.2.3