常用服务部署脚本(nodejs,pyenv,go,redis,)

根据工作总结的常用安装脚本,要求linux-64系统

#!/bin/bash
path=/usr/local/src

node () {
  cd $path
  #wget https://nodejs.org/dist/v8.11.4/node-v8.11.4-linux-x64.tar.xz
<<<<<<< HEAD
  curl -O  https://nodejs.org/dist/v8.11.4/node-v8.11.4-linux-x64.tar.xz
=======
  curl -O https://nodejs.org/dist/v8.11.4/node-v8.11.4-linux-x64.tar.xz
>>>>>>> f55f1324b629c9be4f9166780e3cebc0f15c8975
  xz -d node-v8.11.4-linux-x64.tar.xz
  tar -xf node-v8.11.4-linux-x64.tar -C /usr/local/
  ln -s /usr/local/node-v8.11.4-linux-x64 /usr/local/node
  echo 'export PATH=/usr/local/node/bin:$PATH' >>/etc/profile
  source /etc/profile
  npm install -g yarn pm2 forever
}

redis () {
  echo "install redis  y/n?"
  read  -t 5 -p "(Default option: y):" option
  [ -z "${option}" ] && option="y"
  if [ "${option}" == "y" ] || [ "${option}" == "Y" ]; then
      cd $path
      wget http://download.redis.io/releases/redis-4.0.10.tar.gz
      tar -zxvf redis-4.0.10.tar.gz -C /usr/local/
      ln -s /usr/local/redis-4.0.10 /usr/local/redis
      cd /usr/local/redis
      make
      find /usr/local/redis/src/ -perm 0755 -exec  ln -s {} /bin/ \;
      cp redis.conf /etc/
  fi
}

pyenv () {
  git clone https://github.com/pyenv/pyenv.git ~/.pyenv
  echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
  echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
  echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
  exec "$SHELL"
}
pyenv_virtual (){
  git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
  echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile
  exec "$SHELL"
}

go (){
	cd $path
	sudo wget https://dl.google.com/go/go1.11.4.linux-amd64.tar.gz
	sudo tar -C /usr/local -xzf go1.11.4.linux-amd64.tar.gz
	export PATH=$PATH:/usr/local/go/bin
}

soft=$1
case $soft in
  node)
    node
    ;;
  redis)
    redis
    ;;
  pyenv)
    pyenv
    ;;
  virtual)
    pyenv_virtual
    ;;
  go)
    go
    ;;
  *)
    echo $0 "node|redis|pyenv"
    ;;
esac
posted @ 2019-05-16 16:27  johnsonjie  阅读(203)  评论(0编辑  收藏  举报