summaryrefslogtreecommitdiff
path: root/sysutils/sysbuild/files/sysbuild.sh
blob: 2dd7d73e94dd50473b45327987f0e4c2e817ae3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
#!/bin/sh
#
# $NetBSD: sysbuild.sh,v 1.5 2002/12/14 23:23:08 jmmv Exp $
#
# sysbuild - Automatic NetBSD system builds
# Copyright (c) 2002, Julio Merino <jmmv@netbsd.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in
#    the documentation and/or other materials provided with the
#    distribution.
# 3. Neither the name of author nor the names of its contributors may
#    be used to endorse or promote products derived from this software
#    without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

progname=`basename $0`
allargs="$*"
conffile=@SYSBUILD_HOMEDIR@/default.conf

# XXX: This is needed when downgrading privileges with su...
PATH=/bin:/sbin:/usr/bin:/usr/sbin:@PREFIX@/bin:@PREFIX@/sbin

usage() {
    echo "usage: sysbuild [-fms] [-c conf] target [target_arguments]"
    echo
    echo "Flags:"
    echo "    -c conf    Base name of configuration file"
    echo "    -f         Fast mode"
    echo "    -m         Send all output by mail instead of console"
    echo "    -s         Run \`su' to change privileges if needed"
    echo
    echo "Available targets:"
    echo "    build-kernels     Build kernels"
    echo "    build-release     Build a complete release"
    echo "    build-sets        Build system sets only"
    echo "    clean             Clean work directories"
    echo "    clean-srcs        Fix ownerships in source directories"
    echo "    config            Create or edit a configuration file"
    echo "    config-kernel     Create or edit a kernel configuration file"
    echo "    destroy           Remove all build stuff"
    echo "    etcupdate         Run etcupdate (interactive)"
    echo "    init              Initialize work directories"
    echo "    install-kernel    Install a built kernel"
    echo "    install-sets      Install system sets"
    echo "    update-srcs       Use CVS to update source directories"
}

err() {
    echo "$progname: $*"
    exit 1
}

# --------------------------------------------------------------------
# Checks
# --------------------------------------------------------------------

check_noroot() {
    if [ "`id -un`" != "$USER" ]; then
        if [ "$autosu" = "yes" ]; then
            echo "$progname: downgrading privileges to \`$USER'"
            su -l $USER -c "@PREFIX@/bin/sysbuild $allargs"
            if [ $? -ne 0 ]; then
                err "cannot switch privileges; aborting"
            fi
            # XXX: After su, terminate inmediately.
            exit 0
        else
            err "this target must be run as \`$USER' user (use the \`-s' flag)"
        fi
    fi
}

check_root() {
    if [ `id -u` -ne 0 ]; then
        if [ "$autosu" = "yes" ]; then
            echo "$progname: becoming root"
            su -l root -c "@PREFIX@/bin/sysbuild $allargs"
            if [ $? -ne 0 ]; then
                err "cannot switch privileges; aborting"
            fi
            # XXX: After su, terminate inmediately.
            exit 0
        else
            err "this target must be run as root (use the \`-s' flag)"
        fi
    fi
}

check_init() {
    _ok=1
    if [ ! -d $HOMEDIR ]; then _ok=0; fi
    if [ ! -d $BUILDDIR ]; then _ok=0; fi
    if [ ! -d $BUILDDIR/kernel ]; then _ok=0; fi
    if [ ! -d $BUILDDIR/obj ]; then _ok=0; fi
    if [ ! -d $BUILDDIR/root ]; then _ok=0; fi
    if [ ! -d $BUILDDIR/tools ]; then _ok=0; fi
    if [ $_ok -eq 0 ]; then
        err "trees not initialized; use the \`init' target first"
    fi
}

# --------------------------------------------------------------------
# Kernel related functions
# --------------------------------------------------------------------

