-
Notifications
You must be signed in to change notification settings - Fork 0
/
funcs
executable file
·62 lines (62 loc) · 1.41 KB
/
funcs
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
57
58
59
60
61
62
#!/bin/bash
is_package_installed(){
local pkg
for pkg in "$@"; do
pacman -Q ${pkg} &> /dev/null && return 0
done
return 1
}
pkg_remove(){
local pkgs pkg opts
for pkg in "$@"; do
case ${pkg} in
-*) opts+=(${pkg});;
*) is_package_installed $pkg && pkgs+=(${pkg});;
esac
done
pacman -Rdd ${opts[@]} ${pkgs[@]}
}
remove_systemd(){
local u
pkg_remove --nosave --noconfirm systemd libsystemd systemd-sysvcompat lib32-systemd
for u in \
systemd-journal \
systemd-journal-gateway \
systemd-timesync \
systemd-network \
systemd-bus-proxy \
systemd-journal-remote \
systemd-journal-upload \
systemd-resolve \
; do
id -u $u 2>/dev/null && userdel $u
id -g $u 2>/dev/null && groupdel $u
done
}
ensure_system_user(){
local user="$1" id="$2" comment="$3"
if ! id -g "$user" 2>/dev/null; then
groupadd -g "$id" log
fi
if ! id -u "$user" 2>/dev/null; then
useradd -M -g "$user" -l -s /usr/bin/nologin -c "${comment}" -r -u "$id" "$user"
fi
}
setup_socklog(){
ensure_system_user nobody 99 'powerless user'
ensure_system_user log 19 'socklog user'
rm -rf /var/service/socklog*
rm -rf /etc/sv/socklog*
rm -rf /var/log/socklog*
rm -rf /var/log/kernel
for x in unix klog; do
[ ! -d "/etc/sv/socklog-$x" ] && socklog-conf $x nobody log
ln -s ../../../sv/socklog-$x /etc/runit/runsvdir/current
done
}
installed_packages(){
(
pacman -Qn
pacman -Qm
) | sed -e's/ .*$//' | sort | uniq
}