Ver código fonte

feat:添加jenkins登录脚本

zhaohaipeng 8 meses atrás
pai
commit
8913634dcc
2 arquivos alterados com 63 adições e 0 exclusões
  1. 12 0
      sh/IP.conf
  2. 51 0
      sh/jenkins_jumpserver.sh

+ 12 - 0
sh/IP.conf

@@ -0,0 +1,12 @@
+192.168.207.19,root,prometheus,cert
+192.168.141.208,root,EMR-模型训练,pwd
+192.168.203.16,root,EMR-特征服务,pwd
+192.168.203.92,root,新算法生产环境,pwd
+192.168.204.120,root,老算法生产环境,pwd
+192.168.204.102,root,算法测试环境,pwd
+192.168.204.182,root,combine-job,pwd
+192.168.203.80,root,commonapi-03,pwd
+192.168.203.79,root,commonapi-04,pwd
+192.168.203.72,root,kubectl-PROD,pwd
+192.168.207.43,root,Docker Register,pwd
+192.168.203.137,root,图数据库,pwd

+ 51 - 0
sh/jenkins_jumpserver.sh

@@ -0,0 +1,51 @@
+#/bin/bash
+
+# 定义数组
+ip=()
+username=()
+desc=()
+way=()
+
+sh_path=$(cd $(dirname $0); pwd)
+
+# 读取文件
+while IFS=',' read -r ip_field username_field desc_field way_field; do
+    ip+=("$ip_field")
+    username+=("$username_field")
+    desc+=("$desc_field")
+    way+=("$way_field")
+done < "${sh_path}/IP.conf"
+
+while [ 1 ]
+do
+
+    echo "机器列表: "
+    for(( i = 0; i < ${#ip[@]}; i++)) do
+	    echo "    $((i+1)). ${ip[i]} (${desc[i]})"
+    done
+    echo ""
+    read -p "请选择要登录的机器(输入q、quit、exit退出): " i
+    case "$i" in
+        'q'|'quit'|'exit')
+            echo "退出"
+            exit 1
+            ;;
+        *)
+            if [[ $i =~ ^[0-9]+$ ]] && (( $i > 0 && $i <= ${#ip[@]} )) ; then
+                index=$i-1
+                echo "即将登录: ${desc[$index]}"
+                echo ""
+                if [[ ${way[$index]} =~ 'cert' ]]; then
+                    ssh -i /root/.ssh/stuuudy.pem  ${username[$index]}@${ip[$index]}
+                    exit 1
+                else
+                    ssh ${username[$index]}@${ip[$index]}
+                    exit 1
+                fi
+            else
+                echo "请选择正确的机器"
+                echo ""
+            fi
+            ;;
+    esac
+done