From 4330d39c35cc44ab1fa5b1e6e1a35207c0635217 Mon Sep 17 00:00:00 2001 From: Evgeniy Alexeev Date: Wed, 12 Oct 2022 13:16:49 +0500 Subject: Add server commands Squashed commit of the following: commit 4ca788c95231709813bbe99220f93b4ef3e9c4ef Author: Evgeniy Alexeev Date: Wed Oct 12 12:19:45 2022 +0500 Add host boot commands, pooulate variant functions commit 21c36beefd0304a600a2f781a60559f647d569fb Author: Evgeniy Alexeev Date: Mon Oct 10 19:07:45 2022 +0500 Begin to add variant type commit b6f6416fa4dfbff9c677c4491fb42c5d3adb9d44 Author: Evgeniy Alexeev Date: Mon Oct 10 14:04:30 2022 +0500 Modify status commands in server commit 72405cee84fbddb8866a8a3d96350010266fc137 Author: Evgeniy Alexeev Date: Mon Oct 10 13:35:37 2022 +0500 Add power&policy status, get sdbus property func commit 81f88de144d6803bf4d53986193bf342772367eb Author: ironcaterpillar Date: Sat Oct 8 13:42:22 2022 +0500 Refactor d_bus_commands to separate file commit 224e5b8317e7e3ffbb04ada342447bf678297002 Author: Evgeniy Alexeev Date: Fri Oct 7 19:18:14 2022 +0500 Add power policy commands, refactor commit 94427ebcf778a2c0cc148c0344002491abdb052c Author: Evgeniy Alexeev Date: Thu Oct 6 18:23:42 2022 +0500 Add server power commands help commit 6888ffd32af65cb984792a47f65983207c00467e Author: Evgeniy Alexeev Date: Thu Oct 6 17:31:26 2022 +0500 Add unknown power command error message commit 5d1b4a2000820de903f10959b499c758eba383e0 Author: Evgeniy Alexeev Date: Thu Oct 6 15:54:37 2022 +0500 Fix host power dbus property name commit 49f8a15abdfb749427bd5769725b3ad54dc0583b Author: Evgeniy Alexeev Date: Thu Oct 6 13:27:37 2022 +0500 Add .gitignore commit 96569d5f9c7f245fd82545919a1910828c1058d9 Author: Evgeniy Alexeev Date: Thu Oct 6 13:27:10 2022 +0500 Add sdbus, server power commands --- src/main.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index e186215..bef33f5 100644 --- a/src/main.c +++ b/src/main.c @@ -20,6 +20,9 @@ #include #include +#include +#include + char *progname; /* The name of this program, as taken from argv[0]. */ int done; /* When non-zero, this global means the user is done using this program. */ @@ -31,15 +34,18 @@ static sigset_t blockmask; COMMAND top_admin_list[] = { { "help", com_help, "Display this text" }, { "?", com_help, "Synonym for `help'" }, + { "server", com_server, "Server commands" }, { "shell", com_shell, "Activate submenu shell" }, { "users", com_users, "Activate submenu users" }, { "quit", com_quit, "Quit using SILA Shell" }, + { (char *)NULL, (rl_icpfunc_t *)NULL, (char *)NULL } }; COMMAND top_operator_list[] = { { "help", com_help, "Display this text" }, { "?", com_help, "Synonym for `help'" }, + { "server", com_server, "Server commands" }, { "shell", com_shell, "Activate submenu shell" }, { "users", com_users, "Activate submenu users" }, { "quit", com_quit, "Quit using SILA Shell" }, @@ -49,6 +55,7 @@ COMMAND top_operator_list[] = { COMMAND top_user_list[] = { { "help", com_help, "Display this text" }, { "?", com_help, "Synonym for `help'" }, + { "server", com_server, "Server commands" }, { "shell", com_shell, "Activate submenu shell" }, { "users", com_users, "Activate submenu users" }, { "quit", com_quit, "Quit using SILA Shell" }, @@ -151,6 +158,42 @@ COMMAND users_user_list[] = { COMMAND_LIST users; +COMMAND server_admin_list[] = { + { "help", com_help, "Display this text" }, + { "?", com_help, "Synonym for `help'" }, + { "power", com_power, "Return to top menu" }, + { "restore-policy", com_power_policy, "Set power restore policy" }, + { "boot", com_boot, "Set host boot options" }, + { "..", com_top, "Return to top menu" }, + { "quit", com_quit, "Quit using SILA Shell" }, + { (char *)NULL, (rl_icpfunc_t *)NULL, (char *)NULL } +}; + +COMMAND server_operator_list[] = { + { "help", com_help, "Display this text" }, + { "?", com_help, "Synonym for `help'" }, + { "power", com_power, "Run on/off/reset" }, + { "restore-policy", com_power_policy, "Set power restore policy" }, + { "boot", com_boot, "Set host boot options" }, + { "..", com_top, "Return to top menu" }, + { "quit", com_quit, "Quit using SILA Shell" }, + { (char *)NULL, (rl_icpfunc_t *)NULL, (char *)NULL } +}; + +COMMAND server_user_list[] = { + { "help", com_help, "Display this text" }, + { "?", com_help, "Synonym for `help'" }, + { "power", com_power, "Return to top menu" }, + { "restore-policy", com_power_policy, "Set power restore policy" }, + { "boot", com_boot, "Set host boot options" }, + { "..", com_top, "Return to top menu" }, + { "quit", com_quit, "Quit using SILA Shell" }, + { (char *)NULL, (rl_icpfunc_t *)NULL, (char *)NULL } +}; + + +COMMAND_LIST server = {"server", NULL}; + COMMAND_LIST *current; @@ -235,24 +278,28 @@ void cmd_lists_init( gid_t gid ) top.name = "top"; shell.name = "shell"; users.name = "users"; + server.name = "server"; if( privileges == ADMIN || gid == 0 ) { top.list = &top_admin_list[0]; shell.list = &shell_admin_list[0]; users.list = &users_admin_list[0]; + server.list = &server_admin_list[0]; } else if( privileges == OPERATOR ) { top.list = &top_operator_list[0]; shell.list = &shell_operator_list[0]; users.list = &users_operator_list[0]; + server.list = &server_operator_list[0]; } else { top.list = &top_user_list[0]; shell.list = &shell_user_list[0]; users.list = &users_user_list[0]; + server.list = &server_user_list[0]; } current = ⊤ -- cgit v1.2.3