@@ -21,18 +21,18 @@ function vagrant_groups() {
21
21
# Change gid for any groups that are not assigned as expected, and remap any associated files and folders
22
22
for i in " ${config_groups[@]} " ; do
23
23
arr=(${i// / } )
24
- group_newGID=${arr[0]}
25
- group_name=${arr[1]}
26
- group_name_padded={ ${arr[1]} ' ' }
24
+ group_newGID=" ${arr[0]} "
25
+ group_name=" ${arr[1]} "
26
+ group_name_padded=" ${arr[1]} ' '"
27
27
28
28
if [ ! $( getent group ${group_name} ) ]; then
29
- echo " Creating new group ${group_name_padded: 1 : 12 } with gid ${group_newGID} "
29
+ echo " Creating new group ${group_name_padded: 0 : 10 } with gid ${group_newGID} "
30
30
groupadd -g ${group_newGID} ${group_name}
31
31
fi
32
32
33
33
if [ $( getent group ${group_name} | cut -d' :' -f3) != ${group_newGID} ]; then
34
34
group_oldGID=$( getent group ${group_name} | cut -d' :' -f3)
35
- echo " Remapping existing group ${group_name_padded: 1 : 12 } from GID ${group_oldGID} to GID ${group_newGID} "
35
+ echo " Remapping existing group ${group_name_padded: 0 : 10 } from GID ${group_oldGID} to GID ${group_newGID} "
36
36
groupmod -g ${group_newGID} ${group_name}
37
37
echo " Reassigning files and folders associated with old group id to the new one"
38
38
$( find / -gid ${group_oldGID} ' !' -type l -exec chgrp ${group_newGID} ' {}' ' ;' 2>&1 | grep -v ' No such file or directory' ) || true
@@ -63,37 +63,36 @@ function vagrant_users() {
63
63
# Change uid and gid for any users that are not assigned as expected, and remap any associated files and folders
64
64
for i in " ${config_users[@]} " ; do
65
65
arr=(${i// / } )
66
- user_newUID=${arr[0]}
67
- user_newGID=${arr[1]}
68
- user_name=${arr[2]}
69
- user_name_padded={ ${arr[2]} ' ' }
70
- user_homeDir=${arr[3]}
71
- user_shell=${arg[4]}
72
- user_comment=${arg[5]}
73
-
74
- if [ ${user_homeDir} == ' -' ]; then user_homeDir_arg=' -M' ; else user_homeDir_arg=" -d ${user_homeDir} " ; fi
75
- if [ ${user_shell} == ' -' ]; then user_shell_arg=' ' ; else user_shell_arg=" -s ${user_shell} " ; fi
76
- if [ ${user_comment} == ' -' ]; then user_comment_arg=' ' ; else user_comment_arg=" -c '${user_comment// -/ / } '" ; fi
66
+ user_newUID=" ${arr[0]} "
67
+ user_newGID=" ${arr[1]} "
68
+ user_name=" ${arr[2]} "
69
+ user_name_padded=" ${arr[2]} ' '"
70
+ user_homeDir=" ${arr[3]} "
71
+ user_shell=" ${arg[4]} "
72
+ user_comment=" ${arg[5]} "
73
+
74
+ if [ " ${user_homeDir} " == ' -' ]; then user_homeDir_arg=' -M' ; else user_homeDir_arg=" -d ${user_homeDir} " ; fi
75
+ if [ " ${user_shell} " == ' -' ]; then user_shell_arg=' ' ; else user_shell_arg=" -s ${user_shell} " ; fi
76
+ if [ " ${user_comment} " == ' -' ]; then user_comment_arg=' ' ; else user_comment_arg=" -c '${user_comment// -/ / } '" ; fi
77
77
78
78
if [ ! $( id -u ${user_name} ) ]; then
79
- echo " Creating new user ${user_name_padded: 1 : 12 } with uid ${user_newUID} and gid ${user_newGID} "
79
+ echo " Creating new user ${user_name_padded: 0 : 10 } with uid ${user_newUID} and gid ${user_newGID} "
80
80
useradd -u ${user_newUID} -g ${user_newGID} ${user_homeDir_arg} ${user_comment_arg} ${user_shell_arg} ${user_name}
81
81
fi
82
82
83
83
if [ $( id -u ${user_name} ) != ${user_newUID} ]; then
84
84
user_oldUID=$( id -u ${user_name} )
85
- echo " Remapping existing user ${user_name_padded: 1 : 12 } from UID ${user_oldUID} to UID ${user_newUID} "
85
+ echo " Remapping existing user ${user_name_padded: 0 : 10 } from UID ${user_oldUID} to UID ${user_newUID} "
86
86
usermod -u ${user_newUID} ${user_name}
87
87
echo " Reassigning files and folders associated with old user id to the new one"
88
88
$( find / -uid ${user_oldUID} ' !' -type l -exec chown ${user_newUID} ' {}' ' ;' 2>&1 | grep -v ' No such file or directory' ) || true
89
89
fi
90
90
91
91
if [ $( id -g ${user_name} ) != ${user_newGID} ]; then
92
92
user_oldGID=$( id -g ${user_name} )
93
- echo " Remapping existing user ${user_name_padded: 1 : 12 } from GID ${user_oldGID} to UID ${user_newGID} "
93
+ echo " Remapping existing user ${user_name_padded: 0 : 10 } from GID ${user_oldGID} to UID ${user_newGID} "
94
94
usermod -g ${user_newGID} ${user_name}
95
95
fi
96
-
97
96
done
98
97
}
99
98
0 commit comments