适用于使用 zip 文件直接部署安装的 shell 管理脚本(Shell management scripts for direct deployment installations using zip files) #475
poplar-at-twilight
started this conversation in
讨论
Replies: 2 comments 1 reply
-
|
本来想试试deb包,结果发现完全找不到data文件路径的说明。 |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
最近翻新了一下,感兴趣的可以拷贝到本地试试: #!/bin/bash
# 本脚本用于 Peerbanhelper 的日常维护
# 注意,本脚本只适用于直接使用 PeerBanHelper_*.zip 文件进行手动部署的方式
PBH_DIR=$HOME/bin/PeerBanHelper
# PeerBanHelper 主目录
ZIP_DIR=$HOME/Downloads
# PeerBanHelper 更新包文件路径
CACHE_TMP=/tmp/pbh_update
SER_FILE=$HOME/.config/systemd/user/pbh.service
# systemd 服务文件
start_pbh () {
systemctl start --user pbh
systemctl status --user pbh | grep "Loaded"
}
stop_pbh () {
systemctl stop --user pbh
systemctl status --user pbh | grep "Loaded"
}
enable_pbh () {
systemctl daemon-reload --user
systemctl enable --user pbh
systemctl status --user pbh | grep "Loaded"
}
disable_pbh () {
systemctl disable --user pbh --now
systemctl status --user pbh | grep "Active"
rm $SER_FILE
systemctl daemon-reload --user
}
update_pbh () {
mkdir -p $CACHE_TMP
printf "WARNING:\nThis will delete the files in the $PBH_DIR folder, do you want to continue? (y/n) "
read -r rm_duble_check
rm_duble_check_caps="${rm_duble_check^^}"
if [[ $rm_duble_check_caps = Y ]]; then
if [[ -n "$(find "$ZIP_DIR" -maxdepth 1 -name "PeerBanHelper*.zip" -print -quit)" ]]; then
printf "INFO: found_tarball_to_unzip\n"
mkdir -p $PBH_DIR
if [[ -d $PBH_DIR/data ]]; then
printf "INFO: found_data_dir_to_backup\n"
mv $PBH_DIR/data $CACHE_TMP
printf "OK: backup_data_dir\n"
rm -rf $PBH_DIR/*
unzip $ZIP_DIR/PeerBanHelper*.zip -d $CACHE_TMP
cp -r $CACHE_TMP/PeerBanHelper/* $PBH_DIR
printf "OK: update_jar_and_libs\n"
mv $CACHE_TMP/data $PBH_DIR
printf "OK: restore_data_dir\n"
else
printf "INFO: no_found_data_dir_to_backup\n"
unzip "$ZIP_DIR"/PeerBanHelper*.zip -d $CACHE_TMP
rm -rf $PBH_DIR/*
cp -r $CACHE_TMP/PeerBanHelper/* $PBH_DIR
printf "OK: update_jar_and_libs\n"
fi
rm -rf $ZIP_DIR/PeerBanHelper*.zip
printf "OK: delete_used_tarball\n"
else
printf "ERROR: no_found_tarball\n"
fi
enable_pbh
else
printf "ERROR: update_canceled\n"
fi
rm -r $CACHE_TMP
}
####
while true; do
printf -- '-%0.s' {1..100} && echo
printf 'You can use the PeerBanHelper maintenance script for:\n\n'
printf '1 - Install PeerBanHelper\n'
printf '2 - Start systemd service\n'
printf '3 - Stop systemd service\n'
printf '4 - Enable systemd service\n'
printf '5 - Delete systemd service\n\n'
printf 'U - Upgrade PeerBanHelper\n'
printf 'L - Read logs of PeerBanHelper\n\n'
printf 'C - Clear terminal output\n'
printf 'Q - Quit\n\n'
printf '==> '
read answer
answer_caps_1="${answer^^}"
# 安装 PeerBanHelper
if [[ $answer = 1 ]]; then
# 注册 systemd 文件
if [[ -f $SER_FILE ]]; then
printf "INFO: found_systemd_ser_files\n"
else
printf "INFO: no_found_systemd_ser_files\n"
mkdir -p ~/.config/systemd/user
echo "[Unit]" > $SER_FILE
echo "Description=Start PeerBanHelper Service" >> $SER_FILE
echo >> $SER_FILE
echo "[Service]" >> $SER_FILE
echo "ExecStart=$(which java) -jar -Xmx512M -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+ShrinkHeapInSteps PeerBanHelper.jar nogui" >> $SER_FILE
echo "Type=simple" >> $SER_FILE
echo "WorkingDirectory=$PBH_DIR" >> $SER_FILE
echo >> $SER_FILE
echo "[Install]" >> $SER_FILE
echo "WantedBy=default.target" >> $SER_FILE
printf "OK: systemd_ser_files_created\n"
fi
# 解压 jar 和库
if [[ -f $PBH_DIR/PeerBanHelper.jar ]] && [[ -d $PBH_DIR/libraries ]]; then
printf "INFO: found_main_bin\n"
enable_pbh
else
update_pbh
fi
elif [[ $answer = 2 ]]; then
start_pbh
elif [[ $answer = 3 ]]; then
stop_pbh
elif [[ $answer = 4 ]]; then
enable_pbh
elif [[ $answer = 5 ]]; then
disable_pbh
printf "OK: uninstall_systemd_ser\n"
elif [[ $answer_caps_1 = U ]]; then
stop_pbh
update_pbh
start_pbh
elif [[ $answer_caps_1 = L ]]; then
# 读取 Peerbanhelper 日志
tail -n 30 $PBH_DIR/data/logs/latest.log
# 读取最新的 30 条日志
# 也可以使用:
#journalctl --user -u pbh
elif [[ $answer_caps_1 = C ]]; then
clear
elif [[ $answer_caps_1 = Q ]]; then
exit
else
echo "ERROR: Invalid input!"
continue
fi
done |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
基于
systemd --user,适用于 PeerBanHelper 的管理脚本:Based on
systemd --user, the administrative scripts for PeerBanHelper are shown below:当前的文件布局 - Current file layout
操作 - Procedures
将下载好的
PeerBanHelper*.zip放置到pbh脚本设定的$PBH_UP文件夹中。Place the downloaded
PeerBanHelper*.zipin the$PBH_UPfolder of thepbhscript settings.使用下文的
pbh安装并启动服务,然后修改~/bin/pbh/data/config/config.yml:Install and start the service using
pbhbelow, then modify~/bin/pbh/data/config/config.yml:server: 将address的值设置为127.0.0.1server: set the value ofaddressto127.0.0.1然后在 http://127.0.0.1:8080。生成 token 并添加 qBittorrent 下载器,并修改
~/bin/pbh/data/config/config.yml:Then at http://127.0.0.1:8080. Generate token and add qBittorrent downloader and modify
~/bin/pbh/data/config/config.yml:language:改为zh_CNlanguage: change tozh_CN.btn:改为true,并填入app-id和app-secretbtn: change totrueand put inapp-idandapp-secret.config-url改为https://btn-prod.ghostchu-services.top/ping/configconfig-urltohttps://btn-prod.ghostchu-services.top/ping/configproxy:将setting: 0改为setting: 2,并检查服务器地址和端口是否正确。proxy: changesetting: 0tosetting: 2and check that the server address and port are correct.logger:将hide-finish-log改为truelogger: changehide-finish-logtotrue.管理脚本 - Management Scripts
注意,解压文件时使用的外部命令是
7z,它由ark归档管理器依赖的7zip所提供。Note that the external command used to decompress the file is
7z, which is provided by7zip, which thearkarchive manager depends on.Beta Was this translation helpful? Give feedback.
All reactions