├── docker_stop.sh ├── docker_build.sh ├── filebrowser.json ├── docker_start.sh ├── aotulogin.sh ├── start.sh ├── config.example.js ├── README.md ├── alpine.patch ├── Dockerfile └── Dockerfile-autologin /docker_stop.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" 3 | docker rm -f gd-utils 4 | -------------------------------------------------------------------------------- /docker_build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" 3 | docker build -t gd-utils:latest $SCRIPTPATH 4 | -------------------------------------------------------------------------------- /filebrowser.json: -------------------------------------------------------------------------------- 1 | { 2 | "port": 80, 3 | "baseURL": "", 4 | "address": "", 5 | "log": "stdout", 6 | "database": "/database.db", 7 | "root": "/" 8 | } 9 | -------------------------------------------------------------------------------- /docker_start.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" 3 | docker run --restart=always -d \ 4 | -e USERPWD="3024-night" \ 5 | -p 4200:4200 \ 6 | -p 80:80 \ 7 | -p 23333:23333 \ 8 | --name gd-utils \ 9 | gd-utils 10 | -------------------------------------------------------------------------------- /aotulogin.sh: -------------------------------------------------------------------------------- 1 | #!bin/bash 2 | #添加gd账号,设置密码 3 | adduser gd -u 20001 -D -S -s /bin/bash -G root 4 | echo -e "${USERPWD}\n${USERPWD}" | passwd root 5 | echo -e "${USERPWD}\n${USERPWD}" | passwd gd 6 | chmod 4755 /bin/busybox 7 | node /gd-utils/server.js & 8 | #免登陆: 9 | /gd-utils/sa/shellinaboxd --no-beep -t --service "/:root:root:/:/bin/bash" 10 | #/gd-utils/sa/shellinaboxd --no-beep -t --user root -s "/:LOGIN" 11 | #filebrowser默认不启动 12 | #filebrowser & 13 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!bin/bash 2 | if [ ! -f "/gd-utils/sa/config.js" ]; 3 | then 4 | mv -f /gd-utils/config.js /gd-utils/sa/config.js 5 | ln -sf /gd-utils/sa/config.js /gd-utils/config.js 6 | else 7 | rm -rf /gd-utils/config.js 8 | ln -sf /gd-utils/sa/config.js /gd-utils/config.js 9 | fi 10 | if [ ! -f "/gd-utils/sa/gdurl.sqlite" ]; 11 | then 12 | mv -f /gd-utils/gdurl.sqlite /gd-utils/sa/gdurl.sqlite 13 | ln -sf /gd-utils/sa/gdurl.sqlite /gd-utils/gdurl.sqlite 14 | else 15 | rm -rf /gd-utils/gdurl.sqlite 16 | ln -sf /gd-utils/sa/gdurl.sqlite /gd-utils/gdurl.sqlite 17 | fi 18 | #添加gd账号,设置密码 19 | adduser gd -u 20001 -D -S -s /bin/bash -G root 20 | echo -e "${USERPWD}\n${USERPWD}" | passwd root 21 | echo -e "${USERPWD}\n${USERPWD}" | passwd gd 22 | chmod 4755 /bin/busybox 23 | node /gd-utils/server.js & 24 | #filebrowser默认启动 25 | filebrowser & 26 | #免登陆:/gd-utils/sa/shellinaboxd --no-beep -t --service "/:root:root:/:/bin/bash" & 27 | /shellinabox/bin/bin/shellinaboxd --no-beep -t --user root -s "/:LOGIN" 28 | 29 | -------------------------------------------------------------------------------- /config.example.js: -------------------------------------------------------------------------------- 1 | // 单次请求多少毫秒未响应以后超时(基准值,若连续超时则下次调整为上次的2倍) 2 | const TIMEOUT_BASE = 7000 3 | // 最大超时设置,比如某次请求,第一次7s超时,第二次14s,第三次28s,第四次56s,第五次不是112s而是60s,后续同理 4 | const TIMEOUT_MAX = 60000 5 | 6 | const LOG_DELAY = 5000 // 日志输出时间间隔,单位毫秒 7 | const PAGE_SIZE = 1000 // 每次网络请求读取目录下的文件数,数值越大,越有可能超时,不得超过1000 8 | 9 | const RETRY_LIMIT = 7 // 如果某次请求失败,允许其重试的最大次数 10 | const PARALLEL_LIMIT = 20 // 网络请求的并行数量,可根据网络环境调整 11 | 12 | const DEFAULT_TARGET = '' // 必填,拷贝默认目的地ID,如果不指定target,则会复制到此处,建议填写团队盘ID 13 | 14 | const AUTH = { // 如果您拥有service account的json授权文件,可将其拷贝至 sa 目录中以代替 client_id/secret/refrest_token 15 | client_id: 'your_client_id', 16 | client_secret: 'your_client_secret', 17 | refresh_token: 'your_refrest_token', 18 | expires: 0, // 可以留空 19 | access_token: '', // 可以留空 20 | tg_token: '', // 你的 telegram robot 的 token,获取方法参见 https://core.telegram.org/bots#6-botfather 21 | tg_whitelist: [''] // 你的tg username(t.me/username),bot只会执行这个列表里的用户所发送的指令 22 | } 23 | 24 | module.exports = { AUTH, PARALLEL_LIMIT, RETRY_LIMIT, TIMEOUT_BASE, TIMEOUT_MAX, LOG_DELAY, PAGE_SIZE, DEFAULT_TARGET } 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [gd-utils](https://github.com/iwestlin/gd-utils)的[Docker版](https://hub.docker.com/r/gdtool/gd-utils-docker),快速搭建google drive 转存工具 2 | 3 | 4 | **docker内包含:** 5 | - **网页版shell**:方便执行git pull等命令 6 | - **文件管理器**,方便上传sa文件以及编辑配置文件和备份数据库 7 | - **gd-utils机器人** 8 | > 具体gd-utils教程请移步官网: [gd-utils](https://github.com/iwestlin/gd-utils) 9 | 10 | 11 | # 注意: 12 | 13 | 为方便持久化,源代码的`/gd-utils/config.js` 和 ` /gd-utils/gdurl.sqlite` 已经软链接到目录`/gd-utils/sa/` 14 | 15 | # 简单使用方法: 16 | 1. 启动容器,假设挂载目录为`/root/gd-utils/sa` 17 | ``` 18 | docker run --restart=always -d \ 19 | -e USERPWD="pwd123456" \ 20 | -p 4200:4200 \ 21 | -p 80:80 \ 22 | -p 23333:23333 \ 23 | --name gd-utils \ 24 | -v /root/gd-utils/sa:/gd-utils/sa \ 25 | gdtool/gd-utils-docker 26 | ``` 27 | 2. 修改配置文件`/root/gd-utils/sa/config.js` 28 | 3. 上传sa文件到`/root/gd-utils/sa/` 29 | 4. 重启容器 30 | 31 | > 如果使用云容器,可以打开`localhost:80`进入容器文件管理器(账号密码`admin`),修改、上传配置文件 32 | 33 | # 其他说明爱看就看,不看也没事儿: 34 | 35 | **4200端口:** webshell,账号:`gd`,密码:`pwd123456` 36 | 37 | **23333端口:** gd-utils机器人 38 | 39 | **80端口:** 文件管理默认启动,**注意安全** 40 | ~~**默认不启动** **默认不启动** **默认不启动** 41 | > 启动方法:登录webshell;`su root` 然后执行`cd / && filebrowser &`,~~ 42 | 账号密码:admin 43 | 44 | **持久化目录:** 45 | 46 | /gd-utils/sa/ 47 | 为方便持久化,源代码的`/gd-utils/config.js` 和 ` /gd-utils/gdurl.sqlite` 已经软链接到目录`/gd-utils/sa/` 48 | 49 | 50 | 51 | 52 | ## 原项目 53 | [gd-utils](https://github.com/iwestlin/gd-utils) 54 | 55 | ## 相关项目(感谢这些开源项目) 56 | 57 | [gd-utils](https://github.com/iwestlin/gd-utils) 58 | 59 | [shellinabox](https://github.com/shellinabox/shellinabox) 60 | 61 | [filebrowser](https://github.com/filebrowser/filebrowser/) 62 | 63 | ## 脚本参考 64 | 65 | [iouAkira](https://github.com/iouAkira/someDockerfile) 66 | 67 | [mics8128](https://github.com/mics8128/gd-utilds-docker) 68 | -------------------------------------------------------------------------------- /alpine.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libhttp/ssl.c b/libhttp/ssl.c 2 | index 6d09035..5fc9bdc 100644 3 | --- a/libhttp/ssl.c 4 | +++ b/libhttp/ssl.c 5 | @@ -1016,11 +1016,11 @@ int sslPromoteToSSL(struct SSLSupport *ssl, SSL **sslHndl, int fd, 6 | } 7 | 8 | BIO *sslGetNextBIO(BIO *b) { 9 | -#if OPENSSL_VERSION_NUMBER <= 0x10100000L 10 | +/*#if OPENSSL_VERSION_NUMBER <= 0x10100000L 11 | return b->next_bio; 12 | -#else 13 | +#else*/ 14 | return BIO_next(b); 15 | -#endif 16 | +//#endif 17 | } 18 | 19 | void sslFreeHndl(SSL **sslHndl) { 20 | diff --git a/shellinabox/launcher.c b/shellinabox/launcher.c 21 | index ba54b36..96f0585 100644 22 | --- a/shellinabox/launcher.c 23 | +++ b/shellinabox/launcher.c 24 | @@ -1573,19 +1573,19 @@ static void childProcess(struct Service *service, int width, int height, 25 | #ifdef HAVE_UTMPX_H 26 | if (enableUtmpLogging) { 27 | setutxent(); 28 | - struct utmpx utmpx = utmp->utmpx; 29 | + struct utmpx utmpxx = utmp->utmpx; 30 | if (service->useLogin || service->authUser) { 31 | - utmpx.ut_type = LOGIN_PROCESS; 32 | - memset(utmpx.ut_host, 0, sizeof(utmpx.ut_host)); 33 | + utmpxx.ut_type = LOGIN_PROCESS; 34 | + memset(utmpxx.ut_host, 0, sizeof(utmpxx.ut_host)); 35 | } 36 | - pututxline(&utmpx); 37 | + pututxline(&utmpxx); 38 | endutxent(); 39 | 40 | #if defined(HAVE_UPDWTMP) || defined(HAVE_UPDWTMPX) 41 | if (!utmp->useLogin) { 42 | - memset(&utmpx.ut_user, 0, sizeof(utmpx.ut_user)); 43 | - strncat(&utmpx.ut_user[0], "LOGIN", sizeof(utmpx.ut_user) - 1); 44 | - updwtmpx("/var/log/wtmp", &utmpx); 45 | + memset(&utmpxx.ut_user, 0, sizeof(utmpxx.ut_user)); 46 | + strncat(&utmpxx.ut_user[0], "LOGIN", sizeof(utmpxx.ut_user) - 1); 47 | + updwtmpx("/var/log/wtmp", &utmpxx); 48 | } 49 | #endif 50 | } 51 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | MAINTAINER Tdtool 3 | ARG VERSION=2020-09-15 4 | 5 | ENV USERPWD mysec55rdet9966 6 | USER root 7 | 8 | ADD start.sh / 9 | COPY alpine.patch /alpine.patch 10 | 11 | 12 | 13 | RUN set -ex \ 14 | && apk update \ 15 | && apk add --no-cache nodejs npm \ 16 | && apk add ca-certificates mailcap curl bash \ 17 | && apk add --no-cache --virtual .build-deps make gcc g++ python3 git \ 18 | && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ 19 | && echo "Asia/Shanghai" > /etc/timezone 20 | 21 | ARG VERSION 22 | RUN set -ex \ 23 | && git clone https://github.com/iwestlin/gd-utils /gd-utils \ 24 | && cd /gd-utils \ 25 | && npm install \ 26 | && apk del .build-deps 27 | 28 | 29 | RUN apk add --no-cache --update --virtual build-deps alpine-sdk autoconf automake libtool curl tar git && \ 30 | adduser -D -H shusr && \ 31 | git clone https://github.com/shellinabox/shellinabox.git /shellinabox && \ 32 | cd /shellinabox && \ 33 | git apply /alpine.patch && \ 34 | autoreconf -i && \ 35 | ./configure --prefix=/shellinabox/bin && \ 36 | make && make install && cd / && \ 37 | #mv /shellinabox/bin/bin/shellinaboxd /gd-utils/sa/shellinaboxd && \ 38 | #rm -rf /shellinabox && \ 39 | apk del build-deps && rm -rf /var/cache/apk/ 40 | COPY filebrowser.json /.filebrowser.json 41 | RUN curl -fsSL https://filebrowser.xyz/get.sh | bash 42 | RUN chmod +x /start.sh && \ 43 | chmod 777 /shellinabox/bin/bin/shellinaboxd 44 | #添加gd账号,设置密码 45 | #RUN adduser gd -u 20001 -D -S -s /bin/bash -G root && \ 46 | # echo -e "${USERPWD}\n${USERPWD}" | passwd root && \ 47 | # echo -e "${USERPWD}\n${USERPWD}" | passwd gd && \ 48 | # chmod 4755 /bin/busybox 49 | EXPOSE 23333 4200 80 50 | VOLUME /gd-utils 51 | 52 | 53 | ENTRYPOINT [ "/start.sh" ] 54 | -------------------------------------------------------------------------------- /Dockerfile-autologin: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | MAINTAINER Tdtool 3 | ARG VERSION=2020-07-06 4 | 5 | ENV USERPWD mysec55rdet9966 6 | USER root 7 | 8 | ADD aotulogin.sh / 9 | COPY alpine.patch /alpine.patch 10 | 11 | 12 | 13 | RUN set -ex \ 14 | && apk update \ 15 | && apk add --no-cache nodejs npm \ 16 | && apk add ca-certificates mailcap curl bash \ 17 | && apk add --no-cache --virtual .build-deps make gcc g++ python3 git \ 18 | && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ 19 | && echo "Asia/Shanghai" > /etc/timezone 20 | 21 | ARG VERSION 22 | RUN set -ex \ 23 | && git clone https://github.com/iwestlin/gd-utils /gd-utils \ 24 | && cd /gd-utils \ 25 | && npm install \ 26 | && apk del .build-deps 27 | 28 | 29 | RUN apk add --no-cache --update --virtual build-deps alpine-sdk autoconf automake libtool curl tar git && \ 30 | adduser -D -H shusr && \ 31 | git clone https://github.com/shellinabox/shellinabox.git /shellinabox && \ 32 | cd /shellinabox && \ 33 | git apply /alpine.patch && \ 34 | autoreconf -i && \ 35 | ./configure --prefix=/shellinabox/bin && \ 36 | make && make install && cd / && \ 37 | mv /shellinabox/bin/bin/shellinaboxd /gd-utils/sa/shellinaboxd && \ 38 | rm -rf /shellinabox && \ 39 | apk del build-deps && rm -rf /var/cache/apk/ 40 | COPY filebrowser.json /.filebrowser.json 41 | RUN curl -fsSL https://filebrowser.xyz/get.sh | bash 42 | RUN chmod +x /aotulogin.sh && \ 43 | chmod 777 /gd-utils/sa/shellinaboxd 44 | #添加gd账号,设置密码 45 | #RUN adduser gd -u 20001 -D -S -s /bin/bash -G root && \ 46 | # echo -e "${USERPWD}\n${USERPWD}" | passwd root && \ 47 | # echo -e "${USERPWD}\n${USERPWD}" | passwd gd && \ 48 | # chmod 4755 /bin/busybox 49 | EXPOSE 23333 4200 80 50 | VOLUME /gd-utils 51 | 52 | 53 | ENTRYPOINT [ "/aotulogin.sh" ] 54 | --------------------------------------------------------------------------------