From ff0cb79b1774cc85cc0acc0091011afae76d8190 Mon Sep 17 00:00:00 2001 From: marschap Date: Sat, 15 Apr 2006 19:48:11 +0000 Subject: [PATCH] let lcdproc & lcdexec have their own private config file; install server & client config files to $(sysconfdir) (using automake features) --- ChangeLog | 3 ++ Makefile.am | 5 ++- clients/examples/Makefile.am | 2 +- clients/headlines/Makefile.am | 2 +- clients/lcdexec/Makefile.am | 7 ++++- clients/lcdexec/lcdexec.c | 7 ++++- clients/lcdexec/lcdexec.conf | 57 +++++++++++++++++++++++++++++++++++ clients/lcdproc/Makefile.am | 7 ++++- clients/lcdproc/main.c | 20 +++++++----- clients/metar/Makefile.am | 2 +- docs/lcdexec.1 | 6 ++-- server/Makefile.am | 2 +- server/main.c | 6 +++- 13 files changed, 107 insertions(+), 19 deletions(-) create mode 100644 clients/lcdexec/lcdexec.conf diff --git a/ChangeLog b/ChangeLog index 243c2d4..35a4f2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ Key: * Something changed / fixed v.0.5dev (ongoing development) + + config file support in lcdproc client (thanks Andrew Foss) + * install server & client config files n $(sysconfdir) + v0.5.0 This version has split off from unstable-0.4.3. Includes major changes. diff --git a/Makefile.am b/Makefile.am index 3f47f3c..c3afee1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,10 @@ AUTOMAKE_OPTIONS = foreign SUBDIRS = shared clients server docs scripts -EXTRA_DIST = LCDd.conf LCDclients.conf CREDITS README.IRman contrib +sysconf_DATA = LCDd.conf + +EXTRA_DIST = $(sysconf_DATA) CREDITS README.IRman contrib + dox: $(MAKE) -C docs $@ diff --git a/clients/examples/Makefile.am b/clients/examples/Makefile.am index d99633f..448fa43 100644 --- a/clients/examples/Makefile.am +++ b/clients/examples/Makefile.am @@ -2,6 +2,6 @@ bin_SCRIPTS = fortune.pl iosock.pl tail.pl x11amp.pl -EXTRA_DIST = fortune.pl iosock.pl tail.pl x11amp.pl +EXTRA_DIST = $(bin_SCRIPTS) ## EOF diff --git a/clients/headlines/Makefile.am b/clients/headlines/Makefile.am index d1107f7..f06d01d 100644 --- a/clients/headlines/Makefile.am +++ b/clients/headlines/Makefile.am @@ -2,6 +2,6 @@ bin_SCRIPTS = lcdheadlines -EXTRA_DIST = lcdheadlines +EXTRA_DIST = $(bin_SCRIPTS) ## EOF diff --git a/clients/lcdexec/Makefile.am b/clients/lcdexec/Makefile.am index 6228c06..3cfb08f 100644 --- a/clients/lcdexec/Makefile.am +++ b/clients/lcdexec/Makefile.am @@ -1,11 +1,16 @@ ## Process this file with automake to produce Makefile.in +sysconf_DATA = lcdexec.conf + bin_PROGRAMS = lcdexec lcdexec_SOURCES = lcdexec.c menu.c menu.h lcdexec_LDADD = @ldap_libs@ ../../shared/libLCDstuff.a -AM_CPPFLAGS = -I$(top_srcdir) +AM_CPPFLAGS = -I$(top_srcdir) -DSYSCONFDIR=\"$(sysconfdir)\" + + +EXTRA_DIST = $(sysconf_DATA) ## EOF diff --git a/clients/lcdexec/lcdexec.c b/clients/lcdexec/lcdexec.c index e31d17b..46b4dee 100644 --- a/clients/lcdexec/lcdexec.c +++ b/clients/lcdexec/lcdexec.c @@ -33,7 +33,12 @@ #include "menu.h" -#define DEFAULT_CONFIGFILE "/etc/LCDclients.conf" +#if !defined(SYSCONFDIR) +# define SYSCONFDIR "/etc" +#endif + +#define DEFAULT_CONFIGFILE SYSCONFDIR "/lcdexec.conf" + char * help_text = "lcdexec - LCDproc client to execute commands from the LCDd menu.\n" diff --git a/clients/lcdexec/lcdexec.conf b/clients/lcdexec/lcdexec.conf new file mode 100644 index 0000000..ac2f3e5 --- /dev/null +++ b/clients/lcdexec/lcdexec.conf @@ -0,0 +1,57 @@ +# lcdexec LCDproc client configuration file + +## general options for lcdexec ## +[lcdexec] +# address of the LCDd server to connect to +Address=localhost + +# Port of the server to connect to +Port=13666 + +# set reporting level +ReportLevel=2 + +# report to to syslog ? +ReportToSyslog=false + +# stay in foreground ? +Foreground=false + +# menu commands for the main menu +# format: , +MenuCommand="You can say A, echo A" +MenuCommand="Or you can say B, echo B" + +# sub menu for the main menu +# format: , +SubMenu="A menu, menu1" + +# sub menu commands +# option names must start with the name of a defined menu +# format: see menu commands +menu1_MenuCommand="p, echo P" +menu1_MenuCommand="q, echo Q" + + +# Ideally lcdexec should be re-written so that menu definitions +# look somewhat like: +# +#[Menu] +#Type=Menu +#Entry=SubMenu1 +#Entry=SubMenu2 +# +#[SubMenu1] +#Type=Action +#Exec=/bin/program to execute with parameters +# +#[SubMenu2] +#Type=Action +#Exec=/bin/otherprogram with parameters +# +# Further Extensions: +# - use input for parameters e.g. IP-Adresses, Sliders +# - display result if a command on Screen +# - jump to other menus depending on the output/result of a command + +# EOF diff --git a/clients/lcdproc/Makefile.am b/clients/lcdproc/Makefile.am index 7835e2f..b0379bc 100644 --- a/clients/lcdproc/Makefile.am +++ b/clients/lcdproc/Makefile.am @@ -1,5 +1,7 @@ ## Process this file with automake to produce Makefile.in +sysconf_DATA = lcdproc.conf + bin_PROGRAMS = lcdproc lcdproc_SOURCES = main.c main.h mode.c mode.h batt.c batt.h chrono.c chrono.h cpu.c cpu.h cpu_smp.c cpu_smp.h disk.c disk.h load.c load.h mem.c mem.h machine.h machine_Linux.c machine_OpenBSD.c machine_FreeBSD.c machine_NetBSD.c machine_Darwin.c machine_SunOS.c util.c util.h @@ -10,6 +12,9 @@ if DARWIN AM_LDFLAGS = -framework CoreFoundation -framework IOKit endif -AM_CPPFLAGS = -I$(top_srcdir) +AM_CPPFLAGS = -I$(top_srcdir) -DSYSCONFDIR=\"$(sysconfdir)\" + + +EXTRA_DIST = $(sysconf_DATA) ## EOF diff --git a/clients/lcdproc/main.c b/clients/lcdproc/main.c index 60156e5..4fa2393 100644 --- a/clients/lcdproc/main.c +++ b/clients/lcdproc/main.c @@ -57,14 +57,24 @@ static void exit_program(int val); static void main_loop(); static int process_command_line(int argc, char **argv); static int process_configfile(char *cfgfile); + + #define CHAIN(e,f) { if (e>=0 ) { e=(f); }} #define CHAIN_END(e,msg) { if (e<0 ) { report( RPT_CRIT,(msg)); exit(e); }} -static int islow = -1; - // 1/8th second is a single time unit... #define TIME_UNIT 125000 +#if !defined(SYSCONFDIR) +# define SYSCONFDIR "/etc" +#endif + +#define UNSET_INT -1 +#define UNSET_STR "\01" +#define DEFAULT_SERVER "127.0.0.1" +#define DEFAULT_CONFIGFILE SYSCONFDIR "/lcdproc.conf" + + /* list of modes to run */ mode sequence[] = { @@ -89,12 +99,8 @@ mode sequence[] = -// TODO: Config file; not just command line /* All variables are set to 'unset' values*/ -#define UNSET_INT -1 -#define UNSET_STR "\01" -#define DEFAULT_SERVER "127.0.0.1" -#define DEFAULT_CONFIGFILE "/usr/local/etc/lcdproc.conf" +static int islow = -1; char * progname = "lcdproc"; char * server = NULL; int port = LCDPORT; diff --git a/clients/metar/Makefile.am b/clients/metar/Makefile.am index fbc23d6..edd0e4a 100644 --- a/clients/metar/Makefile.am +++ b/clients/metar/Makefile.am @@ -2,6 +2,6 @@ bin_SCRIPTS = lcdmetar.pl -EXTRA_DIST = lcdmetar.pl +EXTRA_DIST = $(bin_SCRIPTS) ## EOF diff --git a/docs/lcdexec.1 b/docs/lcdexec.1 index 14c06df..6d8ba1b 100644 --- a/docs/lcdexec.1 +++ b/docs/lcdexec.1 @@ -23,7 +23,7 @@ lcdexec connects to LCDd (the LCDproc server) and adds a submenu to the LCDd mai understands the following options, with corresponding configfile settings between {} brackets: .TP 8 .B \-c \fIfilename\fP -Set the name of the config file to read, /etc/LCDclients.conf by default +Set the name of the config file to read, /etc/lcdexec.conf by default .TP 8 .B \-a \fIaddress\fP Set the address of the host which LCDd is running on, localhost by default @@ -63,7 +63,7 @@ All configfile settings should be put in the [lcdexec] section. You can use a qu .SH FILES .TP -.B LCDclients.conf +.B lcdexec.conf This file should have a "ini-file"-like format, with sections that are preceded by a [section] header and lines that consist of key=value pairs. Strings with characters other than [a-za-Z0-9_] should be quoted with double quotes. If you want a quote or a backslash in the string, escape it by preceding it by a backslash. .TP The contents of the [lcdexec] section of this file should be as descriped in the options section. @@ -88,7 +88,7 @@ sd_MenuCommand="Reboot now, shutdown -r now" .PP Start lcdexec with: -lcdexec -c /usr/local/etc/LCDclients.conf +lcdexec -c /usr/local/etc/lcdexec.conf .PP This will allow you to eject the CD-ROM by opening the LCDd menu, selecting "lcdexec" and selecting "Eject CD-ROM". Further it allows you to do various shutdowns, among others the "Shutdown in 5 minutes" by opening the LCDd menu, selecting "lcdexec", selecting "Shutdown" and selecting "Shutdown in 5 minutes". diff --git a/server/Makefile.am b/server/Makefile.am index a8abb05..8684b55 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -12,6 +12,6 @@ if !DARWIN AM_LDFLAGS = -rdynamic -uget_args endif -AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -DSYSCONFDIR=\"$(sysconfdir)\" ## EOF diff --git a/server/main.c b/server/main.c index 2973a44..0a895c3 100644 --- a/server/main.c +++ b/server/main.c @@ -72,9 +72,13 @@ extern int optind, optopt, opterr; #include "main.h" +#if !defined(SYSCONFDIR) +# define SYSCONFDIR "/etc" +#endif + #define DEFAULT_BIND_ADDR "127.0.0.1" #define DEFAULT_BIND_PORT LCDPORT -#define DEFAULT_CONFIGFILE "/etc/LCDd.conf" +#define DEFAULT_CONFIGFILE SYSCONFDIR "/LCDd.conf" #define DEFAULT_USER "nobody" #define DEFAULT_DRIVER "curses" #define DEFAULT_DRIVER_PATH "" /* not needed */