sysbuild_build_kernels() {
    check_noroot
    check_init

    _confs="$*"
    if [ -z "$_confs" ]; then
        _confs="$KERNCONF"
    fi

    sysbuild_build_tools

    _log=`mktemp /tmp/sysbuild.XXXX`
    if [ "$MAIL_CMDLOG" = "yes" ]; then
        echo "Logging to $_log (will be removed later)"
    else
        echo "Logging to $_log (will NOT be removed later)"
    fi
    echo
    for _k in $_confs; do
        if [ ! -f "$KERNCONFDIR/$_k" ]; then
            echo "No such kernel configuration $_k"
        elif [ "$fast" = "yes" -a -d $BUILDDIR/kernel/$_k ]; then
            cd $BUILDDIR/kernel/$_k
            printf "Buildling kernel $_k (fast mode):"
            $BUILDDIR/tools/bin/nbmake-`uname -m` BSDSRCDIR=$SRCDIR OBJMACHINE=yes MKOBJDIRS=yes >> $_log 2>&1
            if [ $? -ne 0 ]; then
                echo " failed."
            else
                echo " done."
                echo "Kernel MD5: `md5 netbsd`"
            fi
        else
            printf "Configuring kernel $_k:"
            mkdir -p $BUILDDIR/kernel/$_k
            $BUILDDIR/tools/bin/nbconfig -s $SRCDIR/sys -b $BUILDDIR/kernel/$_k $KERNCONFDIR/$_k >> $_log 2>&1
            if [ $? -ne 0 ]; then
                echo " failed."
            else
                echo " done."
                cd $BUILDDIR/kernel/$_k

                printf "Cleaning kernel $_k:"
                $BUILDDIR/tools/bin/nbmake-`uname -m` BSDSRCDIR=$SRCDIR OBJMACHINE=yes MKOBJDIRS=yes cleandir >> $_log 2>&1
                echo " done."

                printf "Depending kernel $_k:"
                $BUILDDIR/tools/bin/nbmake-`uname -m` BSDSRCDIR=$SRCDIR OBJMACHINE=yes MKOBJDIRS=yes depend >> $_log 2>&1
                if [ $? -ne 0 ]; then
                    echo " failed."
                else
                    echo " done."

                    printf "Buildling kernel $_k:"
                    $BUILDDIR/tools/bin/nbmake-`uname -m` BSDSRCDIR=$SRCDIR OBJMACHINE=yes MKOBJDIRS=yes >> $_log 2>&1
                    if [ $? -ne 0 ]; then
                        echo " failed."
                    else
                        echo " done."
                        echo "Kernel MD5: `md5 netbsd`"
                    fi
                fi
            fi
        fi
        echo
    done

    if [ "$MAIL_CMDLOG" = "yes" ]; then
        echo "Command log follows:"
        cat $_log
        rm -f $_log
    fi
}

sysbuild_install_kernel() {
    check_root
    check_init

    _conf="$*"
    if [ -z "$_conf" ]; then
        _conf="$KERNCONF"
    fi
    _conf=`echo $_conf | cut -d ' ' -f 1`

    if [ ! -f $BUILDDIR/kernel/$_conf/netbsd ]; then
        err "kernel $_conf is not built."
    else
        cd $BUILDDIR/kernel/$_conf
        echo "Kernel MD5: `md5 netbsd`"
        echo "Installing $_conf kernel:"
        $BUILDDIR/tools/bin/nbmake-`uname -m` BSDSRCDIR=$SRCDIR OBJMACHINE=yes MKOBJDIRS=yes install
    fi
}

# --------------------------------------------------------------------
# Release related functions
# --------------------------------------------------------------------

sysbuild_build_release() {
    check_noroot
    check_init

    _log=`mktemp /tmp/sysbuild.XXXX`

    if [ "$fast" = "no" ]; then
        sysbuild_clean
    fi
    sysbuild_build_tools
    if [ "$MAIL_CMDLOG" = "yes" ]; then
        echo "Logging to $_log (will be removed later)"
    else
        echo "Logging to $_log (will NOT be removed later)"
    fi
    printf "Building full release:"
    mkdir -p $RELEASEDIR
    cd $SRCDIR
    if [ "$fast" = "yes" ]; then
        BSDSRCDIR=$SRCDIR BSDOBJDIR=$BUILDDIR/obj OBJMACHINE=yes MKOBJDIRS=yes ./build.sh -T $BUILDDIR/tools -D $BUILDDIR/root -R $RELEASEDIR -U -u >> $_log 2>&1
    else
        BSDSRCDIR=$SRCDIR BSDOBJDIR=$BUILDDIR/obj OBJMACHINE=yes MKOBJDIRS=yes ./build.sh -T $BUILDDIR/tools -D $BUILDDIR/root -R $RELEASEDIR -U >> $_log 2>&1
    fi
    if [ $? -ne 0 ]; then
        echo " failed."
    else
        echo " done."
    fi

    if [ "$MAIL_CMDLOG" = "yes" ]; then
        echo "Command log follows:"
        cat $_log
        rm -f $_log
    fi
}

