Created
September 3, 2017 16:57
-
-
Save joergre/be3e0cd6afa47215e2057af0e53e3c7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
apt update | |
apt -y dist-upgrade | |
apt -y install mariadb-server mariadb-client | |
read -p "Geben sie die Zahl der Schueler an: " anzahl_schueler | |
pass="fbs" | |
for (( zaehler=1; zaehler<=$anzahl_schueler; zaehler++)) | |
do | |
username="schueler$zaehler" | |
echo "$username" | |
useradd -m -s /bin/bash "$username" | |
echo "$username:$pass" | chpasswd | |
echo "Lege Datenbank $username an!" | |
mysql -u root -pfbsfbs -e "CREATE DATABASE ${username};" | |
mysql -u root -pfbsfbs -e "CREATE USER ${username}@localhost IDENTIFIED BY '${pass}';" | |
mysql -u root -pfbsfbs -e "GRANT ALL PRIVILEGES ON ${username}.* TO '${username}'@'localhost';" | |
mysql -u root -pfbsfbs -e "FLUSH PRIVILEGES;" | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment