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.

160 lines
6.1 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/blindcoder/ezipupdate/mod_ezipupdate.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] 60 ezipupdate EZ-Ipupdate Configuration (dyndns et al)
  24. ezipupdate_new_step3 () {
  25. cmd=""
  26. iface="$1"
  27. tos="$2"
  28. gui_input "Please enter the dns name you want to update" "" hostname
  29. gui_input "Please enter the username for $hostname" "" user
  30. gui_input "Please enter the password for $hostname" "" pass
  31. gui_input "Please enter the MX record for $hostname" "$hostname" mx
  32. gui_input "Please enter the number of times the update should be tried" 3 retries
  33. gui_input "Please enter the mail-address errors should be reported to" "root@localhost" errorsto
  34. gui_input "Please enter the period to check if the IP-address changed in seconds" 1800 checkperiod
  35. gui_yesno "Do you want wildcard dnsnames? (*.$hostname would all resolve to your current IP-Address)"
  36. wildcard=$?
  37. cmd="-e 's,INTERFACE,$iface,g'"
  38. cmd="$cmd -e 's,SERVICETYPE,$tos,g'"
  39. cmd="$cmd -e 's,HOSTNAME,$hostname,g'"
  40. cmd="$cmd -e 's,USER,$user,g'"
  41. cmd="$cmd -e 's,PASS,$pass,g'"
  42. cmd="$cmd -e 's,MXADDRESS,$mx,g'"
  43. cmd="$cmd -e 's,RETRIES,$retries,g'"
  44. cmd="$cmd -e 's,EMAILADDRESS,$errorsto,g'"
  45. cmd="$cmd -e 's,PERIOD,$checkperiod,g'"
  46. [ $wildcard -eq 1 ] && cmd="$cmd -e 's,wildcard,# nowildcard,g'"
  47. eval "sed $cmd /etc/ezipupdate/stone.conf.template > /etc/ezipupdate/stone.$iface"
  48. }
  49. ezipupdate_new_step2 () {
  50. cmd=""
  51. iface="$1"
  52. for x in ezip pgpow dhs dyndns dyndns-static dyndns-custom ods tzo \
  53. easydns easydns-partner gnudip justlinux dyns hn zoneedit \
  54. heipv6tb ; do
  55. cmd="$cmd '$x' 'ezipupdate_new_step3 $iface $x'"
  56. done
  57. eval "gui_menu ezipupdate_new_step2 'Please select the type of service' $cmd"
  58. }
  59. ezipupdate_new_step1 () {
  60. cmd=""
  61. while read iface ; do
  62. [ -f /etc/ezipupdate/stone.$iface ] && continue
  63. cmd="$cmd '$iface' 'ezipupdate_new_step2 $iface'"
  64. done < <( grep interface /etc/network/config | cut -f 2 -d\ | cut -f1 -d\( | sort )
  65. eval "gui_menu ezipupdate_new_step1 'Please select the interface to use' $cmd"
  66. }
  67. ezipupdate_change_tos () {
  68. cmd=""
  69. for x in ezip pgpow dhs dyndns dyndns-static dyndns-custom ods tzo \
  70. easydns easydns-partner gnudip justlinux dyns hn zoneedit \
  71. heipv6tb ; do
  72. cmd="$cmd '$x' 'tos=$x'"
  73. done
  74. eval "gui_menu ezipupdate_change_tos 'Please select the new type of service' $cmd"
  75. }
  76. ezipupdate_change_wildcard () {
  77. gui_yesno "Do you want wildcard dnsnames? (*.$hostname would all resolve to your current IP-Address)"
  78. case "$?" in
  79. 1) wildcard=0 ; ;;
  80. 0) wildcard=1 ; ;;
  81. esac
  82. }
  83. ezipdate_change_iface () {
  84. cmd=""
  85. while read i ; do
  86. [ -f /etc/ezipupdate/stone.$i -a $i != $oldiface ] && continue
  87. cmd="$cmd '$i' 'iface=$i'"
  88. done < <( grep interface /etc/network/config | cut -f 2 -d\ | cut -f1 -d\( | sort )
  89. eval "gui_menu ezipupdate_change_iface 'Please select the new interface to use' $cmd"
  90. }
  91. ezipupdate_edit () {
  92. iface=$1
  93. oldiface=$1
  94. conf=/etc/ezipupdate/stone.$iface
  95. tos="`grep ^service-type $conf | cut -f2 -d=`"
  96. hostname="`grep ^host $conf | cut -f2 -d=`"
  97. IFS=":" read user pass < <( grep ^user $conf | cut -f2 -d= )
  98. mx="`grep ^mx $conf | cut -f2 -d=`"
  99. retries="`grep ^retrys $conf | cut -f2 -d=`"
  100. errorsto="`grep ^notify-email $conf | cut -f2 -d=`"
  101. checkperiod="`grep ^period $conf | cut -f2 -d=`"
  102. wildcard=`grep -c ^wildcard $conf`
  103. run=0
  104. while [ $run -eq 0 ] ; do
  105. yesno="yes"
  106. [ $wildcard -eq 0 ] && yesno="no"
  107. gui_menu "ezipupdate_edit" "EZ-IPUpdate settings for $iface" \
  108. "Type of service: $tos" "ezipupdate_change_tos" \
  109. "Interface to check: $iface" "ezipdate_change_iface" \
  110. "Hostname: $hostname" "gui_input 'Enter new hostname' '$hostname' hostname" \
  111. "Username: $user" "gui_input 'Enter new username' '$user' user" \
  112. "Password: $pass" "gui_input 'Enter new password' '$pass' pass" \
  113. "MX-Record: $mx" "gui_input 'Enter new MX-Record' '$mx' mx" \
  114. "Retries: $retries" "gui_input 'Enter new number of retries' '$retries' retries" \
  115. "Report errors to: $errorsto" "gui_input 'Enter new mail address to report errors to' '$errorsto' errorsto" \
  116. "Checking period in seconds: $checkperiod" "gui_input 'Enter new period to check if IP-address changed in seconds' '$checkperiod' checkperiod" \
  117. "Wildcard DNS: $yesno" "ezipupdate_change_wildcard"
  118. run=$?
  119. done
  120. rm -f /etc/ezipupdate/stone.$oldiface
  121. cmd="-e 's,INTERFACE,$iface,g'"
  122. cmd="$cmd -e 's,SERVICETYPE,$tos,g'"
  123. cmd="$cmd -e 's,HOSTNAME,$hostname,g'"
  124. cmd="$cmd -e 's,USER,$user,g'"
  125. cmd="$cmd -e 's,PASS,$pass,g'"
  126. cmd="$cmd -e 's,MXADDRESS,$mx,g'"
  127. cmd="$cmd -e 's,RETRIES,$retries,g'"
  128. cmd="$cmd -e 's,EMAILADDRESS,$errorsto,g'"
  129. cmd="$cmd -e 's,PERIOD,$checkperiod,g'"
  130. [ $wildcard -eq 0 ] && cmd="$cmd -e 's,wildcard,# nowildcard,g'"
  131. eval "sed $cmd /etc/ezipupdate/stone.conf.template > /etc/ezipupdate/stone.$iface"
  132. }
  133. main() {
  134. run=0
  135. while [ $run -eq 0 ] ; do
  136. cmd=""
  137. for conf in /etc/ezipupdate/stone.* ; do
  138. [ -f $conf ] || continue
  139. [ "$conf" == "/etc/ezipupdate/stone.conf.template" ] && continue
  140. interface="`grep 'interface=' $conf | cut -f2 -d=`"
  141. if [ -z "$interface" ] ; then
  142. gui_message "Bogus interface configuration: $interface! Please edit $conf manually!"
  143. continue
  144. fi
  145. cmd="$cmd 'Edit interface $interface' 'ezipupdate_edit $interface'"
  146. done
  147. cmd="$cmd 'Add new interface' 'ezipupdate_new_step1'"
  148. eval "gui_menu ezipupdate 'EZ-Ipupdate Configuration' $cmd"
  149. run=$?
  150. done
  151. }