Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. #!/usr/bin/env
  2. clear
  3. ipCheckCount=0
  4.  
  5.  
  6. function CreateMountPointY(){
  7.  
  8. if [ ! -d /mnt/y ]; then
  9. mkdir /mnt/y
  10. fi
  11.  
  12. umount /mnt/y
  13.  
  14. return 0
  15. }
  16.  
  17. function DetectSubnetPrefix(){
  18.  
  19. ipCheckCount+=
  20. GW=`route -n|tail -n1|awk '{ print $2 }'`
  21.  
  22. subNetPrefix=""
  23.  
  24. if [ ${GW:0:9} == "192.19.26" ]; then
  25. echo "You are in the test lab."
  26. subNetPrefix="192.19.26."
  27. else
  28.  
  29. if [ ${GW:0:10} == "192.17.141" ]; then
  30. echo "You are live!"
  31. subNetPrefix="192.17.141."
  32. fi
  33.  
  34. fi
  35.  
  36. if [ $subNetPrefix == "" ]; then
  37. if [ $ipCheckCount -gt 10 ]; then
  38. Echo should have given up by now
  39. fi
  40. Sleep 5
  41. DetectSubnetPrefix
  42. fi
  43.  
  44. }
  45.  
  46. function MountYDrive(){
  47.  
  48. mount -t cifs //${subNetPrefix}31/results /mnt/y -o username=PEDriveMapper,password=password1234,dir_mode=0777,file_mode=0777
  49.  
  50. }
  51.  
  52. function CreateAndMountPartitions(){
  53.  
  54. declare -a arrVol
  55. declare -a arrPar
  56.  
  57. intVol=0
  58. intPar=0
  59.  
  60. for i in $(ls -d /dev/sd*);
  61. do
  62.  
  63. if [ ${#i} == 8 ]; then
  64. #echo intVol is $intVol
  65. arrVol[$intVol]=${i%%}
  66. intVol+=
  67. echo Found a volume: ${i:0:8}
  68. else
  69. #echo intPar is $intPar
  70. arrPar[$intPar]=${i%%}
  71. intPar+=
  72. echo Found a partition: ${i%%}
  73. fi
  74.  
  75. done
  76.  
  77. for i in "${arrPar[@]}"
  78. do
  79. echo Remove partition $i
  80. umount $i
  81. parted --s ${i:0:8} rm ${i##${i:0:8}}
  82. done
  83.  
  84. strMountPoint=0
  85. for i in "${arrVol[@]}"
  86. do
  87. echo Create single large partition on $i
  88. echo parted --s $i mkpart primary 0 -- -0
  89. parted --s $i mkpart primary 0 -- -0
  90.  
  91. echo mkfs.ntfs -Q ${i}1
  92. mkfs.ntfs -Q ${i}1
  93.  
  94. echo Mount it
  95. if [ ! -d /mnt/${drive}${strMountPoint} ]; then
  96. mkdir /mnt/${drive}${strMountPoint}
  97. fi
  98. echo mount -t ntfs ${i}1 /mnt/${drive}${strMountPoint}
  99. mount -t ntfs ${i}1 /mnt/${drive}${strMountPoint}
  100. strMountPoint+=
  101. done
  102.  
  103. unset arrVol
  104. unset arrPar
  105.  
  106. }
  107.  
  108. CreateMountPointY
  109. DetectSubnetPrefix
  110. MountYDrive
  111. #LaunchBurnIn
  112.  
  113. read -p "WARRNING!!! Continuing will erase all data on all drives attached to this system. Press CTRL-C to abort or hit Enter to continue..."
  114.  
  115. CreateAndMountPartitions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement