rc.local.in 2.52 KB
Newer Older
Nikos Skalkotos's avatar
Nikos Skalkotos committed
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
#!/bin/bash

# Copyright 2011 GRNET S.A. All rights reserved.
#
# 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.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
#
# The views and conclusions contained in the software and documentation are
# those of the authors and should not be interpreted as representing official
# policies, either expressed or implied, of GRNET S.A.

Nikos Skalkotos's avatar
Nikos Skalkotos committed
32
. @datarootdir@/@base_name@/common.sh
Nikos Skalkotos's avatar
Nikos Skalkotos committed
33

Nikos Skalkotos's avatar
Nikos Skalkotos committed
34
35
set -e

Nikos Skalkotos's avatar
Nikos Skalkotos committed
36
37
38
# terminate helper vm when the script exits
CLEANUP+=("telinit 0")

Nikos Skalkotos's avatar
Nikos Skalkotos committed
39
40
41
42
43
if [ ! -b $FLOPPY_DEV ]; then
    log_error "Floppy device is not present!"
fi

floppy=$(mktemp -d --tmpdir floppy.XXXXXXXX)
Nikos Skalkotos's avatar
Nikos Skalkotos committed
44
CLEANUP+=("rmdir $floppy")
Nikos Skalkotos's avatar
Nikos Skalkotos committed
45

Nikos Skalkotos's avatar
Nikos Skalkotos committed
46
47
48
49
50
mount $FLOPPY_DEV $floppy
CLEANUP+=("umount $floppy")

if [ -f $floppy/rules ]; then
    source $floppy/rules
Nikos Skalkotos's avatar
Nikos Skalkotos committed
51
else
Nikos Skalkotos's avatar
Nikos Skalkotos committed
52
    log_error "Floppy does not contain \`rules\' file"
53
fi
Nikos Skalkotos's avatar
Nikos Skalkotos committed
54

Nikos Skalkotos's avatar
Nikos Skalkotos committed
55
# Image mount point...
Nikos Skalkotos's avatar
Nikos Skalkotos committed
56
57
target=$(mktemp -d --tmpdir target.XXXXXXXX) || exit 1
CLEANUP+=("rmdir $target")
Nikos Skalkotos's avatar
Nikos Skalkotos committed
58

59
export SNF_IMAGE_TARGET=$target
Nikos Skalkotos's avatar
Nikos Skalkotos committed
60

61
62
63
if [ ! -d "/usr/lib/snf-image/tasks" ]; then
    log_error "snf-image/tasks directory is missing"
fi
Nikos Skalkotos's avatar
Nikos Skalkotos committed
64

65
66
67
RUN_PARTS=$(which run-parts)
if [ -z "$RUN_PARTS" ]; then
    log_error "run-parts programe is missing from the system"
Nikos Skalkotos's avatar
Nikos Skalkotos committed
68
69
fi

70
71
72
echo "Execute all snf-image tasks...." 
$RUN_PARTS -v --exit-on-error "/usr/lib/snf-image/tasks"

73
74
echo "SUCCESS" > $RESULT

Nikos Skalkotos's avatar
Nikos Skalkotos committed
75
76
77
78
79
80
81
cleanup
trap - EXIT

# never called...
exit 0

# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :