-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/hectorqin/reader
- Loading branch information
Showing
4 changed files
with
297 additions
and
13 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
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
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,50 @@ | ||
version: '3.1' | ||
services: | ||
# reader 在线阅读 | ||
# 公开服务器(服务器位于日本):[https://reader.nxnow.top](https://reader.nxnow.top) 测试账号/密码分别为guest/guest123,也可自行创建账号添加书源,不定期删除长期未登录账号(2周) | ||
# 阅读官方书源 : [https://legado.pages.dev](https://legado.pages.dev) 或者 [http://legado.git.llc](https://legado.pages.dev) 点击打开连接,添加远程书源即可 | ||
# 公众号汇总 : [https://mp.weixin.qq.com/s/5t8nfSnRfHjJNAvT76fA_A](https://mp.weixin.qq.com/s/5t8nfSnRfHjJNAvT76fA_A) | ||
# 手动更新方式 : 在此文件所在的目录下执行 docker-compose pull && docker-compose up -d | ||
reader: | ||
#image: hectorqin/reader # 普通镜像 | ||
image: hectorqin/reader:openj9-latest # Openj9镜像,arm64架构或小内存机器优先使用 | ||
container_name: reader #容器名 可自行修改 | ||
restart: always | ||
ports: | ||
- 4396:8080 #4396端口映射可自行修改,8080请勿修改 | ||
volumes: | ||
- /home/reader/logs:/logs #log映射目录 /home/reader/logs 映射目录可自行修改 | ||
- /home/reader/storage:/storage #数据映射目录 /home/reader/storage 映射目录可自行修改 | ||
environment: | ||
- SPRING_PROFILES_ACTIVE=prod | ||
#- READER_APP_USERLIMIT=50 #用户上限,默认且最大值为50 | ||
- READER_APP_USERBOOKLIMIT=200 #用户书籍上限,默认200 | ||
- READER_APP_CACHECHAPTERCONTENT=true #开启缓存章节内容 | ||
- READER_APP_REMOTEWEBVIEWAPI=http://readerwebview:8050 #启用webview(若下方readerwebview容器不开启需注释此行 | ||
# ↓多用户模式配置↓ | ||
- READER_APP_SECURE=true #开启登录鉴权,开启后将支持多用户模式 | ||
- READER_APP_SECUREKEY=adminpwd #管理员密码 建议修改 | ||
- READER_APP_INVITECODE=registercode #注册邀请码 建议修改,如不需要可注释或删除 | ||
# 如需支持webview书源,打开(占用较大,不需要可加 # 注释) | ||
readerwebview: | ||
image: hectorqin/remote-webview | ||
container_name: readerwebview | ||
restart: always | ||
environment: | ||
- TZ=Asia/Shanghai | ||
# 自动更新docker镜像 | ||
watchtower: | ||
image: containrrr/watchtower | ||
container_name: watchtower | ||
restart: always | ||
environment: | ||
- TZ=Asia/Shanghai | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
command: reader readerwebview watchtower --cleanup --schedule "0 0 4 * * *" | ||
# 仅更新reader与watchtower容器,如需其他自行添加 '容器名' ,如:reader watchtower nginx | ||
# --cleanup 更新后清理旧版本镜像 | ||
# --schedule 自动检测更新 crontab定时(限定6位crontab) 此处代表凌晨4点整 | ||
volumes: | ||
reader: | ||
readerwebview: |
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,202 @@ | ||
#!/bin/bash | ||
|
||
red='\033[0;31m' | ||
green="\033[32m" | ||
yellow='\033[0;33m' | ||
plain='\033[0m' | ||
|
||
file_dir="" | ||
remotePort="" | ||
isMultiUser="" | ||
adminPassword="" | ||
registerCode="" | ||
strTrue="true" | ||
dockerImages="" | ||
|
||
# CheckRoot | ||
if [[ $EUID -ne 0 ]]; then | ||
echo "请使用root用户登录!" 1>&2 | ||
exit 1 | ||
fi | ||
|
||
# CheckSystem | ||
if [[ -f /etc/redhat-release ]]; then | ||
release="centos" | ||
elif cat /etc/issue | grep -q -E -i "debian"; then | ||
release="debian" | ||
elif cat /etc/issue | grep -q -E -i "ubuntu"; then | ||
release="ubuntu" | ||
elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then | ||
release="centos" | ||
elif cat /proc/version | grep -q -E -i "debian"; then | ||
release="debian" | ||
elif cat /proc/version | grep -q -E -i "ubuntu"; then | ||
release="ubuntu" | ||
elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then | ||
release="centos" | ||
fi | ||
bit=$(uname -m) | ||
if test "$bit" != "x86_64"; then | ||
bit="arm64" | ||
else bit="amd64" | ||
fi | ||
|
||
os_version="" | ||
|
||
# os version | ||
if [[ -f /etc/os-release ]]; then | ||
os_version=$(awk -F'[= ."]' '/VERSION_ID/{print $3}' /etc/os-release) | ||
fi | ||
if [[ -z "$os_version" && -f /etc/lsb-release ]]; then | ||
os_version=$(awk -F'[= ."]+' '/DISTRIB_RELEASE/{print $2}' /etc/lsb-release) | ||
fi | ||
|
||
if [[ x"${release}" == x"centos" ]]; then | ||
if [[ ${os_version} -le 6 ]]; then | ||
echo -e "${red}请使用 CentOS 7 或更高版本的系统!${plain}\n" && exit 1 | ||
fi | ||
elif [[ x"${release}" == x"ubuntu" ]]; then | ||
if [[ ${os_version} -lt 16 ]]; then | ||
echo -e "${red}请使用 Ubuntu 16 或更高版本的系统!${plain}\n" && exit 1 | ||
fi | ||
elif [[ x"${release}" == x"debian" ]]; then | ||
if [[ ${os_version} -lt 9 ]]; then | ||
echo -e "${red}请使用 Debian 9 或更高版本的系统!${plain}\n" && exit 1 | ||
fi | ||
fi | ||
|
||
install_dockercompose() { | ||
if [[ x"${release}" == x"centos" ]]; then | ||
yum install wget curl -y | ||
echo -e "${green} 正在移除CentOS遗留无效Docker文件 ${plain}" | ||
yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine -y | ||
echo -e "${green} 正在安装Docker ${plain}" | ||
yum install yum-utils device-mapper-persistent-data lvm2 -y | ||
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo | ||
yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y | ||
echo -e "${green} 正在启动Docker ${plain}" | ||
systemctl start docker | ||
systemctl restart docker | ||
systemctl enable docker | ||
echo -e "${green} 正在安装docker-compose ${plain}" | ||
curl -L "https://ghproxy.com/https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose | ||
else | ||
echo -e "${green} 正在安装docker-compose ${plain}" | ||
apt update && apt install wget curl docker-compose -y | ||
fi | ||
} | ||
|
||
install_reader() { | ||
mkdir -p ${orgin_file_dir}/storage/data/default | ||
cd ${orgin_file_dir} | ||
rm docker-compose* | ||
wget https://ghproxy.com/https://raw.githubusercontent.com/hectorqin/reader/master/docker-compose.yml | ||
echo -e "${green} 正在配置默认书源 ${plain}" | ||
wget https://legado.pages.dev/sy-yc.json -O storage/data/default/bookSource.json | ||
echo -e "${green} 正在配置docker变量 ${plain}" | ||
sed -i "s/\/home\/reader/${file_dir}/" docker-compose.yml | ||
sed -i "s/4396/${remotePort}/" docker-compose.yml | ||
sed -i "s/openj9-latest/${dockerImages}/" docker-compose.yml | ||
# 多用户 | ||
sed -i "s/READER_APP_SECURE\=true/READER_APP_SECURE\=${isMultiUser}/" docker-compose.yml | ||
sed -i "s/adminpwd/${adminPassword}/" docker-compose.yml | ||
sed -i "s/registercode/${registerCode}/" docker-compose.yml | ||
echo -e "${green} 准备启动 ${plain}" | ||
# 远程webview | ||
docker-compose up -d | ||
} | ||
|
||
getRemotePort () { | ||
echo "请输入部署端口,例如 4396" | ||
read -p "不填默认为4396: " remotePort | ||
if [[ -z "$remotePort" ]];then | ||
remotePort="4396" | ||
fi | ||
if [ "$remotePort" -gt 0 ] 2>/dev/null;then | ||
if [[ $remotePort -lt 0 || $remotePort -gt 65535 ]];then | ||
echo -e "${red} 端口号不正确,请输入0-65535${plain}" | ||
getRemotePort | ||
exit 0 | ||
fi | ||
else | ||
echo -e "${red} 端口号不正确,请输入0-65535${plain}" | ||
getRemotePort | ||
exit 0 | ||
fi | ||
} | ||
|
||
|
||
getfileDir () { | ||
echo -e "${green} 请输入数据存放目录,例如 /home/reader : ${plain}" | ||
read -p "不填默认为/home/reader : " file_dir | ||
if [[ -z "$file_dir" ]];then | ||
file_dir="/home/reader" | ||
fi | ||
orgin_file_dir=$file_dir | ||
file_dir=${file_dir//\//\\\/} | ||
} | ||
|
||
getMultiUser () { | ||
echo -e "${green} 是否需要开启多用户 : ${plain}" | ||
read -p "填0不开启,不填开启 : " isMultiUser | ||
if [[ -z "$isMultiUser" ]];then | ||
isMultiUser="true" | ||
else | ||
isMultiUser="false" | ||
fi | ||
} | ||
|
||
getPwdOrCode () { | ||
echo -e "${green} 请输入管理密码,用于加载用户空间 : ${plain}" | ||
read -p "建议修改此参数,默认为adminpwd : " adminPassword | ||
if [[ -z "$adminPassword" ]];then | ||
adminPassword="adminpwd" | ||
fi | ||
echo -e "${green} 请输入邀请码,用于注册使用 : ${plain}" | ||
read -p "不填默认为空 : " registerCode | ||
if [[ -z "$registerCode" ]];then | ||
registerCode="" | ||
fi | ||
} | ||
|
||
getDockerImages () { | ||
echo -e "${green} 请输入需要的镜像 arm或者小内存(1G)机器建议openj9,其余建议基础镜像 : ${plain}" | ||
read -p "不输入为基础镜像,输入其他值为openj9 : " dockerImages | ||
if [[ -z "$dockerImages" ]];then | ||
dockerImages="latest" | ||
else | ||
dockerImages="openj9-latest" | ||
fi | ||
} | ||
|
||
Server_IP='' | ||
Public_IP='' | ||
getIpaddr () { | ||
Server_IP=$(hostname -I | awk -F " " '{printf $1}') | ||
Public_IP=$(curl http://pv.sohu.com/cityjson 2>> /dev/null | awk -F '"' '{print $4}') | ||
} | ||
|
||
echo -e "${green}准备部署reader${plain}" | ||
echo -e "${green}甲骨文官方系统可能并不适用此脚本,本脚本仅测试CentOS7,8,Ubuntu20+,Debian10+${plain}" | ||
install_dockercompose | ||
getfileDir | ||
getRemotePort | ||
getMultiUser | ||
if [ $isMultiUser == "true" ]; then | ||
getPwdOrCode | ||
fi | ||
getDockerImages | ||
install_reader | ||
getIpaddr | ||
|
||
echo -e "${green}初步部署完成,已配置默认书源,国内服务器等有控制台面板的服务器厂商请手动在控制台打开reader所需的端口${remotePort}${plain}" | ||
if [ $Server_IP == $Public_IP ];then | ||
echo -e "${green}网址:${plain} http://${Server_IP}:${remotePort}" | ||
else | ||
echo -e "${green}内网网址:${plain} http://${Server_IP}:${remotePort}" | ||
echo -e "${green}公网网址:${plain} http://${Public_IP}:${remotePort}" | ||
fi | ||
|
||
echo -e "${green}如需修改其他配置请前往 cd${orgin_file_dir} 根据注释修改 vim docker-compose.yml文件后${plain}" | ||
echo -e "${green}先自行学习vim用法,否则建议使用sftp或WindTerm等ssh自带sftp的软件直接打开编辑${plain}" | ||
echo -e "${green}修改后前往 cd${orgin_file_dir} 后通过命令docker-compose up -d 重启即可${plain}" |