2014-04-27 21:46:59 +00:00
|
|
|
#!/bin/sh
|
2014-06-10 00:05:16 +00:00
|
|
|
|
2016-07-06 08:45:32 +00:00
|
|
|
set -o errexit
|
2014-04-27 21:46:59 +00:00
|
|
|
|
2019-04-05 11:32:06 +00:00
|
|
|
# Start Avahi to allow MDNS lookups and remove
|
|
|
|
# any pre-defined services
|
|
|
|
rm -f /etc/avahi/services/*
|
2018-07-27 13:18:13 +00:00
|
|
|
mkdir -p /var/run/dbus
|
|
|
|
rm -f /var/run/avahi-daemon/pid
|
2019-01-29 13:13:05 +00:00
|
|
|
rm -f /var/run/dbus/pid
|
2018-07-27 13:18:13 +00:00
|
|
|
/etc/init.d/dbus-1 start
|
|
|
|
/etc/init.d/avahi-daemon start
|
|
|
|
|
2018-10-15 17:05:23 +00:00
|
|
|
# If the legacy /tmp/resin-supervisor exists on the host, a container might
|
|
|
|
# already be using to take an update lock, so we symlink it to the new
|
|
|
|
# location so that the supervisor can see it
|
|
|
|
[ -d /mnt/root/tmp/resin-supervisor ] &&
|
2018-10-23 15:17:35 +00:00
|
|
|
( [ -d /mnt/root/tmp/balena-supervisor ] || ln -s ./resin-supervisor /mnt/root/tmp/balena-supervisor )
|
2018-10-15 17:05:23 +00:00
|
|
|
|
|
|
|
# Otherwise, if the lockfiles directory doesn't exist
|
|
|
|
[ -d /mnt/root/tmp/balena-supervisor ] ||
|
|
|
|
mkdir -p /mnt/root/tmp/balena-supervisor
|
2014-04-27 21:46:59 +00:00
|
|
|
|
2016-06-23 18:07:18 +00:00
|
|
|
# If DOCKER_ROOT isn't set then default it
|
|
|
|
if [ -z "${DOCKER_ROOT}" ]; then
|
|
|
|
DOCKER_ROOT=/mnt/root/var/lib/rce
|
|
|
|
fi
|
2016-07-06 08:45:32 +00:00
|
|
|
|
2016-06-23 18:07:18 +00:00
|
|
|
# Mount the DOCKER_ROOT path equivalent in the container fs
|
|
|
|
DOCKER_LIB_PATH=${DOCKER_ROOT#/mnt/root}
|
2016-07-06 08:45:32 +00:00
|
|
|
|
2016-06-23 18:07:18 +00:00
|
|
|
if [ ! -d "${DOCKER_LIB_PATH}" ]; then
|
|
|
|
ln -s "${DOCKER_ROOT}" "${DOCKER_LIB_PATH}"
|
2016-06-09 05:15:24 +00:00
|
|
|
fi
|
2018-03-16 14:01:50 +00:00
|
|
|
|
|
|
|
if [ -z "$DOCKER_SOCKET" ]; then
|
|
|
|
export DOCKER_SOCKET=/run/docker.sock
|
|
|
|
fi
|
|
|
|
|
|
|
|
export DBUS_SYSTEM_BUS_ADDRESS="unix:path=/mnt/root/run/dbus/system_bus_socket"
|
|
|
|
|
2018-03-13 11:41:06 +00:00
|
|
|
# Include self-signed CAs, should they exist
|
|
|
|
if [ ! -z "${BALENA_ROOT_CA}" ]; then
|
|
|
|
if [ ! -e '/etc/ssl/certs/balenaRootCA.pem' ]; then
|
|
|
|
mkdir -p /usr/local/share/ca-certificates
|
|
|
|
echo "${BALENA_ROOT_CA}" > /usr/local/share/ca-certificates/balenaRootCA.crt
|
|
|
|
update-ca-certificates
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-02-13 10:49:07 +00:00
|
|
|
# Mount the host kernel module path onto the expected location
|
|
|
|
# We need to do this as busybox doesn't support using a custom location
|
2019-02-14 13:49:03 +00:00
|
|
|
if [ ! -d /lib/modules ]; then
|
|
|
|
ln -s /mnt/root/lib/modules /lib/modules
|
|
|
|
fi
|
2019-02-13 10:49:07 +00:00
|
|
|
# Now load the ip6_tables kernel module, so we can do filtering on ipv6 addresses
|
2019-03-08 01:19:02 +00:00
|
|
|
if [ -z "$(cat /proc/config.gz | gunzip | grep CONFIG_IP6_NF_IPTABLES=y || true)" ]; then
|
|
|
|
modprobe ip6_tables
|
|
|
|
fi
|
2019-02-13 10:49:07 +00:00
|
|
|
|
2018-11-05 12:03:12 +00:00
|
|
|
exec node /usr/src/app/dist/app.js
|