系统相关
首页 > 系统相关> > shell - 拉取代码部署执行

shell - 拉取代码部署执行

作者:互联网

#!/bin/bash

nodejs_path=/data/myserver/yihao01-node-js

cd /data/myserver

if [ -d  "$nodejs_path" ]; then
    cd $nodejs_path && git pull https://zuomiaomiao:zuomiaomiao123@gitlab.0easy.com/aiotcloud/yihao01-node-js.git
else
    git clone https://zuomiaomiao:zuomiaomiao123@gitlab.0easy.com/aiotcloud/yihao01-node-js.git
fi

ipaddr='172.0.0.1'
#ipaddr=$(ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}')
ipaddr=$(ip -4 address show | grep inet | grep -v 127.0.0 | awk '{print $2}' | cut -d'/' -f1)
echo $ipaddr

case "$ipaddr" in
  "192.168.0.16")
    env='dev'
  ;;
  "192.168.0.116")
    env='uat'
  ;;
  *)
    env='dev'
  ;;
esac

git clone https://gitlab.0easy.com/aiotcloud/yihao01-node-js.git

cd $nodejs_path
npm install -g npm
npm install
npm run $env

备注:变量赋值中间不能有空格,空格也是命令可以执行的

标签:node,npm,git,nodejs,代码,ipaddr,拉取,shell,js
来源: https://www.cnblogs.com/mmzuo-798/p/11214743.html