blob: 788fb3695548c41d5c7d49ec217920454a4f46a0 (
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
|
#!/bin/sh
set -e
### Create groups
# thin-edge.io compoments run within their own groups and users the following steps add new groups if they don't exist.
if ! getent group tedge-users >/dev/null; then
addgroup --quiet tedge-users
fi
if ! getent group tedge >/dev/null; then
addgroup --quiet --system tedge
fi
### Create users
# Create user tedge with no additional info(--gecos "") no home(--no-create-home), no login(--shell) and in group tedge(--ingroup)
if ! getent passwd tedge >/dev/null; then
adduser --quiet --system --gecos "" --no-create-home --disabled-login --shell /sbin/nologin --ingroup tedge tedge
fi
### Add include to mosquitto.conf so tedge specific conf will be loaded
if ! grep -q "/etc/tedge/mosquitto-conf" "/etc/mosquitto/mosquitto.conf"; then
echo "include_dir /etc/tedge/mosquitto-conf" >>/etc/mosquitto/mosquitto.conf
fi
### Create file in /etc/sudoers.d directory. With this configuration, all users in the group tedge-users have the right to call the tedge command with sudo rights, which is required for system-wide configuration in "/etc/tedge"
echo "%tedge-users ALL = (ALL) /usr/bin/tedge" >/etc/sudoers.d/tedge-users
if [ -f "/etc/sudoers.d/010_pi-nopasswd" ]; then
echo "%tedge-users ALL = (ALL) NOPASSWD: /usr/bin/tedge" >/etc/sudoers.d/tedge-users-nopasswd
fi
# Initialize the tedge
tedge --init
### Below are automatically created script parts by cargo deb (Search for cargo deb DEBHELPER)
#DEBHELPER#
|