Explorar o código

修正 cpuinfo 取值问题

James Iter %!s(int64=8) %!d(string=hai) anos
pai
achega
a75b096c08
Modificáronse 6 ficheiros con 25 adicións e 14 borrados
  1. 15 5
      INSTALL.sh
  2. 1 0
      docs/todo.md
  3. 2 2
      models/guest_xml.py
  4. 2 2
      templates/guest_create.html
  5. 4 4
      templates/guests_show.html
  6. 1 1
      templates/vnc_lite.html

+ 15 - 5
INSTALL.sh

@@ -6,16 +6,26 @@
 #
 # Author: James Iter <james.iter.cn@gmail.com>
 #
-#  This script will help you to automation install JimV-C.
+#   This script will help you to automation install JimV-C.
 #
+# Example:
+#   Pass arguments to the installer.
+#   curl https://raw.githubusercontent.com/jamesiter/JimV-C/master/INSTALL.sh | bash -s -- --version dev
 
 export PYPI='https://mirrors.aliyun.com/pypi/simple/'
-export JIMVC_REPOSITORY_URL='https://raw.githubusercontent.com/jamesiter/JimV-C'
+export JIMVC_REPOSITORY_URL='https://github.com/jamesiter/JimV-C.git'
+export JIMVC_REPOSITORY_URL_CN='https://gitee.com/jimit/JimV-C.git'
+export JIMVC_REPOSITORY_RAW_URL='https://raw.githubusercontent.com/jamesiter/JimV-C'
+export COUNTRY=`curl http://iit.im/ip/country`
 export GENERATE_PASSWORD_SCRIPT_TMP_PATH='/tmp/gen_pswd.sh'
 export SMTP_HOST=''
 export SMTP_USER=''
 export SMTP_PASSWORD=''
 
+if [ ${COUNTRY} = 'CN' ]; then
+    export JIMVC_REPOSITORY_URL=${JIMVC_REPOSITORY_URL_CN}
+fi
+
 ARGS=`getopt -o h --long rdb_root_password:,rdb_jimv_password:,redis_password:,jwt_secret:,secret_key:,version:,help -n 'INSTALL.sh' -- "$@"`
 
 eval set -- "${ARGS}"
