From 2811b5358ee26edbb5601e2d2a434d4c1bdfb2a0 Mon Sep 17 00:00:00 2001 From: Erfan Abdi Date: Sun, 13 Jun 2021 13:09:05 +0430 Subject: [PATCH] anbox: Edit anbox-net script and run it --- scripts/anbox-net.sh | 26 ++++++++++---------------- scripts/install.sh | 3 +++ scripts/run-container.sh | 5 ++--- scripts/stop-container.sh | 1 + 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/scripts/anbox-net.sh b/scripts/anbox-net.sh index b2226f3..f609690 100644 --- a/scripts/anbox-net.sh +++ b/scripts/anbox-net.sh @@ -1,19 +1,15 @@ #!/bin/sh - -distrosysconfdir="@LXC_DISTRO_SYSCONF@" -varrun="@RUNTIME_PATH@/lxc" -varlib="@LOCALSTATEDIR@/lib" - -# These can be overridden in @LXC_DISTRO_SYSCONF@/lxc -# or in @LXC_DISTRO_SYSCONF@/lxc-net +varrun="/run/anbox-lxc" +varlib="/var/lib" USE_LXC_BRIDGE="true" -LXC_BRIDGE="lxcbr0" -LXC_BRIDGE_MAC="00:16:3e:00:00:00" -LXC_ADDR="10.0.3.1" +LXC_BRIDGE="anbox0" +LXC_BRIDGE_MAC="00:16:3e:00:00:01" +LXC_ADDR="192.168.250.1" LXC_NETMASK="255.255.255.0" -LXC_NETWORK="10.0.3.0/24" -LXC_DHCP_RANGE="10.0.3.2,10.0.3.254" +LXC_NETWORK="192.168.250.0/24" +LXC_DHCP_RANGE="192.168.250.2,192.168.250.254" LXC_DHCP_MAX="253" LXC_DHCP_CONFILE="" LXC_DHCP_PING="true" @@ -25,8 +21,6 @@ LXC_IPV6_MASK="" LXC_IPV6_NETWORK="" LXC_IPV6_NAT="false" -[ ! -f $distrosysconfdir/lxc ] || . $distrosysconfdir/lxc - use_nft() { [ -n "$NFT" ] && nft list ruleset > /dev/null 2>&1 && [ "$LXC_USE_NFT" = "true" ] } @@ -114,7 +108,7 @@ add rule ip lxc postrouting ip saddr ${LXC_NETWORK} ip daddr != ${LXC_NETWORK} c start() { [ "x$USE_LXC_BRIDGE" = "xtrue" ] || { exit 0; } - [ ! -f "${varrun}/network_up" ] || { echo "lxc-net is already running"; exit 1; } + [ ! -f "${varrun}/network_up" ] || { echo "anbox-net is already running"; exit 1; } if [ -d /sys/class/net/${LXC_BRIDGE} ]; then stop force || true @@ -125,7 +119,7 @@ start() { cleanup() { set +e if [ "$FAILED" = "1" ]; then - echo "Failed to setup lxc-net." >&2 + echo "Failed to setup anbox-net." >&2 stop force exit 1 fi @@ -224,7 +218,7 @@ delete table ip6 lxc;" stop() { [ "x$USE_LXC_BRIDGE" = "xtrue" ] || { exit 0; } - [ -f "${varrun}/network_up" ] || [ "$1" = "force" ] || { echo "lxc-net isn't running"; exit 1; } + [ -f "${varrun}/network_up" ] || [ "$1" = "force" ] || { echo "anbox-net isn't running"; exit 1; } if [ -d /sys/class/net/${LXC_BRIDGE} ]; then _ifdown diff --git a/scripts/install.sh b/scripts/install.sh index 6e8e046..915cfb9 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -44,6 +44,9 @@ chmod +x run-container.sh rm -f stop-container.sh wget https://github.com/Anbox-halium/anbox-halium/raw/lineage-17.1/scripts/stop-container.sh chmod +x stop-container.sh +rm -f anbox-net.sh +wget https://github.com/Anbox-halium/anbox-halium/raw/lineage-17.1/scripts/anbox-net.sh +chmod +x anbox-net.sh if [ -f anbox.prop ]; then mv anbox.prop anbox.prop.bak diff --git a/scripts/run-container.sh b/scripts/run-container.sh index 8786995..30f9656 100644 --- a/scripts/run-container.sh +++ b/scripts/run-container.sh @@ -11,9 +11,8 @@ umount -l /sys/fs/cgroup/schedtune # start sensors hal start anbox-sensors -# start lxc-net, that sets up lxc bridge -start lxc-net -brctl addbr anbox0 +# start anbox-net, that sets up lxc bridge +/home/anbox/anbox-net.sh start # stop nfcd to not conflict with anbox stop nfcd diff --git a/scripts/stop-container.sh b/scripts/stop-container.sh index d8c74a2..ca54e74 100644 --- a/scripts/stop-container.sh +++ b/scripts/stop-container.sh @@ -1,3 +1,4 @@ #!/bin/bash lxc-stop -n anbox -k +/home/anbox/anbox-net.sh stop -- 2.47.3