#!/bin/bash
#########################################################################
# File Name:XenServer_Add_ISO.sh
# Author:lookback
# email:admin#dwhd.org
# Version:
# Created time:2016 Year March 14 Monday 15:19 58 seconds
#########################################################################
#ColorAuto ================================================================
Echo=echo
for CMD in Echo/bin/echo; Todo
$cmd >/dev/null 2>&1 | | Continue
if! $cmd-E "" | Grep-qe ' ^-e '; Then echo= $cmd && break; Fi
Done
csi=$ ($echo-E "\033[")
Cend= "${csi}0m"
Cdgreen= "${csi}32m"
Cred= "${csi}1;31m"
Cgreen= "${csi}1;32m"
cyellow= "${csi}1;33m"
Cblue= "${csi}1;34m"
Cmagenta= "${csi}1;35m"
Ccyan= "${csi}1;36m"
cquestion= "$CMAGENTA"
Cwarning= "$CRED"
Cmsg= "$CCYAN"
Vg_name= ' VGs 2>/dev/null|awk '/vg_xenstorage/{print $} '
echo "${cgreen}pls input your ISO Storage name: ${cend}"
Read-p "Name:" Iso_storage
echo "${cgreen}pls input your ISO Storage space: ${cend}"
Read-p "Space:" Iso_space
Lvcreate-l ${iso_space}-N ${iso_storage} ${vg_name}
Modprobe dm-mod >/dev/null 2>&1
Vgscan >/dev/null 2>&1
Vgchange-ay >/dev/null 2>&1
Mkfs.ext3/dev/${vg_name}/${iso_storage}
Mkdir-p/${iso_storage}
Echo-e "$ (Blkid/dev/${vg_name}/${iso_storage} |awk ' {print $} ') \t/${iso_storage}\text3\tdefaults\t0 0" >>/etc /fstab
Mount-a
Xe sr-create name-label=iso_storage type=iso device-config:location=/${iso_storage} device-config:legacy_mode=true Content-type=iso
echo "${cwarning}done!${cend}"