-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathqrius_userconfig.sh
executable file
·91 lines (68 loc) · 1.5 KB
/
qrius_userconfig.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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# Qrius user configuration script
set -o pipefail
USERNAME=$1
add_to_plugdev() {
groups ${USERNAME} | grep plugdev > /dev/null
XCODE=(${PIPESTATUS[@]})
if [ ${XCODE[0]} != 0 ]; then return ${XCODE[0]}; fi
if [ ${XCODE[1]} == 0 ]
then
echo "User is already in plugdev group."
else
echo "Adding user to plugdev group."
usermod -a -G plugdev ${USERNAME}
XCODE=$?
if [ ${XCODE} != 0 ]
then
echo "Error in adding user to plugdev group."
return ${XCODE}
fi
fi
}
check_username() {
if [ "${USERNAME}" == "" ]
then
read -p "Specify username: " USERNAME
fi
if [ "${USERNAME}" == "" ]
then
echo "No user name is specified!"
return 1
fi
}
do_userconfig() {
echo ""
echo "++++++++++++++++++++"
date
echo "++++++++++++++++++++"
echo "============================================="
echo "Configuring user ${USERNAME} as a Qrius user "
echo "============================================="
add_to_plugdev
XCODE=$?
if [ ${XCODE} != 0 ]; then return ${XCODE}; fi
}
check_identity() {
MY_IDENTITY=$(whoami)
if [ "${MY_IDENTITY}" != "root" ]
then
echo "This installer needs root permission to run."
return 1
fi
}
main() {
# Check whether root
check_identity
XCODE=$?
if [ ${XCODE} != 0 ]; then return ${XCODE}; fi
check_username
XCODE=$?
if [ ${XCODE} != 0 ]; then return ${XCODE}; fi
# Performs user configuration
do_userconfig 2>&1 | logger -s -t "qrius_userconfig"
}
main
XCODE=$?
read -p "Press ENTER to continue ..."
exit ${XCODE}