inapp software

Installing inapp on Armbian.

Update everything after the fresh installation to get the latest kernel and packages:

apt-get update
apt-get upgrade

Disable the NetworkManager deamon and save ~6MB of RAM:

root@nanopineo:~# systemctl disable NetworkManager
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.

Light DHCP/DNS server

[1]

When the box is connected to with USB, it provides the host with an IP address:

apt-get install dnsmasq
nano /etc/network/interfaces

The network configuration:

# Native Ethernet interface
allow-hotplug eth0
no-auto-down eth0
iface eth0 inet dhcp

# Ethernet over USB-OTG interface
allow-hotplug usb0
iface usb0 inet static
hwaddress ether 82:bc:09:47:28:a9
address 172.24.1.1
netmask 255.255.255.0
# Switch the USB-OTG port to device mode
pre-up /bin/sh -c 'echo 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role'

The DHCP/DNS configuration:

mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
interface=usb0       # Use interface usb0
listen-address=172.24.1.1 # Explicitly specify the address to listen on
bind-interfaces      # Bind to the interface to make sure we aren't sending things elsewhere
domain-needed        # Don't forward short names
bogus-priv           # Never forward addresses in the non-routed address spaces.
dhcp-range=172.24.1.50,172.24.1.150,12h
# Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time

# Disable default router (gateway)
dhcp-option=3
# Disable DNS
dhcp-option=6
service dnsmasq start

Light HTTP server

[2]

The box hosts a website:

apt-get install lighttpd
mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig
nano /etc/lighttpd/lighttpd.conf
[...]
service lighttpd start

Simple USB disk automount

[3]

The box mounts USB disks automatically:

apt-get install usbmount
nano /etc/usbmount/usbmount.conf
MOUNTPOINTS="/mnt/data [...]"
# Mount read-only
MOUNTOPTIONS="ro,noexec,nodev"

inapp websocket server

To build inapp:

apt-get install qtbase5-dev libqt5websockets5-dev
apt-get install liblttng-ust-dev

cd /home/ina/inapp/build
qmake -qt5 ..
make -j2
make install

Note: since the NanoPi NEO has no battery to save the clock, it will always reset to the same time, and print this kind of message:

/usr/lib/arm-linux-gnueabihf/qt5/bin/qmake -o Makefile ../inapp-0.1/project.pro
make: Warning: File '../inapp-0.1/project.pro' has modification time 32835463 s in the future

To touch all files in a directory:

find /home/ina/inapp/ -print -exec touch {} \;

Or set the date:

date -s "26 FEB 2017 12:00:00"

Do not use make -j4 because there is not enought RAM on the NanoPi NEO for 4 concurrent build threads. The result is installed in /opt/ina/pp/:

/opt/ina/pp/etc/start.sh

Startup

Add to /etc/rc.local:

/opt/ina/pp/etc/start.sh &

STRT_FILE=/mnt/data/startup.sh
LOGS_PATH=/tmp/inalogs
if [ -e $STRT_FILE ]
then
    /bin/bash $STRT_FILE &> $LOGS_PATH/startup.log.txt
fi
start-stop-daemon --start --chdir $BASE_PATH/bin --exec $BASE_PATH/bin/inapp2   \
                  --pidfile $TEMP_PATH/inapp2.$i.pid --make-pidfile             \
                  --background                                                  \
                  -- -i $i -p $port

References

[1]dnsmasq project page, http://www.thekelleys.org.uk/dnsmasq/doc.html
[2]lighttpd project page, https://www.lighttpd.net
[3]usbmount project page, http://usbmount.alioth.debian.org