Skip to content

Commit

Permalink
update reader-pro-bin
Browse files Browse the repository at this point in the history
  • Loading branch information
taotieren committed Nov 14, 2024
1 parent 6110609 commit d4e1e48
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 0 deletions.
56 changes: 56 additions & 0 deletions aur-repo/reader-pro-bin/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Maintainer: taotieren <admin@taotieren.com>

pkgname=reader-pro-bin
pkgver=3.2.10
pkgrel=0
epoch=
pkgdesc="Read 3 Server Edition"
arch=(any)
url="https://github.com/hectorqin/reader"
license=('GPL-3.0-or-later')
groups=()
depends=(sh
java-runtime)
makedepends=("gcc")
checkdepends=()
optdepends=()
provides=(${pkgname%-bin})
conflicts=(${pkgname%-bin})
replaces=()
backup=(usr/share/java/reader-pro/conf/application.properties)
options=('!debug')
install=
changelog=
source=("reader-server-${pkgver}.zip::${url}/releases/download/v${pkgver}/reader-server-${pkgver}.zip"
reader-pro.sh
reader-pro.sysusers
reader-pro.tmpfiles
reader-pro-single.service
reader-pro-multi.service)
noextract=(reader-server-${pkgver}.zip)
sha256sums=('ef9dc27b075e00698f7322c8b729b769548aeeb7833573d30563e9a530df38eb'
'20ec09cb6a0938212df8dabf5509f595f8f7c0f73394dbee3bf6b77f84509a6e'
'059e68054efc84a19644366a3006c0501ac75cc5d5db9e2a3b8fac476bac3d8c'
'250551acd0680c5ea1082803341524316a461c21e3576daa2da666fcd9c71f0c'
'66e6282814e485fdd38b7ad5cb0c4d20abf2965db749e5f58f7a884fb0cd8b63'
'71712a0738f0f2c7a4404325cf19a9395e8b49cf319c1c3ca22ee21b728f37ad')
#validpgpkeys=()
build() {
mkdir -pv ${srcdir}/reader-server-${pkgver}
bsdtar -xf ${srcdir}/reader-server-${pkgver}.zip -C ${srcdir}/reader-server-${pkgver}
}

package() {
install -Dm0755 "${srcdir}/reader-pro.sh" "${pkgdir}/usr/bin/${pkgname%-bin}"
install -Dm0644 "${srcdir}/reader-pro.sysusers" "${pkgdir}/usr/lib/sysusers.d/reader-pro.conf"
install -Dm0644 "${srcdir}/reader-pro.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/reader-pro.conf"
install -Dm0644 -t "${pkgdir}/usr/lib/systemd/system/" "${srcdir}/reader-pro-single.service"
install -Dm0644 -t "${pkgdir}/usr/lib/systemd/system/" "${srcdir}/reader-pro-multi.service"
install -dm0755 "${pkgdir}/var/lib/reader-pro/" \
"${pkgdir}/var/log/reader-pro/"

cd "${srcdir}/reader-server-${pkgver}"
install -Dm0755 target/reader-pro-${pkgver}.jar "${pkgdir}/usr/share/java/${pkgname%-bin}/${pkgname%-bin}.jar"
install -Dm0644 conf/application.properties "${pkgdir}/usr/share/java/${pkgname%-bin}/conf/application.properties"
rm -rf ${srcdir}/reader-server-${pkgver}
}
15 changes: 15 additions & 0 deletions aur-repo/reader-pro-bin/lilac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
maintainers:
- github: taotieren
build_prefix: extra-x86_64
pre_build_script: |
update_pkgver_and_pkgrel(_G.newver)
post_build_script: |
git_pkgbuild_commit()
update_aur_repo()
update_on:
- source: github
github: hectorqin/reader
use_latest_release: true
prefix: v
# use_max_tag: true
# prefix: v
21 changes: 21 additions & 0 deletions aur-repo/reader-pro-bin/reader-pro-multi.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=Reader Pro Multi User Mode
After=network.target

[Service]
User=reader-pro
Group=reader-pro
WorkingDirectory=/var/lib/reader-pro
Environment=JAVA_HOME=/usr/lib/jvm/default
ExecStart=/usr/bin/reader-pro -m multi -i <invite-code> -k <secure-key>
SuccessExitStatus=143
Restart=on-failure
RestartSec=5
TimeoutStartSec=30
TimeoutStopSec
StandardOutput=journal+console
StandardError=journal+console
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
21 changes: 21 additions & 0 deletions aur-repo/reader-pro-bin/reader-pro-single.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=Reader Pro Single User Mode
After=network.target

[Service]
User=reader-pro
Group=reader-pro
WorkingDirectory=/var/lib/reader-pro
Environment=JAVA_HOME=/usr/lib/jvm/default
ExecStart=/usr/bin/reader-pro -m single
SuccessExitStatus=143
Restart=on-failure
RestartSec=5
TimeoutStartSec=30
TimeoutStopSec
StandardOutput=journal+console
StandardError=journal+console
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
82 changes: 82 additions & 0 deletions aur-repo/reader-pro-bin/reader-pro.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

