Okay, so I made a thread earlier about how I am working on making a server which will allow two nodes to boot up and re-image themselves from an image residing on a second partition of their drives. I successfully got them to the point that they boot up and I can run a script I made, which is /usr/bin/restore.
When I boot up, I can enter the word, "restore," on the command line, and the script works without error. All it does is call another script with sudo, which contains the following:
Code:
#!/bin/bash
#
# Super-User part of restore script
mkdir /mnt/source
mount -t ext2 -o ro /dev/sda2 /mnt/source
echo Restoring boot sector...
dd if=/mnt/source/bootsect.dd of=/dev/sda
echo Restoring partition...
dd if=/mnt/source/Recover.dd of=/dev/sda1 bs=32768
echo Done. Restarting...
reboot
The thing is, however, that I would like to eliminate the need for entering this command. I would prefer if the computers simply booted up, restored themselves, and then restarted. The problem I'm having, is that when I add the word, "restore" to the end of my ~/.bash_profile script, the computer boots up, but then prints a whole bunch of errors and reboots before I can see what happened. I'm currently building the image with "reboot" removed from the end, to see what exactly is going on.
I don't understand how a script that when typed, will function perfectly, however if it is run from "~/.bash_profile," it has errors. Other than the way the script is called, there is no difference.