users.sh
876 Bytes
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
#!/bin/bash
# Make sure to create user colab and colabdev group
COLAB_USER=colab
COLAB_GROUP=colabdev
# Get user and group
COLAB_USER_EXISTS=`cat /etc/group | grep $COLAB_USER:`
COLAB_GROUP_EXISTS=`cat /etc/group | grep $COLAB_GROUP:`
# Errors
ERROR_NOT_ALLOWED=126
ERROR_ALREADY_EXIST=9
# Make sure colab user exist
if [ -e $COLAB_USER_EXISTS ]; then
sudo adduser $COLAB_USER;
LAST_CMD=`echo $?`
if [ $LAST_CMD == $ERROR_NOT_ALLOWED ]; then
echo "You don't have permission to create users"
echo "Aborting installation"
exit -1
fi
fi
# Make sure colab group exist
if [ -e $COLAB_GROUP_EXISTS ]; then
sudo groupadd $COLAB_GROUP;
LAST_CMD=`echo $?`
if [ $LAST_CMD == $ERROR_NOT_ALLOWED ]; then
echo "You don't have permission to create groups"
echo "Aborting installation"
exit -1
fi
fi