summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2018-05-18 16:12:00 +0200
committerGitHub <noreply@github.com>2018-05-18 16:12:00 +0200
commitfff5d7f6f14c4b547a92f3c262420d1bdaa5d17f (patch)
treee299acbfdc5843b7bf1e33aac7c41f6246adc89b
parente7fc5bf0b771f308af2046e258ce3d44c2154809 (diff)
parentc53fc74bb87189aaf46d19ab6909f435a7bb6a27 (diff)
downloadserial-barcode-scanner-fff5d7f6f14c4b547a92f3c262420d1bdaa5d17f.tar.bz2
Merge pull request #31 from smilix/master
Adds docker
-rw-r--r--docker/Dockerfile43
-rw-r--r--docker/README.md26
-rwxr-xr-xdocker/init.sh11
-rwxr-xr-xdocker/setupEnv.sh23
-rw-r--r--docker/tmux-config29
-rw-r--r--example.cfg1
-rw-r--r--src/input-device/input-device.vala4
7 files changed, 137 insertions, 0 deletions
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 = "";