Created
January 18, 2018 16:32
-
-
Save egidijus/981f87048ab57c97bf84501a02442825 to your computer and use it in GitHub Desktop.
snapshot guest user account in to a skeleton on ubuntu 16.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Version: 1.1.0 | |
# Date: 19/03/2016 | |
# Origin: http://cascaval.com | |
# | |
# UBUNTU 16.04 | |
# Start a guest session and customize it as you like, then switch users to the main/admin user, and run this script. | |
# The next time you login in to a "fresh" guest, the guest account will be setup from the skeleton. | |
# 1) Find the current guest's home directory | |
guestdir=`find /tmp -maxdepth 1 -type d -iname 'guest-*'` | |
if [ "$guestdir" == "" ]; then | |
echo "The guest's home directory was not found. Is the guest logged in?" | |
exit 1 | |
fi | |
if [[ $(wc -l <<< "$guestdir") > 1 ]]; then | |
echo "More than one guest's directory was found. No idea which one to use." | |
exit 1 | |
fi | |
# 2) Create the guest-session directory if it doesn't exist | |
if [ ! -d "/etc/guest-session/" ]; then | |
mkdir /etc/guest-session | |
fi | |
# 3) Backup the current skel directory | |
if [ -d "/etc/guest-session/skel/" ]; then | |
suffix=$(date -u +%Y-%m-%d-%H%M%S) | |
mv /etc/guest-session/skel /etc/guest-session/skel-$suffix | |
fi | |
# 4) Copy the directory to the skel directory | |
cp -R "$guestdir/" /etc/guest-session/skel | |
# 5) Change ownership and permissions of the skel directory | |
chown -R root:root /etc/guest-session/skel | |
chmod -R 0777 /etc/guest-session/skel | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment