Skip to content

Commit

Permalink
Change nested if conditionals to more compact/readable solution
Browse files Browse the repository at this point in the history
  • Loading branch information
khurtado committed Jan 10, 2025
1 parent 1c8ddeb commit e4ff9f1
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions docker/pypi/wmagent/wmagent-docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,13 @@ groupEntry=$(getent group $wmaGroup)

# Validation step
# Delete local docker passwd/group files if uucp is not present (so it can be recreated)
if [ -f "$HOST_MOUNT_DIR/admin/etc/passwd" ]; then
if ! grep -q uucp "$HOST_MOUNT_DIR/admin/etc/passwd"; then
[[ -f "$HOST_MOUNT_DIR/admin/etc/passwd" ]] && ! grep -q uucp "$HOST_MOUNT_DIR/admin/etc/passwd" && {
rm $HOST_MOUNT_DIR/admin/etc/passwd
fi
fi
if [ -f "$HOST_MOUNT_DIR/admin/etc/group" ]; then
if ! grep -q uucp "$HOST_MOUNT_DIR/admin/etc/group"; then
}
[[ -f "$HOST_MOUNT_DIR/admin/etc/group" ]] && ! grep -q uucp "$HOST_MOUNT_DIR/admin/etc/group" && {
rm $HOST_MOUNT_DIR/admin/etc/group
fi
fi
}

if ! [ -f $HOST_MOUNT_DIR/admin/etc/passwd ]; then
echo "Creating passwd file"
getent passwd > $HOST_MOUNT_DIR/admin/etc/passwd
Expand Down

0 comments on commit e4ff9f1

Please sign in to comment.