# 设置默认值
BASE_DIR="/var/lib/reader-pro"
LOG_DIR="/var/log/reader-pro"
CONFIG_DIR="/usr/share/java/reader-pro/conf"
STORAGE_PATH="/var/lib/reader-pro"
JAVA_CMD="$JAVA_HOME/bin/java"
JAVA_OPT=""
MODE=""
INVITE_CODE=""
SECURE_KEY=""
SERVER="reader-pro"
NEWEST_JAR=$(ls /usr/share/java/reader-pro/ | grep -Eo 'reader-pro.*\.jar' | sort -nr | head -1)
if [ -n "$NEWEST_JAR" ]; then
SERVER=${NEWEST_JAR/.jar/}
fi

# 解析命令行参数
while getopts ":m:s:i:k:" opt; do
case $opt in
m) MODE=$OPTARG ;;
s) SERVER=$OPTARG ;;
i) INVITE_CODE=$OPTARG ;;
k) SECURE_KEY=$OPTARG ;;
?)
echo "未知的参数: $opt"
exit 1
;;
esac
done

# 根据模式设置JVM选项
if [ -z "$MODE" ]; then
echo "Reader 的运行模式以配置文件 $CONFIG_DIR/application.properties 为准。注意,当前未限制 JVM 内存"
elif [ "$MODE" == "single" ]; then
JAVA_OPT="${JAVA_OPT} -Xms256m -Xmx256m -Xmn128m -Dreader.app.secure=false"
echo "Reader 将以单用户模式运行。注意,当前内存限制为 256m"
else
JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=160m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOG_DIR}/java_heapdump.hprof -XX:-UseLargePages -Dreader.app.secure=true"
TIPS=""
if [ -n "$INVITE_CODE" ]; then
JAVA_OPT="${JAVA_OPT} -Dreader.app.inviteCode=${INVITE_CODE}"
TIPS="${TIPS} 邀请码:${INVITE_CODE}"
fi
if [ -n "$SECURE_KEY" ]; then
JAVA_OPT="${JAVA_OPT} -Dreader.app.secureKey=${SECURE_KEY}"
TIPS="${TIPS} 管理员密码:${SECURE_KEY}"
fi
if [ -z "$TIPS" ]; then
TIPS="邀请码和管理员密码以配置文件 $CONFIG_DIR/application.properties 为准"
fi
TIPS="${TIPS}。注意,当前内存限制为 1g"
echo "Reader 将以多用户模式运行。${TIPS}"
fi

# 添加存储路径到JVM选项
JAVA_OPT="${JAVA_OPT} -Dreader.app.storagePath=${STORAGE_PATH}"

# 确定Java主要版本
JAVA_MAJOR_VERSION=$($JAVA_CMD -version 2>&1 | sed -E -n 's/.* version "([0-9]*).*$/\1/p')
if [ "$JAVA_MAJOR_VERSION" -ge "9" ]; then
JAVA_OPT="${JAVA_OPT} -Xlog:gc*:file=${LOG_DIR}/reader_gc.log:time,tags:filecount=10,filesize=100m"
else
JAVA_OPT="${JAVA_OPT} -Xloggc:${LOG_DIR}/reader_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M"
fi

# 其他JVM选项
JAVA_OPT="${JAVA_OPT} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Dreader.app.workDir=${BASE_DIR} -Dspring.config.location=file:${CONFIG_DIR}/application.properties"

# 创建日志目录(如果不存在)
mkdir -p "${LOG_DIR}"

# 记录启动命令
START_LOG_FILE="${LOG_DIR}/start.out"
echo "启动命令:" >"${START_LOG_FILE}"
echo "$JAVA_CMD $JAVA_OPT -jar /usr/share/java/reader-pro/${SERVER}.jar" >>"${START_LOG_FILE}"
echo "" >>"${START_LOG_FILE}"

# 启动应用程序
echo "Reader 正在启动中,你可以在 ${LOG_DIR}/start.out 查看日志" >>"${START_LOG_FILE}"
exec "$JAVA_CMD" $JAVA_OPT -jar /usr/share/java/reader-pro/${SERVER}.jar
2 changes: 2 additions & 0 deletions aur-repo/reader-pro-bin/reader-pro.sysusers
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Type Name ID GECOS Home directory Shell
u reader-pro - "Read 3 Server Edition" /var/lib/reader-pro /sbin/nologin
3 changes: 3 additions & 0 deletions aur-repo/reader-pro-bin/reader-pro.tmpfiles
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Type Path Mode User Group Age Argument
d /var/lib/reader-pro 0755 reader-pro reader-pro - -
d /var/log/reader-pro 0755 reader-pro reader-pro - -

0 comments on commit d4e1e48

Please sign in to comment.