代码拉取完成,页面将自动刷新
同步操作将从 老竭力/jd-docker 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/sh
clear
echo "
██╗██████╗ ██████╗ ██████╗ ██████╗██╗ ██╗███████╗██████╗ ██╗ ██╗██╗ ██╗
██║██╔══██╗ ██╔══██╗██╔═══██╗██╔════╝██║ ██╔╝██╔════╝██╔══██╗ ██║ ██║██║ ██║
██║██║ ██║ ██║ ██║██║ ██║██║ █████╔╝ █████╗ ██████╔╝ ██║ ██║███████║
██ ██║██║ ██║ ██║ ██║██║ ██║██║ ██╔═██╗ ██╔══╝ ██╔══██╗ ╚██╗ ██╔╝╚════██║
╚█████╔╝██████╔╝ ██████╔╝╚██████╔╝╚██████╗██║ ██╗███████╗██║ ██║ ╚████╔╝ ██║
╚════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝
==== Create by 老竭力 ====
本脚本将会添加作者的助力码,感谢你的支持!
注意:本脚本已经没有网页版控制面板了!!!
"
DOCKER_IMG_NAME="nevinee/jd"
JD_PATH=""
SHELL_FOLDER=$(pwd)"/jd_docker"
CONTAINER_NAME=""
CONFIG_PATH=""
LOG_PATH=""
TAG="v4"
NETWORK="host"
JD_PORT=5678
HAS_IMAGE=false
EXT_SCRIPT=false
PULL_IMAGE=false
HAS_CONTAINER=false
DEL_CONTAINER=true
INSTALL_WATCH=false
TEST_BEAN_CHAGE=false
ENABLE_TTYD=true
ENABLE_WEB_PANEL=true
ENABLE_HANGUP=true
OLD_IMAGE_ID=""
MOUNT_SCRIPT=""
MAPPING_PORT=""
ENABLE_HANGUP_ENV=""
log() {
echo -e "\e[32m$1 \e[0m\n"
}
warn() {
echo -e "\e[31m$1 \e[0m\n"
}
cancelrun() {
if [ $# -gt 0 ]; then
echo -e "\033[31m $1 \033[0m"
fi
exit 1
}
#Docker 的检测与安装
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
if [ $? -ne 0 ]; then
cancelrun "无法安装docker!请重试。"
else
echo "安装docker环境...安装完成!"
fi
fi
fi
}
docker_install
#检查whiptail
whiptail_install(){
if [ -x "$(command -v whiptail)" ]; then
echo ""
else
if [ -r /etc/os-release ]; then
lsb_dist="$(. /etc/os-release && echo "$ID")"
fi
if [ $lsb_dist == "openwrt" ]; then
opkg update
opkg install whiptail
#exit 1
elif [ $lsb_dist == "debian" ] || [ $lsb_dist == "ubuntu" ] || [ $lsb_dist == "raspbian" ]; then
apt -y update
apt -y install whiptail
elif [ $lsb_dist == "centos" ]; then
yum update
yum install newt
fi
fi
}
whiptail_install
TITLE="JD-DOCKER V4 安装脚本"
#配置文件目录
TEMPPATH=$(whiptail --title "${TITLE}" --inputbox "请输入配置文件保存的绝对路径" 10 60 ${SHELL_FOLDER} 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
JD_PATH=$TEMPPATH
if [ -z "$TEMPPATH" ]; then
JD_PATH=$SHELL_FOLDER
fi
else
cancelrun "你已取消安装"
fi
CONFIG_PATH=$JD_PATH/config
LOG_PATH=$JD_PATH/log
OWN_PATH=$JD_PATH/own
SCRIPT_PATH=$JD_PATH/scripts
#映射SCRIPT
if (whiptail --title "${TITLE}" --yesno "是否将scripts目录映射到外部?" 10 60) then
EXT_SCRIPT=true
fi
#检测镜像是否存在
if [ ! -z "$(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)
if (whiptail --title "${TITLE}" --yesno "检测到先前已经存在的镜像,是否拉取最新的镜像?" 10 60) then
PULL_IMAGE=true
fi
fi
#检测容器是否存在
check_container_name() {
if [ ! -z "$(docker ps -a | grep $CONTAINER_NAME 2> /dev/null)" ]; then
HAS_CONTAINER=true
if (whiptail --title "${TITLE}" --yesno "检测到先前已经存在的容器,是否删除先前的容器?" 10 60) then
PULL_IMAGE=true
else
PULL_IMAGE=false
input_container_name "您选择了不要删除之前的容器,需要重新输入容器名称"
fi
fi
}
#容器名称
input_container_name() {
container_name=$(whiptail --title "${TITLE}" --inputbox "${1}" 10 60 jd 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
CONTAINER_NAME=$container_name
if [ -z "$container_name" ]; then
CONTAINER_NAME="jd"
fi
else
cancelrun "你已取消安装"
fi
check_container_name
}
input_container_name "请输入要创建的Docker容器名称"
#是否安装WatchTower
if (whiptail --title "${TITLE}" --yes-button "不安装" --no-button "安装" --yesno "是否安装containrrr/watchtower自动更新Docker容器?" 10 60) then
INSTALL_WATCH=false
else
INSTALL_WATCH=true
fi
#网络类型选择
NETTYPE=$(whiptail --title "Menu Dialog" --menu "请选择容器的网络类型." 15 60 2 \
"host" "Host 模式" \
"bridge" "Bridge 模式" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
NETWORK=$NETTYPE
fi
#是否启动自动挂机
if (whiptail --title "${TITLE}" --yesno "是否在启动容器时自动启动挂机程序?" 10 60) then
ENABLE_HANGUP_ENV="--env ENABLE_HANGUP=true"
fi
#配置已经创建完成,开始执行
log "1.开始创建配置文件目录"
mkdir -p $CONFIG_PATH
mkdir -p $LOG_PATH
mkdir -p $OWN_PATH
if [ $EXT_SCRIPT = true ]; then
mkdir -p $SCRIPT_PATH
fi
if [ $? -ne 0 ] ; then
cancelrun "** 错误: 目录创建错误请重试!"
fi
if [ $HAS_CONTAINER = true ] && [ $DEL_CONTAINER = true ]; then
log "2.1.删除先前的容器"
docker stop $CONTAINER_NAME >/dev/null
docker rm $CONTAINER_NAME >/dev/null
fi
if [ $HAS_IMAGE = true ] && [ $PULL_IMAGE = true ]; then
if [ ! -z "$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
if [ $EXT_SCRIPT = true ]; then
MOUNT_SCRIPT="-v $SCRIPT_PATH:/jd/scripts"
fi
if [ "$NETWORK" = "bridge" ]; then
MAPPING_PORT="-p $JD_PORT:5678"
fi
log "3.开始创建容器并执行"
docker run -dit \
-t \
-v $CONFIG_PATH:/jd/config \
-v $LOG_PATH:/jd/log \
-v $OWN_PATH:/jd/own \
$MOUNT_SCRIPT \
--name $CONTAINER_NAME \
--hostname jd \
--restart always \
--network $NETWORK \
$ENABLE_HANGUP_ENV \
$DOCKER_IMG_NAME:$TAG
if [ $? -ne 0 ] ; then
cancelrun "** 错误: 容器创建失败,多数由于docker空间不足引起,请检查!"
fi
if [ $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 \
--cleanup
fi
#检查config文件是否存在
if [ ! -f "$CONFIG_PATH/config.sh" ]; then
docker cp $CONTAINER_NAME:/jd/sample/config.sample.sh $CONFIG_PATH/config.sh
if [ $? -ne 0 ] ; then
cancelrun "** 错误: 找不到配置文件!"
fi
#添加脚本作者助力码
sed -i -e '/## ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 第三区域:互助码填写区域 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓/a\ForOtherFruit1="3bea619de1814b5688e5504af8c58591@a4ee8a28bc3d4265b5c7cfd343aa47c8@e974332dbff343cf864f6e56c2a5224a@6e6e811bf81543e4a57998f98ecc17db"\
ForOtherBean1="ckvke3ri7sj4c7u3xbhnnuirk4@owbcfvgssaf7hetu5bw4dwacfi@qpb2rslaqgfqrqgpyys4ntjufi@zbei5cjpebrwm4gkhhsl6qqgg45ac3f4ijdgqji"\
ForOtherJdFactory1="T0085KgxAldCCjVWnYaS5kRrbA@T011-b4vFU9HqwECjVWnYaS5kRrbA@T0164qQtFEtBqgqAInWpCjVWnYaS5kRrbA@T0105q8yGkJTrQCjVWnYaS5kRrbA"\
ForOtherJdzz1="S5KgxAldC@S5awtF0VIqwO4c1K9@S4qggGEtb9FXX@S5q8yGkJTrQ"\
ForOtherJoy1="mGjQUKjeeEI="\
ForOtherSgmh1="T0085KgxAldCCjVQmoaT5kRrbA@T011-b4vFU9HqwECjVQmoaT5kRrbA"\
ForOtherDreamFactory1="wIZlHwWMXHCRVBJQpxp58A=="\
ForOtherPet1="MTE1NDQ5OTUwMDAwMDAwNDMwNDgyMDE="\
ForOtherJdFactory1="T0085KgxAldCCjVWnYaS5kRrbA@T011-b4vFU9HqwECjVWnYaS5kRrbA"\
ForOtherCfd1="DC12E70A1060DDB29E9A349955AD0960437A40CA0AACBBB44421BD247F623228@41EFF1857EBE78AF24B407372BAEFB53B4BA50E3608C0B01B7A3B297CC9CAB1D"\
ForOtherCash1="eU51LqXp@ZFhrOb3sOKk"
' $CONFIG_PATH/config.sh
fi
log "4.下面列出所有容器"
docker ps
log "5.安装已经完成。创建好后请阅读映射的config目录下的的config.sh,并根据注释修改。"
log "命令提示:"
log "jtask mtask otask链接的都是同一个脚本,m=my,o=own,j=jd。三者区分仅用在crontab.list中,以区别不同类型任务,手动运行直接jtask即可。\ndocker exec $CONTAINER_NAME jtask # 运行scripts脚本\ndocker exec $CONTAINER_NAME otask # 运行own脚本\ndocker exec $CONTAINER_NAME mtask # 运行你自己的脚本,如果某些own脚本识别不出来cron,你也可以自行添加mtask任务\ndocker exec $CONTAINER_NAME jlog # 删除旧日志\ndocker exec $CONTAINER_NAME jup # 更新所有脚本\ndocker exec $CONTAINER_NAME jcode # 导出所有互助码\ndocker exec $CONTAINER_NAME jcsv # 记录豆豆变化情况"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。