|
#!/bin/sh
|
|
|
|
DNS_LOCAL="192.168.250.1.53"
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
echo "ERROR: You need to run this script as root!"
|
|
exit 1
|
|
fi
|
|
|
|
CONTAINER_PATH="$SNAP_COMMON/containers"
|
|
CONTAINER_NAME=default
|
|
|
|
if [ -z "$SNAP" ] ; then
|
|
CONTAINER_PATH=/var/lib/anbox/containers
|
|
fi
|
|
|
|
state=$(lxc-info -P "$CONTAINER_PATH" -n "$CONTAINER_NAME" -s | cut -d':' -f 2 | tr -d '[:space:]')
|
|
if [ "$state" != "RUNNING" ] ; then
|
|
echo "ERROR: Cannot attach to container as it is not running"
|
|
exit 1
|
|
fi
|
|
|
|
exec lxc-attach \
|
|
-P "$CONTAINER_PATH" \
|
|
-n "$CONTAINER_NAME" \
|
|
--clear-env -- \
|
|
/system/bin/sh -c \
|
|
"/system/bin/iptables -t nat -A OUTPUT -o eth0 -p tcp -m tcp --dport 53 -j DNAT --to-destination ${DNS_LOCAL}
|
|
/system/bin/iptables -t nat -A OUTPUT -o eth0 -p udp -m udp --dport 53 -j DNAT --to-destination ${DNS_LOCAL}"
|