Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I_smell_the_brand() {
- # Doing server detection here
- echo "Identifying your server model from DMI data"
- dmidata="`dmidecode`"
- ServerType=unknown
- if echo "$dmidata" | grep -e S5000 -e S3210 -e S5520 >/dev/null; then
- ServerType=Intel_Server
- elif echo "$dmidata" | grep "MSI X58 Pro-E" >/dev/null; then
- ServerType=Hetzner_EQ4
- elif echo "$dmidata" | grep "IBM System x3655" >/dev/null; then
- # IBM, every system may be different
- ServerType=IBM_x3655
- elif echo "$dmidata" | grep -i -e virtualbox -e vmware >/dev/null;l then
- ServerType=virtual
- fi
- export ServerType
- }
- I_smell_the_rootdisk() {
- # For certain disk models I KNOW they are the root device.
- set -A definite_root_media TS2GUFM-V TS4GUFM-V USB2FlashStorage # Transcend Flash modules, Verbatim 2G USB Stick
- # For certain systems I KNOW where root should be.
- # Use the following arrays to group them.
- # any others will be try to be handled "just right"
- set -A root_usb_servers Intel_Server # Intel Server boards
- set -A root_sata_dmraid_servers Hetzner_EQ4 # Hetzner EQ4
- set -A root_hwraid_servers IBM_x3655 # IBM Server
- # One!
- if it's in definite_root_media
- # commented useless double safety
- # and the server is in root_usb_servers
- save its name and return
- # Two!
- # look for a small lun / disk
- sizelimit=16G
- check the list of disks we were given
- if it's size is smaller than 16G
- save its name and return
- # Three!
- # if we get here then there was no small disk
- if the ServerType is in root_hwraid_servers
- set -A valid_raid_luns
- set type hwraid
- set type boots_from_data_disk
- check the list of disks we were given
- look for the first one that is in valid_raid_luns
- save its name and return
- # meh and if we're here than we are dealing with something meh.
- look at the list of disks, if we have more than one we might want a raid
- save the size of the first disk
- look at the second disk
- if the first and the second disk are equal-sized
- boots_from_data_disk=yes
- we'll build a raid
- swraid=yes
- save the disk
- save the partner disk
- return
- otherwise, we'll now use the first disk and use that one.
- # here you'd hook in to protect your diskarray.
- # piggyback here to exclude certain lun names
- set -A invalid_raid_luns
- save the first disk if its not in invalid_raid_luns
- return
- }
- get_disk_size(){
- # get size in gigabytes
- blocks=`cat /sys/block/${osdisk}/size`
- # bc is not included
- size=`python -c "x = $blocks / 1024 / 1024 /2; print x"`
- export size
- }
- ### old stuff wont need much of this any more.
- else
- # fall back to a non-existant disk
- osdisk=sdzz
- sleep 60
- exit 1
- fi
- export osdisk
- }
- finddatadisks() {
- for disk in /sys/block/sd[a-z]; do
- disk=`basename $disk`
- if [ "$disk" != "$osdisk" ]; then
- ignoredisks="$disk $ignoredisks"
- fi
- done
- export ignoredisks
- return 0
- }
- write_partitions_xenonly_rootdisk() {
- # case one: the OS disk is some 2-8GB media for OS only
- echo "bootloader --location=mbr --dom0_mem=512 --driveorder=${osdisk}
- clearpart --all --initlabel --drives=${osdisk}" > /tmp/kickstart.partition
- if ! [ -z $ignoredisks ]; then
- echo "ignoredisk --drives=$ignoredisks" >> /tmp/kickstart.partition
- fi
- echo "part / --fstype ext3 --size=1800 --ondisk=${osdisk}
- part /state --fstype ext3 --size=128 --ondisk=${osdisk}" >> /tmp/kickstart.partition
- }
- check_osdisk() {
- }
- findrootdisk &&
- finddatadisks &&
- check_osdisk &&
- # wenn die platte kleiner 16gb ist und??
- if [ $size -lt 17 ]; then
- write_partitions_xenonly_rootdisk
- else
Add Comment
Please, Sign In to add comment