2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
4 # stefan.k.berg@ericsson.com
5 # jonas.bjurel@ericsson.com
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
14 fusermount -u $tmporigdir 2>/dev/null
15 test -d $tmporigdir && rmdir $tmporigdir
18 trap exit_handler exit
26 error_exit "Input argument error"
29 top=$(cd `dirname $0`; pwd)
30 origiso=$(cd `dirname $1`; echo `pwd`/`basename $1`)
31 newiso=$(cd `dirname $2`; echo `pwd`/`basename $2`)
39 tmporigdir=${tmpdir}/origiso
40 tmpnewdir=${tmpdir}/newiso
42 test -f $origiso || error_exit "Could not find origiso $origiso"
43 test -d $tmpdir || error_exit "Could not find tmpdir $tmpdir"
46 if [ "`whoami`" != "root" ]; then
47 error_exit "You need be root to run this script"
51 rm -Rf $tmpnewdir || error_exit "Failed deleting old ISO copy dir"
52 mkdir -p $tmporigdir $tmpnewdir
53 fuseiso $origiso $tmporigdir || error_exit "Failed to FUSE mount ISO"
55 find . | cpio -pd $tmpnewdir || error_exit "Failed to copy FUSE ISO with cpio"
57 fusermount -u $tmporigdir || error_exit "Failed to FUSE unmount ISO"
58 rmdir $tmporigdir || error_exit "Failed to delete original FUSE ISO directory"
59 chmod -R 755 $tmpnewdir || error_exit "Failed to set protection on new ISO dir"
63 # Patch ISO to make it suitable for automatic deployment
64 cat $top/ks.cfg.patch | patch -p0 || error_exit "Failed patching ks.cfg"
67 # Add dynamic Fuel content
68 echo "isolinux.cfg before: `grep netmask isolinux/isolinux.cfg`"
69 sed -i "s/ ip=[^ ]*/ ip=$fuelIp/" isolinux/isolinux.cfg
70 sed -i "s/ gw=[^ ]*/ gw=$fuelGateway/" isolinux/isolinux.cfg
71 sed -i "s/ dns1=[^ ]*/ dns1=$fuelDns/" isolinux/isolinux.cfg
72 sed -i "s/ netmask=[^ ]*/ netmask=$fuelNetmask/" isolinux/isolinux.cfg
73 sed -i "s/ hostname=[^ ]*/ hostname=$fuelHostname/" isolinux/isolinux.cfg
74 sed -i "s/ showmenu=[^ ]*/ showmenu=yes/" isolinux/isolinux.cfg
75 echo "isolinux.cfg after: `grep netmask isolinux/isolinux.cfg`"
78 echo "Creating iso $newiso"
80 -J -R -b isolinux/isolinux.bin \
82 -boot-load-size 4 -boot-info-table \
84 -x "lost+found" -o $newiso . || error_exit "Failed making iso"