summaryrefslogtreecommitdiff
path: root/localnsrequest
blob: 6a0309d326f397c7e43749aa328ad3a8a002cdc0 (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/bin/localnsrequest
  4. # Copyright 2001, 2002 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: localnsrequest,v 1.4 2002-08-29 11:06:50 jonas Exp $
  7. #
  8. # Send requests regarding domain registrations to registrars
  9. #
  10. # TODO
  11. # * Loop through all options *before* sending any mail, to exit
  12. # on error with no half-done batch
  13. # * Look for password in home, similar to mysql my.cnf.
  14. # * Clean up the mess of handles being both e.g. spiff and radar
  15. #
  16. set -e
  17. prg=$(basename $0)
  18. copyright="(C) 2002 Jonas Smedegaard <dr@jones.dk>"
  19. usage="$prg, $copyright
  20. Usage: $prg <handle> reg|redel <domain> [<otherdomain> ...]"
  21. if [ $# \< 3 ]; then
  22. echo "Too few parameters!"
  23. echo
  24. echo "$usage"
  25. exit 1
  26. fi
  27. handle=$1
  28. shift
  29. action=$1
  30. shift
  31. if [ -z "$handle" ]; then
  32. echo "Error: Missing handle!"
  33. echo
  34. echo "$usage"
  35. exit 1
  36. fi
  37. BCC=""
  38. [ -n "$EMAIL" ] && BCC="-c $EMAIL"
  39. for DOMAIN in $@; do
  40. case $DOMAIN in
  41. *.dk)
  42. dir='/etc/local-COMMON/DK-Hostmaster'
  43. TO="hostmaster@dk-hostmaster.dk"
  44. case $action in
  45. reg)
  46. file=domain.3.00.dansk.txt-$handle
  47. ;;
  48. redel)
  49. file=redelegation.3.00.dansk.txt-$handle
  50. ;;
  51. *)
  52. echo "Unsupported action: \"$action\"!"
  53. echo
  54. echo "$usage"
  55. echo
  56. echo "Supported actions for this TLD: reg redel"
  57. exit 1
  58. ;;
  59. esac
  60. if [ ! -f $dir/$file ]; then
  61. echo "Error: File \"$dir/$file\" doesn't exist!"
  62. echo "Did you use a valid handle?"
  63. echo
  64. echo "$usage"
  65. exit 1
  66. fi
  67. sed -e "s/{DOMAIN}/$DOMAIN/g" $dir/$file \
  68. | mail -s "$action $DOMAIN ($handle)" -a "Content-Type: TEXT/PLAIN; charset=ISO-8859-1" $BCC -e $TO
  69. ;;
  70. *.com|*.org|*.net)
  71. dir='/etc/local-COMMON/TotalRegistrations'
  72. # TO="register@totalregistrations.com"
  73. file=email-$handle
  74. case $action in
  75. reg)
  76. ACTION=N
  77. ;;
  78. redel)
  79. ACTION=T
  80. ;;
  81. *)
  82. echo "Unsupported action: \"$action\"!"
  83. echo
  84. echo "$usage"
  85. echo
  86. echo "Supported actions for this TLD: reg redel"
  87. exit 1
  88. ;;
  89. esac
  90. echo -n "Enter TotalRegistrations password: "
  91. read -s PASSWD
  92. echo
  93. [ -z "$PASSWD" ] && {
  94. echo "No password provided. Exiting..."
  95. exit 1
  96. }
  97. if [ ! -f $dir/$file ]; then
  98. echo "Error: File \"$dir/$file\" doesn't exist!"
  99. echo "Did you use a valid handle?"
  100. echo
  101. echo "$usage"
  102. exit 1
  103. fi
  104. account=`cat $dir/$file | grep '^11a\.' | sed -e 's/.*:\W\([[:alnum:]]\+\)/\1/'`
  105. TO=$account@totalregistrations.com
  106. sed -e "s/{DOMAIN}/$DOMAIN/g" -e "s/{ACTION}/$ACTION/g" -e "s/{PASSWD}/$PASSWD/g" $dir/$file \
  107. | mail -s "$action $DOMAIN ($handle)" -a "Content-Type: TEXT/PLAIN; charset=ISO-8859-1" -e $TO
  108. # | gpg -ea -r $TO | mail -s "$action $DOMAIN ($handle)" -a "Content-Type: TEXT/PLAIN; charset=ISO-8859-1" -e $TO
  109. ;;
  110. *)
  111. echo "Unsupported domain: \"$DOMAIN\"!"
  112. echo
  113. echo "$usage"
  114. exit 1
  115. ;;
  116. esac
  117. done