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