config_store.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. #
  3. # store config settings
  4. #
  5. CONF="/etc/speaker.conf"
  6. NET_CONF="/tmp/interfaces"
  7. [ ! -f "/etc/speaker.conf" ] && exit 1
  8. net_type=`sysconf ${CONF} get system ip_assign`
  9. if [ "${net_type}" = "dhcp" ]; then
  10. cat << END > ${NET_CONF}
  11. # interfaces(5) file used by ifup(8) and ifdown(8)
  12. # Include files from /etc/network/interfaces.d:
  13. auto lo
  14. iface lo inet loopback
  15. auto eth0
  16. iface eth0 inet dhcp
  17. udhcpc_opts -R -n -O tftp
  18. END
  19. echo -n > /tmp/resolv.conf
  20. elif [ "${net_type}" = "static" ]; then
  21. ip=`sysconf ${CONF} get system ipaddr`
  22. mask=`sysconf ${CONF} get system netmask`
  23. gateway=`sysconf ${CONF} get system gateway`
  24. cat << END > ${NET_CONF}
  25. # interfaces(5) file used by ifup(8) and ifdown(8)
  26. # Include files from /etc/network/interfaces.d:
  27. auto lo
  28. iface lo inet loopback
  29. auto eth0
  30. iface eth0 inet static
  31. address ${ip}
  32. netmask ${mask}
  33. gateway ${gateway}
  34. END
  35. dns1=`sysconf ${CONF} get system dns1`
  36. dns2=`sysconf ${CONF} get system dns2`
  37. echo -n > /tmp/resolv.conf
  38. [ ! -z "${dns1}" ] && echo "nameserver ${dns1}" >> /tmp/resolv.conf
  39. [ ! -z "${dns2}" ] && echo "nameserver ${dns2}" >> /tmp/resolv.conf
  40. fi