#!/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

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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2022-01-20
  • 2021-10-10
  • 2022-12-23
  • 2021-11-30
  • 2021-06-12
猜你喜欢
  • 2021-10-10
  • 2021-12-27
  • 2021-08-29
  • 2021-12-23
  • 2022-12-23
  • 2021-05-11
  • 2022-12-23
相关资源
相似解决方案