fix redis auto install

fix redis password auto-gen and append to local_settings.py
This commit is contained in:
Leven 2023-01-09 23:05:16 +08:00
parent d10601b9ab
commit 51a600c8a4
2 changed files with 19 additions and 1 deletions

View File

@ -155,9 +155,13 @@ else
else else
echo "脚本目录下没有发现Python${PYTHON_VER}.tar.xz将会下载python ${PYTHON_VER}" echo "脚本目录下没有发现Python${PYTHON_VER}.tar.xz将会下载python ${PYTHON_VER}"
sudo wget https://www.python.org/ftp/python/${PYTHON_VER}/Python-${PYTHON_VER}.tar.xz 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 tar xf Python-${PYTHON_VER}.tar.xz
cd Python-${PYTHON_VER} cd Python-${PYTHON_VER}
sudo ./configure --prefix=${PYTHON_INSTALL_DIR} && make && make install sudo ./configure --prefix=${PYTHON_INSTALL_DIR} && make && make install
else
echo "下载${PYTHON_VER}/Python-${PYTHON_VER}.tar.xz失败请重新运行本脚本再次重试"
fi
fi fi
if [[ $? -eq 0 ]] if [[ $? -eq 0 ]]
@ -178,6 +182,20 @@ else
fi 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源为国内 ##修改PIP源为国内
mkdir -p ~/.pip mkdir -p ~/.pip
cat << EOF > ~/.pip/pip.conf cat << EOF > ~/.pip/pip.conf

View File

@ -54,7 +54,7 @@ WEWORK_AGENT_ID = r'修改为自己的'
WEWORK_AGNET_SECRET = r'修改为自己的' WEWORK_AGNET_SECRET = r'修改为自己的'
# Redis配置 # Redis配置
# redis的连接地址redis://<Ip/Host>:<Port>/<数据库> # redis的连接地址redis://<Ip/Host>:<Port>
REDIS_LOCATION = r'redis://127.0.0.1:6379' REDIS_LOCATION = r'redis://127.0.0.1:6379'
REDIS_PASSWORD = r'修改为自己的' REDIS_PASSWORD = r'修改为自己的'