I'm interested in writing a (hopefully) simple Linux Shell Script.
Upon shutdown of the system (or upon reboot), I would like the script to automatically reset any changes made during that session. This includes files saved to the hard disk as well as any configuration changes. I would also like the script to be run only with guest accounts, the administrative account would not have the script run.
Can anyone help me out? I'm not even sure where to start.
Give that script a name like clean_guest.sh, move it to somewhere like /usr/local/bin, make it executable:
chmod +x /usr/local/bin/clean_guest.sh
Call it from inside /etc/rc.local (redhat) or similar init script and now any changes made or files copied will be gone and have a freshly built user home again.
Or, for a more complex case, you could setup your system to use LVM for all partitions and create a snapshot of the filesystem in it's desired state. Then add an script to the shutdown/reboot runlevels (/etc/init.d and /etc/rc.d/rc.{0,6} for most Linux systems) or for startup that resets the disks to this snapshot.
I'm not too familiar with running LVM from a shell script or even setting it up to run on shutdown/reboot/startup. How would the coding for that look like?
An example for an init script can be found at /etc/init.d/skeleton in most distributions.
As for the snapshot, create it first from the shell and modify /etc/fstab to boot from the snapshot instead of the usual partition. Then, in the init script, make sure that all required modules are loaded, remove the old snapshot using lvremove, and create it new, using the same command as on the command line.
A good intro to LVM can be found at The Linux Documentation Project