Ignore:
Timestamp:
Aug 29, 2010, 2:48:03 PM (14 years ago)
Author:
rock
Message:

Add function Code: check_drbl_client.sh (Detect DRBL clinet status)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • drbl-virt/sbin/functions_drbl_virt

    r190 r195  
    1616VMM_select=""
    1717
     18
    1819# [Check Root]
    1920function check_root(){     
     
    2425}
    2526
     27# [Change root to run]
    2628function check_root_run(){
    2729    if [ $USER != "root" ]; then
     
    4143}
    4244
     45
    4346# [Check System Version]
    4447function check_systemInfo(){
     
    4750Linux_Version=$(lsb_release -r | awk '{print $2}')
    4851}
     52
    4953
    5054# [Select Hypervisior(Xen/KVM)]
     
    7074}   
    7175
     76
    7277# [Check Hypervisior]
    7378function check_hypervisior(){
     
    140145
    141146
     147# [Tunning Debain env for Xen]
    142148function debain-lenny_xen_patch(){
    143149echo xen.independent_wallclock=1 >> /etc/sysctl.conf
     
    148154
    149155
     156# [Get ethX for DRBL environment usage ]
    150157function get_DRBL_eth(){
    151158eths=$(ls /etc/drbl | grep macadr-eth[0-9] | grep [0-9].txt$ | cut -d "-" -f2 | cut -d "." -f1)
     
    160167}
    161168
     169
     170# [Get DRBL client IP range]
    162171function get_Host_IP_range(){
    163172if [ ! -e /usr/bin/ipcalc ] || [ ! -e /opt/drbl/bin/drbl-get-network ] || [ ! -e /opt/drbl/bin/drbl-get-ipadd ]; then
     
    175184}
    176185
     186
     187# [Input VM IP range]
    177188function get_VM_IP_range_and_prefix_name(){
    178 
    179189echo ""
    180190echo "DRBL client IP range -> $eth: [$Host_first_IP ~ $Host_last_IP]"
     
    213223
    214224
     225# [Get VM prefix name]
    215226#function get_VM_prefix_name(){
    216227#jude="no"
     
    224235#}
    225236
     237
     238# [Create VM IP table]
    226239function create_VM_IP_table(){
    227240#/etc/drbl-virt/etc/IP_VM_eth
     
    271284}
    272285
     286
     287# [Creat VM Mac table]
    273288function generate_Xen_MAC_address(){
    274289#echo "eth $eth"
     
    312327}
    313328
     329
    314330#function add_VM_dhcpd_conf(){
    315331## backup dhcpd.conf
     
    353369
    354370
     371
     372# [create ssh key amd cpoy to client]
     373function drbl_sshkey(){
     374# The reasone we do not to use $HOME is that sudo will not change
     375# environmental variable $HOME, but it will change the $USER
     376# we need to know who is really running this after applying sudo.
     377# say, sudo echo "$HOME", it will show user's home, instead of root's home,
     378REALHOME=$(LC_ALL=C grep -Ew "^$USER" /etc/passwd | cut -d":" -f6)
     379drblroot="/tftpboot/nodes"
     380
     381if [ ! -f $REALHOME/.ssh/id_rsa ]; then
     382  ssh-keygen -t rsa -q -f $REALHOME/.ssh/id_rsa -N ""
     383fi
     384
     385# Put authorized_keys for the user. 2 cases:
     386# (1). It is root running drbl-doit.
     387# (2). It is normal user running drbl-doit.
     388# For root, we will NOT copy authorized_keys in server, since the root in the client should not share the same authorized_keys with that in server. We only put them in the client. (Note! Every client has its own root directory in $ihost/root/)
     389# For normal user, we let user can ssh login back to server and other machine without password (Note! This is NFS-based home, so we just have to copy id_rsa.pub as authorized_keys in user's home, then no matter which machine user logins, it will use this key).
     390if [ "$UID" = "0" ]; then
     391  # for root, copy id_rsa.pub as authorized_keys in clients.
     392  for ihost in $drblroot/*; do
     393    if [ -f "$REALHOME/.ssh/id_rsa.pub" ]; then
     394      mkdir -p $ihost/root/.ssh
     395      cp -af $REALHOME/.ssh/id_rsa.pub $ihost/root/.ssh/authorized_keys
     396    fi
     397  done
     398else
     399  if [ -f "$REALHOME/.ssh/id_rsa.pub" ]; then
     400    cp -af $REALHOME/.ssh/id_rsa.pub $REALHOME/.ssh/authorized_keys
     401  fi
     402fi
     403
     404}
Note: See TracChangeset for help on using the changeset viewer.