blob: 329d64beaa0e8eceb1a0e074f33be676d7628e06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
post_install() {
# Create rust-socksd user and group
if ! getent passwd rust-socksd &>/dev/null; then
useradd -r -s /usr/bin/nologin -d /var/lib/rust-socksd -c "rust-socksd User" rust-socksd
fi
if ! getent group rust-socksd &>/dev/null; then
groupadd -r rust-socksd
fi
# Set ownership and permissions
mkdir -p /var/lib/rust-socksd
mkdir -p /var/log/rust-socksd
chown -R rust-socksd:rust-socksd /var/lib/rust-socksd
chmod 750 /var/lib/rust-socksd
chown -R rust-socksd:rust-socksd /var/log/rust-socksd
chmod 750 /var/log/rust-socksd
chown root:rust-socksd /etc/rust-socksd/config.yml
chmod 640 /etc/rust-socksd/config.yml
chown root:rust-socksd /etc/rust-socksd/users.yml
chmod 660 /etc/rust-socksd/users.yml
# Enable the service
systemctl daemon-reload
systemctl enable rust-socksd.service
echo "rust-socksd has been installed successfully."
echo "Edit /etc/rust-socksd/config.yml to configure the server."
echo "Start the service with: systemctl start rust-socksd"
}
post_upgrade() {
systemctl daemon-reload
echo "rust-socksd has been upgraded."
echo "Restart the service with: systemctl restart rust-socksd"
}
pre_remove() {
systemctl stop rust-socksd.service &>/dev/null || true
systemctl disable rust-socksd.service &>/dev/null || true
}
post_remove() {
systemctl daemon-reload
# Remove user and group
getent passwd rust-socksd &>/dev/null && userdel rust-socksd
getent group rust-socksd &>/dev/null && groupdel rust-socksd
# Remove directories (but preserve configuration)
rm -rf /var/log/rust-socksd
rm -rf /var/lib/rust-socksd
echo "rust-socksd has been removed."
echo "Configuration files in /etc/rust-socksd have been preserved."
}
|