You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -104,19 +92,6 @@ function minimum_version_check() {
104
92
echo"$VERSION_GOOD"
105
93
}
106
94
107
-
functionuser_in_group()
108
-
{
109
-
if grep -q $1 /etc/group ;then
110
-
if id -nGz "$USER"| grep -qzxF "$1";then
111
-
echo"true"
112
-
else
113
-
echo"false"
114
-
fi
115
-
else
116
-
echo"notgroup"
117
-
fi
118
-
}
119
-
120
95
functioncheck_git_updates()
121
96
{
122
97
UPSTREAM=${1:-'@{u}'}
@@ -134,6 +109,7 @@ function check_git_updates()
134
109
echo"Diverged"
135
110
fi
136
111
}
112
+
137
113
functioninstall_python3_and_deps() {
138
114
CURR_PYTHON_VER="${1:-Unknown}"
139
115
CURR_VIRTUALENV="${2:-Unknown}"
@@ -190,20 +166,30 @@ function do_python3_checks() {
190
166
fi
191
167
}
192
168
193
-
functiondo_env_setup() {
194
-
echo"Setting up environment:"
195
-
if [[ !"$(user_in_group bluetooth)"=="notgroup" ]] && [[ !"$(user_in_group bluetooth)"=="true" ]];then
196
-
echo"User is NOT in 'bluetooth' group. Adding:">&2
197
-
echo"sudo usermod -G bluetooth -a $USER">&2
198
-
echo"You will need to restart your system before the changes take effect."
199
-
sudo usermod -G "bluetooth" -a $USER
200
-
fi
169
+
functionshould_add_user_to_group()
170
+
{
171
+
# sense group does not exist
172
+
grep -q "^$1:" /etc/group ||return 1
173
+
# sense group exists and user is already a member
174
+
groups | grep -q "\b$1\b"&&return 1
175
+
# group exists, user should be added
176
+
return 0
177
+
}
201
178
202
-
if [ !"$(user_in_group docker)"=="true" ];then
203
-
echo"User is NOT in 'docker' group. Adding:">&2
204
-
echo"sudo usermod -G docker -a $USER">&2
205
-
echo"You will need to restart your system before the changes take effect."
206
-
sudo usermod -G "docker" -a $USER
179
+
functiondo_required_groups_checks() {
180
+
# best-practice for group membership
181
+
local DESIRED_GROUPS="docker bluetooth dialout"
182
+
local LOGOUT_REQUIRED=false
183
+
local GROUP
184
+
forGROUPin$DESIRED_GROUPS;do
185
+
if should_add_user_to_group $GROUP;then
186
+
echo"sudo /usr/sbin/usermod -G $GROUP -a $USER">&2
187
+
sudo /usr/sbin/usermod -G $GROUP -a $USER
188
+
LOGOUT_REQUIRED=true
189
+
fi
190
+
done
191
+
if [ "$LOGOUT_REQUIRED"="true" ] ;then
192
+
echo"You will need to logout and login again before the changes take effect."
207
193
fi
208
194
}
209
195
@@ -256,19 +242,7 @@ function do_docker_checks() {
256
242
if (whiptail --title "Docker and Docker-Compose" --yesno "Docker is not currently installed, and is required to run IOTstack. Would you like to install docker and docker-compose now?\nYou will not be prompted again." 20 78);then
0 commit comments