[update] docker support v1/v2

This commit is contained in:
Lkeme 2022-08-22 18:07:45 +08:00
parent 182d7d4df8
commit c69b903ca2
3 changed files with 79 additions and 47 deletions

View File

@ -8,7 +8,9 @@ ENV USER_NAME='' \
REPO_URL='https://github.com/' \
CUSTOM_CLONE_URL='https://speed.example.com/example/example.git' \
MIRRORS="0" \
CONIFG_PATH='/app/profile/user/config/user.ini' \
VERSION="2"
V1_CONIFG_PATH='/app/conf/user.ini' \
V2_CONIFG_PATH='/app/profile/user/config/user.ini' \
Green="\\033[32m" \
Red="\\033[31m" \
GreenBG="\\033[42;37m" \

View File

@ -58,14 +58,37 @@ echo -e "\n ======== \n ${Info} ${GreenBG} 安装/更新 项目运行依赖 ${Fo
php composer.phar install
echo -e "\n \n \n \n"
# 版本切换
case ${VERSION} in
"1")
echo -e "\n ======== \n ${Info} ${GreenBG} 正在使用版本V1方案 ${Font} \n ======== \n"
# 判断类型
if [[ -f ${CONIFG_PATH} ]]; then
if [[ -f ${V1_CONIFG_PATH} ]]; then
echo -e "\n ======== \n ${GreenBG} 正在使用外部配置文件 ${Font} \n ======== \n"
else
echo -e "${OK} ${GreenBG} 正在使用传入的环境变量进行用户配置。\n 如果需要配置更多选择项请通过挂载配置文件来传入。具体参考项目中的README。\n https://github.com/lkeme/BiliHelper-personal.git ${Font} \n ======== \n "
cp /app/conf/user.ini.example /app/conf/user.ini
sed -i ''"$(cat /app/conf/user.ini -n | grep "username = \"\"" | awk '{print $1}')"'c '"$(echo "username = \"${USER_NAME}\"")"'' ${V1_CONIFG_PATH}
sed -i ''"$(cat /app/conf/user.ini -n | grep "password = \"\"" | awk '{print $1}')"'c '"$(echo "password = \"${USER_PASSWORD}\"")"'' ${V1_CONIFG_PATH}
fi
php index.php
;;
"2")
echo -e "\n ======== \n ${Info} ${GreenBG} 正在使用版本V2方案 ${Font} \n ======== \n"
# 判断类型
if [[ -f ${V2_CONIFG_PATH} ]]; then
echo -e "\n ======== \n ${GreenBG} 正在使用外部配置文件 ${Font} \n ======== \n"
else
echo -e "${OK} ${GreenBG} 正在使用传入的环境变量进行用户配置。\n 如果需要配置更多选择项请通过挂载配置文件来传入。具体参考项目中的README。\n https://github.com/lkeme/BiliHelper-personal.git ${Font} \n ======== \n "
cp /app/profile/example /app/profile/user
sed -i ''"$(cat /app/profile/user/config/user.ini -n | grep "username = \"\"" | awk '{print $1}')"'c '"$(echo "username = \"${USER_NAME}\"")"'' ${CONIFG_PATH}
sed -i ''"$(cat /app/profile/user/config/user.ini -n | grep "password = \"\"" | awk '{print $1}')"'c '"$(echo "password = \"${USER_PASSWORD}\"")"'' ${CONIFG_PATH}
sed -i ''"$(cat /app/profile/user/config/user.ini -n | grep "username = \"\"" | awk '{print $1}')"'c '"$(echo "username = \"${USER_NAME}\"")"'' ${V2_CONIFG_PATH}
sed -i ''"$(cat /app/profile/user/config/user.ini -n | grep "password = \"\"" | awk '{print $1}')"'c '"$(echo "password = \"${USER_PASSWORD}\"")"'' ${V2_CONIFG_PATH}
fi
php app.php m:a
;;
*)
echo -e "\n ======== \n ${Info} ${RedBG} 错误的版本方案选择 ${Font} \n ======== \n"
;;
esac

View File

@ -191,6 +191,13 @@ $ docker run -itd --rm -e USER_NAME=你的B站登录账号 -e USER_PASSWORD=你
$ docker run -itd --rm -v /path/to/your/confFilePath:/app/profile/user lkeme/bilihelper-personal
```
- 版本兼容
```shell script
$ -e VERSION=1 # 使用 版本 V1.x.x
$ -e MIRRORS=2 # 使用 版本 V2.x.x(默认)
```
- 使用github镜像加速
```shell script