sh bitbucket-deploy.sh
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh bitbucket-deploy.sh相关的知识,希望对你有一定的参考价值。
#!/bin/bash
# Environment variables:
# REMOTE_USER, REMOTE_HOST — obviously
# Read more about deployment over SSH:
# https://confluence.atlassian.com/bitbucket/access-remote-hosts-via-ssh-847452940.html
set -e # automatic exit on error
REMOTE_DIR="~/www"
DIST_FILE="/tmp/dist.tar.gz"
SSH_USER="$REMOTE_USER@$REMOTE_HOST"
SSH_OPTIONS=""
echo "creating an archive of project files"
tar -czf $DIST_FILE --exclude .git --exclude dist.tar.gz ./
echo "uploading the archive on the remote host"
scp $SSH_OPTIONS $DIST_FILE $SSH_USER:~/dist.tar.gz
echo "unpacking the archive and restart the servcies"
ssh $SSH_USER $SSH_OPTIONS << EOF
mkdir -p ~/dist
mkdir -p $REMOTE_DIR
tar xf ~/dist.tar.gz -C ~/dist
if [[ -d $REMOTE_DIR ]]; then
rm -rf $REMOTE_DIR
fi
mv ~/dist $REMOTE_DIR
EOF
rm $DIST_FILE
echo "Done"
exit 0
以上是关于sh bitbucket-deploy.sh的主要内容,如果未能解决你的问题,请参考以下文章
如何使我的命令行在具有扩展名(.sh)和名称如“weird.sh.sh.sh”的文件上工作
sh sh_template.sh
sh sh.sh
Linux下面如何运行 SH文件
配置告警系统主脚本main.sh mon.sh load.sh 502.sh disk.sh
shell 脚本各种执行方式(source ./*.sh, . ./*.sh, ./*.sh)的区别