mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.8 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/base/sysfiles/stone_mod_network.sh
  9. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version. A copy of the GNU General Public
  15. # License can be found at Documentation/COPYING.
  16. #
  17. # Many people helped and are helping developing ROCK Linux. Please
  18. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  19. # file for details.
  20. #
  21. # --- ROCK-COPYRIGHT-NOTE-END ---
  22. #
  23. # [MAIN] 20 network Network Configuration
  24. set_name() {
  25. old1="$HOSTNAME" old2="$HOSTNAME.$DOMAINNAME" old3="$DOMAINNAME"
  26. if [ $1 = HOSTNAME ] ; then
  27. gui_input "Set a new hostname (without domain part)" \
  28. "${!1}" "$1"
  29. else
  30. gui_input "Set a new domainname (without host part)" \
  31. "${!1}" "$1"
  32. fi
  33. new="$HOSTNAME.$DOMAINNAME $HOSTNAME"
  34. echo "$HOSTNAME" > /etc/HOSTNAME ; hostname "$HOSTNAME"
  35. #ip="`echo $IPADDR | sed 's,[/ ].*,,'`"
  36. #if grep -q "^$ip\\b" /etc/hosts ; then
  37. # tmp="`mktemp`"
  38. # sed -e "/^$ip\\b/ s,\\b$old2\\b[ ]*,,g" \
  39. # -e "/^$ip\\b/ s,\\b$old1\\b[ ]*,,g" \
  40. # -e "/^$ip\\b/ s,[ ]\\+,&$new ," < /etc/hosts > $tmp
  41. # cat $tmp > /etc/hosts ; rm -f $tmp
  42. #else
  43. # echo -e "$ip\\t$new" >> /etc/hosts
  44. #fi
  45. if [ $1 = DOMAINNAME ] ; then
  46. tmp="`mktemp`"
  47. grep -vx "search $old3" /etc/resolv.conf > $tmp
  48. [ -n "$DOMAINNAME" ] && echo "search $DOMAINNAME" >> $tmp
  49. cat $tmp > /etc/resolv.conf
  50. rm -f $tmp
  51. fi
  52. }
  53. set_dns() {
  54. gui_input "Set a new (space seperated) list of DNS Servers" "$DNSSRV" "DNSSRV"
  55. DNSSRV="`echo $DNSSRV`" ; [ -z "$DNSSRV" ] && DNSSRV="none"
  56. tmp="`mktemp`" ; grep -v '^nameserver\b' /etc/resolv.conf > $tmp
  57. for x in $DNSSRV ; do
  58. [ "$x" != "none" ] && echo "nameserver $x" >> $tmp
  59. done
  60. cat $tmp > /etc/resolv.conf
  61. rm -f $tmp
  62. }
  63. HOSTNAME="`hostname`"
  64. DOMAINNAME="`hostname -d 2> /dev/null`"
  65. tmp="`mktemp`"
  66. grep '^nameserver ' /etc/resolv.conf | tr '\t' ' ' | tr -s ' ' | \
  67. sed 's,^nameserver *\([^ ]*\),DNSSRV="$DNSSRV \1",' > $tmp
  68. DNSSRV='' ; . $tmp ; DNSSRV="`echo $DNSSRV`"
  69. [ -z "$DNSSRV" ] && DNSSRV="none" ; rm -f $tmp
  70. main_detailed() {
  71. while
  72. cmd="gui_menu network 'Network Configuration'"
  73. cmd="$cmd 'Static hostname: $HOSTNAME' 'set_name HOSTNAME'"
  74. cmd="$cmd 'Static domainname: $DOMAINNAME' 'set_name DOMAINNAME'"
  75. cmd="$cmd 'Static DNS-Server: $DNSSRV' 'set_dns' '' ''"
  76. cmd="$cmd 'Configure runlevels for network service'"
  77. cmd="$cmd '$STONE runlevel edit_srv network'"
  78. cmd="$cmd '(Re-)Start network init script'"
  79. cmd="$cmd '$STONE runlevel restart network'"
  80. cmd="$cmd '' ''"
  81. cmd="$cmd 'View/Edit /etc/resolv.conf file' 'gui_edit /etc/resolv.conf /etc/resolv.conf'"
  82. cmd="$cmd 'View/Edit /etc/hosts file' 'gui_edit /etc/hosts /etc/hosts'"
  83. cmd="$cmd 'View/Edit /etc/network/config file' 'gui_edit /etc/network/config /etc/network/config'"
  84. cmd="$cmd '' ''"
  85. cmd="$cmd 'Read the /etc/network/README file' 'gui_edit /etc/network/README /etc/network/README'"
  86. eval "$cmd"
  87. do : ; done
  88. }
  89. main() {
  90. while
  91. cmd="gui_menu network 'Network Configuration'"
  92. cmd="$cmd 'Just edit /etc/network/config' 'gui_edit /etc/network/config /etc/network/config'"
  93. cmd="$cmd 'Read the /etc/network/README file' 'gui_edit /etc/network/README /etc/network/README'"
  94. cmd="$cmd 'Detailed Networking configuration' 'exec $0 network main_detailed'"
  95. eval "$cmd"
  96. do : ; done
  97. }