TringaliLuca

Temporary user

Jan 3rd, 2021 (edited)
807
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. myuser='studente'
  3. mylock='/tmp/cleanedstudente'
  4. #adduser $myuser
  5. #usermod -d /tmp/$myuser $myuser
  6. touch $mylock
  7. while true; do
  8.   if who | grep tty | grep -q "$myuser"; then
  9.     if [ -f $mylock ]; then
  10.     rm $mylock
  11.     fi
  12.   else
  13.     if [ ! -d /tmp/$myuser ]; then
  14.       rm $mylock
  15.     fi
  16.     if [ ! -f /tmp/$myuser/Desktop/BRAN ]; then
  17.       rm $mylock
  18.     fi
  19.     if [ ! -f $mylock ]; then
  20.       rm -r /tmp/$myuser
  21.       sudo -u $myuser mkdir /tmp/$myuser
  22.       shopt -s dotglob
  23.       sudo -u $myuser cp -r /etc/skel/* /tmp/$myuser/
  24.       sudo -u $myuser dbus-launch gio set "/tmp/$myuser/Desktop/BRAN" -t string metadata::trust "true"
  25.       sudo -u $myuser dbus-launch gio set "/tmp/$myuser/Desktop/eduroam-linux-UdSdT-eduroam_UniTS_generico.py" -t string metadata::trust "true"
  26.       touch $mylock
  27.     fi
  28.   fi
  29. sleep 10
  30. done
RAW Paste Data