diff --git a/import_users.sh b/import_users.sh index 07cdcf8..b82f049 100755 --- a/import_users.sh +++ b/import_users.sh @@ -99,11 +99,13 @@ function get_iam_users() { | sed "s/\r//g" else for group in $(echo ${IAM_AUTHORIZED_GROUPS} | tr "," " "); do - aws iam get-group \ + if ! aws iam get-group \ --group-name "${group}" \ --query "Users[].[UserName]" \ - --output text \ - | sed "s/\r//g" + --output text; + then + continue; + fi done fi } @@ -142,10 +144,13 @@ function get_sudoers_users() { [[ -z "${SUDOERS_GROUPS}" ]] || [[ "${SUDOERS_GROUPS}" == "##ALL##" ]] || for group in $(echo "${SUDOERS_GROUPS}" | tr "," " "); do - aws iam get-group \ + if ! aws iam get-group \ --group-name "${group}" \ --query "Users[].[UserName]" \ - --output text + --output text; + then + continue; + fi done } diff --git a/install.sh b/install.sh index f07b464..9bf6ffd 100755 --- a/install.sh +++ b/install.sh @@ -97,7 +97,7 @@ tmpdir=$(mktemp -d) cd "$tmpdir" -git clone -b master https://github.com/widdix/aws-ec2-ssh.git +git clone -b master https://github.com/nicholascowan/aws-ec2-ssh.git cd "$tmpdir/aws-ec2-ssh" @@ -143,8 +143,10 @@ SHELL=/bin/bash PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin MAILTO=root HOME=/ -*/10 * * * * root $IMPORT_USERS_SCRIPT_FILE +RANDOM_DELAY=19 +*/20 * * * * root $IMPORT_USERS_SCRIPT_FILE EOF + chmod 0644 /etc/cron.d/import_users $IMPORT_USERS_SCRIPT_FILE