Hello everyone!
Sorry if this question is already some where.
I administrate FreeBSD web server in our school. Server is used for student's html, css and so on testing.
I need to add account to base system and sometimes also to mysql.
I have created shell script what read lastname firstname group name and users student number from file.
I have managed to add account to base system, but now I have problem to add accounts to mySQL.
Here is code what I have created.
This code ask mysql root users password for every user account. I would like to give mySQL root password only one time. How I could do that?
How I could give same password for every base account in pw usedadd or usermod command?
Thanks in advance of your help.
Regards:
Mr Keijo Salakari from Finland
Sorry if this question is already some where.
I administrate FreeBSD web server in our school. Server is used for student's html, css and so on testing.
I need to add account to base system and sometimes also to mysql.
I have created shell script what read lastname firstname group name and users student number from file.
I have managed to add account to base system, but now I have problem to add accounts to mySQL.
Here is code what I have created.
Code:
#!/bin/sh
NEW_USER="/root/komentoja/tunnarit"
HOME_BASE="/home/"
PASSU="Password_here"
TANAAN=$(date "+%Y_%m_%d") #today
#SKEL="/usr/share/skel"
SKEL="/usr/share/skel_os_commerce"
# Twho skeleton because some groups need OsCommerce and others doesn't
cat ${NEW_USER} | \
while read LASTNAME FIRSTNAME GROUP USER
do
NAME="$LASTNAME $FIRSTNAME"
KANSIO="$GROUP"_"$USER"
TUNNUS="$USER"_"$FIRSTNAME"
#Group add
pw groupadd ${GROUP}
#Create user account, pasword expires next day
pw useradd -n ${KANSIO} -g ${GROUP} -p +1d -k ${SKEL} -m -d ${HOME_BASE}${KANSIO}
# muutetaan user accountin kommenttia
pw usermod ${KANSIO} -c "${NAME}" -w random
#I would like here that PASSU so that all user get first time same password
# mySQL command
mysql -t -p <<STOP
CREATE DATABASE $KANSIO;
CREATE USER '$KANSIO'@'localhost' identified by '$PASSU';
GRANT ALL on $KANSIO.* to '$KANSIO'@'localhost';
\q
STOP
done
exit 0
This code ask mysql root users password for every user account. I would like to give mySQL root password only one time. How I could do that?
How I could give same password for every base account in pw usedadd or usermod command?
Thanks in advance of your help.
Regards:
Mr Keijo Salakari from Finland