init.sh 949 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. gw4=$(ip -4 route show|grep ^default|sed -e 's/.* via \([0-9.]*\)\W.*/\1/')
  3. gw6=$(ip -6 route show|grep ^default|sed -e 's/.* via \([0-9a-f:]*\)\W.*/\1/')
  4. ipmask4=$(ip -4 addr show eth0|grep inet|sed -e 's|.* inet \([0-9.]*\)/\([0-9]*\)\W.*|\1 \2|')
  5. ip4=$(echo $ipmask4|cut -d' ' -f 1)
  6. mask4=$(echo $ipmask4|cut -d' ' -f 2)
  7. ip6=$(ip -6 addr show eth0|grep inet6|grep global|sed -e 's|.* inet6 \([0-9a-f:]*\)/\([0-9]*\)\W.*|\1/\2|')
  8. cat >> /etc/uci-defaults/60_docker-network << EOF
  9. #!/bin/sh
  10. uci set network.lan.proto=static
  11. uci set network.lan.ipaddr=$ip4
  12. uci set network.lan.netmask=$mask4
  13. uci set network.lan.gateway=$gw4
  14. uci set network.lan.ip6addr=$ip6
  15. uci set network.lan.ip6gw=$gw6
  16. uci delete network.lan.type
  17. uci delete network.lan6
  18. uci commit network.lan
  19. exit 0
  20. EOF
  21. cat >> /etc/uci-defaults/50_passwd << EOF
  22. #!/bin/sh
  23. echo -e "openwrtpassword\nopenwrtpassword" | passwd
  24. exit 0
  25. EOF
  26. export container=lxc
  27. exec /sbin/init "$@"