-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debian Improvements #732
Debian Improvements #732
Changes from all commits
72b3151
a4d4254
7418b83
670e104
7337840
35f8651
b9590ad
8fa69b9
fe9168a
bb61c91
be5d5b0
b54fc2f
0f11369
803d6ec
c453b88
8d5d944
c8c6ada
5b4a358
4bf10fd
e7cb11b
2f2a33a
b46fb0c
5a4f742
bae1a36
dc9a042
e0cb833
bc6021b
8b5295f
37f4c53
579ebae
5f78997
97115cc
b0f6ae9
65bc375
a449a4d
cce7403
43c9ed6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# PeerBanHelper | ||
[简体中文](./README.md) | ||
|
||
Automatically block unwanted, leeches and abnormal BT peers with support for customized and cloud rules. | ||
|
||
![page-views](https://raw.githubusercontent.com/PBH-BTN/views-counter/refs/heads/master/svg/754169590/badge.svg) | ||
## Introduction | ||
|
||
Following function are provided by PeerBanHelper: | ||
|
||
- [PeerID Blacklist](https://docs.pbh-btn.com/en/docs/module/peer-id) | ||
- [Client Name Blacklist](https://docs.pbh-btn.com/en/docs/module/client-name) | ||
- [IP/GeoIP/IP type Blacklist](https://docs.pbh-btn.com/en/docs/module/ip-address-blocker) | ||
- [Fake progress checker (heuristic client detection)](https://docs.pbh-btn.com/en/docs/module/progress-cheat-blocker) | ||
- [Auto range ban](https://docs.pbh-btn.com/en/docs/module/auto-range-ban) | ||
- [Multi-dail ban](https://docs.pbh-btn.com/en/docs/module/multi-dial) | ||
- Peer ID/Client Name camouflage check, powered by [AviatorScript Engine](https://docs.pbh-btn.com/en/docs/module/expression-engine) | ||
- [Active monitoring(data analysis)](https://docs.pbh-btn.com/en/docs/module/active-monitoring) | ||
- [IP set subscribe](https://docs.pbh-btn.com/en/docs/module/ip-address-blocker-rules) | ||
- a mordern WebUI | ||
|
||
In addition, PeerBanHelper downloads the GeoIP library at startup, and supports the following functions once it successful loaded: | ||
- View IP address attribution, AS information (ASN, ISP, AS name, etc.), network type information (broadband, base station, IoT, data center, etc.) in the blocking list. | ||
- Based on GeoIP information, block IP addresses by country/region, city, network type, ASN and so on. | ||
- View GeoIP statistics | ||
|
||
> [!TIP] | ||
> For best results, it is recommended to work with the IP rule [PBH-BTN/BTN-Collected-Rules](https://github.com/PBH-BTN/BTN-Collected-Rules) and [BTN Network](https://docs.pbh-btn.com/en/docs/btn/intro) , but this is completely optional. | ||
|
||
|
||
## Supported clients | ||
|
||
- qBittorrent **4.5.0 or higher** | ||
- BiglyBT([plugin](https://github.com/PBH-BTN/PBH-Adapter-BiglyBT) is required) | ||
- Deluge([plugin](https://github.com/PBH-BTN/PBH-Adapter-Deluge) is required) | ||
- Azureus(Vuze)([plugin](https://github.com/PBH-BTN/PBH-Adapter-Azureus) is required) | ||
- Transmission **(deprected;3.00-20 or higher)** | ||
- BitComet **v2.10 Beta6 [20240928] or higher** | ||
|
||
|
||
# Screenshots | ||
|
||
| Dashboard | Banlist | Banlogs | Rule subscribe | | ||
| :------------------------------------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------- | | ||
| <img width="1280" alt="homepage" src="https://github.com/PBH-BTN/PeerBanHelper/assets/19235246/d7f7ea9f-70df-40f1-a782-260450972bc9"> | <img width="1280" alt="banlist" src="https://github.com/PBH-BTN/PeerBanHelper/assets/19235246/c3e139e6-eb82-423f-b083-1839713ec801"> | <img width="1280" alt="banlogs" src="https://github.com/PBH-BTN/PeerBanHelper/assets/19235246/00d8efcc-0dd7-4e05-bdeb-9444e14739d6"> | <img width="1280" alt="banMetrics" src="https://github.com/PBH-BTN/PeerBanHelper/assets/19235246/dc312186-9643-4f23-9d53-7b8e0852f228"> | | ||
|
||
## Install | ||
|
||
Please read the [docs](https://docs.pbh-btn.com/en/docs/category/%E5%AE%89%E8%A3%85%E9%83%A8%E7%BD%B2) | ||
|
||
|
||
## FAQ | ||
|
||
Before submit issue, please read the [FAQ](https://docs.pbh-btn.com/en/docs/faq) | ||
|
||
## Support | ||
Consider join our [Telegram](https://t.me/+_t3Nt5GZ6bJmYjBl) group. | ||
|
||
## Declaration | ||
|
||
Illegal websites and black and grey industries should not initiate any kind of manual service request to our organization's development or support staff; it is strictly prohibited to use any services or products of PBH-BTN team to engage in any illegal activities such as violating the law, endangering national security, committing or helping others to commit telecommunication crimes, and other illegal activities. | ||
Users are not allowed to carry out any activities that harm the interests of other individuals or organizations through any services or products of PBH-BTN Team. The use of any PBH-BTN Team services or products in violation of the rights and interests of any individual or organization is not permitted. | ||
|
||
## Star History | ||
|
||
[![Star History Chart](https://api.star-history.com/svg?repos=PBH-BTN/PeerBanHelper&type=Date)](https://star-history.com/#PBH-BTN/PeerBanHelper&Date) | ||
|
||
## Credit | ||
|
||
### Backend | ||
|
||
- [Cordelia](https://github.com/bochkov/cordelia) | ||
- [IPAddress](https://github.com/seancfoley/IPAddress) | ||
- [YamlConfiguration](https://github.com/bspfsystems/YamlConfiguration) | ||
- [libby](https://github.com/AlessioDP/libby) | ||
- [AviatorScript](https://github.com/killme2008/aviatorscript) | ||
- [javalin](https://javalin.io/) | ||
- [deluge-java](https://github.com/RangerRick/deluge-java) | ||
- [jSystemThemeDetector](https://github.com/Dansoftowner/jSystemThemeDetector) | ||
- [Methanol](https://github.com/mizosoft/methanol) | ||
- [Flatlaf](https://github.com/JFormDesigner/FlatLaf) | ||
- [GeoIP2](https://dev.maxmind.com/geoip) | ||
- [ormlite](https://ormlite.com/) | ||
- [SimpleReloadLib](https://github.com/Ghost-chu/SimpleReloadLib) | ||
|
||
### WebUI | ||
|
||
- [Vue](https://vuejs.org/) | ||
- [ArcoDesign](https://arco.design/) | ||
- [ECharts](https://echarts.apache.org/en/index.html) | ||
|
||
### Install4j | ||
|
||
PeerBanHelper use [Install4j multi-platform installer builder](https://www.ej-technologies.com/products/install4j/overview.html) to build its multi-platform installer. Thanks the open-source license provided by ej-technolgies. Click the link or the image below to download install4j. | ||
|
||
[![Install4j](https://www.ej-technologies.com/images/product_banners/install4j_large.png)](https://www.ej-technologies.com/products/install4j/overview.html) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/etc/peerbanhelper/data/config.yml | ||
/etc/peerbanhelper/config.yml | ||
/etc/peerbanhelper/profile.yml |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,10 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
#!/bin/sh | ||||||||||||||||||||||||||||||||||||||||||||||
USER=peerbanhelper | ||||||||||||||||||||||||||||||||||||||||||||||
adduser --system $USER | ||||||||||||||||||||||||||||||||||||||||||||||
mkdir -p /etc/peerbanhelper | ||||||||||||||||||||||||||||||||||||||||||||||
chown $USER /etc/peerbanhelper | ||||||||||||||||||||||||||||||||||||||||||||||
#!/bin/sh -e | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
getent passwd peerbanhelper > /dev/null || adduser --quiet --system --group --home /var/lib/peerbanhelper peerbanhelper | ||||||||||||||||||||||||||||||||||||||||||||||
chown -R peerbanhelper: /etc/peerbanhelper | ||||||||||||||||||||||||||||||||||||||||||||||
chown -R root: /usr/lib/peerbanhelper | ||||||||||||||||||||||||||||||||||||||||||||||
mkdir /var/log/peerbanhelper | ||||||||||||||||||||||||||||||||||||||||||||||
chown peerbanhelper: /var/log/peerbanhelper | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+4
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix directory creation and permission handling Several critical issues in directory management:
Apply these changes: -chown -R peerbanhelper: /etc/peerbanhelper
-chown -R root: /usr/lib/peerbanhelper
-mkdir /var/log/peerbanhelper
-chown peerbanhelper: /var/log/peerbanhelper
+# Ensure directories exist with correct permissions
+[ -d /etc/peerbanhelper ] || install -d -m 750 -o peerbanhelper -g peerbanhelper /etc/peerbanhelper
+[ -d /usr/lib/peerbanhelper ] || install -d -m 755 -o root -g root /usr/lib/peerbanhelper
+[ -d /var/log/peerbanhelper ] || install -d -m 750 -o peerbanhelper -g peerbanhelper /var/log/peerbanhelper
+
+# Set permissions recursively for existing content
+find /etc/peerbanhelper -type d -exec chmod 750 {} +
+find /etc/peerbanhelper -type f -exec chmod 640 {} +
+find /usr/lib/peerbanhelper -type d -exec chmod 755 {} +
+find /usr/lib/peerbanhelper -type f -exec chmod 644 {} + 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
systemctl daemon-reload | ||||||||||||||||||||||||||||||||||||||||||||||
systemctl start peerbanhelper.service | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve service management robustness The service management needs better error handling and should enable the service for system startup. Apply these changes: -systemctl daemon-reload
-systemctl start peerbanhelper.service
+systemctl daemon-reload || {
+ echo "Failed to reload systemd daemon" >&2
+ exit 1
+}
+
+systemctl enable peerbanhelper.service || {
+ echo "Failed to enable peerbanhelper service" >&2
+ exit 1
+}
+
+systemctl start peerbanhelper.service || {
+ echo "Failed to start peerbanhelper service" >&2
+ exit 1
+}
+
+# Verify service is running
+systemctl is-active --quiet peerbanhelper.service || {
+ echo "Service failed to start properly" >&2
+ exit 1
+} 📝 Committable suggestion
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,3 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
#!/bin/sh -e | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
[ $1 = purge ] && deluser --quiet peerbanhelper && rm -rf /var/lib/peerbanhelper || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve error handling and safety checks The current implementation has several potential issues:
Consider this safer implementation: -[ $1 = purge ] && deluser --quiet peerbanhelper && rm -rf /var/lib/peerbanhelper || true
+case "$1" in
+ purge)
+ # Remove peerbanhelper user if exists
+ if id "peerbanhelper" >/dev/null 2>&1; then
+ if ! deluser --quiet peerbanhelper; then
+ echo "Warning: Failed to remove peerbanhelper user" >&2
+ fi
+ fi
+
+ # Remove data directory if exists
+ if [ -d "/var/lib/peerbanhelper" ]; then
+ if ! rm -rf "/var/lib/peerbanhelper"; then
+ echo "Warning: Failed to remove /var/lib/peerbanhelper directory" >&2
+ exit 1
+ fi
+ fi
+ ;;
+ remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+ # No action needed for other removal cases
+ ;;
+ *)
+ echo "postrm called with unknown argument '$1'" >&2
+ exit 1
+ ;;
+esac 📝 Committable suggestion
Suggested change
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Service files are not properly cleaned up during package removal The package has systemd service files and service-related operations, but the
🔗 Analysis chainVerify systemd service cleanup Ensure that systemd-related files are properly cleaned up during package removal. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for systemd service files that might need cleanup
# Check if there are any systemd service files
rg -l "peerbanhelper" "/lib/systemd/system/" "/etc/systemd/system/"
# Check if there are any remaining systemd runtime files
rg -l "peerbanhelper" "/run/systemd/system/"
Length of output: 289 Script: #!/bin/bash
# Let's check the repository for any systemd service files and their cleanup
# First, find any systemd service files in the repository
fd -e service
# Check for any systemd-related cleanup in package scripts
rg -l "systemctl|systemd" pkg/deb/
# Look for service definitions or systemd mentions in the codebase
rg -l "\.service"
# Check package scripts for service-related operations
cat pkg/deb/DEBIAN/{preinst,postinst,prerm,postrm} 2>/dev/null
Length of output: 1686 |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,12 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#!/bin/sh -e | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# migrate <= 7.1.2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if getent passwd peerbanhelper | grep --quiet /nonexistent; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+3
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement explicit version checking The current version detection relies on checking the user's home directory, which is an indirect and potentially unreliable method. Consider implementing explicit version checking. Example implementation: # migrate <= 7.1.2
+if [ -f /var/lib/dpkg/status ]; then
+ OLD_VERSION=$(dpkg-query -W -f='${Version}' peerbanhelper 2>/dev/null || echo "0.0.0")
+ if dpkg --compare-versions "$OLD_VERSION" le "7.1.2"; then
+ if getent passwd peerbanhelper | grep --quiet /nonexistent; then
-if getent passwd peerbanhelper | grep --quiet /nonexistent; then 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
deluser --quiet peerbanhelper | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
adduser --quiet --system --group --home /var/lib/peerbanhelper peerbanhelper | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for user management operations The -deluser --quiet peerbanhelper
-adduser --quiet --system --group --home /var/lib/peerbanhelper peerbanhelper
+if ! deluser peerbanhelper; then
+ echo "Error: Failed to remove existing peerbanhelper user" >&2
+ exit 1
+fi
+if ! adduser --system --group --home /var/lib/peerbanhelper peerbanhelper; then
+ echo "Error: Failed to create peerbanhelper user" >&2
+ exit 1
+fi 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
chown -R peerbanhelper: /etc/peerbanhelper | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mv /etc/peerbanhelper/config/config.yml /etc/peerbanhelper/config/profile.yml /etc/peerbanhelper | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rm -rf /etc/peerbanhelper/config /etc/peerbanhelper/data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mv /etc/peerbanhelper/logs /var/log/peerbanhelper | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
find /etc/peerbanhelper -mindepth 1 -maxdepth 1 -type d -exec mv {} /var/lib/peerbanhelper \; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+7
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add safety checks and backups for file operations The file operations lack error handling and backups. This could lead to data loss or incomplete migration. +# Create backup
+BACKUP_DIR="/etc/peerbanhelper.backup.$(date +%Y%m%d_%H%M%S)"
+if ! cp -a /etc/peerbanhelper "$BACKUP_DIR"; then
+ echo "Error: Failed to create backup" >&2
+ exit 1
+fi
+# Ensure target directories exist
+mkdir -p /var/log/peerbanhelper /var/lib/peerbanhelper
# Change ownership
-chown -R peerbanhelper: /etc/peerbanhelper
+if ! chown -R peerbanhelper: /etc/peerbanhelper; then
+ echo "Error: Failed to change ownership" >&2
+ exit 1
+fi
# Move configuration files
-mv /etc/peerbanhelper/config/config.yml /etc/peerbanhelper/config/profile.yml /etc/peerbanhelper
+for file in config.yml profile.yml; do
+ if [ -f "/etc/peerbanhelper/config/$file" ]; then
+ if ! mv "/etc/peerbanhelper/config/$file" /etc/peerbanhelper/; then
+ echo "Error: Failed to move $file" >&2
+ exit 1
+ fi
+ fi
+done
# Cleanup old directories
-rm -rf /etc/peerbanhelper/config /etc/peerbanhelper/data
-mv /etc/peerbanhelper/logs /var/log/peerbanhelper
+if [ -d /etc/peerbanhelper/logs ]; then
+ if ! mv /etc/peerbanhelper/logs/* /var/log/peerbanhelper/; then
+ echo "Error: Failed to move logs" >&2
+ exit 1
+ fi
+fi
+
+# Remove old directories only if they exist
+for dir in config data logs; do
+ if [ -d "/etc/peerbanhelper/$dir" ]; then
+ rm -rf "/etc/peerbanhelper/$dir"
+ fi
+done 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+11
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve safety of directory migration The find command could potentially move unintended directories. Add validation and error handling. -find /etc/peerbanhelper -mindepth 1 -maxdepth 1 -type d -exec mv {} /var/lib/peerbanhelper \;
+# Move remaining directories with validation
+while IFS= read -r dir; do
+ dir_name=$(basename "$dir")
+ case "$dir_name" in
+ config|data|logs)
+ continue # Skip already handled directories
+ ;;
+ *)
+ if ! mv "$dir" /var/lib/peerbanhelper/; then
+ echo "Error: Failed to move directory $dir" >&2
+ exit 1
+ fi
+ ;;
+ esac
+done < <(find /etc/peerbanhelper -mindepth 1 -maxdepth 1 -type d) 📝 Committable suggestion
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh -e | ||
|
||
systemctl daemon-reload | ||
systemctl stop peerbanhelper.service | ||
Comment on lines
+3
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification 🛠️ Refactor suggestion Add error handling for systemd operations in both prerm and postinst scripts The verification confirms that both installation scripts (
#!/bin/sh -e
getent passwd peerbanhelper > /dev/null || adduser --quiet --system --group --home /var/lib/peerbanhelper peerbanhelper
chown -R peerbanhelper: /etc/peerbanhelper
chown -R root: /usr/lib/peerbanhelper
mkdir /var/log/peerbanhelper
chown peerbanhelper: /var/log/peerbanhelper
-systemctl daemon-reload
-systemctl start peerbanhelper.service
+# Check if systemd is running
+if [ -d /run/systemd/system ]; then
+ systemctl daemon-reload || true
+ systemctl start peerbanhelper.service || true
+else
+ echo "Warning: systemd not detected, skipping service management"
+fi 🔗 Analysis chainAdd error handling for systemd-specific operations. The script assumes systemd is present and running, which might not always be true. Consider adding checks and graceful fallbacks. Here's a suggested implementation with better error handling: #!/bin/sh -e
-systemctl daemon-reload
-systemctl stop peerbanhelper.service
+# Check if systemd is running
+if [ -d /run/systemd/system ]; then
+ # Stop service if it's running
+ if systemctl is-active --quiet peerbanhelper.service; then
+ systemctl stop peerbanhelper.service || true
+ fi
+ systemctl daemon-reload || true
+else
+ echo "Warning: systemd not detected, skipping service management"
+fi This implementation:
Let's verify the service configuration: The verification results show that:
Let's verify the presence of similar error handling in the postinst script: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify service configuration and related files
# Check if service file exists and its contents
fd -t f "peerbanhelper.service" -x cat {}
# Check for other related systemd unit files
fd -t f "peerbanhelper*.service"
# Look for any systemctl commands in other installation scripts
rg "systemctl" pkg/
Length of output: 880 Script: #!/bin/bash
# Check the content of postinst script
cat pkg/deb/DEBIAN/postinst
# Check if there are any other init system related files
fd -t f "init|upstart|openrc" pkg/
Length of output: 417 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add error handling and explicit umask setting
While the user creation logic is correct, consider:
📝 Committable suggestion