1 | #!/bin/sh␊ |
2 | ␊ |
3 | # Copyright 2009 org.darwinx86.app. All rights reserved.␊ |
4 | #␊ |
5 | ␊ |
6 | # Modified Nov 18th 2011 by Rekursor␊ |
7 | # Added 2 parameters to specify repectively :␊ |
8 | # $1 = Extra dir location␊ |
9 | # $2 = cdboot file dir location␊ |
10 | # Added error return codes to be able to better interface the script from the prefpane call␊ |
11 | # Fixed BootCD.iso would be generated in the current script working directory␊ |
12 | #␊ |
13 | ␊ |
14 | ␊ |
15 | # Directories␊ |
16 | if [[ $# < 1 ]];then␊ |
17 | ␉extra="/Extra"␊ |
18 | else␊ |
19 | ␉extra="$1"␊ |
20 | fi␊ |
21 | ␊ |
22 | if [[ $# < 2 ]];then␊ |
23 | ␉cdBootDir="${extra}"␊ |
24 | else␊ |
25 | ␉cdBootDir="$2"␊ |
26 | fi␊ |
27 | ␊ |
28 | echo "Extra dir is ${extra} and cdboot dir is ${cdBootDir}"␊ |
29 | mydir=`dirname $0`␊ |
30 | ␊ |
31 | tempDir=/tmp␊ |
32 | finaldir=~/Desktop/Chameleon␊ |
33 | isodir=/tmp/newiso␊ |
34 | extradir=/tmp/newiso/Extra␊ |
35 | preDir=/tmp/newiso/Extra/Preboot␊ |
36 | prebootDir="${preDir}/Extra"␊ |
37 | bkpdir="${finaldir}/Previous-dmg"␊ |
38 | ␊ |
39 | echo "Starting CD Boot ISO creation script..."␊ |
40 | ␊ |
41 | #errors␊ |
42 | if ([ ! -f $extra/Extensions.mkext ] && [ ! -d $extra/Extensions ]);then␊ |
43 | ␉echo "*** Error: no Extensions.mkext or Extensions folder. One of them is required"␊ |
44 | ␉exit 1␊ |
45 | fi␊ |
46 | ␊ |
47 | if [ ! -f $extra/org.chameleon.Boot.plist ];then␊ |
48 | echo "*** Error: no org.chameleon.Boot.plist found. File required"␊ |
49 | exit 1␊ |
50 | fi␊ |
51 | ␊ |
52 | if [ ! -f $cdBootDir/cdboot ];then␊ |
53 | echo "*** Error: no cdboot found. File required"␊ |
54 | exit 1␊ |
55 | fi␊ |
56 | ␊ |
57 | # Create a work directory␊ |
58 | echo " Creating folders ..."␊ |
59 | #copy Extra files to temp directory␊ |
60 | if ([ ! -d $prebootDir ]);then␊ |
61 | ␉mkdir -p $prebootDir␊ |
62 | fi␊ |
63 | if ([ ! -d $bkpdir ]);then␊ |
64 | ␉mkdir -p $bkpdir␊ |
65 | fi␊ |
66 | echo " Copying files ..."␊ |
67 | ␊ |
68 | if [ -f $cdBootDir/cdboot ];then␊ |
69 | cp -R $cdBootDir/cdboot $isodir␊ |
70 | fi␊ |
71 | ␊ |
72 | if [ -f $extra/dsdt.aml ];then␊ |
73 | cp -R $extra/dsdt.aml $prebootDir␊ |
74 | fi␊ |
75 | ␊ |
76 | if [ -f $extra/DSDT.aml ];then␊ |
77 | ␉cp -R $extra/DSDT.aml $prebootDir␊ |
78 | fi␊ |
79 | ␊ |
80 | if [ -f $extra/NVIDIA.ROM ];then␊ |
81 | ␉cp -R $extra/NVIDIA.ROM $prebootDir␊ |
82 | fi␊ |
83 | ␊ |
84 | if [ -f $extra/smbios.plist ];then␊ |
85 | cp -R $extra/smbios.plist $prebootDir␊ |
86 | fi␊ |
87 | ␊ |
88 | if [ -f $extra/Extensions.mkext ];then␊ |
89 | cp -R $extra/Extensions.mkext $prebootDir␊ |
90 | fi␊ |
91 | ␊ |
92 | if [ -d $extra/Extensions ];then␊ |
93 | cp -Rp $extra/Extensions $prebootDir␊ |
94 | fi␊ |
95 | ␊ |
96 | if [ -f $extra/org.chameleon.Boot.plist ];then␊ |
97 | ␉cp -R $extra/org.chameleon.Boot.plist $prebootDir␊ |
98 | fi␊ |
99 | if [ -f $tempDir/org.chameleon.Boot.plist ];then␊ |
100 | cp -R $tempDir/org.chameleon.Boot.plist $extradir␊ |
101 | fi␊ |
102 | ␊ |
103 | echo " Files copied in temp folder"␊ |
104 | ␊ |
105 | # ramdisk creator␊ |
106 | if [ -f $extradir/Preboot.dmg ];then␊ |
107 | ␉rm $extradir/Preboot.dmg␊ |
108 | fi␊ |
109 | hdiutil create -srcfolder $preDir/ -layout GPTSPUD -fs HFS+ -format UDRW -volname Preboot $extradir/Preboot.dmg␊ |
110 | rm -R $preDir␊ |
111 | echo " Ram disk created"␊ |
112 | ␊ |
113 | # boot cd creator␊ |
114 | hdiutil makehybrid -o $tempDir/BootCD.iso $isodir/ -iso -hfs -joliet -eltorito-boot $isodir/cdboot -no-emul-boot -hfs-volume-name "Boot CD" -joliet-volume-name "Boot CD"␊ |
115 | if [ ! -f $tempDir/BootCD.iso ];then␊ |
116 | ␉echo "*** Error: couldn't Create ISO Image."␊ |
117 | ␉exit 1␊ |
118 | else␊ |
119 | ␉echo " Hybrid image created"␊ |
120 | fi␊ |
121 | ␊ |
122 | # Create output and backup directories␊ |
123 | if [ -f $finaldir/BootCD.iso ];then␊ |
124 | if [ ! -d $bkpdir ];then␊ |
125 | mkdir -p $bkpdir␊ |
126 | echo " Backup folder created"␊ |
127 | ␉fi␊ |
128 | mv -f $finaldir/BootCD.iso $bkpdir/BootCd-$(date +"%d-%y-%Hh%M").iso␊ |
129 | echo " Previous ISO moved into backup folder"␊ |
130 | fi␊ |
131 | mv $tempDir/BootCD.iso $finaldir␊ |
132 | echo " ISO moved on desktop"␊ |
133 | ␊ |
134 | # cleanup␊ |
135 | rm -rf $isodir/*␊ |
136 | echo " ISO created successfully"␊ |
137 | exit 0 |