今天,我尝试用下面的脚本更新远程主机上的代码。
由于我当地的网络状况不佳,我安装了screen
软件以防断线。
然后我执行了上面的脚本。前几台应用服务器一切顺利。
但是当它转到最后一个主服务器时。我收到了有关主管的错误。
然后在调试之后,我发现主服务器上的整个文件系统突然变成了只读。
我通过 ssh 重新启动了它,但无法再连接到它。
我执行下面脚本的操作是否有可能导致这个文件系统只读灾难?
我现在很害怕,因为公司的 $$$ 此刻正在蒸发。
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: `basename $0` <tag or branch>"
exit 1
fi
TAG=$1
WORK_DIR=$(cd "$(dirname "$0")"; pwd)
GIT_REPO_PATH="/data/repo/backend_english"
APP_SRV_LIST="${WORK_DIR}/app_prd_srv.txt"
# Read the Destination directory
_DES_DIR="backend_english"
DES_FULL_DIR=''
read -p "Please Select the destination directory: [$_DES_DIR] " DES_DIR
if [ "x${DES_DIR}" != "x" ]; then
DES_FULL_DIR="/data/sites/${DES_DIR}/"
fi
if [ ! -d "$DES_FULL_DIR" ]; then
echo "Selecting default: /data/sites/${_DES_DIR}/"
DES_FULL_DIR="/data/sites/${_DES_DIR}/"
else
echo "destination dir: ${DES_FULL_DIR}"
fi
HOST=(`cat ${APP_SRV_LIST} | grep -v '^#' `)
echo "Deploy to the hosts:"
for i in ${HOST[@]}
do
echo $i
done
read -p "Are you sure you want to continue (y/n)?" MFLAG
if [ "x${MFLAG}" != "xy" ]; then
exit 1
fi
cd $GIT_REPO_PATH
/usr/bin/git fetch --all
/usr/bin/git checkout $TAG
THOST=${HOST[0]}
/usr/bin/rsync --dry-run -a --delete --progress --exclude='*.pyc' --exclude='upload_xls' --exclude='.git' --exclude='.gitignore' --exclude='logs' --exclude='test/local_config.py' $GIT_REPO_PATH/ admin@$THOST:$DES_FULL_DIR/
read -p "Are you sure you want to continue (y/n)?" CFLAG
if [ "x${CFLAG}" != "xy" ]; then
exit 1
fi
echo $TAG > $WORK_DIR/version_prd.txt
for host in ${HOST[@]}
do
echo $host
rsync -a --delete --progress --exclude='upload_xls' --exclude='.git' --exclude='.gitignore' --exclude='logs' --exclude='test/local_config.py' $GIT_REPO_PATH/ admin@$host:$DES_FULL_DIR/
done
echo " "
echo " "
read -p "Restart all process (y/n)?" RFLAG
if [ "x${RFLAG}" != "xy" ]; then
exit 0
fi
for host in ${HOST[@]}
do
echo $host
ssh admin@$host /usr/local/bin/supervisorctl -u my_account -p my_password restart all
done