blob: e8cdd4dfcb1605dac54f8af9044cfce78c434ee1 (
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
|
msg() {
ALL_OFF="\e[1;0m"
BOLD="\e[1;1m"
GREEN="${BOLD}\e[1;32m"
local mesg=$1; shift
printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}" "$@" >&2
}
add_users() {
_l="/etc/login.defs"
_p="/etc/passwd"
## get mini UID limit ##
l=$(grep "^UID_MIN" $_l)
## get max UID limit ##
l1=$(grep "^UID_MAX" $_l)
## use awk to print if UID >= $MIN and UID <= $MAX and shell is not /sbin/nologin ##
users=$(awk -F':' -v "min=${l##UID_MIN}" -v "max=${l1##UID_MAX}" '{ if ( $3 >= min && $3 <= max && $7 != "/sbin/nologin" ) print $0 }' "$_p" | cut -d: -f1)
for i in $users; do
msg "Adding user '$i' to user-group 'sys,cups,lp'"
usermod -a -G sys $i
usermod -a -G cups $i
usermod -a -G lp $i
done
}
add_group() {
getent group "sys" &>/dev/null || groupadd -r sys
getent group "cups" &>/dev/null || groupadd -r cups
getent group "lp" &>/dev/null || groupadd -r lp
add_users
}
post_install() {
post_upgrade
}
post_upgrade() {
msg "Attempting to enable services..."
systemctl disable cups.service
systemctl is-active cups.socket >/dev/null || systemctl enable cups.socket
add_group
echo ""
msg "services should now be enabled."
msg "Please add new users to 'sys,cups,lp' group."
msg "Reboot your system, so changes will take effect.."
echo ""
}
# vim: ts=2 sw=2 et:
|