@@ -12,11 +12,18 @@ set -e
1212# ######### Variable ##########
1313CURRENT_USER=" $( id -un 2> /dev/null || true) "
1414BOOTSTRAP_DIR=" /tmp/hyper-bootstrap-${CURRENT_USER} "
15+ BASH_C=" bash -c"
1516# ######### Parameter ##########
1617S3_URL=" http://hyper-install.s3.amazonaws.com"
1718PKG_FILE=" hyper-latest.tgz"
1819UNTAR_DIR=" hyper-pkg"
1920SUPPORT_EMAIL=" support@hyper.sh"
21+ # ########### RPM ##############
22+ CENTOS7_QEMU_HYPER=" qemu-hyper-2.4.1-2.el7.centos.x86_64"
23+ CENTOS7_HYPERSTART=" hyperstart-0.5-1.el7.centos.x86_64"
24+ CENTOS7_HYPER=" hyper-0.5-1.el7.centos.x86_64"
25+ FC23_HYPERSTART=" hyperstart-0.5-1.fc23.x86_64"
26+ FC23_HYPER=" hyper-0.5-1.fc23.x86_64"
2027# ######### Constant ##########
2128SUPPORT_DISTRO=(debian ubuntu fedora centos linuxmint)
2229LINUX_MINT_CODE=(rafaela rebecca qiana)
@@ -49,22 +56,31 @@ ERR_UNTAR_PKG_FAILED=(62 "Untar install package failed!")
4956ERR_EXEC_INSTALL_FAILED=(70 " Install hyper failed!" )
5057ERR_INSTALL_SERVICE_FAILED=(71 " Install hyperd as service failed!" )
5158ERR_HYPER_NOT_FOUND=(72 " Can not find hyper and hyperd after setup!" )
59+ ERR_HYPER_NO_NEW_VERSION=(80 " You are using the newest hyper\n" )
5260ERR_UNKNOWN_MSG_TYPE=98
5361ERR_UNKNOWN=99
5462# ######### Function Definition ##########
5563main () {
5664 check_user
57- check_deps
58- check_hyper_before_install
59- if [[ -f install.sh ]] && [[ -d bin ]] && [[ -d boot ]] && [[ -d service ]]; then
60- show_message debug " Install from local ${BASE_DIR} /"
61- BOOTSTRAP_DIR=" ${BASE_DIR} "
65+ check_os_platform
66+ check_os_distro
67+ if [[ " ${LSB_DISTRO} " == " centos" ]] && [[ " ${CMAJOR} " == " 7" ]]; then
68+ install_from_rpm " centos7"
69+ elif [[ " ${LSB_DISTRO} " == " fedora" ]] && [[ " ${CMAJOR} " == " 23" ]]; then
70+ install_from_rpm " fedora23"
6271 else
63- show_message debug " Install from remote"
64- fetch_hyper_package
72+ check_deps
73+ check_hyper_before_install
74+ if [[ -f install.sh ]] && [[ -d bin ]] && [[ -d boot ]] && [[ -d service ]]; then
75+ show_message debug " Install from local ${BASE_DIR} /"
76+ BOOTSTRAP_DIR=" ${BASE_DIR} "
77+ else
78+ show_message debug " Install from remote"
79+ fetch_hyper_package
80+ fi
81+ stop_running_hyperd
82+ install_hyper
6583 fi
66- stop_running_hyperd
67- install_hyper
6884 start_hyperd_service
6985 exit 0
7086}
@@ -84,7 +100,6 @@ COMMENT
84100 fi
85101}
86102check_user () {
87- BASH_C=" bash -c"
88103 if [ " ${CURRENT_USER} " != " root" ]; then
89104 if (command_exist sudo); then
90105 BASH_C=" sudo -E bash -c"
@@ -97,20 +112,17 @@ check_user() {
97112}
98113check_deps () {
99114 show_message info " Check dependency "
100- check_deps_platform
101- check_deps_distro
102115 check_deps_qemu || check_deps_xen || exit ${${ERR_NO_HYPERVISOR[0]} }
103116 check_deps_initsystem
104117 show_message done " Done"
105118}
106- check_deps_platform () {
119+ check_os_platform () {
107120 ARCH=" $( uname -m) "
108121 if [ " ${ARCH} " != " x86_64" ]; then
109122 show_message error " ${ERR_NOT_SUPPORT_PLATFORM[1]} " && exit ${ERR_NOT_SUPPORT_PLATFORM[0]}
110123 fi
111- echo -n " ."
112124}
113- check_deps_distro () {
125+ check_os_distro () {
114126 LSB_DISTRO=" " ; LSB_VER=" " ; LSB_CODE=" "
115127 if (command_exist lsb_release); then
116128 LSB_DISTRO=" $( lsb_release -si) "
@@ -179,7 +191,6 @@ check_deps_distro() {
179191 exit ${ERR_NOT_SUPPORT_DISTRO[0]}
180192 ;;
181193 esac
182- echo -n " ."
183194}
184195check_deps_xen () {
185196 set +e
@@ -387,6 +398,44 @@ COMMENT
387398 fi
388399 set -e
389400}
401+ install_from_rpm (){
402+ show_message info " Fetch rpm package for centos7...\n"
403+ set +e
404+ ${BASH_C} " ping -c 3 -W 2 hyper-install.s3.amazonaws.com >/dev/null 2>&1"
405+ if [ $? -ne 0 ]; then
406+ S3_URL=" http://mirror-hyper-install.s3.amazonaws.com"
407+ else
408+ S3_URL=" http://hyper-install.s3.amazonaws.com"
409+ fi
410+ case " $1 " in
411+ centos7)
412+ rpm -qa | grep ${CENTOS7_HYPER} > /dev/null 2>&1
413+ if [ $? -eq 0 ]; then
414+ show_message info " ${ERR_HYPER_NO_NEW_VERSION[1]} " ; exit 1
415+ fi
416+ if (command_exist hyper hyperd); then
417+ _ACT=" update"
418+ else
419+ _ACT=" install"
420+ fi
421+ ${BASH_C} " yum ${_ACT} ${S3_URL} /${CENTOS7_QEMU_HYPER} .rpm ${S3_URL} /${CENTOS7_HYPERSTART} .rpm ${S3_URL} /${CENTOS7_HYPER} .rpm"
422+ ;;
423+ fedora23)
424+ rpm -qa | grep ${FC23_HYPER} > /dev/null 2>&1
425+ if [ $? -eq 0 ]; then
426+ show_message info " ${ERR_HYPER_NO_NEW_VERSION[1]} " ; exit 1
427+ fi
428+ if (command_exist hyper hyperd); then
429+ _ACT=" update"
430+ else
431+ _ACT=" install"
432+ fi
433+ ${BASH_C} " yum ${_ACT} ${S3_URL} /${FC23_HYPERSTART} .rpm ${S3_URL} /${FC23_HYPER} .rpm"
434+ ;;
435+ * ) show_message error " rpm install support centos7 & fedora23 only" ; exit 1;;
436+ esac
437+ set -e
438+ }
390439display_support () {
391440 echo " Sorry, we are suffering from some technical issue($1 ), please contact ${SUPPORT_EMAIL} "
392441 if [ $# -eq 0 ]; then exit ${ERR_UNKNOWN}
0 commit comments