summaryrefslogtreecommitdiff
path: root/localnsrequest
blob: 6e6d4daf2ec63ffffd6f8712b5b31ed906127fd5 (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.2 2002-08-09 01:32:55 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. prg=$(basename $0)
  17. copyright="(C) 2002 Jonas Smedegaard <dr@jones.dk>"
  18. usage="$prg, $copyright
  19. Usage: $prg <handle> reg|redel <domain> [<otherdomain> ...]"
  20. if [ $# \< 3 ]; then
  21. echo "Too few parameters!"
  22. echo
  23. echo "$usage"
  24. exit 1
  25. fi
  26. handle=$1
  27. shift
  28. action=$1
  29. shift
  30. if [ -z "$handle" ]; then
  31. echo "Error: Missing handle!"
  32. echo
  33. echo "$usage"
  34. exit 1
  35. fi
  36. BCC=""
  37. [ -n "$EMAIL" ] && BCC="-c $EMAIL"
  38. for DOMAIN in $@; do
  39. case $DOMAIN in
  40. *.dk)
  41. dir='/etc/local-COMMON/DK-Hostmaster'
  42. TO="hostmaster@dk-hostmaster.dk"
  43. case $action in
  44. reg)
  45. file=domain.3.00.dansk.txt-$handle
  46. ;;
  47. redel)
  48. file=redelegation.3.00.dansk.txt-$handle
  49. ;;
  50. *)
  51. echo "Unsupported action: \"$action\"!"
  52. echo
  53. echo "$usage"
  54. echo
  55. echo "Supported actions for this TLD: reg redel"
  56. exit 1
  57. ;;
  58. esac
  59. if [ ! -f $dir/$file ]; then
  60. echo "Error: File \"$dir/$file\" doesn't exist!"
  61. echo "Did you use a valid handle?"
  62. echo
  63. echo "$usage"
  64. exit 1
  65. fi
  66. sed -e "s/{DOMAIN}/$DOMAIN/g" $dir/$file \
  67. | mail -s "$action $DOMAIN ($handle)" -a "Content-Type: TEXT/PLAIN; charset=ISO-8859-1" $BCC -e $TO
  68. ;;
  69. *.com|*.org|*.net)
  70. dir='/etc/local-COMMON/TotalRegistrations'
  71. TO="register@totalregistrations.com"
  72. file=email-$handle
  73. case $action in
  74. reg)
  75. ACTION=N
  76. ;;
  77. redel)
  78. ACTION=T
  79. ;;
  80. *)
  81. echo "Unsupported action: \"$action\"!"
  82. echo
  83. echo "$usage"
  84. echo
  85. echo "Supported actions for this TLD: reg redel"
  86. exit 1
  87. ;;
  88. esac
  89. echo -n "Enter TotalRegistrations password: "
  90. read -s PASSWD
  91. echo
  92. [ -z "$PASSWD" ] && {
  93. echo "No password provided. Exiting..."
  94. exit 1
  95. }
  96. if [ ! -f $dir/$file ]; then
  97. echo "Error: File \"$dir/$file\" doesn't exist!"
  98. echo "Did you use a valid handle?"
  99. echo
  100. echo "$usage"
  101. exit 1
  102. fi
  103. sed -e "s/{DOMAIN}/$DOMAIN/g" -e "s/{ACTION}/$ACTION/g" -e "s/{PASSWD}/$PASSWD/g" $dir/$file \
  104. | mail -s "$action $DOMAIN ($handle)" -a "Content-Type: TEXT/PLAIN; charset=ISO-8859-1" $BCC -e $TO
  105. # | gpg -ea -r $TO | mail -s "$action $DOMAIN ($handle)" -a "Content-Type: TEXT/PLAIN; charset=ISO-8859-1" $BCC -e $TO
  106. ;;
  107. *)
  108. echo "Unsupported domain: \"$DOMAIN\"!"
  109. echo
  110. echo "$usage"
  111. exit 1
  112. ;;
  113. esac
  114. done