#!/bin/bash for i in 2 3 4 5 6 7 8 9 10 11 12 do password=`openssl rand -base64 8` md5password=`md5 -qs $password` echo "ehealthsuisse $i : login = admin$i and password is ${password} (md5=${md5password})" >> passwords scp add_admin.sql gazelle@ehealthsuisse$i.ihe-europe.net:/home/gazelle ssh gazelle@ehealthsuisse$i.ihe-europe.net "sudo sed -i 's/KEYWORD/ehealthsuisse$i/g' /home/gazelle/add_admin.sql" ssh gazelle@ehealthsuisse$i.ihe-europe.net "sudo sed -i 's/ADMIN/admin$i/g' /home/gazelle/add_admin.sql" ssh gazelle@ehealthsuisse$i.ihe-europe.net "sudo sed -i 's/NAME/ehealthsuisse$i/g' /home/gazelle/add_admin.sql" ssh gazelle@ehealthsuisse$i.ihe-europe.net "sudo sed -i 's/MD5PASSWORD/$md5password/g' /home/gazelle/add_admin.sql" ssh gazelle@ehealthsuisse$i.ihe-europe.net "sudo sed -i 's/EMAIL/ehealthsuisse$i@ihe-europe.net/g' /home/gazelle/add_admin.sql" ssh gazelle@ehealthsuisse$i.ihe-europe.net "psql -U gazelle -d gazelle < add_admin.sql" done