-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_user.sh
executable file
·51 lines (45 loc) · 948 Bytes
/
create_user.sh
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
#!/usr/bin/env bash
#
# Description: Add user & group for mosquitto broker
#
# Author: [email protected]
#
# Configuration file: none
#
# Parameters: none
#
#
# get the OS id
#
OS=$(awk '/^ID=/' /etc/*-release | sed 's/ID=//' | tr '[:upper:]' '[:lower]')
#
# Function for Arch Linux
env_arch() {
echo "Operating System ID: arch"
useradd -u 1883 -M -s /sbin/nologin mosquitto
useradd -u 101 -M -s /sbin/nologin nginx
}
#
# Function for Raspian
#
env_raspbian() {
echo "Operating System ID: raspbian"
adduser --uid 1883 --quiet --no-create-home --disabled-login mosquitto
adduser --uid 101 --quiet --no-create-home --disabled-login nginx
#addgroup -S -g 1883 mosquitto
}
#
# I'm root?
#
if [ "$EUID" -ne 0 ]
then echo "Please run as root or with sudo $(basename "$0")"
exit
fi
#
# Depending on the OS
#
case "$OS" in
arch) env_arch ;;
raspbian) env_raspbian ;;
*) echo "unknown os - exiting" ; exit 1 ;;
esac