kc-users-gen.sh 604 B

12345678910111213141516171819
  1. #!/bin/bash
  2. # Generate list of KC users with passwords
  3. # one line per user account:
  4. # user001:pass1
  5. # user002:pass2
  6. # ...
  7. # Getting input data from variables.tf
  8. KC_USER_CNT=$(grep -A3 kc_user_count variables.tf | grep default | awk -F "\"" '{print $2}')
  9. KC_USER_PFX=$(grep -A3 kc_user_prefix variables.tf | grep default | awk -F "\"" '{print $2}')
  10. KC_USER_FN=$(grep -A3 kc_user_file variables.tf | grep default | awk -F "\"" '{print $2}')
  11. rm -f $KC_USER_FN
  12. for cnt in $(seq -w 001 $KC_USER_CNT)
  13. do
  14. echo $KC_USER_PFX$cnt:$(openssl rand -base64 12 | awk '{print substr($0,0,12)}') >> $KC_USER_FN
  15. done