@@ -85,7 +95,7 @@ function prepare() {
     fi
 
     if [ ! -e ${GENERATE_PASSWORD_SCRIPT_TMP_PATH} ]; then
-        curl ${JIMVC_REPOSITORY_URL}'/'${JIMV_VERSION}'/misc/gen_pswd.sh' -o ${GENERATE_PASSWORD_SCRIPT_TMP_PATH}
+        curl ${JIMVC_REPOSITORY_RAW_URL}'/'${JIMV_VERSION}'/misc/gen_pswd.sh' -o ${GENERATE_PASSWORD_SCRIPT_TMP_PATH}
         chmod +x ${GENERATE_PASSWORD_SCRIPT_TMP_PATH}
     fi
 
@@ -191,7 +201,7 @@ function install_Redis() {
 }
 
 function install_Nginx() {
-    export NGINX_JIMV_URL=${JIMVC_REPOSITORY_URL}'/'${JIMV_VERSION}'/misc/nginx_jimv.conf'
+    export NGINX_JIMV_URL=${JIMVC_REPOSITORY_RAW_URL}'/'${JIMV_VERSION}'/misc/nginx_jimv.conf'
 
     # 安装 Nginx
     yum install nginx -y
@@ -217,7 +227,7 @@ function create_web_sites_directory() {
 }
 
 function clone_and_checkout_JimVC() {
-    su - www -c "git clone https://github.com/jamesiter/JimV-C.git ~/sites/JimV-C"
+    su - www -c "git clone ${JIMVC_REPOSITORY_URL} ~/sites/JimV-C"
     su - www -c "cd ~/sites/JimV-C && git checkout ${JIMV_VERSION}"
 }
 

+ 1 - 0
docs/todo.md

@@ -85,4 +85,5 @@
 - [ ] 根据计算节点 CPU 是否支持 VT-X,来确定虚拟机是使用 KVM 还是 QEMU
 - [ ] 修复在大磁盘虚拟机创建快照时,等待时间过长的问题
 - [ ] IP 地址池管理功能。对 IP 池中的 IP 有查看、添加、禁用、解禁等功能
+- [ ] 安装脚本加入中国本土仓库
 

+ 2 - 2
models/guest_xml.py

@@ -45,8 +45,8 @@ class GuestXML(object):
     def get_hypervisor(self):
         hypervisor = 'qemu'
 
-        if self.host.cpuinfo is not None and 'flags' in self.host.cpuinfo:
-            if 'vmx' in self.host.cpuinfo['flags'] or 'svm' in self.host.cpuinfo['flags']:
+        if self.host['cpuinfo'] is not None and 'flags' in self.host['cpuinfo']:
+            if 'vmx' in self.host['cpuinfo']['flags'] or 'svm' in self.host['cpuinfo']['flags']:
                 hypervisor = 'kvm'
 
         return hypervisor

+ 2 - 2
templates/guest_create.html

@@ -312,9 +312,9 @@
                         </div>
                     </div>
                     <div class="form-group">
-                        <label class="col-sm-2 control-label"><span class="glyph-icon icon-signal"></span>&nbsp;&nbsp;内网带宽</label>
+                        <label class="col-sm-2 control-label"><span class="glyph-icon icon-signal"></span>&nbsp;&nbsp;带宽</label>
                         <div class="col-sm-7">
-                            <input id="bandwidth" title="内网带宽" type="text" name="bandwidth">
+                            <input id="bandwidth" title="带宽" type="text" name="bandwidth">
                         </div>
                         <div class="col-sm-1" style="bottom: -10px;">
                             <select id="bandwidth_unit" name="bandwidth_unit" title="单位..." class="selectpicker" data-width="120%">

+ 4 - 4
templates/guests_show.html

@@ -1341,9 +1341,9 @@
                         </div>
                         <div class="form-group">
                             <div class="col-sm-1"></div>
-                            <label class="col-sm-2 control-label"><span class="glyph-icon icon-signal"></span>&nbsp;&nbsp;内网带宽</label>
+                            <label class="col-sm-2 control-label"><span class="glyph-icon icon-signal"></span>&nbsp;&nbsp;带宽</label>
                             <div class="col-sm-7">
-                                <input id="bandwidth" title="内网带宽" type="text" name="bandwidth">
+                                <input id="bandwidth" title="带宽" type="text" name="bandwidth">
                             </div>
                             <div class="col-sm-2" style="bottom: -10px;">
                                 <select id="bandwidth_unit" name="bandwidth_unit" title="单位..." class="selectpicker" data-width="80%">
@@ -1378,9 +1378,9 @@
                     <form class="form-horizontal bordered-row">
                         <div class="form-group">
                             <div class="col-sm-1"></div>
-                            <label class="col-sm-2 control-label"><span class="glyph-icon icon-signal"></span>&nbsp;&nbsp;内网带宽</label>
+                            <label class="col-sm-2 control-label"><span class="glyph-icon icon-signal"></span>&nbsp;&nbsp;带宽</label>
                             <div class="col-sm-7">
-                                <input id="batch_bandwidth" title="内网带宽" type="text" name="batch_bandwidth">
+                                <input id="batch_bandwidth" title="带宽" type="text" name="batch_bandwidth">
                             </div>
                             <div class="col-sm-2" style="bottom: -10px;">
                                 <select id="batch_bandwidth_unit" name="batch_bandwidth_unit" title="单位..." class="selectpicker" data-width="80%">

+ 1 - 1
templates/vnc_lite.html

@@ -60,7 +60,7 @@
 
     <!-- promise polyfills promises for IE11 -->
     <script src="{{ url_for('static', filename='novnc/vendor/promise.js') }}"></script>
-    <script src="{{ url_for('static', filename='novnc/vendor/browser-es-module-loader/dist/browser-es-module-loader.js') }}"></script>
+    <!--<script src="{{ url_for('static', filename='novnc/vendor/browser-es-module-loader/dist/browser-es-module-loader.js') }}"></script>-->
     <script type="module">
         // Load supporting scripts
         import * as WebUtil from "{{ url_for('static', filename='novnc/app/webutil.js') }}";