Commit a268d82d authored by Adam Wujek's avatar Adam Wujek 💬

[FEATURE: 1583] disable web interface via dot-config

Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 74a34027
...@@ -920,6 +920,12 @@ config CUSTOM_BOOT_SCRIPT_SOURCE_REMOTE_URL ...@@ -920,6 +920,12 @@ config CUSTOM_BOOT_SCRIPT_SOURCE_REMOTE_URL
endmenu endmenu
config HTTPD_DISABLE
bool "Disable web interface"
default n
help
Disable web interface.
menu "Developer options" menu "Developer options"
config MONIT_DISABLE config MONIT_DISABLE
bool "Disable monit" bool "Disable monit"
......
...@@ -926,6 +926,9 @@ appropriate way, before the respective service is started. ...@@ -926,6 +926,9 @@ appropriate way, before the respective service is started.
up a batch of switches with different configurations (similar to the up a batch of switches with different configurations (similar to the
@t{CONFIG_DOTCONF_URL}, please refer to @ref{The Configuration File}). @t{CONFIG_DOTCONF_URL}, please refer to @ref{The Configuration File}).
@item CONFIG_HTTPD_DISABLE
Disable web interface on a switch.
@item CONFIG_MONIT_DISABLE @item CONFIG_MONIT_DISABLE
Disable monitoring of running processes by @i{Monit}. @i{Monit} by Disable monitoring of running processes by @i{Monit}. @i{Monit} by
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
# #
# Starts lighttpd daemon. # Starts lighttpd daemon.
# #
MONIT=/usr/bin/monit
dotconfig=/wr/etc/dot-config
start_counter() { start_counter() {
# increase boot counter # increase boot counter
...@@ -17,6 +20,25 @@ start_counter() { ...@@ -17,6 +20,25 @@ start_counter() {
start() { start() {
echo -n "Starting lighttpd daemon: " echo -n "Starting lighttpd daemon: "
if [ -f $dotconfig ]; then
. $dotconfig
else
echo "$0 unable to source dot-config ($dotconfig)!"
fi
if [ "$CONFIG_HTTPD_DISABLE" = "y" ]; then
echo "web interface disabled in dot-config!"
if [ "$1" != "force" ]; then
# Unmonitor web server (lighttpd), ignore all printouts
# from monit.
# Run in background since monit may wait for a timeout.
$MONIT unmonitor lighttpd &>/dev/null &
exit 0
fi
echo -n "Force start of lighttpd: "
fi
# note start-stop-daemon does not create pidfile, only check if pid is # note start-stop-daemon does not create pidfile, only check if pid is
# running # running
start-stop-daemon -q -p /var/run/lighttpd.pid -S \ start-stop-daemon -q -p /var/run/lighttpd.pid -S \
...@@ -30,6 +52,15 @@ start() { ...@@ -30,6 +52,15 @@ start() {
else else
echo "Failed" echo "Failed"
fi fi
# check whether the process was monitored
$MONIT summary 2>&1 | grep lighttpd | grep "Not monitored" &> /dev/null
if [ $? -eq 0 ]; then
echo "web interface was not monitored, enabling monitoring"
# the process was not monitored, enable monitoring
# this will generate extra log entries from monit
$MONIT monitor lighttpd
fi
} }
stop() { stop() {
...@@ -60,7 +91,8 @@ case "$1" in ...@@ -60,7 +91,8 @@ case "$1" in
restart restart
;; ;;
*) *)
echo $"Usage: $0 {start|stop|restart}" echo "Usage: $0 {start <force>|stop|restart}"
echo " start force -- enable web interface even it is disabled in the dot-config"
exit 1 exit 1
esac esac
......
...@@ -93,6 +93,7 @@ struct wrs_usd_item { ...@@ -93,6 +93,7 @@ struct wrs_usd_item {
uint32_t cnt; /* number of processes found */ uint32_t cnt; /* number of processes found */
}; };
#define UDI_HTTP 4 /* index of web server in userspace_daemons array */
#define UDI_MONIT 5 /* index of MONIT in userspace_daemons array */ #define UDI_MONIT 5 /* index of MONIT in userspace_daemons array */
/* user space daemon list */ /* user space daemon list */
/* - key contain process name reported by ps command /* - key contain process name reported by ps command
...@@ -107,7 +108,8 @@ static struct wrs_usd_item userspace_daemons[] = { ...@@ -107,7 +108,8 @@ static struct wrs_usd_item userspace_daemons[] = {
[1] = {"/wr/bin/wrsw_hal", 2}, /* two wrsw_hal instances */ [1] = {"/wr/bin/wrsw_hal", 2}, /* two wrsw_hal instances */
[2] = {"/wr/bin/wrsw_rtud", 1}, [2] = {"/wr/bin/wrsw_rtud", 1},
[3] = {"/wr/bin/ppsi", 1}, [3] = {"/wr/bin/ppsi", 1},
[4] = {"/usr/sbin/lighttpd", 1}, [UDI_HTTP] = {"/usr/sbin/lighttpd", 1}, /* web interface can be
* disabled in dot-config */
[UDI_MONIT] = {"/usr/bin/monit", 1}, /* Monit can be disabled in [UDI_MONIT] = {"/usr/bin/monit", 1}, /* Monit can be disabled in
* dot-config */ * dot-config */
[6] = {"/usr/sbin/snmpd", 1}, [6] = {"/usr/sbin/snmpd", 1},
...@@ -475,6 +477,14 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array) ...@@ -475,6 +477,14 @@ static void update_daemon_expectancy(struct wrs_usd_item *daemon_array)
snmp_log(LOG_INFO, "SNMP: Info wrsBootUserspaceDaemonsMissing:" snmp_log(LOG_INFO, "SNMP: Info wrsBootUserspaceDaemonsMissing:"
" CONFIG_MONIT_DISABLE=y in dot-config\n"); " CONFIG_MONIT_DISABLE=y in dot-config\n");
} }
tmp = libwr_cfg_get("HTTPD_DISABLE");
if (tmp && !strcmp(tmp, "y")) {
/* SNMP should not expect lighttpd (web server) to be running*/
daemon_array[UDI_HTTP].exp = 0;
snmp_log(LOG_INFO, "SNMP: Info wrsBootUserspaceDaemonsMissing:"
" CONFIG_HTTPD_DISABLE=y in dot-config\n");
}
} }
/* check if daemons from userspace_daemons array are running */ /* check if daemons from userspace_daemons array are running */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment