I'm in the process of building a kiosk system and need to give the guest user a new temporary home directory at every login.
I wrote a little bash script that takes care of that but when it tries to change the home directory of the user it throws the error 'usermod: user guest is currently used by process 20465'
The script itself look as follows:
#!/bin/bash
NEW_RAND =$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
mkdir /tmp/guest-$NEW_RAND
chown guest:guest /tmp/guest-$NEW_RAND
ln -s /etc/guest /tmp/guest-$NEW_RAND
usermod -d /tmp/guest-$NEW_RAND guest
How would I force the user into that new home directory?
Best regards
Edit: Just to clarify I run the script on login via .bashrc.
Best Answer
Why not using the building guest account as suggested by Byte Commander ? You can have a full control of the process by modifying the needed files. There is a good overview at help.unbuntu.com .
So skeleton files go in
/etc/guest-session/skel
and custom commands go in/etc/guest-session/prefs.sh
.