Skip to content

Commit aa33dba

Browse files
committed
Refactor systemd service files for SQLPage
- Update service descriptions and documentation references - Adjust restart settings and security options for improved stability - Streamline environment variable definitions and working directory paths
1 parent 5df461a commit aa33dba

File tree

3 files changed

+72
-22
lines changed

3 files changed

+72
-22
lines changed

debian/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Debian Packaging for SQLPage
2+
3+
This directory contains the source files for building Debian packages of SQLPage.
4+
5+
## Files
6+
7+
- `control` - Package metadata and dependencies
8+
- `changelog` - Version history for debian packaging
9+
- `copyright` - License and copyright information
10+
- `rules` - Build instructions
11+
- `install` - Files to install and their destinations
12+
- `postinst` - Post-installation script
13+
- `postrm` - Post-removal script
14+
- `sqlpage.service` - systemd service file for package installations
15+
16+
## systemd Service Files
17+
18+
There are **two** systemd service files in this repository:
19+
20+
1. **`/sqlpage.service`** (repository root)
21+
- For manual/source installations
22+
- Uses `/usr/local/bin/sqlpage.bin`
23+
- Includes `RUST_LOG` and `LISTEN_ON` environment variables
24+
- Includes `AmbientCapabilities=CAP_NET_BIND_SERVICE` for port 80 binding
25+
26+
2. **`/debian/sqlpage.service`** (this directory)
27+
- For Debian/Ubuntu package installations
28+
- Uses `/usr/bin/sqlpage` (FHS standard location)
29+
- Includes `SQLPAGE_CONFIGURATION_DIRECTORY` and `SQLPAGE_WEB_ROOT` variables
30+
- Does not bind to privileged ports by default
31+
32+
Both files share the same security hardening settings but are customized for their respective installation methods.
33+
34+
## Building
35+
36+
To build the Debian package:
37+
38+
```bash
39+
dpkg-buildpackage -us -uc
40+
```
41+
42+
The built `.deb` file will be placed in the parent directory.
43+
44+
## Testing
45+
46+
After building, you can test the package installation:
47+
48+
```bash
49+
sudo dpkg -i ../sqlpage_*.deb
50+
```
51+

debian/sqlpage.service

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ User=sqlpage
99
Group=sqlpage
1010
WorkingDirectory=/var/www/sqlpage
1111
ExecStart=/usr/bin/sqlpage
12+
1213
Environment="SQLPAGE_CONFIGURATION_DIRECTORY=/etc/sqlpage"
1314
Environment="SQLPAGE_WEB_ROOT=/var/www/sqlpage"
15+
1416
Restart=on-failure
15-
RestartSec=5s
17+
RestartSec=10s
18+
19+
SyslogIdentifier=sqlpage
1620

17-
# Security settings
1821
NoNewPrivileges=true
1922
PrivateTmp=true
2023
ProtectSystem=strict
@@ -23,6 +26,11 @@ ReadWritePaths=/var/www/sqlpage /var/log/sqlpage
2326
ProtectKernelTunables=true
2427
ProtectKernelModules=true
2528
ProtectControlGroups=true
29+
ProtectClock=true
30+
ProtectHostname=true
31+
ProtectProc=invisible
32+
33+
LimitNOFILE=65536
2634

2735
[Install]
2836
WantedBy=multi-user.target

sqlpage.service

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,41 @@
1-
# This is a basic systemd service file for SQLPage
2-
# For more information about systemd service files, see https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html
3-
# Put this file in /etc/systemd/system/sqlpage.service
1+
# SQLPage systemd service file for manual/source installations
2+
# For package installations, see debian/sqlpage.service
3+
# Install to: /etc/systemd/system/sqlpage.service
44

55
[Unit]
6-
Description=SQLPage website
6+
Description=SQLPage Web Server
77
Documentation=https://sql-page.com
88
After=network.target
99

1010
[Service]
11-
# Define the user and group to run the service
11+
Type=simple
1212
User=sqlpage
1313
Group=sqlpage
14-
15-
# Set the working directory and the executable path
1614
WorkingDirectory=/var/www/sqlpage
1715
ExecStart=/usr/local/bin/sqlpage.bin
1816

19-
# Environment variables
2017
Environment="RUST_LOG=info"
2118
Environment="LISTEN_ON=0.0.0.0:80"
2219

23-
# Allow binding to port 80
2420
AmbientCapabilities=CAP_NET_BIND_SERVICE
2521

26-
# Restart options
2722
Restart=always
28-
RestartSec=10
23+
RestartSec=10s
2924

30-
# Logging options
31-
#StandardOutput=syslog
32-
#StandardError=syslog
3325
SyslogIdentifier=sqlpage
3426

35-
# Security options
3627
NoNewPrivileges=true
37-
ProtectSystem=full
3828
PrivateTmp=true
39-
ProtectControlGroups=true
40-
ProtectKernelModules=true
29+
ProtectSystem=strict
30+
ProtectHome=true
31+
ReadWritePaths=/var/www/sqlpage /var/log/sqlpage
4132
ProtectKernelTunables=true
33+
ProtectKernelModules=true
34+
ProtectControlGroups=true
4235
ProtectClock=true
4336
ProtectHostname=true
4437
ProtectProc=invisible
45-
ProtectClock=true
4638

47-
# Resource limits
4839
LimitNOFILE=65536
4940

5041
[Install]

0 commit comments

Comments
 (0)