代码拉取完成,页面将自动刷新
同步操作将从 decbe/idcops 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/sh
cd "$(dirname "$0")"
VIRTUALENV="$(pwd -P)/venv"
PYTHON="${PYTHON:-python3}"
# 备份 `settings.py` 配置文件
if [ -f "proj/settings.py" ];then
COMMAND="\cp -f proj/settings.py /tmp/"
echo "backup \`settings.py\` configure file"
eval $COMMAND
else
echo "Warning: configure file \`proj/settings.py\` not exists"
fi
OLD_VER=$(git log --pretty=oneline|head -1|awk '{print $1}')
git fetch --all && git reset --hard origin/master && git pull
git diff --name-only ${OLD_VER}|grep 'requirements.txt'
if [ $? -eq 0 ];then
which python3
if [ $? -ne 0 ];then
echo "Need install python3 version."
exit 1
fi
# Remove the existing virtual environment (if any)
if [ -d "$VIRTUALENV" ]; then
COMMAND="\rm -rf ${VIRTUALENV}"
echo "Removing old virtual environment..."
eval $COMMAND
else
WARN_MISSING_VENV=1
fi
# Create a new virtual environment
COMMAND="`which python3` -m venv ${VIRTUALENV}"
echo "Creating a new virtual environment at ${VIRTUALENV}..."
eval $COMMAND || {
echo "--------------------------------------------------------------------"
echo "ERROR: Failed to create the virtual environment. Check that you have"
echo "the required system packages installed and the following path is"
echo "writable: ${VIRTUALENV}"
echo "--------------------------------------------------------------------"
exit 1
}
# Activate the virtual environment
. ${VIRTUALENV}/bin/activate
# Install necessary system packages
COMMAND="pip install wheel -i https://mirrors.aliyun.com/pypi/simple"
echo "Installing Python system packages ($COMMAND)..."
eval $COMMAND || exit 1
# Install requirement packages
COMMAND="pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple"
echo "Installing Python requirement packages ($COMMAND)..."
eval $COMMAND || exit 1
fi
. ${VIRTUALENV}/bin/activate
python manage.py makemigrations
# Test schema migrations integrity
COMMAND="python manage.py showmigrations"
eval $COMMAND > /dev/null 2>&1 || {
echo "--------------------------------------------------------------------"
echo "ERROR: Database schema migrations are out of synchronization. (No"
echo "data has been lost.) . For further detail on the exact error,"
echo "run the following commands:"
echo ""
echo " source ${VIRTUALENV}/bin/activate"
echo " ${COMMAND}"
echo "--------------------------------------------------------------------"
exit 1
}
# 恢复 `settings.py` 配置文件
if [ -f "/tmp/settings.py" ];then
COMMAND="\cp -f /tmp/settings.py proj/settings.py"
echo "recovery \`settings.py\` configure file"
eval $COMMAND
else
echo "Warning: backup file \`/tmp/settings.py\` not exists"
fi
MIGRATE_TOTAL=$(python manage.py showmigrations|grep -E '\[ \]'|wc -l)
if [ ${MIGRATE_TOTAL} -gt 0 ];then
python manage.py migrate
fi
# collect static files
python manage.py collectstatic --no-input
# Delete any expired user sessions
COMMAND="python manage.py clearsessions"
echo "Removing expired user sessions ($COMMAND)..."
eval $COMMAND || exit 1
echo "Upgrade complete! Don't forget to restart the idcops services:"
echo " > /opt/idcops/scripts/stop.sh"
echo " > /opt/idcops/scripts/start.sh"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。