From 51a600c8a41e2431272fdefdcef45b2652fcbdd0 Mon Sep 17 00:00:00 2001 From: Leven Date: Mon, 9 Jan 2023 23:05:16 +0800 Subject: [PATCH] fix redis auto install fix redis password auto-gen and append to local_settings.py --- auto-install.sh | 18 ++++++++++++++++++ conf/local_settings.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/auto-install.sh b/auto-install.sh index 4ae6872..3523fa5 100644 --- a/auto-install.sh +++ b/auto-install.sh @@ -155,9 +155,13 @@ else else echo "脚本目录下没有发现Python${PYTHON_VER}.tar.xz,将会下载python ${PYTHON_VER}" sudo wget https://www.python.org/ftp/python/${PYTHON_VER}/Python-${PYTHON_VER}.tar.xz + if [[ $? -eq 0 ]]; then tar xf Python-${PYTHON_VER}.tar.xz cd Python-${PYTHON_VER} sudo ./configure --prefix=${PYTHON_INSTALL_DIR} && make && make install + else + echo "下载${PYTHON_VER}/Python-${PYTHON_VER}.tar.xz失败,请重新运行本脚本再次重试" + fi fi if [[ $? -eq 0 ]] @@ -178,6 +182,20 @@ else fi +yum install -y redis +if [[ $? -eq 0 ]]; then + gen_password=$(echo "$(hostname)$(date)" |base64) + sed -i 's@^requirepass.*@@g' /etc/redis.conf + sed -i "/# requirepass foobared/a requirepass ${gen_password}" /etc/redis.conf + systemctl restart redis + sed -i "s@REDIS_PASSWORD.*@REDIS_PASSWORD = r'${gen_password}'@g" ${SHELL_FOLDER}/conf/local_settings.py + echo "安装 redis-server 成功" + echo "Redis Server密码是:${gen_password},可在/etc/redis.conf中查到" +else + echo "安装 redis-server 失败,请重新运行本脚本再试" +fi + + ##修改PIP源为国内 mkdir -p ~/.pip cat << EOF > ~/.pip/pip.conf diff --git a/conf/local_settings.py b/conf/local_settings.py index 057780f..c3c003d 100644 --- a/conf/local_settings.py +++ b/conf/local_settings.py @@ -54,7 +54,7 @@ WEWORK_AGENT_ID = r'修改为自己的' WEWORK_AGNET_SECRET = r'修改为自己的' # Redis配置 -# redis的连接地址,redis://:/<数据库> +# redis的连接地址,redis://: REDIS_LOCATION = r'redis://127.0.0.1:6379' REDIS_PASSWORD = r'修改为自己的'