hi @robertbindar ,
your solution in the video is exactly what i am looking for. Thanks a lot for helping me.
I had some problems with my server (tried to much and couldnt reverse some thingsâŚ), so i set it up again. Sorry for the delay.
When it comes to mariadb_kernel i tried this in a terminal from jupyterhub:
sudo -E python3 -m pip install mariadb_kernel
and i got these warnings:
WARNING: The directory '/home/jupyter-jupyteradmin/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, youshould use sudo's -H flag.
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
so i did, as the -H option is recommended i the warning.
sudo -E -H python3 -m pip install mariadb_kernel
and i only got one warning left:
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
And then finally
sudo -E -H python3 -m mariadb_kernel.install
Then i got what you called the âwildwest szenarioâ.
I can create users and they all use the same mariadb with unlimited access. Which is super as i never got that far until now.
But what I need is the scenario you described in your video.
Unfortunately it does not work for me.
I used your script (and learned a lot about scripting, therefore i tipped it manually) and had to change some things and i added some echos in order to find out where things went wrong.
I wonder if the âsudo -uâ thing in the script is working correct in my case, because the dirs and the files are owned by root, after i run the script. I would have expected that the owner is the user $username
I changed the owner to the correct user with chown, but it had no effect.
jupyterhup gives the following after a while:
#### Connection failed
A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration.
Now i am stuck again. Close to the finish line.
Here is my last version of your script, which runs with no errors:
#!/bin/bash
# Script from Robert Bindar https://www.youtube.com/watch?v=lnrn9eDYR7Y
#some minor changes from F. Ehlers
port=3306
for dir in /home/*;
do
echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#generate username from home directory
username=`echo $dir | cut -d'/' -f3`
echo "Working on user $username"
#print current dir
echo $dir
#delete old dirs
#I am not sure why this is needed, because the datadir is deleted as well
rm -rf $dir/datadir $dir/.my.cnf $dir/.jupyter/mariadb_config.json
echo "Delete old dirs"
#create new dirs for user
sudo -u $username mkdir $dir/datadir $dir/.jupyter &>/dev/null
echo "Create new dirs"
#install mariadb for each user
#mariadb-install-db from version 10.4 i have 10.3 until then mysql_install_db
#Please notice the diffrence between - and _
sudo -u $username mysql_install_db --user=$username --datadir=$dir/datadir --auth-root-authentication-method=normal &>/dev/null
echo "Installed database"
#create .my.cnf
sudo -u $username echo "
[client-server]
socket=$dir/mariadb_dbg.socket
port=$port
[mariabdb]
max-connections=20
datadir=$dir/datadir" > $dir/.my.cnf
echo "Wrote .my.cnf "
#mariadb_config.json schreiben
sudo -u $username echo "
{
\"user\": \"root\",
\"host\": \"localhost\",
\"port\": \"$port\",
\"password\": \"\",
\"start_server\": \"True\",
\"client_bin\": \"mariadb\",
\"server_bin\": \"mariadbd\"
}" > $dir/.jupyter/mariadb_config.json
echo "wrote json "
# add 1 to the portnumber for the next user, brackets are necessary
port=$((port+1))
done
You asked if i mind sharing my goal:
I work as a teacher in a vocational school (Berufsbildende Schule) in germany. The subject is computer science at the vocational high school (Berufliches Gymnasium). The students are in their 13th and around 18 years of age.
I donât have the option to install the necessary software, because our IT support is not able to do this and they donât want to either. Thats what we call âDigitalisierungâ around here. It is frustrating.
So I thought âjupyter notebooksâ might be the solution.
I am currently working with instahub.org to teach databases. This is a great tool. The students learn how databases work on a very nice social network. And it is completly in the net.
I wanted to use jupyter to deepen this topic and maybe get into python in the next half year. Exams could perhaps also be handled very cleverly with nbgrader.
And it would be something that the âbig boysâ at university also use.
I am realy looking forward to get this to work.