免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1449 | 回复: 0
打印 上一主题 下一主题

dsview install menu [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-23 03:10 |只看该作者 |倒序浏览
  1. #!/bin/bash


  2. function import(){

  3. #init answer=no so that exect the first time.
  4. answer="no"
  5. #press any key retype the information
  6. while [ $answer="no" ]
  7. do
  8. {
  9. #if it is not a valid ip address ,retype the information
  10. while [ -z "$ip" ]
  11. do read -p "#########################
  12. Input Target DataBase IP
  13. --------------------------

  14. Please input Target DataBase IP: " dbip
  15. #check if it is a valid ip
  16. ip=`echo $dbip|awk -F . '{ if(NF==4&&$1<255&&$2<255&&$3<255&&$4<255){print $0} }'`
  17. echo
  18. echo
  19. #ip input done
  20. done

  21. #if it is not a valid port number, retype the information
  22. while [ -z "$port" ]
  23. do read -p "#########################
  24. Input Target DataBase Port
  25. --------------------------

  26. please input Target DataBase Port : " dbport
  27. #check if it is a valid port number
  28. port=`echo $dbport|awk '{ if(NF==1&&$1<65535){print $0} }'`
  29. echo
  30. echo
  31. #port input done
  32. done


  33. while [ -z "$dbusername" ]
  34. do read -p "#########################
  35. Input Target DataBase username
  36. --------------------------

  37. please input Target DataBase Username : " dbusername
  38. echo
  39. echo
  40. done

  41. while [ -z "$dbpasswd" ]
  42. do read -p "#########################
  43. Input Target DataBase Password
  44. --------------------------

  45. please input Target DataBase Password : " dbpasswd
  46. echo
  47. echo
  48. done

  49. #check if the migration file path is a valid direction
  50. while [ ! -d "$migration" ]
  51. do read -p "#########################
  52. Input The Migration File Path
  53. --------------------------

  54. please input the Migration File Path : " migration
  55. echo
  56. echo
  57. done

  58. #check if the backup file location is a valid direction
  59. while [ ! -d "$backup" ]
  60. do read -p "#########################
  61. Input Data Backup File Location
  62. --------------------------

  63. please input Data Backup File Location : " backup
  64. echo
  65. echo
  66. done
  67. echo "please Review the Following Before Continuing:"
  68. echo
  69. echo "Target DataBase IP: $dbip"
  70. echo "Target DataBase Port: $dbport"
  71. echo "Target DataBase Username: $dbusername"
  72. echo "Target DataBase Password: $dbpasswd"
  73. echo "The Migration File Path: $migration"
  74. echo "The Data Backup File Location : $backup"
  75. #echo "Data Backup File Password : $password"

  76. echo
  77. echo

  78. read -p "Are you sure you want to Import the summary?
  79. or press any key retype Information (Y/N) " answer
  80. echo
  81. if [ "$answer" = "Y" -o "$answer" = "y" ]
  82. then
  83. {
  84. echo
  85. echo "Target DataBase IP : $dbip"
  86. echo "Target DataBase Port : $dbport"
  87. echo "Target DataBase Username : $dbusername"
  88. echo "Target DataBase Password : $dbpasswd"
  89. echo "The Migration File Path : $migration"
  90. echo "The Data Backup File Location : $backup"
  91. #echo "Data Backup File Password : $password"
  92. exit
  93. }
  94. else
  95. {
  96. #user type any key or no, go to the point of retype information.
  97. answer="no"
  98. #clear all the information and retype it.
  99. ip=""
  100. port=""
  101. dbusername=""
  102. dbpasswd=""
  103. migration=""
  104. backup=""
  105. #password=""
  106. }
  107. fi
  108. }
  109. #retype done
  110. done
  111.  }



  112. function export(){

  113. answer="no"
  114. while [ "$answer" = "no" ]
  115. do
  116. {
  117. while [ "$servertype" != "1" -a "$servertype" != "2" ]
  118. do read -p "####################################
  119. Choose Server Type <HUB or SPOKE>
  120. ------------------------------------

  121.         1 HUB
  122.         2 SPOKE

  123. Please choose the Server Type : " servertype
  124. echo
  125. echo
  126. done
  127. if [ $servertype == "1" ]
  128. then
  129. SERVERTYPE="HUB"
  130. else
  131. SERVERTYPE="SPOKE"
  132. fi


  133. while [ "$dbtype" != "1" -a "$dbtype" != "2" ]
  134. do read -p "####################################
  135. Choose DataBase Type <DSView or PMP>
  136. ------------------------------------

  137.         1 DSView
  138.         2 PMP

  139. Please choose the Server Type : " dbtype
  140. echo
  141. echo
  142. done
  143. if [ $dbtype == "1" ]
  144. then
  145. DBTYPE="DSView"
  146. else
  147. DBTYPE="PMP"
  148. fi

  149. echo "#############################################################
  150. Please input Database Backup File Name and the Migration File Path
  151. -------------------------------------------------------------------"
  152. echo
  153. echo

  154. while [ ! -f "$backup" ]
  155. do read -p "Please input Database Backup File Name: " backup
  156. echo
  157. done


  158. while [ ! -d "$migration" ]
  159. do read -p "Please input the Migration File Path: " migration
  160. echo
  161. done

  162. #while [ -z "$password" ]
  163. #do echo "######################################
  164. #Please input Database Backup File Password
  165. #--------------------------------------------"
  166. #echo
  167. #echo
  168. #read -p "Please input Database Backup File Password: " password
  169. #echo
  170. #echo
  171. #done

  172. echo "please Review the Following Before Continuing:"
  173. echo
  174. echo "ServerType: $SERVERTYPE"
  175. echo "DataBaseType: $DBTYPE"
  176. echo "Database Backup File Name: $backup"
  177. echo "The Migration File Path: $migration"
  178. #echo "Database Backup File Password: $password"
  179. echo
  180. read -p "Are you sure you want to export the summary?
  181. or press any key to retype Information (Y/N) " answer
  182. echo
  183. if [ "$answer" = "Y" -o "$answer" = "y" ]
  184. then
  185. {

  186. echo "ServerType: $SERVERTYPE"
  187. echo "DataBaseType: $DBTYPE"
  188. echo "Database Backup File Name: $backup"
  189. echo "The Migration File Path: $migration"
  190. #echo "Database Backup File Password: $password"
  191. answer="yes"
  192. exit
  193. }
  194. else
  195. {
  196. answer="no"
  197. servertype=""
  198. dbtype=""
  199. backup=""
  200. migration=""
  201. password=""
  202. }
  203. fi
  204. }
  205. done
  206. }



  207. echo "#########################
  208. Choose the operation
  209. ------------------------

  210.         1 Import
  211.         2 Export
  212.         3 Exit

  213. "
  214. read -p "Please Choose the operation : " answer
  215. echo
  216. case $answer in
  217. 1)
  218. import
  219. ;;
  220. 2)
  221. export
  222. ;;
  223. *)
  224. exit
  225. esac
  226. #echo "$answer"
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP