docker安裝青龍面板
發布時間:2023-11-16 11:44:21
作者:超級管理員
來源:WEB
瀏覽量(722)
點贊(129)
摘要:1.1、一鍵腳本安裝wget-qhttps://raw.githubusercontents.com/Oreomeow/VIP/main/Scripts/sh/ql.sh-Oql.sh&&bashql.sh腳本代碼:#!/usr/bin/envbash#shellcheckdisable=SC2181clearecho-e"e[36m▄▄▄
1.1、一鍵腳本安裝
wget -q https://raw.githubusercontents.com/Oreomeow/VIP/main/Scripts/sh/ql.sh -O ql.sh && bash ql.sh
腳本代碼:
#!/usr/bin/env bash # shellcheck disable=SC2181 clear echo -e "e[36m ▄▄▄▄ ██ ▄▄▄▄ ██??██ ?? ??██ ██ ██ ████ ██▄████▄ ▄███▄██ ██ ▄████▄ ██▄████▄ ▄███▄██ ██ ██ ██ ██? ██ ██? ?██ ██ ██? ?██ ██? ██ ██? ?██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▄▄██? ▄▄▄██▄▄▄ ██ ██ ?██▄▄███ ██▄▄▄ ?██▄▄██? ██ ██ ?██▄▄███ ???██ ???????? ?? ?? ▄??? ██ ???? ???? ?? ?? ▄??? ██ ? ?████?? ?████?? e[0m "DOCKER_IMG_NAME="whyour/qinglong"QL_PATH=""SHELL_FOLDER=$(pwd) CONTAINER_NAME=""TAG="latest"NETWORK="bridge"QL_PORT=5700HAS_IMAGE=falsePULL_IMAGE=trueHAS_CONTAINER=falseDEL_CONTAINER=trueINSTALL_WATCH=falseENABLE_HANGUP=trueENABLE_WEB_PANEL=trueOLD_IMAGE_ID=""log() { echo -e "e[32m $1 e[0m "} inp() { echo -e "e[33m $1 e[0m "} opt() { echo -n -e "e[36m輸入您的選擇->e[0m"} warn() { echo -e "e[31m$1 e[0m "} cancelrun() { if [ $# -gt 0 ]; then echo -e "e[31m $1 e[0m" fi exit 1} docker_install() { echo "檢測 Docker......" if [ -x "$(command -v docker)" ]; then echo "檢測到 Docker 已安裝!" else if [ -r /etc/os-release ]; then lsb_dist="$(. /etc/os-release && echo "$ID")" fi if [ "$lsb_dist" == "openwrt" ]; then echo "openwrt 環境請自行安裝 docker" exit 1 else echo "安裝 docker 環境..." curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun echo "安裝 docker 環境...安裝完成!" systemctl enable docker systemctl start docker fi fi } docker_install warn "降低學習成本,小白回車到底,一路默認選擇"# 配置文件保存目錄 echo -n -e "e[33m一、請輸入配置文件保存的絕對路徑(示例:/root/ql1),回車默認為 當前目錄/ql:e[0m"read -r ql_pathif [ -z "$ql_path" ]; then mkdir -p "$SHELL_FOLDER"/ql QL_PATH=$SHELL_FOLDER/ql elif [ -d "$ql_path" ]; then QL_PATH=$ql_pathelse mkdir -p "$ql_path" QL_PATH=$ql_path fi # 檢測鏡像是否存在if [ -n "$(docker images -q $DOCKER_IMG_NAME:$TAG 2>/dev/null)" ]; then HAS_IMAGE=true OLD_IMAGE_ID=$(docker images -q --filter reference=$DOCKER_IMG_NAME:$TAG) inp "檢測到先前已經存在的鏡像,是否拉取最新的鏡像: 1) 拉取[默認] 2) 不拉取" opt read -r update if [ "$update" = "2" ]; then PULL_IMAGE=false fi fi # 檢測容器是否存在 check_container_name() { if docker ps -a | grep "$CONTAINER_NAME" 2>/dev/null; then HAS_CONTAINER=true inp "檢測到先前已經存在的容器,是否刪除先前的容器: 1) 刪除[默認] 2) 不刪除" opt read -r update if [ "$update" = "2" ]; then PULL_IMAGE=false inp "您選擇了不刪除之前的容器,需要重新輸入容器名稱" input_container_name fi fi } # 容器名稱 input_container_name() { echo -n -e "e[33m 二、請輸入要創建的 Docker 容器名稱[默認為:qinglong]->e[0m" read -r container_name if [ -z "$container_name" ]; then CONTAINER_NAME="qinglong" else CONTAINER_NAME=$container_name fi check_container_name } input_container_name # 是否安裝 WatchTower inp "是否安裝 containrrr/watchtower 自動更新 Docker 容器: 1) 安裝 2) 不安裝[默認]"opt read -r watchtowerif [ "$watchtower" = "1" ]; then INSTALL_WATCH=truefi inp "請選擇容器的網絡類型: 1) host 2) bridge[默認]"opt read -r netif [ "$net" = "1" ]; then NETWORK="host" MAPPING_QL_PORT=""fi inp "是否在啟動容器時自動啟動掛機程序: 1) 開啟[默認] 2) 關閉"opt read -r hang_sif [ "$hang_s" = "2" ]; then ENABLE_HANGUP=falsefi inp "是否啟用青龍面板: 1) 啟用[默認] 2) 不啟用"opt read -r panelif [ "$panel" = "2" ]; then ENABLE_WEB_PANEL=falsefi # 端口問題 modify_ql_port() { inp "是否修改青龍端口[默認 5700]: 1) 修改 2) 不修改[默認]" opt read -r change_ql_port if [ "$change_ql_port" = "1" ]; then echo -n -e "e[36m輸入您想修改的端口->e[0m" read -r QL_PORT fi }if [ "$NETWORK" = "bridge" ]; then inp "是否映射端口: 1) 映射[默認] 2) 不映射" opt read -r port if [ "$port" = "2" ]; then MAPPING_QL_PORT="" fi fi # 配置已經創建完成,開始執行 # log "1.開始創建配置文件目錄"# PATH_LIST=("$CONFIG_PATH" "$DB_PATH" "$REPO_PATH" "$RAW_PATH" "$SCRIPT_PATH" "$LOG_PATH" "$JBOT_PATH") # for i in "${PATH_LIST[@]}"; do# mkdir -p "$i"# doneif [ $HAS_CONTAINER = true ] && [ $DEL_CONTAINER = true ]; then log "2.1.刪除先前的容器" docker stop "$CONTAINER_NAME" >/dev/null docker rm "$CONTAINER_NAME" >/dev/nullfiif [ $HAS_IMAGE = true ] && [ $PULL_IMAGE = true ]; then if [ -n "$OLD_IMAGE_ID" ] && [ $HAS_CONTAINER = true ] && [ $DEL_CONTAINER = true ]; then log "2.2.刪除舊的鏡像" docker image rm "$OLD_IMAGE_ID" fi log "2.3.開始拉取最新的鏡像" docker pull $DOCKER_IMG_NAME:$TAG if [ $? -ne 0 ]; then cancelrun "** 錯誤:拉取不到鏡像!" fi fi # 端口存在檢測 check_port() { echo "正在檢測端口:$1" netstat -tlpn | grep "[[:graph:]]*:${1}"}if [ "$port" != "2" ]; then while check_port "$QL_PORT"; do echo -n -e "e[31m端口:$QL_PORT 被占用,請重新輸入青龍面板端口:e[0m" read -r QL_PORT done echo -e "e[34m恭喜,端口:$QL_PORT 可用e[0m" MAPPING_QL_PORT="-p $QL_PORT:5700"fi log "3.開始創建容器并執行"# shellcheck disable=SC2086 docker run -dit -t -v "$QL_PATH":/ql/data $MAPPING_QL_PORT --name "$CONTAINER_NAME" --hostname qinglong --restart always --network $NETWORK --env ENABLE_HANGUP="$ENABLE_HANGUP" --env ENABLE_WEB_PANEL="$ENABLE_WEB_PANEL" $DOCKER_IMG_NAME:$TAGif [ $? -ne 0 ]; then cancelrun "** 錯誤:容器創建失敗,請翻譯以上英文報錯,Google/百度嘗試解決問題!"fiif [ $INSTALL_WATCH = true ]; then log "3.1.開始創建容器并執行" docker run -d --name watchtower --restart always -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower -c --schedule "13,14,15 3 * * * *" "$CONTAINER_NAME"fi # 檢查 config 文件是否存在if [ ! -f "$CONFIG_PATH/config.sh" ]; then docker cp "$CONTAINER_NAME":/ql/sample/config.sample.sh "$CONFIG_PATH"/config.sh if [ $? -ne 0 ]; then cancelrun "** 錯誤:找不到配置文件!" fi fi log "4.下面列出所有容器"docker ps # Nginx 靜態解析檢測 log "5.開始檢測 Nginx 靜態解析"echo "開始掃描靜態解析是否在線!"pgrep -f nginxif [ $? -ne 0 ]; then echo "$(date +%Y-%m-%d" "%H:%M:%S) 掃描結束!Nginx 靜態解析停止!準備重啟!" docker exec -it "$CONTAINER_NAME" nginx -c /etc/nginx/nginx.conf echo "$(date +%Y-%m-%d" "%H:%M:%S) Nginx 靜態解析重啟完成!"else echo "$(date +%Y-%m-%d" "%H:%M:%S) 掃描結束!Nginx 靜態解析正常!"fiif [ "$port" = "2" ]; then log "6.用戶名和密碼已顯示,請登錄 ip:$QL_PORT" cat "$CONFIG_PATH"/auth.json fi log "enjoy!!!"
或自定義安裝
docker run -dit -v $PWD/ql/config:/ql/config -v $PWD/ql/log:/ql/log -v $PWD/ql/scripts:/ql/scripts -v $PWD/ql/db:/ql/db --net host --name qinglong --hostname qinglong --restart always whyour/qinglong:latest
2.1、一鍵配置腳本依賴
docker exec -it qinglong bash; curl -fsSL https://ghproxy.com/https://raw.githubusercontent.com/shufflewzc/QLDependency/main/Shell/QLOneKeyDependency.sh | sh
或
curl -fsSL https://api.dujin.org/js/qinglong/qinglong-yilaiku-dujin.org.sh | sh
3.1、登錄青龍面板
瀏覽器打開 ip:5700,這里的ip是你服務器的公網ip,如:123.123.123:5700 -注意,沒開放5700端口是訪問不了的喔~
獲取京豆教程
4.1、拉腳本倉庫
ql repo https://github.com/gys619/jdd.git "jd_|jx_|jddj_|gua_|jddj_|getJDCookie|wskey" "activity|backUp|scf_test_event" "^jd[^_]|USER|utils|ZooFaker_Necklace|JDJRValidator_Pure|sign_graphics_validate|jddj_cookie|function"
5.1、獲取并添加JD cookie
掃一掃,關注我們
129