Skip to content
This repository has been archived by the owner on Jan 4, 2025. It is now read-only.

Commit

Permalink
Update setup.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
SIPC committed Feb 14, 2024
1 parent 20eb501 commit 37a18c7
Showing 1 changed file with 57 additions and 47 deletions.
104 changes: 57 additions & 47 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ info "Docker 工作状态正常"

if docker ps -a -q --filter "name=lyrify" | grep -q .; then
# 升级
if [ -f "/tmp/.Lyrify/config.txt" ]; then
source "/tmp/.Lyrify/config.txt"
else
echo "config.txt 未找到,请重新输入以下信息以配置 Lyrify:"
read -p "OpenAI API Endpoint (Press Enter to use default)" openai_api_endpoint
read -p "OpenAI API Key: " openai_api_key
read -p "OpenAI Model: " openai_model
read -p "Gemini API Endpoint (Press Enter to use default): " gemini_api_endpoint
read -p "Gemini API Key: " gemini_api_key
read -p "NIUTRANS Key: " niutrans_key
read -p "DEEPL_X API URL: " deepl_x_api_url

cat <<EOL > /tmp/.Lyrify/config.txt
if [ -f "/tmp/.Lyrify/config.txt" ]; then
source "/tmp/.Lyrify/config.txt"
else
echo "config.txt 未找到,请重新输入以下信息以配置 Lyrify:"
read -p "OpenAI API Endpoint (Press Enter to use default)" openai_api_endpoint
read -p "OpenAI API Key: " openai_api_key
read -p "OpenAI Model: " openai_model
read -p "Gemini API Endpoint (Press Enter to use default): " gemini_api_endpoint
read -p "Gemini API Key: " gemini_api_key
read -p "NIUTRANS Key: " niutrans_key
read -p "DEEPL_X API URL: " deepl_x_api_url

cat <<EOL >/tmp/.Lyrify/config.txt
openai_api_endpoint=${openai_api_endpoint:-https://api.openai.com/v1/chat/completions}
openai_api_key=$openai_api_key
openai_model=$openai_model
Expand All @@ -88,28 +88,38 @@ gemini_api_key=$gemini_api_key
niutrans_key=$niutrans_key
deepl_x_api_url=$deepl_x_api_url
EOL
fi

info "即将开始下载新版本 Docker 镜像"
docker pull sipcink/lyrify:latest

info "即将开始替换 Docker 容器"
docker stop lyrify > /dev/null 2>&1 && docker rm lyrify > /dev/null 2>&1
docker run -d --name lyrify \
-p 3000:3000 \
-e OpenAI_API_ENDPOINT="$openai_api_endpoint" \
-e OpenAI_API_KEY="$openai_api_key" \
-e OpenAI_MODEL="$openai_model" \
-e Gemini_API_ENDPOINT="$gemini_api_endpoint" \
-e Gemini_API_KEY="$gemini_api_key" \
-e NIUTRANS_KEY="$niutrans_key" \
-e DEEPL_X_API_URL="$deepl_x_api_url" \
sipcink/lyrify:latest

if [ $? -ne "0" ]; then
abort "替换 Docker 容器失败"
fi
info "升级成功"
fi

info "即将开始下载新版本 Docker 镜像"
docker pull sipcink/lyrify:online

info "即将开始替换 Docker 容器"
docker stop lyrify >/dev/null 2>&1 && docker rm lyrify >/dev/null 2>&1
docker run -d --name lyrify \
-p 3000:3000 \
-e OpenAI_API_ENDPOINT="$openai_api_endpoint" \
-e OpenAI_API_KEY="$openai_api_key" \
-e OpenAI_MODEL="$openai_model" \
-e Gemini_API_ENDPOINT="$gemini_api_endpoint" \
-e Gemini_API_KEY="$gemini_api_key" \
-e NIUTRANS_KEY="$niutrans_key" \
-e DEEPL_X_API_URL="$deepl_x_api_url" \
sipcink/lyrify:online

if [ $? -ne 0 ]; then
abort "替换 Docker 容器失败"
else
info "替换 Docker 容器成功"
# 检查并删除旧镜像
docker rmi $(docker images | grep "lyrify" | grep "none" | awk '{print $3}')
if [ $? -ne 0 ]; then
warn "删除旧镜像失败"
else
info "删除旧镜像成功"
fi
fi
info "升级成功"

else
# 安装
mkdir -p "/tmp/.Lyrify" || {
Expand All @@ -122,8 +132,8 @@ else
read -p "OpenAI API Endpoint (Press Enter to use default): " openai_api_endpoint
read -p "OpenAI API Key: " openai_api_key
read -p "OpenAI Model: " openai_model
read -p "Gemini API Endpoint (Press Enter to use default): " gemini_api_endpoint
read -p "Gemini API Key: " gemini_api_key
read -p "Gemini API Endpoint (Press Enter to use default): " gemini_api_endpoint
read -p "Gemini API Key: " gemini_api_key
read -p "NIUTRANS Key: " niutrans_key
read -p "DEEPL_X API URL: " deepl_x_api_url

Expand All @@ -137,16 +147,16 @@ niutrans_key=$niutrans_key
deepl_x_api_url=$deepl_x_api_url
EOL

docker run -d --name lyrify \
-p 3000:3000 \
-e OpenAI_API_ENDPOINT="$openai_api_endpoint" \
-e OpenAI_API_KEY="$openai_api_key" \
-e OpenAI_MODEL="$openai_model" \
-e Gemini_API_ENDPOINT="$gemini_api_endpoint" \
-e Gemini_API_KEY="$gemini_api_key" \
-e NIUTRANS_KEY="$niutrans_key" \
-e DEEPL_X_API_URL="$deepl_x_api_url" \
sipcink/lyrify:latest
docker run -d --name lyrify \
-p 3000:3000 \
-e OpenAI_API_ENDPOINT="$openai_api_endpoint" \
-e OpenAI_API_KEY="$openai_api_key" \
-e OpenAI_MODEL="$openai_model" \
-e Gemini_API_ENDPOINT="$gemini_api_endpoint" \
-e Gemini_API_KEY="$gemini_api_key" \
-e NIUTRANS_KEY="$niutrans_key" \
-e DEEPL_X_API_URL="$deepl_x_api_url" \
sipcink/lyrify:online

if [ $? -ne "0" ]; then
abort "启动 Docker 容器失败"
Expand Down

0 comments on commit 37a18c7

Please sign in to comment.