Auto XP partion restore

At my computer shop where I work, we got alot of used PC's from some place. It's my job to refurbish them for resale. Each computer comes with XP pro. So the boss man asks me if there is a way to put a XP restore option. I say yes if I install Linux on a small partion and use partimage to make a image of the XP partion and store in on the Ubuntu side. I wrote a small shell script so the end user could restore XP without having to bring it in theshop when they foul XP up.

Here is the script:

Code:
\#!/bin/bash

# System Restore

echo "***************************** XP System Restore *****************************"
read -n 1 -p "Press any key to continue"

echo "This will restore your Windows XP installation"

echo "YOU WILL LOSE ALL DATA IF YOU CONTINUE"
echo "ONLY RUN THIS IF YOU WANT A FRESH INSTALL OF XP"
echo "Y to continue N to exit Y/N"

read a
if [[ $a == "N" || $a == "n" ]]; then
read -n 1 -p "Press any key to continue..."
exit

	else

if [[ $a == "Y" || $a == "y" ]]; then
 	echo "Restore System Now? \*\*Warning** ALL DATA WILL BE ERASED!! Y/N?"
	read a
if [[ $a == "N" || $a == "n" ]]; then
	exit
	else
if [[ $a == "Y" || $a == "y" ]]; then
	read -n 1 -p "Press any key to continue... The password is owner"
	sudo partimage restore /dev/sda1 /home/owner/XP-Restore.000
    
fi
fi
fi

fi
It works fine but not simple enough for end users (So the Boss Man says). So I edited GRUB so it would only give two options "Windows XP Pro" and "System Restore"--Ubuntu--.

Is there a way to have the script auto run on boot or login and have partimage restore without any input from the end user other then the Y/N questions that I have in the script.

If anyone can help me out here it would be greatly appreciated

Would the use of flag -BX work here.

  • -BX, --fully-batch=X batch mode without GUI, X is a challenge response string

I don't understand the batch = X part... is the X meant to be replaced with something or would the command just look like this?

Code:
sudo partimage restore -BX /dev/sda1 /home/owner/XP-Restore.000

Can you use the /etc/init.d startup scripts area, although I'm not sure if this would not allow the user to respond.

Running the script from /etc/profile should evoke it at login for all users, or from .profile for specific users.

Alternatively, maybe try creating a user with your script as its defined shell in /etc/passwd. This is what I used to do to get my kids to shutdown my Linux box properly after they'd been playing games...I told them to login as "shutdown" which was a user with no password but with a shutdown script defined in passwd.

Jerry