blob: b02ccf445de28be424bc382c784042b0e89704db (
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#!/bin/sh
# -*- coding: utf-8 -*-
info()
{
echo "--- $*"
}
error()
{
echo "=== ERROR: $*" >&2
}
warning()
{
echo "=== WARNING: $*" >&2
}
die()
{
error "$*"
exit 1
}
entry_checks()
{
[ "$(id -u)" = "0" ] || die "Must be root to create users."
}
sys_groupadd()
{
local args="--system"
info "groupadd $args $*"
groupadd $args "$@" || die "Failed groupadd"
}
sys_useradd()
{
local args="--system -s /usr/sbin/nologin -d /nonexistent -M -N"
info "useradd $args $*"
useradd $args "$@" || die "Failed useradd"
}
do_usermod()
{
info "usermod $*"
usermod "$@" || die "Failed usermod"
}
stop_daemons()
{
systemctl stop letmeind.socket >/dev/null 2>&1
systemctl stop letmeind.service >/dev/null 2>&1
systemctl stop letmeinfwd.socket >/dev/null 2>&1
systemctl stop letmeinfwd.service >/dev/null 2>&1
}
remove_users()
{
# Delete all existing users and groups, if any.
userdel letmeind >/dev/null 2>&1
groupdel letmeind >/dev/null 2>&1
}
add_users()
{
sys_groupadd letmeind
sys_useradd -g letmeind letmeind
}
entry_checks
stop_daemons
remove_users
add_users
# vim: ts=4 sw=4 expandtab
|