Helper script to create users on all OpenVZ VEs simultaneously:
#!/bin/bash
# create_ve_users.sh
# Usage: ./create_ve_users.sh <username> <password> <uid> <group1,group2>
USERNAME=$1
PASSWORD=$2
USERID=$3
GROUP=$4
EXPECTED_ARGS=4
OUT_FILE=.create_users_$$
/>
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` <username> <password> <uid> <group1,group2>"
/> exit 65
fi
VE_LIST=$(/usr/sbin/vzlist -H -o veid)
for VE in ${VE_LIST}
do
&nbs p; vzctl exec $VE \
&nbs p; &nbs p; &nbs p; "echo useradd -u $USERID -G $GROUP -p \''`openssl passwd -1 $PASSWORD`'\' $USERNAME > /tmp/${OUT_FILE} ; \
&nbs p; &nbs p; &nbs p; sh /tmp/${OUT_FILE} ; \
&nbs p; &nbs p; &nbs p; rm -f /tmp/${OUT_FILE}"
done
exit 0
- sandip's blog
- Login or register to post comments