diff options
author | Ricardo Salveti <ricardo.salveti@linaro.org> | 2015-10-26 17:59:40 -0200 |
---|---|---|
committer | Fathi Boudra <fathi.boudra@linaro.org> | 2015-12-03 12:47:42 +0000 |
commit | 5e0af7480639f4a50955214a5bb2f871650d71a2 (patch) | |
tree | dc3402ea909d9530408c2ce09e9f42ad0dde4ad5 /jessie-armhf-alip | |
parent | 41254f4477264583806477df69eba82b9b34b0ee (diff) |
jessie: 02-add_linaro_to_groups: simplifying logic
Simplifying logic to use a for instead of duplicating every new entry.
Change-Id: I92a5431b780635354a6c6bf20dbbbbd2a62113ba
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
Diffstat (limited to 'jessie-armhf-alip')
-rwxr-xr-x | jessie-armhf-alip/customization/hooks/02-add_linaro_to_groups.chroot | 83 |
1 files changed, 12 insertions, 71 deletions
diff --git a/jessie-armhf-alip/customization/hooks/02-add_linaro_to_groups.chroot b/jessie-armhf-alip/customization/hooks/02-add_linaro_to_groups.chroot index fb20bdd..9890d14 100755 --- a/jessie-armhf-alip/customization/hooks/02-add_linaro_to_groups.chroot +++ b/jessie-armhf-alip/customization/hooks/02-add_linaro_to_groups.chroot @@ -1,77 +1,18 @@ -#!/bin/sh -x +#!/bin/sh -x DEFGROUPS="admin,adm,dialout,cdrom,audio,dip,video,plugdev,bluetooth,pulse-access" -/bin/egrep -i "^admin" /etc/group -if [ $? -eq 0 ]; then - echo "User admin exists in /etc/group" -else - echo "User admin does not exists in /etc/group must create" - groupadd admin -fi -/bin/egrep -i "^adm" /etc/group -if [ $? -eq 0 ]; then - echo "User adm exists in /etc/group" -else - echo "User adm does not exists in /etc/group must create" - groupadd adm -fi -/bin/egrep -i "^dialout" /etc/group -if [ $? -eq 0 ]; then - echo "User dialout exists in /etc/group" -else - echo "User dialout does not exists in /etc/group must create" - groupadd dialout -fi -/bin/egrep -i "^cdrom" /etc/group -if [ $? -eq 0 ]; then - echo "User cdrom exists in /etc/group" -else - echo "User cdrom does not exists in /etc/group must create" - groupadd cdrom -fi -/bin/egrep -i "^audio" /etc/group -if [ $? -eq 0 ]; then - echo "User audio exists in /etc/group" -else - echo "User audio does not exists in /etc/group must create" - groupadd audio -fi -/bin/egrep -i "^dip" /etc/group -if [ $? -eq 0 ]; then - echo "User dip exists in /etc/group" -else - echo "User dip does not exists in /etc/group must create" - groupadd dip -fi -/bin/egrep -i "^video" /etc/group -if [ $? -eq 0 ]; then - echo "User video exists in /etc/group" -else - echo "User video does not exists in /etc/group must create" - groupadd video -fi -/bin/egrep -i "^plugdev" /etc/group -if [ $? -eq 0 ]; then - echo "User plugdev exists in /etc/group" -else - echo "User plugdev does not exists in /etc/group must create" - groupadd plugdev -fi -/bin/egrep -i "^bluetooth" /etc/group -if [ $? -eq 0 ]; then - echo "User bluetooth exists in /etc/group" -else - echo "User bluetooth does not exists in /etc/group must create" - groupadd bluetooth -fi -/bin/egrep -i "^pulse-access" /etc/group -if [ $? -eq 0 ]; then - echo "User pulse-access exists in /etc/group" -else - echo "User pulse-access does not exists in /etc/group must create" - groupadd pulse-access -fi +IFS=',' +for group in $DEFGROUPS; do + /bin/egrep -i "^$group" /etc/group + if [ $? -eq 0 ]; then + echo "Group '$group' exists in /etc/group" + else + echo "Group '$group' does not exists in /etc/group, creating" + groupadd $group + fi +done +unset IFS echo "I: add linaro to ($DEFGROUPS) groups" usermod -a -G ${DEFGROUPS} linaro |