sysbuild_build_sets() {
    check_noroot
    check_init

    _log=`mktemp /tmp/sysbuild.XXXX`

    if [ "$fast" = "no" ]; then
        sysbuild_clean
    fi
    sysbuild_build_tools
    if [ "$MAIL_CMDLOG" = "yes" ]; then
        echo "Logging to $_log (will be removed later)"
    else
        echo "Logging to $_log (will NOT be removed later)"
    fi
    printf "Building system:"
    cd $SRCDIR
    if [ "$fast" = "yes" ]; then
        BSDSRCDIR=$SRCDIR BSDOBJDIR=$BUILDDIR/obj OBJMACHINE=yes MKOBJDIRS=yes ./build.sh -T $BUILDDIR/tools -d -D $BUILDDIR/root -U >> $_log 2>&1
    else
        BSDSRCDIR=$SRCDIR BSDOBJDIR=$BUILDDIR/obj OBJMACHINE=yes MKOBJDIRS=yes ./build.sh -T $BUILDDIR/tools -d -D $BUILDDIR/root -U -u >> $_log 2>&1
    fi
    if [ $? -ne 0 ]; then
        echo " failed."
    else
        echo " done."

        printf "Making sets:"
        mkdir -p $RELEASEDIR/binary/sets
        cd $SRCDIR/distrib/sets
        $BUILDDIR/tools/bin/nbmake-`uname -m` sets BSDSRCDIR=$SRCDIR OBJMACHINE=yes MKOBJDIRS=yes TOOLDIR=$BUILDDIR/tools DESTDIR=$BUILDDIR/root RELEASEDIR=$RELEASEDIR UNPRIVED=yes >> $_log 2>&1
        if [ $? -ne 0 ]; then
            echo " failed."
        else
            echo " done."
        fi
    fi

    if [ "$MAIL_CMDLOG" = "yes" ]; then
        echo "Command log follows:"
        cat $_log
        rm -f $_log
    fi
}

sysbuild_install_sets() {
    check_root
    check_init

    for _s in $SETS; do
        printf "Installing $_s:"
        if [ ! -f $RELEASEDIR/binary/sets/$_s ]; then
            echo " not built yet"
        else
            cd / && tar xzpf $RELEASEDIR/binary/sets/$_s > /dev/null 2>&1
            if [ $? -ne 0 ]; then
                echo " failed."
            else
                echo " done."
            fi
        fi
    done
    echo
    echo "You MUST now run \`sysbuild etcupdate' by hand to update /etc."
}

