From c53fc74bb87189aaf46d19ab6909f435a7bb6a27 Mon Sep 17 00:00:00 2001 From: Holger Cremer Date: Fri, 29 Dec 2017 19:00:01 +0100 Subject: adds docker --- docker/Dockerfile | 43 ++++++++++++++++++++++++++++++++++++++ docker/README.md | 26 +++++++++++++++++++++++ docker/init.sh | 11 ++++++++++ docker/setupEnv.sh | 23 ++++++++++++++++++++ docker/tmux-config | 29 +++++++++++++++++++++++++ example.cfg | 1 + src/input-device/input-device.vala | 4 ++++ 7 files changed, 137 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/README.md create mode 100755 docker/init.sh create mode 100755 docker/setupEnv.sh create mode 100644 docker/tmux-config diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..0f043e9 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,43 @@ +FROM debian:jessie + +RUN set -ex && \ + apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + wget \ + build-essential \ + valac \ + libesmtp-dev \ + libgpgme11-dev \ + libncursesw5-dev \ + libncurses5-dev \ + libgee-dev \ + libgmime-2.6-dev \ + libarchive-dev \ + libgstreamer0.10-dev \ + librsvg2-dev \ + libsqlite3-dev \ + libpango1.0-dev \ + libssl-dev \ + dbus-x11 \ + fonts-lmodern \ + sqlite3 \ + libgtk2.0-dev \ + libsoup2.4-dev \ + libgee-0.8-dev \ + tmux \ + mdbus2 \ + && rm -rf /var/lib/apt/lists/* + + RUN set -ex && \ + useradd shop && \ + mkdir /var/run/dbus + +ENV SBC_DIR /mnt/serial-barcode-scanner + +COPY tmux-config /root/.tmux.conf +COPY init.sh /root/ + +WORKDIR $SBC_DIR + +ENTRYPOINT ["/root/init.sh"] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..065bacf --- /dev/null +++ b/docker/README.md @@ -0,0 +1,26 @@ +# Install + +Create the docker image with: +```bash +docker build -t sbs-build . +``` + +# Config + +Change (or create) the `ktt-shopsystem.cfg` file that everything lays in `/mnt/serial-barcode-scanner` (change every folder...). + + +# Usage + +Run the image with: +```bash +# change into the "serial-barcode-scanner" directory +cd .. + +docker run --rm -it -p 8080:8080 -v "$PWD":/mnt/serial-barcode-scanner sbs-build +``` + +You have now a tmux terminal to work with the vala files and run the program. E.g. +- `cd src && make` to make the whole project +- `cd src/curses-ui/ && ./curses-ui` to start the curses ui. +- ... diff --git a/docker/init.sh b/docker/init.sh new file mode 100755 index 0000000..15b7741 --- /dev/null +++ b/docker/init.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +cd dbus +make install +cd config +make install + +cd ../.. +dbus-daemon --system +echo "Ready!" +tmux diff --git a/docker/setupEnv.sh b/docker/setupEnv.sh new file mode 100755 index 0000000..bb32952 --- /dev/null +++ b/docker/setupEnv.sh @@ -0,0 +1,23 @@ +#!/bin/bash +DBUS_FILE=/root/dbus.env + +if [ "$SBC_DIR" == "" ]; then + echo "SBC_DIR not set" + exit 1 +fi + +if [ -f $DBUS_FILE ]; then + echo "Already initialized." + . $DBUS_FILE +else + dbus-launch --sh-syntax > $DBUS_FILE + . $DBUS_FILE + + mkdir -p $SBC_DIR + + # create symlink for service files that autostarts the single binaries + mkdir -p /root/.local/share/dbus-1 + if [[ ! -d /root/.local/share/dbus-1/services ]]; then + ln -s $SBC_DIR/dbus /root/.local/share/dbus-1/services + fi +fi diff --git a/docker/tmux-config b/docker/tmux-config new file mode 100644 index 0000000..f70a089 --- /dev/null +++ b/docker/tmux-config @@ -0,0 +1,29 @@ +# remap prefix to Control + a +set -g prefix C-a +unbind C-b +bind C-a send-prefix + +# scroll mode with s +bind s copy-mode + +# use windows like tabs (S means shift key) +bind -n S-down new-window +bind -n S-left prev +bind -n S-right next + +# Start numbering at 1 +set -g base-index 1 + +# COLORS! +set -g default-terminal "screen-256color" + +# status line +set -g status-utf8 on +set -g status-fg white +set -g status-bg blue +set -g window-status-current-bg white +set -g window-status-current-fg blue + +# colorize messages in the command line +set-option -g message-bg black #base02 +set-option -g message-fg brightred #orange diff --git a/example.cfg b/example.cfg index 1d52d06..1dbede7 100644 --- a/example.cfg +++ b/example.cfg @@ -1,6 +1,7 @@ [DATABASE] file = /path/to/shop.db [INPUT] +# use ignore if you have no device (this skips the input feature) device = /dev/input/by-id/path-to-barcode-scanner [MAIL] server = mail.server.example.com diff --git a/src/input-device/input-device.vala b/src/input-device/input-device.vala index 9e2680c..6988c6d 100644 --- a/src/input-device/input-device.vala +++ b/src/input-device/input-device.vala @@ -22,6 +22,10 @@ public class Device { public signal void received_barcode(string barcode); public Device(string device) { + if (device == "ignore") { + stdout.printf("Ignoring InputDevice!\n"); + return; + } try { io_read = new IOChannel.file(device, "r"); buffer = ""; -- cgit v1.2.3