From 61d4e2fc64793446c264c8e3697245688c83b34c Mon Sep 17 00:00:00 2001 From: Igor Socec Date: Tue, 10 Jan 2017 16:33:58 +0100 Subject: [PATCH 01/12] Start using Travis CI Add .travis.yml file and build status flag. --- .travis.yml | 7 +++++++ README.md | 2 ++ 2 files changed, 9 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..23135f1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: cpp + +compiler: +- gcc +- clang + +script: make diff --git a/README.md b/README.md index e3f8b1c..d4e5767 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/socec/moxanix.svg?branch=master)](https://travis-ci.org/socec/moxanix) + moxanix ======= From efc292af2cacdc3ad5aa6fcdc33d87e12bd082bf Mon Sep 17 00:00:00 2001 From: Igor Socec Date: Wed, 11 Jan 2017 17:30:13 +0100 Subject: [PATCH 02/12] Improve source tree --- .gitignore | 6 +-- Makefile | 52 +++++++++------------- moxanix.cfg => moxanix/moxanix.cfg | 0 moxanix.sh => moxanix/moxanix.sh | 0 moxerver/Makefile | 54 +++++++++++++++++++++++ client.c => moxerver/client.c | 0 client.h => moxerver/client.h | 0 common.h => moxerver/common.h | 0 moxerver.c => moxerver/moxerver.c | 0 server.c => moxerver/server.c | 0 server.h => moxerver/server.h | 0 task_threads.c => moxerver/task_threads.c | 0 task_threads.h => moxerver/task_threads.h | 0 telnet.c => moxerver/telnet.c | 0 telnet.h => moxerver/telnet.h | 0 tty.c => moxerver/tty.c | 0 tty.h => moxerver/tty.h | 0 17 files changed, 77 insertions(+), 35 deletions(-) rename moxanix.cfg => moxanix/moxanix.cfg (100%) rename moxanix.sh => moxanix/moxanix.sh (100%) create mode 100644 moxerver/Makefile rename client.c => moxerver/client.c (100%) rename client.h => moxerver/client.h (100%) rename common.h => moxerver/common.h (100%) rename moxerver.c => moxerver/moxerver.c (100%) rename server.c => moxerver/server.c (100%) rename server.h => moxerver/server.h (100%) rename task_threads.c => moxerver/task_threads.c (100%) rename task_threads.h => moxerver/task_threads.h (100%) rename telnet.c => moxerver/telnet.c (100%) rename telnet.h => moxerver/telnet.h (100%) rename tty.c => moxerver/tty.c (100%) rename tty.h => moxerver/tty.h (100%) diff --git a/.gitignore b/.gitignore index 709140d..93bbd66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ -# executables -moxerver - -# object files +# object files/output directories *.o +*.dir # logs directory during development logs diff --git a/Makefile b/Makefile index fa9aaef..5cf4626 100644 --- a/Makefile +++ b/Makefile @@ -1,43 +1,33 @@ -# target name -TARGET = moxerver +# components +MOXERVER = moxerver +MOXANIX = moxanix -# special include directories -INCDIRS = -I. -# special library directories -LIBDIRS = -L. -# used libraries -#LIBS = -lm -LIBS = -lpthread +# installation root +INSTALL_ROOT = ./install.dir -# compiler and flags -CC = gcc -CFLAGS = -Wall $(INCDIRS) $(LIBDIRS) $(LIBS) +# ============================================================================== -# objects are .o files created from all .c files in the directory (same name) -OBJECTS = $(patsubst %.c,%.o,$(wildcard *.c)) -# headers are all .h files in the directory -HEADERS = $(wildcard *.h) +MOXERVER_BUILDDIR = build.dir -# all objects are built from their .c files and all headers in the directory -%.o: %.c $(HEADERS) - $(CC) $(CFLAGS) -c $< -o $@ +# ============================================================================== -# target is built from all object files -$(TARGET): $(OBJECTS) - $(CC) $(OBJECTS) $(CFLAGS) -o $@ - - -# support for default, clean and all options +# supported make options (clean, install...) .PHONY: default all clean # all calls all other options all: default -# default builds target -default: $(TARGET) +# default builds moxerver +default: + cd $(MOXERVER) && make OUTDIR=$(MOXERVER_BUILDDIR) -# clean removed object files and target +# install handles moxerver and moxanix installation +install: default + mkdir -p $(INSTALL_ROOT) + cp $(MOXERVER)/$(MOXERVER_BUILDDIR)/$(MOXERVER) $(INSTALL_ROOT)/$(MOXERVER) + cp $(MOXANIX)/$(MOXANIX).* $(INSTALL_ROOT)/ + +# clean removes build and install results clean: - -rm -f *.o - -rm -f $(TARGET) - + cd $(MOXERVER) && make clean + -rm -rf $(INSTALL_ROOT) diff --git a/moxanix.cfg b/moxanix/moxanix.cfg similarity index 100% rename from moxanix.cfg rename to moxanix/moxanix.cfg diff --git a/moxanix.sh b/moxanix/moxanix.sh similarity index 100% rename from moxanix.sh rename to moxanix/moxanix.sh diff --git a/moxerver/Makefile b/moxerver/Makefile new file mode 100644 index 0000000..c798acb --- /dev/null +++ b/moxerver/Makefile @@ -0,0 +1,54 @@ +# target name +TARGET = moxerver + +# directory for build results +BUILDDIR = build.dir + +# ============================================================================== + +# add include directories +INCDIRS = -I. +# add library directories +LIBDIRS = -L. +# list used libraries +#LIBS = -lm +LIBS = -lpthread + +# ============================================================================== + +# compiler and flags +CC = gcc +CFLAGS = -Wall $(INCDIRS) $(LIBDIRS) $(LIBS) + +# ============================================================================== + +# build everything in a dedicated directory $(OUTDIR) + +# objects are .o files created from all .c files in the directory (same name) +OBJECTS = $(patsubst %.c, $(BUILDDIR)/%.o, $(wildcard *.c)) +# headers are all .h files in the directory +HEADERS = $(wildcard *.h) + +# all objects are built from their .c files in the directory +$(BUILDDIR)/%.o: %.c + mkdir -p $(BUILDDIR) + $(CC) $(CFLAGS) -c $< -o $@ + +# target is built from all object files +$(BUILDDIR)/$(TARGET): $(OBJECTS) + $(CC) $(OBJECTS) $(CFLAGS) -o $@ + +# ============================================================================== + +# supported make options (clean, install...) +.PHONY: default all clean + +# all calls all other options +all: default + +# default builds target +default: $(BUILDDIR)/$(TARGET) + +# clean removes object files and target (ignore errors with "-" before commands) +clean: + -rm -rf $(BUILDDIR) diff --git a/client.c b/moxerver/client.c similarity index 100% rename from client.c rename to moxerver/client.c diff --git a/client.h b/moxerver/client.h similarity index 100% rename from client.h rename to moxerver/client.h diff --git a/common.h b/moxerver/common.h similarity index 100% rename from common.h rename to moxerver/common.h diff --git a/moxerver.c b/moxerver/moxerver.c similarity index 100% rename from moxerver.c rename to moxerver/moxerver.c diff --git a/server.c b/moxerver/server.c similarity index 100% rename from server.c rename to moxerver/server.c diff --git a/server.h b/moxerver/server.h similarity index 100% rename from server.h rename to moxerver/server.h diff --git a/task_threads.c b/moxerver/task_threads.c similarity index 100% rename from task_threads.c rename to moxerver/task_threads.c diff --git a/task_threads.h b/moxerver/task_threads.h similarity index 100% rename from task_threads.h rename to moxerver/task_threads.h diff --git a/telnet.c b/moxerver/telnet.c similarity index 100% rename from telnet.c rename to moxerver/telnet.c diff --git a/telnet.h b/moxerver/telnet.h similarity index 100% rename from telnet.h rename to moxerver/telnet.h diff --git a/tty.c b/moxerver/tty.c similarity index 100% rename from tty.c rename to moxerver/tty.c diff --git a/tty.h b/moxerver/tty.h similarity index 100% rename from tty.h rename to moxerver/tty.h From aae67971ffb83c37f21e42ce3d769b7325e5f918 Mon Sep 17 00:00:00 2001 From: Igor Socec Date: Tue, 24 Jan 2017 18:16:47 +0100 Subject: [PATCH 03/12] Improve Makefiles with build and install directories --- Makefile | 30 ++++++++++++++++++++---------- moxanix/Makefile | 31 +++++++++++++++++++++++++++++++ moxerver/Makefile | 24 +++++++++++++++++------- 3 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 moxanix/Makefile diff --git a/Makefile b/Makefile index 5cf4626..a490142 100644 --- a/Makefile +++ b/Makefile @@ -2,32 +2,42 @@ MOXERVER = moxerver MOXANIX = moxanix -# installation root +# ============================================================================== + +# system install root directory INSTALL_ROOT = ./install.dir # ============================================================================== -MOXERVER_BUILDDIR = build.dir +# directories used for local component builds +BUILDDIR = build.dir +INSTALLDIR = install.dir # ============================================================================== # supported make options (clean, install...) -.PHONY: default all clean +.PHONY: all default install clean # all calls all other options -all: default +all: default install -# default builds moxerver +# default builds components default: - cd $(MOXERVER) && make OUTDIR=$(MOXERVER_BUILDDIR) + cd $(MOXERVER) && make BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) + cd $(MOXANIX) && make BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) -# install handles moxerver and moxanix installation +# install handles component installation install: default mkdir -p $(INSTALL_ROOT) - cp $(MOXERVER)/$(MOXERVER_BUILDDIR)/$(MOXERVER) $(INSTALL_ROOT)/$(MOXERVER) - cp $(MOXANIX)/$(MOXANIX).* $(INSTALL_ROOT)/ + + cd $(MOXERVER) && make install BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) + cp -r $(MOXERVER)/$(INSTALLDIR)/* $(INSTALL_ROOT)/ + + cd $(MOXANIX) && make install BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) + cp -r $(MOXANIX)/$(INSTALLDIR)/* $(INSTALL_ROOT)/ # clean removes build and install results clean: - cd $(MOXERVER) && make clean + cd $(MOXERVER) && make clean BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) + cd $(MOXANIX) && make clean BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) -rm -rf $(INSTALL_ROOT) diff --git a/moxanix/Makefile b/moxanix/Makefile new file mode 100644 index 0000000..e439d43 --- /dev/null +++ b/moxanix/Makefile @@ -0,0 +1,31 @@ +# target names +TARGET_CONTROL = moxanix.sh +TARGET_CONFIG = moxanix.cfg + +# ============================================================================== + +# directory for build results +BUILDDIR = build.dir +# installation root +INSTALLDIR = install.dir + +# ============================================================================== + +# supported make options (clean, install...) +.PHONY: default install clean + +# default does nothing +default: + +# install targets +install: + # install control script + mkdir -p $(INSTALLDIR)/bin + cp $(TARGET_CONTROL) $(INSTALLDIR)/bin/ + # install configuration file + mkdir -p $(INSTALLDIR)/etc + cp $(TARGET_CONFIG) $(INSTALLDIR)/etc/ + +# clean removes object files and target (ignore errors with "-" before commands) +clean: + -rm -rf $(INSTALLDIR) diff --git a/moxerver/Makefile b/moxerver/Makefile index c798acb..5a5c22b 100644 --- a/moxerver/Makefile +++ b/moxerver/Makefile @@ -1,8 +1,12 @@ -# target name -TARGET = moxerver +# target names +TARGET_BINARY = moxerver + +# ============================================================================== # directory for build results BUILDDIR = build.dir +# installation root +INSTALLDIR = install.dir # ============================================================================== @@ -22,7 +26,7 @@ CFLAGS = -Wall $(INCDIRS) $(LIBDIRS) $(LIBS) # ============================================================================== -# build everything in a dedicated directory $(OUTDIR) +# build everything in a dedicated directory $(BUILDDIR) # objects are .o files created from all .c files in the directory (same name) OBJECTS = $(patsubst %.c, $(BUILDDIR)/%.o, $(wildcard *.c)) @@ -35,20 +39,26 @@ $(BUILDDIR)/%.o: %.c $(CC) $(CFLAGS) -c $< -o $@ # target is built from all object files -$(BUILDDIR)/$(TARGET): $(OBJECTS) +$(BUILDDIR)/$(TARGET_BINARY): $(OBJECTS) $(CC) $(OBJECTS) $(CFLAGS) -o $@ # ============================================================================== # supported make options (clean, install...) -.PHONY: default all clean +.PHONY: all default install clean # all calls all other options -all: default +all: default install # default builds target -default: $(BUILDDIR)/$(TARGET) +default: $(BUILDDIR)/$(TARGET_BINARY) + +# install target +install: default + mkdir -p $(INSTALLDIR)/bin + cp $(BUILDDIR)/$(TARGET_BINARY) $(INSTALLDIR)/bin/ # clean removes object files and target (ignore errors with "-" before commands) clean: -rm -rf $(BUILDDIR) + -rm -rf $(INSTALLDIR) From aa3adfee0c8c73c52aad28191d80157c52620c6c Mon Sep 17 00:00:00 2001 From: Igor Socec Date: Tue, 24 Jan 2017 18:42:03 +0100 Subject: [PATCH 04/12] Update README.md --- README.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d4e5767..7128e71 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,37 @@ [![Build Status](https://travis-ci.org/socec/moxanix.svg?branch=master)](https://travis-ci.org/socec/moxanix) -moxanix +Moxanix ======= A serial device server, provides console access to multiple serial devices through telnet connection. +Architecture +============ + +The serial device server is broken down into multiple micro servers dedicated to a single serial device and TCP port pair. +These micro servers are then managed by a control script. The control script allows the user to start and stop these micro servers or check their status. +Connections between serial devices and TCP ports are configured in a separate file. +This design allows scalability and customization based on the number of available serial connections and TCP port availability. moxerver -------- -- server application handling the session between a specific TCP port and a specific serial device +- a light server application handling the session between one TCP port and one serial device - allows bidirectional communication -- it is expected to run a separate instance for every serial device +- it is expected to run a separate instance for every serial device and TCP port pair moxanix.sh ---------- - starts, stops or displays status for different moxervers - commands can handle one specific or all moxervers at once + +moxanix.cfg +----------- +- defines connections between serial devices and TCP ports +- each line corresponds to one micro server handling the defined connection + +Build and install +================= + +Run "make" to build the project. +The build artifacts can be found in the directory "install.dir" and should be copied from there. +If you want to install directly to some directory run "make INSTALL_ROOT=/some/dir". From a1162d167468e14652a95e0521e6eeacf54d7ae8 Mon Sep 17 00:00:00 2001 From: Igor Socec Date: Tue, 24 Jan 2017 20:40:57 +0100 Subject: [PATCH 05/12] Use a prefix when installing executables --- Makefile | 7 +++++-- moxanix/Makefile | 6 ++++-- moxerver/Makefile | 6 ++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index a490142..d349e17 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ MOXANIX = moxanix # system install root directory INSTALL_ROOT = ./install.dir +# prefix for /bin directory +BIN_PREFIX = /usr + # ============================================================================== # directories used for local component builds @@ -30,10 +33,10 @@ default: install: default mkdir -p $(INSTALL_ROOT) - cd $(MOXERVER) && make install BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) + cd $(MOXERVER) && make install BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) BIN_PREFIX=$(BIN_PREFIX) cp -r $(MOXERVER)/$(INSTALLDIR)/* $(INSTALL_ROOT)/ - cd $(MOXANIX) && make install BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) + cd $(MOXANIX) && make install BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) BIN_PREFIX=$(BIN_PREFIX) cp -r $(MOXANIX)/$(INSTALLDIR)/* $(INSTALL_ROOT)/ # clean removes build and install results diff --git a/moxanix/Makefile b/moxanix/Makefile index e439d43..52cd9b6 100644 --- a/moxanix/Makefile +++ b/moxanix/Makefile @@ -8,6 +8,8 @@ TARGET_CONFIG = moxanix.cfg BUILDDIR = build.dir # installation root INSTALLDIR = install.dir +# prefix for /bin directory +BIN_PREFIX = /usr # ============================================================================== @@ -20,8 +22,8 @@ default: # install targets install: # install control script - mkdir -p $(INSTALLDIR)/bin - cp $(TARGET_CONTROL) $(INSTALLDIR)/bin/ + mkdir -p $(INSTALLDIR)/$(BIN_PREFIX)/bin + cp $(TARGET_CONTROL) $(INSTALLDIR)/$(BIN_PREFIX)/bin/ # install configuration file mkdir -p $(INSTALLDIR)/etc cp $(TARGET_CONFIG) $(INSTALLDIR)/etc/ diff --git a/moxerver/Makefile b/moxerver/Makefile index 5a5c22b..2c9a19f 100644 --- a/moxerver/Makefile +++ b/moxerver/Makefile @@ -7,6 +7,8 @@ TARGET_BINARY = moxerver BUILDDIR = build.dir # installation root INSTALLDIR = install.dir +# prefix for /bin directory +BIN_PREFIX = /usr # ============================================================================== @@ -55,8 +57,8 @@ default: $(BUILDDIR)/$(TARGET_BINARY) # install target install: default - mkdir -p $(INSTALLDIR)/bin - cp $(BUILDDIR)/$(TARGET_BINARY) $(INSTALLDIR)/bin/ + mkdir -p $(INSTALLDIR)/$(BIN_PREFIX)/bin + cp $(BUILDDIR)/$(TARGET_BINARY) $(INSTALLDIR)/$(BIN_PREFIX)/bin # clean removes object files and target (ignore errors with "-" before commands) clean: From 83bd22bef9aaf6f85e48556709f0d486574e50e0 Mon Sep 17 00:00:00 2001 From: Igor Socec Date: Wed, 25 Jan 2017 01:33:37 +0100 Subject: [PATCH 06/12] Change names of config file and control script Also make top Makefile more tidy. --- Makefile | 22 ++++++++++++---------- README.md | 12 ++++++------ moxerver/Makefile | 4 ++-- {moxanix => tools}/Makefile | 4 ++-- moxanix/moxanix.cfg => tools/moxerver.cfg | 0 moxanix/moxanix.sh => tools/moxerverctl | 0 6 files changed, 22 insertions(+), 20 deletions(-) rename {moxanix => tools}/Makefile (93%) rename moxanix/moxanix.cfg => tools/moxerver.cfg (100%) rename moxanix/moxanix.sh => tools/moxerverctl (100%) diff --git a/Makefile b/Makefile index d349e17..7cb6718 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # components -MOXERVER = moxerver -MOXANIX = moxanix +SERVER = moxerver +TOOLS = tools # ============================================================================== @@ -15,6 +15,8 @@ BIN_PREFIX = /usr # directories used for local component builds BUILDDIR = build.dir INSTALLDIR = install.dir +# directory configuration for local component builds +DIR_CONFIG = BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) BIN_PREFIX=$(BIN_PREFIX) # ============================================================================== @@ -26,21 +28,21 @@ all: default install # default builds components default: - cd $(MOXERVER) && make BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) - cd $(MOXANIX) && make BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) + cd $(SERVER) && make $(DIR_CONFIG) + cd $(TOOLS) && make $(DIR_CONFIG) # install handles component installation install: default mkdir -p $(INSTALL_ROOT) - cd $(MOXERVER) && make install BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) BIN_PREFIX=$(BIN_PREFIX) - cp -r $(MOXERVER)/$(INSTALLDIR)/* $(INSTALL_ROOT)/ + cd $(SERVER) && make install $(DIR_CONFIG) + cp -r $(SERVER)/$(INSTALLDIR)/* $(INSTALL_ROOT)/ - cd $(MOXANIX) && make install BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) BIN_PREFIX=$(BIN_PREFIX) - cp -r $(MOXANIX)/$(INSTALLDIR)/* $(INSTALL_ROOT)/ + cd $(TOOLS) && make install $(DIR_CONFIG) + cp -r $(TOOLS)/$(INSTALLDIR)/* $(INSTALL_ROOT)/ # clean removes build and install results clean: - cd $(MOXERVER) && make clean BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) - cd $(MOXANIX) && make clean BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) + cd $(SERVER) && make clean $(DIR_CONFIG) + cd $(TOOLS) && make clean $(DIR_CONFIG) -rm -rf $(INSTALL_ROOT) diff --git a/README.md b/README.md index 7128e71..cd1f95e 100644 --- a/README.md +++ b/README.md @@ -19,19 +19,19 @@ moxerver - allows bidirectional communication - it is expected to run a separate instance for every serial device and TCP port pair -moxanix.sh ----------- +moxerverctl +----------- - starts, stops or displays status for different moxervers - commands can handle one specific or all moxervers at once -moxanix.cfg ------------ +moxerver.cfg +------------ - defines connections between serial devices and TCP ports - each line corresponds to one micro server handling the defined connection Build and install ================= -Run "make" to build the project. +Run `make` to build the project. The build artifacts can be found in the directory "install.dir" and should be copied from there. -If you want to install directly to some directory run "make INSTALL_ROOT=/some/dir". +If you want to install directly to some directory run `make INSTALL_ROOT=/some/dir`. diff --git a/moxerver/Makefile b/moxerver/Makefile index 2c9a19f..458cb5e 100644 --- a/moxerver/Makefile +++ b/moxerver/Makefile @@ -40,7 +40,7 @@ $(BUILDDIR)/%.o: %.c mkdir -p $(BUILDDIR) $(CC) $(CFLAGS) -c $< -o $@ -# target is built from all object files +# target binary is built from all object files $(BUILDDIR)/$(TARGET_BINARY): $(OBJECTS) $(CC) $(OBJECTS) $(CFLAGS) -o $@ @@ -55,7 +55,7 @@ all: default install # default builds target default: $(BUILDDIR)/$(TARGET_BINARY) -# install target +# install target binary install: default mkdir -p $(INSTALLDIR)/$(BIN_PREFIX)/bin cp $(BUILDDIR)/$(TARGET_BINARY) $(INSTALLDIR)/$(BIN_PREFIX)/bin diff --git a/moxanix/Makefile b/tools/Makefile similarity index 93% rename from moxanix/Makefile rename to tools/Makefile index 52cd9b6..e1ee535 100644 --- a/moxanix/Makefile +++ b/tools/Makefile @@ -1,6 +1,6 @@ # target names -TARGET_CONTROL = moxanix.sh -TARGET_CONFIG = moxanix.cfg +TARGET_CONTROL = moxerverctl +TARGET_CONFIG = moxerver.cfg # ============================================================================== diff --git a/moxanix/moxanix.cfg b/tools/moxerver.cfg similarity index 100% rename from moxanix/moxanix.cfg rename to tools/moxerver.cfg diff --git a/moxanix/moxanix.sh b/tools/moxerverctl similarity index 100% rename from moxanix/moxanix.sh rename to tools/moxerverctl From ee5aaa269052129e5670c0ea663913d25dfa2ef4 Mon Sep 17 00:00:00 2001 From: Igor Socec Date: Wed, 25 Jan 2017 01:44:34 +0100 Subject: [PATCH 07/12] Update README.md --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cd1f95e..007cab9 100644 --- a/README.md +++ b/README.md @@ -33,5 +33,8 @@ Build and install ================= Run `make` to build the project. -The build artifacts can be found in the directory "install.dir" and should be copied from there. -If you want to install directly to some directory run `make INSTALL_ROOT=/some/dir`. +This default build will produce artifacts in a directory "install.dir" with executables installed in "usr/bin" (prefix is "usr"). + +You can install directly into some directory with `make INSTALL_ROOT=/some/dir`. +You can change the install prefix for executables with `make BIN_PREFIX=someprefix`. +These options can also be combined into `make INSTALL_ROOT=/some/dir BIN_PREFIX=someprefix` From ce8971eb2b56c3d49a457db4871c89c5520515b9 Mon Sep 17 00:00:00 2001 From: Igor Socec Date: Wed, 25 Jan 2017 10:59:49 +0100 Subject: [PATCH 08/12] Correct paths in moxerverctl and adapt Makefiles --- Makefile | 11 ++--------- moxerver/Makefile | 7 +++---- tools/Makefile | 13 ++++++------- tools/moxerverctl | 8 +++++--- 4 files changed, 16 insertions(+), 23 deletions(-) mode change 100755 => 100644 tools/moxerverctl diff --git a/Makefile b/Makefile index 7cb6718..20bd335 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,8 @@ SERVER = moxerver TOOLS = tools -# ============================================================================== - # system install root directory -INSTALL_ROOT = ./install.dir +INSTALL_ROOT = $(abspath ./install.dir) # prefix for /bin directory BIN_PREFIX = /usr @@ -14,9 +12,8 @@ BIN_PREFIX = /usr # directories used for local component builds BUILDDIR = build.dir -INSTALLDIR = install.dir # directory configuration for local component builds -DIR_CONFIG = BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALLDIR) BIN_PREFIX=$(BIN_PREFIX) +DIR_CONFIG = BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALL_ROOT) BIN_PREFIX=$(BIN_PREFIX) # ============================================================================== @@ -34,12 +31,8 @@ default: # install handles component installation install: default mkdir -p $(INSTALL_ROOT) - cd $(SERVER) && make install $(DIR_CONFIG) - cp -r $(SERVER)/$(INSTALLDIR)/* $(INSTALL_ROOT)/ - cd $(TOOLS) && make install $(DIR_CONFIG) - cp -r $(TOOLS)/$(INSTALLDIR)/* $(INSTALL_ROOT)/ # clean removes build and install results clean: diff --git a/moxerver/Makefile b/moxerver/Makefile index 458cb5e..b04f9d0 100644 --- a/moxerver/Makefile +++ b/moxerver/Makefile @@ -4,9 +4,9 @@ TARGET_BINARY = moxerver # ============================================================================== # directory for build results -BUILDDIR = build.dir +BUILDDIR = $(abspath build.dir) # installation root -INSTALLDIR = install.dir +INSTALLDIR = $(abspath install.dir) # prefix for /bin directory BIN_PREFIX = /usr @@ -57,8 +57,7 @@ default: $(BUILDDIR)/$(TARGET_BINARY) # install target binary install: default - mkdir -p $(INSTALLDIR)/$(BIN_PREFIX)/bin - cp $(BUILDDIR)/$(TARGET_BINARY) $(INSTALLDIR)/$(BIN_PREFIX)/bin + install -Dm0755 $(BUILDDIR)/$(TARGET_BINARY) $(INSTALLDIR)/$(BIN_PREFIX)/bin/$(TARGET_BINARY) # clean removes object files and target (ignore errors with "-" before commands) clean: diff --git a/tools/Makefile b/tools/Makefile index e1ee535..9bc4e54 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -5,9 +5,9 @@ TARGET_CONFIG = moxerver.cfg # ============================================================================== # directory for build results -BUILDDIR = build.dir +BUILDDIR = $(abspath build.dir) # installation root -INSTALLDIR = install.dir +INSTALLDIR = $(abspath install.dir) # prefix for /bin directory BIN_PREFIX = /usr @@ -21,12 +21,11 @@ default: # install targets install: - # install control script - mkdir -p $(INSTALLDIR)/$(BIN_PREFIX)/bin - cp $(TARGET_CONTROL) $(INSTALLDIR)/$(BIN_PREFIX)/bin/ # install configuration file - mkdir -p $(INSTALLDIR)/etc - cp $(TARGET_CONFIG) $(INSTALLDIR)/etc/ + install -Dm0644 $(TARGET_CONFIG) $(INSTALLDIR)/etc/$(TARGET_CONFIG) + # install control script, referring to the configuration file + install -Dm0755 $(TARGET_CONTROL) $(INSTALLDIR)/$(BIN_PREFIX)/bin/$(TARGET_CONTROL) + sed -i -e 's#ROOT=\"\"#ROOT=$(INSTALLDIR)#' $(INSTALLDIR)/$(BIN_PREFIX)/bin/$(TARGET_CONTROL) # clean removes object files and target (ignore errors with "-" before commands) clean: diff --git a/tools/moxerverctl b/tools/moxerverctl old mode 100755 new mode 100644 index 03b72be..b0ed7c9 --- a/tools/moxerverctl +++ b/tools/moxerverctl @@ -4,10 +4,12 @@ # setup # ===== +ROOT="" + # parameters -CONFIGURATION_FILE="./moxanix.cfg" -SERVER_BINARY="./moxerver" -LOG_DIRECTORY="./logs" +CONFIGURATION_FILE="$ROOT/etc/moxerver.cfg" +SERVER_BINARY="moxerver" +LOG_DIRECTORY="$ROOT/var/logs/moxerver" # global variables for configuration From cded0313c28b57de02d43cb5b67ec6cc24ef8fbf Mon Sep 17 00:00:00 2001 From: Igor Socec Date: Wed, 25 Jan 2017 11:39:26 +0100 Subject: [PATCH 09/12] Don't install with just make, require make install --- .travis.yml | 2 +- Makefile | 5 +---- README.md | 8 ++++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 23135f1..fb156f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,4 @@ compiler: - gcc - clang -script: make +script: make install diff --git a/Makefile b/Makefile index 20bd335..49f1fee 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,7 @@ DIR_CONFIG = BUILDDIR=$(BUILDDIR) INSTALLDIR=$(INSTALL_ROOT) BIN_PREFIX=$(BIN_PR # ============================================================================== # supported make options (clean, install...) -.PHONY: all default install clean - -# all calls all other options -all: default install +.PHONY: default install clean # default builds components default: diff --git a/README.md b/README.md index 007cab9..ede4025 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,9 @@ moxerver.cfg Build and install ================= -Run `make` to build the project. -This default build will produce artifacts in a directory "install.dir" with executables installed in "usr/bin" (prefix is "usr"). +Run `make` to build the project and `make install` to install it. +This default build will produce artifacts in a directory "install.dir" with executables installed in "usr/bin" (default prefix is "usr"). -You can install directly into some directory with `make INSTALL_ROOT=/some/dir`. -You can change the install prefix for executables with `make BIN_PREFIX=someprefix`. +You can install directly into some other directory with `make INSTALL_ROOT=/some/dir`. +You can change the default install prefix for executables with `make BIN_PREFIX=someprefix`. These options can also be combined into `make INSTALL_ROOT=/some/dir BIN_PREFIX=someprefix` From f3babe58df4e67b8b7cad32c282e49b3b67df2d6 Mon Sep 17 00:00:00 2001 From: Igor Socec Date: Wed, 25 Jan 2017 16:14:52 +0100 Subject: [PATCH 10/12] Put logs in a standard location: /var/log --- tools/moxerverctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/moxerverctl b/tools/moxerverctl index b0ed7c9..76ae3d6 100644 --- a/tools/moxerverctl +++ b/tools/moxerverctl @@ -9,7 +9,7 @@ ROOT="" # parameters CONFIGURATION_FILE="$ROOT/etc/moxerver.cfg" SERVER_BINARY="moxerver" -LOG_DIRECTORY="$ROOT/var/logs/moxerver" +LOG_DIRECTORY="$ROOT/var/log/moxerver" # global variables for configuration From b375ee19cedde35dd0165066519e2911febd095a Mon Sep 17 00:00:00 2001 From: Igor Socec Date: Wed, 25 Jan 2017 16:36:02 +0100 Subject: [PATCH 11/12] Fix bug where tty is dropped out of device name --- tools/moxerverctl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/moxerverctl b/tools/moxerverctl index 76ae3d6..d37eb3e 100644 --- a/tools/moxerverctl +++ b/tools/moxerverctl @@ -63,9 +63,9 @@ do_read_config() # configuration lines CONF_LINES[$CONF_SIZE]=$(echo -n $line) # extract configuration arguments - tcp=$(echo $line | awk '{print $1}' | tr -d "tcp=") - tty=$(echo $line | awk '{print $2}' | tr -d "tty=") - baud=$(echo $line | awk '{print $3}' | tr -d "baud=") + tcp=$(echo $line | awk '{print $1}' | sed -e 's/tcp=//') + tty=$(echo $line | awk '{print $2}' | sed -e 's/tty=//') + baud=$(echo $line | awk '{print $3}' | sed -e 's/baud=//') # compose configuration argument lines for passing to the servers CONF_ARGS[$CONF_SIZE]="-p $tcp -t $tty -b $baud" # increment configuration size (array index) From a3addedfe7e8403763ab9816e91764ad4c6d4ac4 Mon Sep 17 00:00:00 2001 From: Jeena Paradies Date: Thu, 2 Feb 2017 11:34:07 +0100 Subject: [PATCH 12/12] Add space in printout There is a space missing betweet two words in the "Please provide your username" string to separate "to" and "other". This patch adds a space in the right place. --- moxerver/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moxerver/client.c b/moxerver/client.c index 673c199..65ee94a 100644 --- a/moxerver/client.c +++ b/moxerver/client.c @@ -133,7 +133,7 @@ int client_ask_username(client_t *client) /* show username request to the client */ snprintf(msg, BUFFER_LEN, - "\nPlease provide a username to identify yourself to" + "\nPlease provide a username to identify yourself to " "other users (max %d characters):\n", USERNAME_LEN); client_write(client, msg, strlen(msg));