Chinaunix
标题:
dsview install menu
[打印本页]
作者:
viviecho
时间:
2011-12-23 03:10
标题:
dsview install menu
#
!
/
bin
/
bash
function
import
(
)
{
#init answer
=
no so that exect the first time
.
answer
=
"no"
#press any key retype the information
while
[
$answer
=
"no"
]
do
{
#if it is not
a
valid ip
address
,
retype the information
while
[
-
z
"$ip"
]
do read
-
p
"#########################
Input Target DataBase IP
--------------------------
Please input Target DataBase IP: " dbip
#check if it is
a
valid ip
ip
=
`
echo $dbip
|
awk
-
F
.
'{ if(NF==4&&$1<255&&$2<255&&$3<255&&$4<255){print $0} }'
`
echo
echo
#ip
input
done
done
#if it is not
a
valid port number
,
retype the information
while
[
-
z
"$port"
]
do read
-
p
"#########################
Input Target DataBase Port
--------------------------
please input Target DataBase Port : " dbport
#check if it is
a
valid port number
port
=
`
echo $dbport
|
awk
'{ if(NF==1&&$1<65535){print $0} }'
`
echo
echo
#port
input
done
done
while
[
-
z
"$dbusername"
]
do read
-
p
"#########################
Input Target DataBase username
--------------------------
please input Target DataBase Username : " dbusername
echo
echo
done
while
[
-
z
"$dbpasswd"
]
do read
-
p
"#########################
Input Target DataBase Password
--------------------------
please input Target DataBase Password : " dbpasswd
echo
echo
done
#check if the migration
file
path is
a
valid
direction
while
[
!
-
d
"$migration"
]
do read
-
p
"#########################
Input The Migration File Path
--------------------------
please input the Migration File Path : " migration
echo
echo
done
#check if the backup
file
location is
a
valid
direction
while
[
!
-
d
"$backup"
]
do read
-
p
"#########################
Input Data Backup File Location
--------------------------
please input Data Backup File Location : " backup
echo
echo
done
echo
"please Review the Following Before Continuing:"
echo
echo
"Target DataBase IP: $dbip"
echo
"Target DataBase Port: $dbport"
echo
"Target DataBase Username: $dbusername"
echo
"Target DataBase Password: $dbpasswd"
echo
"The Migration File Path: $migration"
echo
"The Data Backup File Location : $backup"
#echo
"Data Backup File Password : $password"
echo
echo
read
-
p
"Are you sure you want to Import the summary?
or press any key retype Information (Y/N) " answer
echo
if
[
"$answer"
=
"Y"
-
o
"$answer"
=
"y"
]
then
{
echo
echo
"Target DataBase IP : $dbip"
echo
"Target DataBase Port : $dbport"
echo
"Target DataBase Username : $dbusername"
echo
"Target DataBase Password : $dbpasswd"
echo
"The Migration File Path : $migration"
echo
"The Data Backup File Location : $backup"
#echo
"Data Backup File Password : $password"
exit
}
else
{
#user
type
any key or no
,
go to the point of retype information
.
answer
=
"no"
#
clear
all the information and retype it
.
ip
=
""
port
=
""
dbusername
=
""
dbpasswd
=
""
migration
=
""
backup
=
""
#password
=
""
}
fi
}
#retype done
done
}
function export
(
)
{
answer
=
"no"
while
[
"$answer"
=
"no"
]
do
{
while
[
"$servertype"
!
=
"1"
-
a
"$servertype"
!
=
"2"
]
do read
-
p
"####################################
Choose Server Type <HUB or SPOKE>
------------------------------------
1 HUB
2 SPOKE
Please choose the Server Type : " servertype
echo
echo
done
if
[
$servertype
=
=
"1"
]
then
SERVERTYPE
=
"HUB"
else
SERVERTYPE
=
"SPOKE"
fi
while
[
"$dbtype"
!
=
"1"
-
a
"$dbtype"
!
=
"2"
]
do read
-
p
"####################################
Choose DataBase Type <DSView or PMP>
------------------------------------
1 DSView
2 PMP
Please choose the Server Type : " dbtype
echo
echo
done
if
[
$dbtype
=
=
"1"
]
then
DBTYPE
=
"DSView"
else
DBTYPE
=
"PMP"
fi
echo
"#############################################################
Please input Database Backup File Name and the Migration File Path
-------------------------------------------------------------------"
echo
echo
while
[
!
-
f
"$backup"
]
do read
-
p
"Please input Database Backup File Name: "
backup
echo
done
while
[
!
-
d
"$migration"
]
do read
-
p
"Please input the Migration File Path: "
migration
echo
done
#while
[
-
z
"$password"
]
#do echo
"######################################
#Please input Database Backup File Password
#--------------------------------------------"
#echo
#echo
#read
-
p
"Please input Database Backup File Password: "
password
#echo
#echo
#done
echo
"please Review the Following Before Continuing:"
echo
echo
"ServerType: $SERVERTYPE"
echo
"DataBaseType: $DBTYPE"
echo
"Database Backup File Name: $backup"
echo
"The Migration File Path: $migration"
#echo
"Database Backup File Password: $password"
echo
read
-
p
"Are you sure you want to export the summary?
or press any key to retype Information (Y/N) " answer
echo
if
[
"$answer"
=
"Y"
-
o
"$answer"
=
"y"
]
then
{
echo
"ServerType: $SERVERTYPE"
echo
"DataBaseType: $DBTYPE"
echo
"Database Backup File Name: $backup"
echo
"The Migration File Path: $migration"
#echo
"Database Backup File Password: $password"
answer
=
"yes"
exit
}
else
{
answer
=
"no"
servertype
=
""
dbtype
=
""
backup
=
""
migration
=
""
password
=
""
}
fi
}
done
}
echo
"#########################
Choose the operation
------------------------
1 Import
2 Export
3 Exit
"
read
-
p
"Please Choose the operation : "
answer
echo
case $answer in
1
)
import
;
;
2
)
export
;
;
*
)
exit
esac
#echo
"$answer"
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2