當我在我的開發服務器上部署時,我使用rsync。但rsync的後,我需要「後」部署像清除緩存操作執行.SH文件...如何在rsync後執行bash腳本
通常我通過SSH做到這一點,但如果我部署它往往會很無聊寫:
- SSH ...
- 寫入密碼
- CD /無功/網絡/ MyApp的/ WEB
- ./after_deploy.sh
有一種方法可以快速做到這一點?這是我的rsync.sh:
#!/bin/bash
host=""
directory="/var/www/myapp/web"
password=""
usage(){
echo "Cant do rsync";
echo "Using:";
echo " $0 direct";
echo "Or:";
echo " $0 dry";
}
echo "Host: $host";
echo "Directory: $directory"
if [ $# -eq 1 ]; then
if [ "$1" == "dry" ]; then
echo "DRY-RUN mode";
rsync -CvzrltD --force --delete --exclude-from="app/config/rsync_exclude.txt" -e "sshpass -p '$password' ssh -p22" ./ $host:$directory --dry-run
elif [ "$1" == "direct" ]; then
echo "Normal mode";
rsync -CvzrltD --force --delete --exclude-from="app/config/rsync_exclude.txt" -e "sshpass -p '$password' ssh -p22" ./ $host:$directory
else
usage;
fi;
else
usage;
fi
shell腳本已經到主機系統上執行或遠程? –
它必須遠程執行 – Diego