So I wrote small this script, we needed it for our laptops at work, they have a single user account for simplicity.
When our students sign in to google.com, their username is keept, which makes it problematic for user other students to sign in if not cleaned from Chrome.
This script restores chrome to default choosen settings.
#!/bin/sh
# This script will clean Google Chrome and extract settings from archive
echo “Lukker Google Chrome”
pkill -u superbruger chrome
sleep 2
echo “Sletter filer”
rm -rf ~/.cache/google-chrome
rm -rf ~/.config/google-chrome
echo “Indstiller Google Chrome til standart”
sleep 1
cd ~/.config/
tar xf chrome-default.tar.gz
This scripts creates a file called ~/.config/chrome-default.tar.gz from the content of ~/.config/google-chrome – If exist rename older backup.
#!/bin/sh
# This file creates a backup of google chrome config folder, if backup exist, then move old backup with to backupfile+date
NOW=$(date +%Y-%m-%d_%H.%M.%S)
FILENAME=chrome-default.tar.gz
echo $NOW
cd ~/.config
echo “Looking for $FILENAME”
if [ -f $FILENAME ];
then
echo “$FILENAME allready exist, renaming file to $FILENAME.$NOW” && mv $FILENAME $FILENAME.$NOW
fi
echo “Writting new backup file $FILENAME”
tar cf $FILENAME google-chrome/
echo “script done/”