Made the script simpler

Move to shell script
Use a copy/restore strategy for more flexibility