source: drbl-virt/sbin/functions_drbl_virt @ 171

Last change on this file since 171 was 171, checked in by rock, 14 years ago

Add: DRBL patch for Xen

File size: 2.4 KB
RevLine 
[156]1#!/bin/bash
2# Program:
3#   DRBL virt module
4# Author:
5#   Jazz, Rock {jazz, rock}@nchc.org.tw
6# Version:
7#    1.0
8# History:
9#   2010/07/20  Rock    First release (1.0)
10
11# [Variable Declation]
12cpu_flag="no"
13Linux_bit=""
14Linux_Distribution=""
15Linux_Version=""
16VMM_select=""
17
18# [Check Root]
19function check_root(){     
20  if [ $USER != "root" ]; then
[171]21    echo -e "Please change root to run it!"
22    exit
[156]23  fi
24} 
25
[171]26function check_root_run(){
27    if [ $USER != "root" ]; then
28    echo -e "Please change root to run it!"
29    sudo su -c ~/"$0" "$@"
30    exit
31fi
32}
33
34
[156]35# [Check CPU support]
36function cpu_check(){
37egrep '(vmx|svm)' --color=always /proc/cpuinfo > /dev/null
38if [ $? == 0 ]; then
39    cpu_flag="yes"
40fi
41}
42
43# [Check System Version]
44function check_systemInfo(){
45Linux_bit=$(uname -m)
46Linux_Distribution=$(lsb_release -i | awk '{print $3}')
47Linux_Version=$(lsb_release -r | awk '{print $2}')
48}
49
[171]50# [Select Hypervisior(Xen/KVM)]
[156]51function VMM_select(){
52if [ $cpu_flag == "yes" ]; then
53    while [ "$VMM_select" != "1" -a "$VMM_select" != "2"  ]
54    do
[157]55       read -p "Which VMM/Hypervisior will be used in DRBL (1)Xen (2)KVM: " VMM_select
[156]56    done
[171]57  if [ $VMM_select == "1"  ]; then
58    echo "Xen" > $Work_Home/.tmp/hypervisior
59  else
60    echo "KVM" > $Work_Home/.tmp/hypervisior
61  fi 
[156]62else
63    echo "Xen will be the only Hypervisior in your DRBL"
[171]64    echo -e "Because CPU don't support virtualization, it can't choose KVM to be the Hypervisior"
65    echo ""
66    VMM_select=1
67    echo "Xen" > $Work_Home/.tmp/hypervisior
[156]68fi 
69}   
70
[171]71
72# [Create drbl-virt path]
[161]73function install_drbl-virt_dir(){
74    mkdir -p $Work_Home/.tmp
75}
76
[171]77
78# [Check Hypervisior]
[161]79function check_hypervisior(){
[171]80    hypervisior=$(cat $Work_Home/.tmp/hypervisior)   
[161]81}
82
[171]83
84# [Check Debian Xen package]
85function check_debian_xen(){
86aptitude update
87check_debian_xen_pkg=$(aptitude search xen-linux-system)
88if [ -n $check_debian_xen_pkg  ]; then
89    check_debian_xen_pkg="yes"
90else
91    check_debian_xen_pkg="no"
92fi
93}
94
95
96# [Check Xen kernel]
97function check_xen_nu(){
98Kernels=$(ls /boot | grep vmlinuz)
99Kernel_choose=""
100jude="no"
101
102while [ $jude != "yes" -a $jude != "y" ]
103do
104    declare -i i=1
105    echo ""
106   
107    for Kernel in $Kernels
108    do
109        echo "($i) $Kernel" 
110        i=i+1
111    done
112
113    read -p "Xen Kenrel is (1/2/...): " Kernel_choose
114    read -p "Are you sure (yes/no): " jude
115done
116
117Xen_Kernel=$(echo $Kernels | cut -d " " -f${Kernel_choose})
118#echo "debug: Xen_Kernel=$Xen_Kernel"
119}
120
[157]121# [DRBL Check]
[156]122
[171]123
124
Note: See TracBrowser for help on using the repository browser.