Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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