forked from basten1899/jd_shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dd9aa11
Showing
34 changed files
with
5,391 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
FROM node:lts-alpine | ||
ARG JD_SCRIPTS_URL=https://gitee.com/lxk0301/jd_scripts | ||
ARG JD_SCRIPTS_BRANCH=master | ||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ | ||
LANG=zh_CN.UTF-8 \ | ||
SHELL=/bin/bash \ | ||
PS1="\u@\h:\w \$ " \ | ||
JD_DIR=/jd \ | ||
ENABLE_HANGUP=true \ | ||
ENABLE_WEB_PANEL=true | ||
WORKDIR ${JD_DIR} | ||
ADD src.tgz ${JD_DIR} | ||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ | ||
&& apk update -f \ | ||
&& apk upgrade \ | ||
&& apk --no-cache add -f bash \ | ||
coreutils \ | ||
moreutils \ | ||
git \ | ||
wget \ | ||
curl \ | ||
nano \ | ||
tzdata \ | ||
perl \ | ||
openssl \ | ||
openssh-client \ | ||
&& rm -rf /var/cache/apk/* \ | ||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ | ||
&& echo "Asia/Shanghai" > /etc/timezone \ | ||
&& cd ${JD_DIR}/panel \ | ||
&& npm install \ | ||
&& git clone -b ${JD_SCRIPTS_BRANCH} ${JD_SCRIPTS_URL} ${JD_DIR}/scripts \ | ||
&& cd ${JD_DIR}/scripts \ | ||
&& npm install \ | ||
&& npm install -g pm2 \ | ||
&& ln -sf ${JD_DIR}/jd.sh /usr/local/bin/jd \ | ||
&& ln -sf ${JD_DIR}/git_pull.sh /usr/local/bin/git_pull \ | ||
&& ln -sf ${JD_DIR}/rm_log.sh /usr/local/bin/rm_log \ | ||
&& ln -sf ${JD_DIR}/export_sharecodes.sh /usr/local/bin/export_sharecodes \ | ||
&& cp -f ${JD_DIR}/docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh \ | ||
&& chmod 777 /usr/local/bin/docker-entrypoint.sh \ | ||
&& chmod 777 ${JD_DIR}/*.sh \ | ||
&& rm -rf /root/.npm | ||
ENTRYPOINT ["docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
version: "2.0" | ||
services: | ||
# 第1个容器 | ||
jd1: | ||
image: evinedeng/jd # 如果要从gitee更新脚本,则为:evinedeng/jd:gitee | ||
container_name: jd1 | ||
restart: always | ||
tty: true | ||
network_mode: "bridge" | ||
hostname: jd1 | ||
volumes: | ||
- ./jd1/config:/jd/config | ||
- ./jd1/log:/jd/log | ||
#- ./jd1/scripts:/jd/scripts # 如果想要看到lxk0301大佬的js脚本,以方便的添加额外脚本,可以解除本行注释,下同 | ||
ports: | ||
- 5678:5678 | ||
environment: | ||
- ENABLE_HANGUP=true # 是否在启动容器时自动启动挂机程序 | ||
- ENABLE_WEB_PANEL=true # 是否在启动容器时自动启动控制面板 | ||
|
||
# 第2个容器 | ||
jd2: | ||
image: evinedeng/jd # 如果要从gitee更新脚本,则为:evinedeng/jd:gitee | ||
container_name: jd2 | ||
restart: always | ||
tty: true | ||
network_mode: "bridge" | ||
hostname: jd2 | ||
volumes: | ||
- ./jd2/config:/jd/config | ||
- ./jd2/log:/jd/log | ||
ports: | ||
- 5679:5678 | ||
environment: | ||
- ENABLE_HANGUP=true # 是否在启动容器时自动启动挂机程序 | ||
- ENABLE_WEB_PANEL=true # 是否在启动容器时自动启动控制面板 | ||
|
||
# 第3个容器,以此类推 | ||
jd3: | ||
image: evinedeng/jd # 如果要从gitee更新脚本,则为:evinedeng/jd:gitee | ||
container_name: jd3 | ||
restart: always | ||
tty: true | ||
network_mode: "bridge" | ||
hostname: jd3 | ||
volumes: | ||
- ./jd3/config:/jd/config | ||
- ./jd3/log:/jd/log | ||
ports: | ||
- 5680:5678 | ||
environment: | ||
- ENABLE_HANGUP=true # 是否在启动容器时自动启动挂机程序 | ||
- ENABLE_WEB_PANEL=true # 是否在启动容器时自动启动控制面板 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
if [ ! -d ${JD_DIR}/config ]; then | ||
echo -e "没有映射config配置目录给本容器,请先按教程映射config配置目录...\n" | ||
exit 1 | ||
fi | ||
|
||
echo -e "\n========================1. 更新源代码========================\n" | ||
[ ! -d ${JD_DIR}/log ] && mkdir -p ${JD_DIR}/log | ||
crond | ||
bash git_pull | ||
echo | ||
|
||
echo -e "========================2. 检测配置文件========================\n" | ||
|
||
if [ -s ${JD_DIR}/config/crontab.list ] | ||
then | ||
echo -e "检测到config配置目录下存在crontab.list,自动导入定时任务...\n" | ||
crontab ${JD_DIR}/config/crontab.list | ||
echo -e "成功添加定时任务...\n" | ||
else | ||
echo -e "检测到config配置目录下不存在crontab.list或存在但文件为空,从示例文件复制一份用于初始化...\n" | ||
cp -fv ${JD_DIR}/sample/docker.list.sample ${JD_DIR}/config/crontab.list | ||
echo | ||
crontab ${JD_DIR}/config/crontab.list | ||
echo -e "成功添加定时任务...\n" | ||
fi | ||
|
||
if [ ! -s ${JD_DIR}/config/config.sh ]; then | ||
echo -e "检测到config配置目录下不存在config.sh,从示例文件复制一份用于初始化...\n" | ||
cp -fv ${JD_DIR}/sample/config.sh.sample ${JD_DIR}/config/config.sh | ||
echo | ||
fi | ||
|
||
if [ ! -s ${JD_DIR}/config/auth.json ]; then | ||
echo -e "检测到config配置目录下不存在auth.json,从示例文件复制一份用于初始化...\n" | ||
cp -fv ${JD_DIR}/sample/auth.json ${JD_DIR}/config/auth.json | ||
echo | ||
fi | ||
|
||
echo -e "========================3. 启动挂机程序========================\n" | ||
if [[ ${ENABLE_HANGUP} == true ]]; then | ||
. ${JD_DIR}/config/config.sh | ||
if [ -n "${Cookie1}" ]; then | ||
bash jd hangup 2>/dev/null | ||
echo -e "挂机程序启动成功...\n" | ||
else | ||
echo -e "config.sh中还未填入有效的Cookie,可能是首次部署容器,因此不启动挂机程序...\n" | ||
fi | ||
elif [[ ${ENABLE_HANGUP} == false ]]; then | ||
echo -e "已设置为不自动启动挂机程序,跳过...\n" | ||
fi | ||
|
||
echo -e "========================4. 启动控制面板========================\n" | ||
if [[ ${ENABLE_WEB_PANEL} == true ]]; then | ||
pm2 start ${JD_DIR}/panel/server.js | ||
echo -e "控制面板启动成功...\n" | ||
echo -e "如未修改用户名密码,则初始用户名为:admin,初始密码为:adminadmin\n" | ||
echo -e "请访问 http://<ip>:5678 登陆并修改配置...\n" | ||
elif [[ ${ENABLE_WEB_PANEL} == false ]]; then | ||
echo -e "已设置为不自动启动控制面板,跳过...\n" | ||
fi | ||
echo -e "容器启动成功...\n" | ||
|
||
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then | ||
set -- node "$@" | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bash | ||
|
||
## 路径、环境判断 | ||
ShellDir=${JD_DIR:-$(cd $(dirname $0); pwd)} | ||
LogDir=${ShellDir}/log | ||
[[ ${ANDROID_RUNTIME_ROOT}${ANDROID_ROOT} ]] && Opt="P" || Opt="E" | ||
Tips="从日志中未找到任何互助码..." | ||
|
||
## 所有有互助码的活动,只需要把脚本名称去掉前缀jd_后列在Name1中,将其中文名称列在Name2中即可。Name1和Name2中两个名称必须一一对应。 | ||
Name1=(fruit pet plantBean dreamFactory jdfactory crazy_joy jdzz jxnc bookshop cash festival immortal nh sgmh newYearMoney) | ||
Name2=(东东农场 东东萌宠 京东种豆得豆 京喜工厂 东东工厂 crazyJoy任务 京东赚赚 京喜农场 口袋书店 签到领现金 手机年终奖 神仙书院 年货节 闪购盲盒 压岁钱) | ||
|
||
## 导出互助码的通用程序 | ||
function Cat_Scodes { | ||
if [ -d ${LogDir}/jd_$1 ] && [[ $(ls ${LogDir}/jd_$1) != "" ]]; then | ||
cd ${LogDir}/jd_$1 | ||
for log in $(ls -r); do | ||
case $# in | ||
1) | ||
codes=$(cat ${log} | grep -${Opt} "开始【京东账号|您的(好友)?助力码为" | uniq | perl -0777 -pe "{s|\*||g; s|开始||g; s|\n您的(好友)?助力码为(:)?:?|:|g; s|,.+||g}" | perl -ne '{print if /:/}') | ||
;; | ||
2) | ||
codes=$(grep -${Opt} $2 ${log} | perl -pe "{s| ||g; s|$2||g}") | ||
;; | ||
esac | ||
[[ ${codes} ]] && break | ||
done | ||
[[ ${codes} ]] && echo "${codes}" || echo ${Tips} | ||
else | ||
echo "还没有运行过 jd_$1 脚本,没有产生日志..." | ||
fi | ||
} | ||
|
||
## 汇总 | ||
function Cat_All { | ||
echo -e "\n本脚本从最后一个正常的日志中寻找互助码,某些账号缺失则代表在最后一个正常的日志中没有找到。" | ||
for ((i=0; i<${#Name1[*]}; i++)); do | ||
echo -e "\n${Name2[i]}:" | ||
[[ $(Cat_Scodes "${Name1[i]}" "的${Name2[i]}好友互助码") == ${Tips} ]] && Cat_Scodes "${Name1[i]}" || Cat_Scodes "${Name1[i]}" "的${Name2[i]}好友互助码" | ||
done | ||
} | ||
|
||
## 执行并写入日志 | ||
LogTime=$(date "+%Y-%m-%d-%H-%M-%S") | ||
LogFile="${LogDir}/export_sharecodes/${LogTime}.log" | ||
[ ! -d "${LogDir}/export_sharecodes" ] && mkdir -p ${LogDir}/export_sharecodes | ||
Cat_All | perl -pe "{s|京东种豆|种豆|; s|crazyJoy任务|疯狂的JOY|}" | tee ${LogFile} |
Oops, something went wrong.