Sylvain St.Germain | 1bb0e66 | 1999-03-14 14:00:22 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # This script is the receipe to generate the key that have to be created like |
| 4 | # if an applicaiton was installed by its installer. It processes using a |
| 5 | # registry based on the picture of the registry before the application is |
| 6 | # installed and the picture of the registry after the application is installed. |
| 7 | # |
| 8 | # Copyright 1999 Sylvain St-Germain |
| 9 | # |
| 10 | |
| 11 | if [ $# -ne 2 ]; then |
| 12 | echo "$0 Usage: " |
| 13 | echo " You must provide 2 arguments." |
| 14 | echo " 1 - Registry output before the application's installation." |
| 15 | echo " 2 - Registry output after the application's installation." |
| 16 | echo |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
| 20 | echo "Assuming that $1 is the \"before\" file..." |
| 21 | echo "Assuming that $2 is the \"after\" file..." |
| 22 | |
| 23 | # |
| 24 | # do not attempt to regFix.pl /dev/null ... |
| 25 | # |
| 26 | echo "Fixing exported registry files..." |
| 27 | if [ $1 != "/dev/null" ]; then |
| 28 | cat $1 | ./regFixer.pl > $1.fix |
| 29 | fi |
| 30 | |
| 31 | cat $2 | ./regFixer.pl > $2.fix |
| 32 | |
| 33 | # |
| 34 | # diff accordingly depending on /dev/null |
| 35 | # |
| 36 | echo "Diffing..." |
| 37 | if [ $1 != "/dev/null" ]; then |
| 38 | diff $1.fix $2.fix > $2.diff |
| 39 | else |
| 40 | diff /dev/null $2.fix > $2.diff |
| 41 | fi |
| 42 | # |
| 43 | # Keep only added lines |
| 44 | # |
| 45 | echo "Grepping keys to add and generating cleaned fixed registry file." |
| 46 | cat $2.diff | grep '^> ' | sed -e 's/^> //' > $2.toAdd |
| 47 | |
| 48 | # |
| 49 | # Restore the file format to the regedit export 'like' format |
| 50 | # |
| 51 | echo "Restoring key's in the regedit export format..." |
| 52 | cat $2.toAdd | ./regRestorer.pl > $2.toAdd.final |
| 53 | |
| 54 | echo "Cleaning..." |
| 55 | rm $1.fix $2.fix >/dev/null 2>&1 |
| 56 | rm $2.diff >/dev/null 2>&1 |
| 57 | rm $2.toAdd >/dev/null 2>&1 |
| 58 | mv $2.toAdd.final $2.toAdd |
| 59 | |
| 60 | echo "Operation completed, result file is $2.toAdd" |
| 61 | |
| 62 | exit 0 |