sysbuild_build_tools() {
    check_noroot
    check_init

    _log=`mktemp /tmp/sysbuild.XXXX`

    if [ -x "$BUILDDIR/tools/bin/nbmake-`uname -m`" ]; then
        echo "$progname: tools seem to be up to date"
        return 0
    fi

    if [ "$MAIL_CMDLOG" = "yes" ]; then
        echo "Logging to $_log (will be removed later)"
    else
        echo "Logging to $_log (will NOT be removed later)"
    fi
    printf "Building tools (toolchain):"
    cd $SRCDIR
    rm -rf $BUILDDIR/tools/*
    BSDSRCDIR=$SRCDIR BSDOBJDIR=$BUILDDIR/obj OBJMACHINE=yes MKOBJDIRS=yes ./build.sh -T $BUILDDIR/tools -t >> $_log 2>&1
    if [ $? -ne 0 ]; then
        echo " failed."
    else
        echo " done."
    fi

    if [ "$MAIL_CMDLOG" = "yes" ]; then
        echo "Command log follows:"
        cat $_log
        rm -f $_log
    fi
}

# --------------------------------------------------------------------
# Cleanup functions
# --------------------------------------------------------------------

sysbuild_clean() {
    check_noroot
    check_init

    printf "Cleaning $BUILDDIR/obj contents:"
    rm -rf $BUILDDIR/obj/*
    echo " done."

    printf "Cleaning $BUILDDIR/root contents:"
    rm -rf $BUILDDIR/root/*
    echo " done."

    printf "Cleaning $BUILDDIR/tools contents:"
    if [ "$KEEP_TOOLS" = "yes" ]; then
        echo " kept."
    else
        rm -rf $BUILDDIR/tools/*
        echo " done."
    fi
}

sysbuild_destroy() {
    check_root

    printf "Destroying $BUILDDIR:"
    rm -rf $BUILDDIR
    echo " done."
}

sysbuild_etcupdate() {
    check_root

    tmp=`mktemp -d /tmp/sysbuild.XXXX`
    if [ ! -f $RELEASEDIR/binary/sets/etc.tgz ]; then
        err "etc.tgz is not yet built."
    fi
    printf "Backing up /etc to /etc.old:"
    rm -rf /etc.old
    cp -rf /etc /etc.old > /dev/null 2>&1
    echo " done."
    printf "Unpacking etc.tgz:"
    cd $tmp && tar xzpf $RELEASEDIR/binary/sets/etc.tgz > /dev/null 2>&1
    if [ $? -ne 0 ]; then
        echo " failed."
    else
        echo " done."
        etcupdate -b $tmp
        rm -rf $tmp
    fi
}

# --------------------------------------------------------------------
# Initialization and configuration
# --------------------------------------------------------------------

sysbuild_init() {
    check_root

    printf "Initializing $HOMEDIR:"
    mkdir -p $HOMEDIR
    chown $USER:$OBJGROUP $HOMEDIR
    if [ ! -f $HOMEDIR/.profile ]; then
        cp @EGDIR@/profile $HOMEDIR/.profile
        cp @EGDIR@/profile $HOMEDIR/.shrc
    fi
    echo " done."

    printf "Initializing $BUILDDIR:"
    # Make main directory
    mkdir -p $BUILDDIR
    chown $USER:$OBJGROUP $BUILDDIR
    chmod 750 $BUILDDIR
    # Make kernel work area
    mkdir -p $BUILDDIR/kernel
    chown $USER:$OBJGROUP $BUILDDIR/kernel
    chmod 750 $BUILDDIR/kernel
    # Make obj work area
    mkdir -p $BUILDDIR/obj
    chown $USER:$OBJGROUP $BUILDDIR/obj
    chmod 750 $BUILDDIR/obj
    # Make root work area
    mkdir -p $BUILDDIR/root
    chown $USER:$OBJGROUP $BUILDDIR/root
    chmod 750 $BUILDDIR/root
    # Make tools directory
    mkdir -p $BUILDDIR/tools
    chown $USER:$OBJGROUP $BUILDDIR/tools
    chmod 750 $BUILDDIR/tools
    echo " done."
}

sysbuild_config() {
    check_root

    _conf="$1"
    if [ -z "$_conf" ]; then
        _conf="default"
    fi
    _conffile="@SYSBUILD_HOMEDIR@/$_conf.conf"

    if [ ! -f "$_conffile" ]; then
        printf "Copying template to $_conffile:"
        cp @EGDIR@/default.conf $_conffile
        chmod 644 $_conffile
        echo " done."
    fi

    if [ -z "$EDITOR" ]; then
        vi $_conffile
    else
        $EDITOR $_conffile
    fi
}

sysbuild_config_kernel() {
    check_root

    _conf="$1"
    if [ -z "$_conf" ]; then
        err "kernel name must be specified"
    fi
    _conffile="@SYSBUILD_HOMEDIR@/$_conf"

    if [ ! -f "$_conffile" ]; then
        printf "Copying template to $_conffile:"
        _generic="$SRCDIR/sys/arch/`uname -p`/conf/GENERIC"
        cp "$_generic" $_conffile
        chmod 644 $_conffile
        echo " done."
    fi

    if [ -z "$EDITOR" ]; then
        vi $_conffile
    else
        $EDITOR $_conffile
    fi
}

# --------------------------------------------------------------------
# Source related functions
# --------------------------------------------------------------------

sysbuild_clean_srcs() {
    check_root

    _dirs="$*"
    if [ -z "$_dirs" ]; then
        _dirs="$CVSDIRS"
    fi

    for _d in $_dirs; do
        printf "Fixing ownerships and permissions of $_d:"
        chown -R $CVSDIRS_OWNER:$CVSDIRS_GROUP $_d
        if [ -n "$CVSDIRS_PERMS" ]; then
            chmod -R $CVSDIRS_PERMS $_d
        fi
        echo " done."
    done
}

sysbuild_update_srcs() {
    check_noroot

    _dirs="$*"
    if [ -z "$_dirs" ]; then
        _dirs="$CVSDIRS"
    fi

    for _d in $_dirs; do
        echo "Updating source tree $_d"
        cd $_d && CVS_RSH=ssh cvs -q -z6 update -dP
        echo
    done
}

# --------------------------------------------------------------------
# Main program
# --------------------------------------------------------------------

# Parse options
args=`getopt c:fms $*`
if [ $? != 0 ]; then
    usage
    exit 1
fi
set -- $args
maillog="no"
autosu="no"
fast="no"
while [ $# -gt 0 ]; do
    case "$1" in
        -c)
            conffile="@SYSBUILD_HOMEDIR@/$2.conf"
            shift
            ;;
        -f)
            fast="yes"
            ;;
        -m)
            maillog="yes"
            maillogfile=`mktemp /tmp/sysbuild.XXXX`
            ;;
        -s)
            autosu="yes"
            ;;
        --)
            shift; break
            ;;
    esac
    shift
done

if [ $# -lt 1 ]; then
    usage
    exit 1
fi

target="$1"
shift

# Read configuration file.
if [ "$target" != "config" -a ! -f $conffile ]; then
    err "configuration file $conffile not found"
elif [ "$target" != "config" ]; then
    . $conffile
fi

# Parse targets.
case $target in
    build-kernels)
        if [ "$maillog" = "yes" ]; then
            sysbuild_build_kernels $* >> $maillogfile
        else
            sysbuild_build_kernels $*
        fi
        ;;
    build-release)
        if [ "$maillog" = "yes" ]; then
            sysbuild_build_release >> $maillogfile
        else
            sysbuild_build_release
        fi
        ;;
    build-sets)
        if [ "$maillog" = "yes" ]; then
            sysbuild_build_sets >> $maillogfile
        else
            sysbuild_build_sets
        fi
        ;;
    clean)
        if [ "$maillog" = "yes" ]; then
            sysbuild_clean >> $maillogfile
        else
            sysbuild_clean
        fi
        ;;
    clean-srcs)
        if [ "$maillog" = "yes" ]; then
            sysbuild_clean_srcs $* >> $maillogfile
        else
            sysbuild_clean_srcs $*
        fi
        ;;
    config)
        sysbuild_config $*
        ;;
    config-kernel)
        sysbuild_config_kernel $*
        ;;
    destroy)
        sysbuild_destroy
        ;;
    etcupdate)
        sysbuild_etcupdate
        ;;
    init)
        sysbuild_init
        ;;
    install-kernel)
        if [ "$maillog" = "yes" ]; then
            sysbuild_install_kernel >> $maillogfile
        else
            sysbuild_install_kernel
        fi
        ;;
    install-sets)
        if [ "$maillog" = "yes" ]; then
            sysbuild_install_sets >> $maillogfile
        else
            sysbuild_install_sets
        fi
        ;;
    update-srcs)
        if [ "$maillog" = "yes" ]; then
            sysbuild_update_srcs $* >> $maillogfile 2>&1
        else
            sysbuild_update_srcs $*
        fi
        ;;
    *)
        err "unknown target \`$target'"
        ;;
esac

if [ "$maillog" = "yes" ]; then
    mail -s "Output of $target target" $MAILTO < $maillogfile
    rm -f $maillogfile
fi

exit 0