Guest User

Untitled

a guest
Oct 18th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1.  
  2. I_smell_the_brand() {
  3. # Doing server detection here
  4. echo "Identifying your server model from DMI data"
  5. dmidata="`dmidecode`"
  6. ServerType=unknown
  7.  
  8. if echo "$dmidata" | grep -e S5000 -e S3210 -e S5520 >/dev/null; then
  9. ServerType=Intel_Server
  10. elif echo "$dmidata" | grep "MSI X58 Pro-E" >/dev/null; then
  11. ServerType=Hetzner_EQ4
  12. elif echo "$dmidata" | grep "IBM System x3655" >/dev/null; then
  13. # IBM, every system may be different
  14. ServerType=IBM_x3655
  15. elif echo "$dmidata" | grep -i -e virtualbox -e vmware >/dev/null;l then
  16. ServerType=virtual
  17. fi
  18. export ServerType
  19. }
  20.  
  21. I_smell_the_rootdisk() {
  22. # For certain disk models I KNOW they are the root device.
  23. set -A definite_root_media TS2GUFM-V TS4GUFM-V USB2FlashStorage # Transcend Flash modules, Verbatim 2G USB Stick
  24.  
  25. # For certain systems I KNOW where root should be.
  26. # Use the following arrays to group them.
  27. # any others will be try to be handled "just right"
  28.  
  29. set -A root_usb_servers Intel_Server # Intel Server boards
  30. set -A root_sata_dmraid_servers Hetzner_EQ4 # Hetzner EQ4
  31. set -A root_hwraid_servers IBM_x3655 # IBM Server
  32.  
  33. # One!
  34. if it's in definite_root_media
  35. # commented useless double safety
  36. # and the server is in root_usb_servers
  37. save its name and return
  38.  
  39. # Two!
  40. # look for a small lun / disk
  41. sizelimit=16G
  42. check the list of disks we were given
  43. if it's size is smaller than 16G
  44. save its name and return
  45.  
  46.  
  47. # Three!
  48. # if we get here then there was no small disk
  49.  
  50. if the ServerType is in root_hwraid_servers
  51. set -A valid_raid_luns
  52.  
  53.  
  54.  
  55. set type hwraid
  56. set type boots_from_data_disk
  57. check the list of disks we were given
  58. look for the first one that is in valid_raid_luns
  59. save its name and return
  60.  
  61. # meh and if we're here than we are dealing with something meh.
  62. look at the list of disks, if we have more than one we might want a raid
  63. save the size of the first disk
  64. look at the second disk
  65. if the first and the second disk are equal-sized
  66. boots_from_data_disk=yes
  67. we'll build a raid
  68. swraid=yes
  69. save the disk
  70. save the partner disk
  71. return
  72.  
  73. otherwise, we'll now use the first disk and use that one.
  74. # here you'd hook in to protect your diskarray.
  75. # piggyback here to exclude certain lun names
  76. set -A invalid_raid_luns
  77.  
  78. save the first disk if its not in invalid_raid_luns
  79. return
  80.  
  81. }
  82.  
  83. get_disk_size(){
  84. # get size in gigabytes
  85. blocks=`cat /sys/block/${osdisk}/size`
  86. # bc is not included
  87. size=`python -c "x = $blocks / 1024 / 1024 /2; print x"`
  88. export size
  89. }
  90.  
  91.  
  92. ### old stuff wont need much of this any more.
  93.  
  94. else
  95. # fall back to a non-existant disk
  96. osdisk=sdzz
  97. sleep 60
  98. exit 1
  99. fi
  100. export osdisk
  101. }
  102.  
  103. finddatadisks() {
  104. for disk in /sys/block/sd[a-z]; do
  105. disk=`basename $disk`
  106. if [ "$disk" != "$osdisk" ]; then
  107. ignoredisks="$disk $ignoredisks"
  108. fi
  109. done
  110. export ignoredisks
  111. return 0
  112. }
  113.  
  114. write_partitions_xenonly_rootdisk() {
  115. # case one: the OS disk is some 2-8GB media for OS only
  116. echo "bootloader --location=mbr --dom0_mem=512 --driveorder=${osdisk}
  117. clearpart --all --initlabel --drives=${osdisk}" > /tmp/kickstart.partition
  118.  
  119. if ! [ -z $ignoredisks ]; then
  120. echo "ignoredisk --drives=$ignoredisks" >> /tmp/kickstart.partition
  121. fi
  122.  
  123. echo "part / --fstype ext3 --size=1800 --ondisk=${osdisk}
  124. part /state --fstype ext3 --size=128 --ondisk=${osdisk}" >> /tmp/kickstart.partition
  125. }
  126.  
  127. check_osdisk() {
  128.  
  129. }
  130.  
  131. findrootdisk &&
  132. finddatadisks &&
  133. check_osdisk &&
  134. # wenn die platte kleiner 16gb ist und??
  135. if [ $size -lt 17 ]; then
  136. write_partitions_xenonly_rootdisk
  137. else
Add Comment
Please, Sign In to add comment