Hi everyone, first post here.
Anyone who isn't interested in the background, press pagedown
.
I sometimes need to make scripts for little things I need in the infrastructure at the company I work at. Currently I am trying to make a wrapper script for a proprietary image-deployment program. In this case RapiDeploy if anyone is curious.
Anyway, I am currently using the selfmade linux-executables created by this program for a custom-made recovery-cd solution I have currently based on SysrescCD 0.4.3 ( Yes I know it's old, but it works
).
Anyway, the recovery-cd simply boots up and runs an autorun-script that probes a number of prospective /dev/cdroms for a file named recovery.exe and then executes it.
The self-extracting executable has an ncurse-ish (it may well be ncurses) interface that outputs as follows if the output is sent to a file(ugly sample, sorry):
Imaging NTFS from slot 1 [0m[u[44;36m Mode: Restore (/mnt/cdrom/recovery.exe)
[0m[44;36m Elapsed: [0m[44;1;37m8:47[0m[44;36m Remaining: [0m[44;1;37m15 minutes[0m[44;36m Thruput: [0m[44;1;37m222 MB/min (30 Mbps)
[0m[44;1;37m þþþþþþþþþþþþþþþþþþþþþþþþþþ[0m[44;36m(0~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(B[0m[44;1;37m 35%
[0m[44;36m Imaging NTFS from slot 1 [0m[u[44;36m
[0m[42;1;37m
The problem comes in when you want to be able to restore from CDs, or the image is too large for DVD, because the images have to be spread out. The images are named, recovery.exe, recovery.002, etc.
When a split image is executed, the program first starts imaging the contents of the first file, recovery.exe, and then asks for the path of .002.
When a user comfortable with the ins and outs of nix-terminals and rdeploy uses it, simply: Switching to another tty - umounting - inserting next cd - mounting - switch back and press enter to search again in the default path (cwd), works just great.
However, I would like to create a wrapper for this executable file, so that someone not so technically inclined may use it. Describing the general outline of my idea in "pseudo-code" below:
correctcd-device=$(__Code to find correct CD device here ( Already have this, ugly but functional))
./recovery.exe < /root/inputtempfile > /root/outputtempfile #
progress=$(cat /root/outputtempfile | sed 'arguments to find application progress % and filter the rubbish'
echo $progress #Or draw a rough progress-bar, prefferably but not necessarily
if/when/case/whatever is suitable - still sketching $(cat /root/outputtempfile | sed 'arguments to find application output')= "Please insert next CD"( umount /mnt/cdrom
eject /dev/$correctcd-device
echo "Please insert next disc and press Enter"
mount /dev/$correctcd-device /mnt/cdrom
echo "Character that equals ENTER" > /root/inputtempfile # This is to make rapideploy act as if someone had typed the ENTER-key, which makes it look again in the default path /mnt/cdrom
)
# Insert more code to make it handle the recovery finishing, initiating unmounting, eject and reboot.
I think you get the idea, the biggest problem for me is how to correctly handle input/output, which is the most important atm. The progress bar etc I guess i could grep my way to later on.
I have looked into and tested back and forth with temp files and mkfifo/named pipes etc without really succeeding at running the application hidden but connected in the way I wish.
This, to me, seems to be the key to all the rest.
Other info:
The livecd has got both sh, bash and zsh.
Kernel version: 2.6.23.01-fd11
Thanks in advance for all your constructive criticism and suggestions, pointers and clues, and even cut-and-paste working code most welcome :P
Regards,
Andreas Ericson