Skip to content

Instantly share code, notes, and snippets.

@joergre
Created September 3, 2017 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joergre/be3e0cd6afa47215e2057af0e53e3c7a to your computer and use it in GitHub Desktop.
Save joergre/be3e0cd6afa47215e2057af0e53e3c7a to your computer and use it in GitHub Desktop.
#!/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