Passing a custom-dir without setting serial was not working
[bootcd.git] / build.sh
1 #!/bin/bash
2 #
3 # Builds custom BootCD ISO and USB images in the current
4 # directory. For backward compatibility, if an old-style static
5 # configuration is specified, that configuration file will be parsed
6 # instead of the current PLC configuration in
7 # /etc/planetlab/plc_config.
8 #
9 # Aaron Klingaman <alk@absarokasoft.com>
10 # Mark Huang <mlhuang@cs.princeton.edu>
11 # Copyright (C) 2004-2007 The Trustees of Princeton University
12 #
13 # $Id$
14 #
15
16 PATH=/sbin:/bin:/usr/sbin:/usr/bin
17
18 CONFIGURATION=default
19 NODE_CONFIGURATION_FILE=
20 TYPES="usb iso usb_serial iso_serial"
21 ALL_TYPES="usb iso usb_serial iso_serial usb_cramfs iso_cramfs usb_cramfs_serial iso_cramfs_serial"
22 # Leave 4 MB of free space
23 FREE_SPACE=4096
24 CUSTOM_DIR=
25 OUTPUT_BASE=
26 MKISOFS_OPTS="-R -J -r -f -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table"
27
28 usage()
29 {
30     echo "Usage: build.sh [OPTION]..."
31     echo "    -c name          (Deprecated) Static configuration to use (default: $CONFIGURATION)"
32     echo "    -f planet.cnf    Node to customize CD for (default: none)"
33     echo "    -t 'types'       Build the specified images (default: $TYPES)"
34     echo "                     All known types: $ALL_TYPES"
35     echo "    -a               Build all supported images"
36     echo "    -C custom-dir    Custom directory"
37     echo "    -O output-base   The basename of the generated files (default: PLC_NAME-BootCD-VERSION)"
38     echo "    -h               This message"
39     exit 1
40 }
41
42 # Get options
43 while getopts "O:c:f:t:C:ah" opt ; do
44     case $opt in
45     c)
46         CONFIGURATION=$OPTARG
47         ;;
48     f)
49         NODE_CONFIGURATION_FILE=$OPTARG
50         ;;
51     t)
52         TYPES="$OPTARG"
53         ;;
54     C)
55         CUSTOM_DIR="$OPTARG"
56         ;;
57     O)
58         OUTPUT_BASE="$OPTARG"
59         ;;
60     a)
61         TYPES="$ALL_TYPES"
62         ;;
63     h|*)
64         usage
65         ;;
66     esac
67 done
68
69 # Do not tolerate errors
70 set -e
71
72 # Change to our source directory
73 srcdir=$(cd $(dirname $0) && pwd -P)
74 pushd $srcdir
75
76 # Root of the isofs
77 isofs=$PWD/build/isofs
78
79 # The reference image is expected to have been built by prep.sh (see .spec)
80 # we disable the initial logic that called prep.sh if that was not the case
81 # this is because prep.sh needs to know pldistro 
82 if [ ! -f $isofs/bootcd.img -o ! -f build/version.txt ] ; then
83     echo "You have to run prep.sh prior to calling $0 - exiting"
84     exit 1
85 fi
86
87 # build/version.txt written by prep.sh
88 BOOTCD_VERSION=$(cat build/version.txt)
89
90 if [ -f /etc/planetlab/plc_config ] ; then
91     # Source PLC configuration
92     . /etc/planetlab/plc_config
93 fi
94
95 ### This support for backwards compatibility can be taken out in the
96 ### future. RC1 based MyPLCs set $PLC_BOOT_SSL_CRT in the plc_config
97 ### file, but >=RC2 based bootcd assumes that $PLC_BOOT_CA_SSL_CRT is
98 ### set.
99 if [ -z "$PLC_BOOT_CA_SSL_CRT" -a ! -z "$PLC_BOOT_SSL_CRT" ] ; then
100     PLC_BOOT_CA_SSL_CRT=$PLC_BOOT_SSL_CRT
101 fi
102
103 # If PLC configuration is not valid, try a static configuration
104 if [ -z "$PLC_BOOT_CA_SSL_CRT" -a -d configurations/$CONFIGURATION ] ; then
105     # (Deprecated) Source static configuration
106     . configurations/$CONFIGURATION/configuration
107     PLC_NAME="PlanetLab"
108     PLC_MAIL_SUPPORT_ADDRESS="support@planet-lab.org"
109     PLC_WWW_HOST="www.planet-lab.org"
110     PLC_WWW_PORT=80
111     if [ -n "$EXTRA_VERSION" ] ; then
112     BOOTCD_VERSION="$BOOTCD_VERSION $EXTRA_VERSION"
113     fi
114     PLC_BOOT_HOST=$PRIMARY_SERVER
115     PLC_BOOT_SSL_PORT=$PRIMARY_SERVER_PORT
116     PLC_BOOT_CA_SSL_CRT=configurations/$CONFIGURATION/$PRIMARY_SERVER_CERT
117     PLC_ROOT_GPG_KEY_PUB=configurations/$CONFIGURATION/$PRIMARY_SERVER_GPG
118 fi
119
120 FULL_VERSION_STRING="$PLC_NAME BootCD $BOOTCD_VERSION"
121
122 echo "* Building images for $FULL_VERSION_STRING"
123
124 # From within a myplc chroot /usr/tmp is too small 
125 # to build all possible images, whereas /data is part of the host
126 # filesystem and usually has sufficient space.  What we
127 # should do is check whether the expected amount of space
128 # is available.
129 BUILDTMP=/usr/tmp
130 if [ -d /data/tmp ] ; then
131     isreadonly=$(mktemp /data/tmp/isreadonly.XXXXXX || /bin/true)
132     if [ -n "$isreadonly" ] ; then
133         rm -f "$isreadonly"
134         BUILDTMP=/data/tmp
135     fi
136 fi
137
138 declare -a _CLEANUPS=()
139 function do_cleanup()
140 {
141     cd /
142     for i in "${_CLEANUPS[@]}"; do
143         $i
144     done
145 }
146 function push_cleanup()
147 {
148     _CLEANUPS=( "${_CLEANUPS[@]}" "$*" )
149 }
150 function pop_cleanup()
151 {
152     unset _CLEANUPS[$((${#_CLEANUPS[@]} - 1))]
153 }
154
155 trap "do_cleanup" ERR INT EXIT
156
157 BUILDTMP=$(mktemp -d ${BUILDTMP}/bootcd.XXXXXX)
158 push_cleanup rm -fr "${BUILDTMP}"
159 mkdir "${BUILDTMP}/isofs"
160 for i in "$isofs"/{bootcd.img,kernel}; do
161     ln -s "$i" "${BUILDTMP}/isofs"
162 done
163 cp "/usr/lib/syslinux/isolinux.bin" "${BUILDTMP}/isofs"
164 isofs="${BUILDTMP}/isofs"
165
166 # Root of the ISO and USB images
167 echo "* Populating root filesystem..."
168 overlay="${BUILDTMP}/overlay"
169 install -d -m 755 $overlay
170 push_cleanup rm -fr $overlay
171
172 # Create version files
173 echo "* Creating version files"
174
175 # Boot Manager compares pl_version in both places to make sure that
176 # the right CD is mounted. We used to boot from an initrd and mount
177 # the CD on /usr. Now we just run everything out of the initrd.
178 for file in $overlay/pl_version $overlay/usr/isolinux/pl_version ; do
179     mkdir -p $(dirname $file)
180     echo "$FULL_VERSION_STRING" >$file
181 done
182
183 # Install boot server configuration files
184 echo "* Installing boot server configuration files"
185
186 # We always intended to bring up and support backup boot servers,
187 # but never got around to it. Just install the same parameters for
188 # both for now.
189 for dir in $overlay/usr/boot $overlay/usr/boot/backup ; do
190     install -D -m 644 $PLC_BOOT_CA_SSL_CRT $dir/cacert.pem
191     install -D -m 644 $PLC_ROOT_GPG_KEY_PUB $dir/pubring.gpg
192     echo "$PLC_BOOT_HOST" >$dir/boot_server
193     echo "$PLC_BOOT_SSL_PORT" >$dir/boot_server_port
194     echo "/boot/" >$dir/boot_server_path
195 done
196
197 # (Deprecated) Install old-style boot server configuration files
198 install -D -m 644 $PLC_BOOT_CA_SSL_CRT $overlay/usr/bootme/cacert/$PLC_BOOT_HOST/cacert.pem
199 echo "$FULL_VERSION_STRING" >$overlay/usr/bootme/ID
200 echo "$PLC_BOOT_HOST" >$overlay/usr/bootme/BOOTSERVER
201 echo "$PLC_BOOT_HOST" >$overlay/usr/bootme/BOOTSERVER_IP
202 echo "$PLC_BOOT_SSL_PORT" >$overlay/usr/bootme/BOOTPORT
203
204 # Generate /etc/issue
205 echo "* Generating /etc/issue"
206
207 if [ "$PLC_WWW_PORT" = "443" ] ; then
208     PLC_WWW_URL="https://$PLC_WWW_HOST/"
209 elif [ "$PLC_WWW_PORT" != "80" ] ; then
210     PLC_WWW_URL="http://$PLC_WWW_HOST:$PLC_WWW_PORT/"
211 else
212     PLC_WWW_URL="http://$PLC_WWW_HOST/"
213 fi
214
215 mkdir -p $overlay/etc
216 cat >$overlay/etc/issue <<EOF
217 $FULL_VERSION_STRING
218 $PLC_NAME Node: \n
219 Kernel \r on an \m
220 $PLC_WWW_URL
221
222 This machine is a node in the $PLC_NAME distributed network.  It has
223 not fully booted yet. If you have cancelled the boot process at the
224 request of $PLC_NAME Support, please follow the instructions provided
225 to you. Otherwise, please contact $PLC_MAIL_SUPPORT_ADDRESS.
226
227 Console login at this point is restricted to root. Provide the root
228 password of the default $PLC_NAME Central administrator account at the
229 time that this CD was created.
230
231 EOF
232
233 # Set root password
234 echo "* Setting root password"
235
236 if [ -z "$ROOT_PASSWORD" ] ; then
237     # Generate an encrypted password with crypt() if not defined
238     # in a static configuration.
239     ROOT_PASSWORD=$(python <<EOF
240 import crypt, random, string
241 salt = [random.choice(string.letters + string.digits + "./") for i in range(0,8)]
242 print crypt.crypt('$PLC_ROOT_PASSWORD', '\$1\$' + "".join(salt) + '\$')
243 EOF
244 )
245 fi
246
247 # build/passwd copied out by prep.sh
248 sed -e "s@^root:[^:]*:\(.*\)@root:$ROOT_PASSWORD:\1@" build/passwd \
249     >$overlay/etc/passwd
250
251 # Install node configuration file (e.g., if node has no floppy disk or USB slot)
252 if [ -f "$NODE_CONFIGURATION_FILE" ] ; then
253     echo "* Installing node configuration file"
254     install -D -m 644 $NODE_CONFIGURATION_FILE $overlay/usr/boot/plnode.txt
255 fi
256
257 # Pack overlay files into a compressed archive
258 echo "* Compressing overlay image"
259 (cd $overlay && find . | cpio --quiet -c -o) | gzip -9 >$isofs/overlay.img
260
261 rm -rf $overlay
262 pop_cleanup
263
264 if [ -n "$CUSTOM_DIR" ]; then
265     echo "* Compressing custom image"
266     (cd "$CUSTOM_DIR" && find . | cpio --quiet -c -o) | gzip -9 >$isofs/custom.img
267 fi
268
269 # Calculate ramdisk size (total uncompressed size of both archives)
270 ramdisk_size=$(gzip -l $isofs/bootcd.img $isofs/overlay.img ${CUSTOM_DIR:+$isofs/custom.img} | tail -1 | awk '{ print $2; }') # bytes
271 ramdisk_size=$((($ramdisk_size + 1023) / 1024)) # kilobytes
272
273 echo "$FULL_VERSION_STRING" >$isofs/pl_version
274
275 popd
276
277 function build_iso()
278 {
279     local iso="$1" ; shift
280     local serial="$1" ; shift
281     local custom="$1"
282
283     # Write isolinux configuration
284     cat >$isofs/isolinux.cfg <<EOF
285 ${serial:+SERIAL 0 115200}
286 DEFAULT kernel
287 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${serial:+console=ttyS0,115200n8}
288 DISPLAY pl_version
289 PROMPT 0
290 TIMEOUT 40
291 EOF
292
293     # Create ISO image
294     echo "* Creating ISO image"
295     mkisofs -o "$iso" \
296         $MKISOFS_OPTS \
297         $isofs
298 }
299 function build_usb_partition()
300 {
301     echo -n "* Creating USB image with partitions..."
302     local usb="$1" ; shift
303     local serial="$1" ; shift
304     local custom="$1"
305
306     local size=$(($(du -Lsk $isofs | awk '{ print $1; }') + $FREE_SPACE))
307     size=$(( $size / 1024 ))
308
309     local heads=64
310     local sectors=32
311     local cylinders=$(( ($size*1024*2)/($heads*$sectors) ))
312     local offset=$(( $sectors*512 ))
313
314     /usr/lib/syslinux/mkdiskimage -M -4 "$usb" $size $heads $sectors
315     
316     cat >${BUILDTMP}/mtools.conf<<EOF
317 drive z:
318 file="${usb}"
319 cylinders=$cylinders
320 heads=$heads
321 sectors=$sectors
322 offset=$offset
323 mformat_only
324 EOF
325     # environment variable for mtools
326     export MTOOLSRC="${BUILDTMP}/mtools.conf"
327
328     ### COPIED FROM build_usb() below!!!!
329     echo -n " populating USB image... "
330     mcopy -bsQ -i "$usb" "$isofs"/* z:/
331         
332     # Use syslinux instead of isolinux to make the image bootable
333     tmp="${BUILDTMP}/syslinux.cfg"
334     cat >$tmp <<EOF
335 ${serial:+SERIAL 0 115200}
336 DEFAULT kernel
337 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${serial:+console=ttyS0,115200n8}
338 DISPLAY pl_version
339 PROMPT 0
340 TIMEOUT 40
341 EOF
342     mdel -i "$usb" z:/isolinux.cfg 2>/dev/null || :
343     mcopy -i "$usb" "$tmp" z:/syslinux.cfg
344     rm -f "$tmp"
345     rm -f "${BUILDTMP}/mtools.conf"
346     unset MTOOLSRC
347
348     echo "making USB image bootable."
349     syslinux -o $offset "$usb"
350
351 }
352
353 # Create USB image
354 function build_usb()
355 {
356     echo -n "* Creating USB image... "
357     local usb="$1" ; shift
358     local serial="$1" ; shift
359     local custom="$1"
360
361     mkfs.vfat -C "$usb" $(($(du -Lsk $isofs | awk '{ print $1; }') + $FREE_SPACE))
362
363     # Populate it
364     echo -n " populating USB image... "
365     mcopy -bsQ -i "$usb" "$isofs"/* ::/
366
367     # Use syslinux instead of isolinux to make the image bootable
368     tmp="${BUILDTMP}/syslinux.cfg"
369     cat >$tmp <<EOF
370 ${serial:+SERIAL 0 115200}
371 DEFAULT kernel
372 APPEND ramdisk_size=$ramdisk_size initrd=bootcd.img,overlay.img${custom:+,custom.img} root=/dev/ram0 rw ${serial:+console=ttyS0,115200n8}
373 DISPLAY pl_version
374 PROMPT 0
375 TIMEOUT 40
376 EOF
377     mdel -i "$usb" ::/isolinux.cfg 2>/dev/null || :
378     mcopy -i "$usb" "$tmp" ::/syslinux.cfg
379     rm -f "$tmp"
380
381     echo "making USB image bootable."
382     syslinux "$usb"
383 }
384
385
386 # Setup CRAMFS related support
387 function prepare_cramfs()
388 {
389     [ -n "$CRAMFS_PREPARED" ] && return 0
390     local custom="$1"
391
392     echo "* Setting up CRAMFS-based images"
393     local tmp="${BUILDTMP}/cramfs-tree"
394     mkdir -p "$tmp"
395     push_cleanup rm -rf $tmp
396     pushd $tmp
397     gzip -d -c $isofs/bootcd.img     | cpio -diu
398     gzip -d -c $isofs/overlay.img    | cpio -diu
399     [ -n "$custom" ] && \
400         gzip -d -c $isofs/custom.img | cpio -diu
401
402     # clean out unnecessary rpm lib
403     echo "* clearing var/lib/rpm/*"
404     rm -f var/lib/rpm/*
405
406     # bootcd requires this directory
407     mkdir -p mnt/confdevice
408
409     # relocate various directory to /tmp
410     rm -rf root
411     ln -fs /tmp/root root
412     ln -fs /sbin/init linuxrc 
413     ln -fs /tmp/resolv.conf etc/resolv.conf
414     ln -fs /tmp/etc/mtab etc/mtab
415
416     # have pl_rsysinit copy over appropriate etc & var directories into /tmp/etc/
417     # make /tmp/etc
418     echo "* renaming dirs in ./etc"
419     pushd etc
420     for dir in `find * -type d -prune | grep -v rc.d`; do
421         mv ${dir} ${dir}_o
422         ln -fs /tmp/etc/${dir} ${dir}
423     done
424     popd
425
426     echo "* renaming dirs in ./var"
427     # rename all top-level directories and put in a symlink to /tmp/var
428     pushd var
429     for dir in `find * -type d -prune`; do
430         mv ${dir} ${dir}_o
431         ln -fs /tmp/var/${dir} ${dir}
432     done
433     popd
434
435     # overwrite fstab to mount / as cramfs and /tmp as tmpfs
436     echo "* Overwriting etc/fstab to use cramfs and tmpfs"
437     rm -f ./etc/fstab
438     cat >./etc/fstab <<EOF
439 /dev/ram0     /              cramfs     ro              0 0
440 none          /dev/pts       devpts     gid=5,mode=620  0 0
441 none          /proc          proc       defaults        0 0
442 none          /sys           sysfs      defaults        0 0
443 EOF
444
445     pushd dev
446     rm -f console
447     mknod console c 5 1
448     #for i in 0 1 2 3 4 5 6 7 8; do rm -f ram${i} ; done
449     #for i in 0 1 2 3 4 5 6 7 8; do mknod ram${i} b 1 ${i} ; done
450     #ln -fs ram1 ram
451     #ln -fs ram0 ramdisk
452     popd
453
454     # update etc/inittab to start with pl_rsysinit
455     sed -i 's,pl_sysinit,pl_rsysinit,' etc/inittab
456
457     # modify inittab to have a serial console
458     echo "T0:23:respawn:/sbin/agetty -L ttyS0 9600 vt100" >> etc/inittab
459     # and let root log in
460     echo "ttyS0" >> etc/securetty
461
462     # calculate the size of /tmp based on the size of /etc & /var + 8MB slack
463     etcsize=$(du -s ./etc | awk '{ print $1 }')
464     varsize=$(du -s ./var | awk '{ print $1 }')
465     let msize=($varsize+$etcsize+8192)/1024
466
467
468     # generate pl_rsysinit
469     cat > etc/rc.d/init.d/pl_rsysinit <<EOF
470 #!/bin/sh
471 # generated by build.sh
472 echo -n "pl_rsysinit: preparing /etc and /var for pl_sysinit..."
473 mount -t tmpfs -orw,size=${msize}M,mode=1777 tmpfs /tmp
474 mkdir -p /tmp/root
475 mkdir -p /tmp/etc
476 touch /tmp/etc/resolv.conf
477 touch /tmp/etc/mtab
478 mkdir -p /tmp/var
479
480 # make mtab happy
481 echo "tmpfs /tmp tmpfs rw,size=${msize}M,mode=1777 1 1" > /tmp/etc/mtab
482
483 # copy over directory contents of all _o directories from /etc and /var
484 # /tmp/etc and /tmp/var
485 pushd /etc
486 for odir in \$(cd /etc && ls -d *_o); do dir=\$(echo \$odir | sed 's,\_o$,,'); (mkdir -p /tmp/etc/\$dir && cd \$odir && find . | cpio -p -d -u /tmp/etc/\$dir); done
487 popd
488 pushd /var
489 for odir in \$(cd /var && ls -d *_o); do dir=\$(echo \$odir | sed 's,\_o$,,'); (mkdir -p /tmp/var/\$dir && cd \$odir && find . | cpio -p -d -u /tmp/var/\$dir); done
490 popd
491
492 echo "done"
493 # hand over to pl_sysinit
494 echo "pl_rsysinit: handing over to pl_sysinit"
495 /etc/init.d/pl_sysinit
496 EOF
497     chmod +x etc/rc.d/init.d/pl_rsysinit
498
499     popd
500
501     # create the cramfs image
502     echo "* Creating cramfs image"
503     mkfs.cramfs $tmp/ ${BUILDTMP}/cramfs.img
504     cramfs_size=$(($(du -sk ${BUILDTMP}/cramfs.img | awk '{ print $1; }') + 1))
505     rm -rf $tmp
506     pop_cleanup
507 }
508
509 # Create ISO CRAMFS image
510 function build_iso_cramfs()
511 {
512     local iso="$1" ; shift
513     local serial="$1" ; shift
514     local custom="$1"
515     prepare_cramfs "$custom"
516     echo "* Creating ISO CRAMFS-based image"
517
518     local tmp="${BUILDTMP}/cramfs-iso"
519     mkdir -p "$tmp"
520     push_cleanup rm -rf $tmp
521     (cd $isofs && find . | grep -v "\.img$" | cpio -p -d -u $tmp/)
522     cat >$tmp/isolinux.cfg <<EOF
523 ${serial:+SERIAL 0 9600}
524 DEFAULT kernel
525 APPEND ramdisk_size=$cramfs_size initrd=cramfs.img root=/dev/ram0 ro ${serial:+console=ttyS0,9600n8}
526 DISPLAY pl_version
527 PROMPT 0
528 TIMEOUT 40
529 EOF
530
531     cp ${BUILDTMP}/cramfs.img $tmp
532     mkisofs -o "$iso" \
533         $MKISOFS_OPTS \
534         $tmp
535
536     rm -fr "$tmp"
537     pop_cleanup
538 }
539
540 # Create USB CRAMFS based image
541 function build_usb_cramfs()
542 {
543     local usb="$1"
544     local serial="$1" ; shift
545     local custom="$1"
546     prepare_cramfs "$custom"
547     echo "* Creating USB CRAMFS based image"
548
549     let vfat_size=${cramfs_size}+$FREE_SPACE
550
551     # Make VFAT filesystem for USB
552     mkfs.vfat -C "$usb" $vfat_size
553
554     # Populate it
555     echo "* Populating USB with overlay images and cramfs"
556     mcopy -bsQ -i "$usb" $isofs/kernel $isofs/pl_version ::/
557     mcopy -bsQ -i "$usb" ${BUILDTMP}/cramfs.img ::/
558
559     # Use syslinux instead of isolinux to make the image bootable
560     tmp="${BUILDTMP}/syslinux.cfg"
561     cat >$tmp <<EOF
562 ${serial:+SERIAL 0 9600}
563 DEFAULT kernel
564 APPEND ramdisk_size=$cramfs_size initrd=cramfs.img root=/dev/ram0 ro ${serial:+console=ttyS0,9600n8}
565 DISPLAY pl_version
566 PROMPT 0
567 TIMEOUT 40
568 EOF
569     mcopy -bsQ -i "$usb" "$tmp" ::/syslinux.cfg
570     rm -f "$tmp"
571
572     echo "* Making USB CRAMFS based image bootable"
573     syslinux "$usb"
574 }
575
576 function type_to_name()
577 {
578     echo $1 | sed '
579         s/usb$/.usb/;
580         s/usb_partition$/-partition.usb/;
581         s/usb_serial$/-serial.usb/;
582         s/iso$/.iso/;
583         s/iso_serial$/-serial.iso/;
584         s/usb_cramfs$/-cramfs.usb/;
585         s/usb_cramfs_serial$/-cramfs-serial.usb/;
586         s/iso_cramfs$/-cramfs.iso/;
587         s/iso_cramfs_serial$/-cramfs-serial.iso/;
588         '
589 }
590
591 [ -z "$OUTPUT_BASE" ] && OUTPUT_BASE="$PLC_NAME-BootCD-$BOOTCD_VERSION"
592
593 for t in $TYPES; do
594     serial=
595     tname=`type_to_name $t`
596     if [[ "$t" == *_serial ]]; then
597         serial=1
598         t=`echo $t | sed 's/_serial$//'`
599     fi
600     build_$t "${OUTPUT_BASE}${tname}" "$serial" "$CUSTOM_DIR"
601 done
602
603 exit 0