Revision bf7c33b2

b/helper/Makefile.am
1
SUBDIRS = tasks
2

  
3
base_name=$(subst -helper,,$(PACKAGE))
4
initdir=$(sysconfdir)
5
commondir=$(datarootdir)/$(base_name)
6
export base_name
1
commondir=$(datarootdir)/$(PACKAGE)
2
scriptsdir=$(libdir)/$(PACKAGE)
3
tasksdir=$(scriptsdir)/tasks
7 4
export commondir
5
export scriptsdir
6
export tasksdir
7

  
8
SUBDIRS = tasks
8 9

  
9 10
dist_doc_DATA = COPYING AUTHORS ChangeLog
10
dist_init_SCRIPTS = rc.local
11
dist_common_SCRIPTS= snf-passtohash.py
11
dist_bin_SCRIPTS = snf-image-helper
12
dist_scripts_SCRIPTS= snf-passtohash.py
12 13
dist_common_DATA = common.sh
13 14

  
14 15
edit = sed \
15 16
	-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
16 17
	-e 's|@localstatedir[@]|$(localstatedir)|g' \
17 18
	-e 's|@datarootdir[@]|$(datarootdir)|g' \
18
	-e 's|@base_name[@]|$(base_name)|g'\
19
	-e 's|@commondir[@]|$(commondir)|g' \
19 20
	-e 's|@RESIZE2FS[@]|$(RESIZE2FS)|g' \
20 21
	-e 's|@XMLSTARLET[@]|$(XMLSTARLET)|g'
21 22

  
22 23
%:%.in Makefile
23
	@echo "Real Path is: $(rootdir)"
24 24
	rm -f $@ $@.tmp
25 25
	srcdir=''; \
26 26
		   test -f ./$@.in || srcdir=$(srcdir)/; \
27 27
		   $(edit) $${srcdir}$@.in >$@.tmp
28 28
	mv $@.tmp $@
29 29

  
30
CLEANFILES = rc.local
30
CLEANFILES = snf-image-helper
/dev/null
1
#!/bin/bash
2

  
3
# Copyright 2011 GRNET S.A. All rights reserved.
4
#
5
# Redistribution and use in source and binary forms, with or without
6
# modification, are permitted provided that the following conditions
7
# are met:
8
#
9
#   1. Redistributions of source code must retain the above copyright
10
#      notice, this list of conditions and the following disclaimer.
11
#
12
#  2. Redistributions in binary form must reproduce the above copyright
13
#     notice, this list of conditions and the following disclaimer in the
14
#     documentation and/or other materials provided with the distribution.
15
#
16
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26
# SUCH DAMAGE.
27
#
28
# The views and conclusions contained in the software and documentation are
29
# those of the authors and should not be interpreted as representing official
30
# policies, either expressed or implied, of GRNET S.A.
31

  
32
. @datarootdir@/@base_name@/common.sh
33

  
34
set -e
35

  
36
# terminate helper vm when the script exits
37
CLEANUP+=("telinit 0")
38

  
39
if [ ! -b $FLOPPY_DEV ]; then
40
    log_error "Floppy device is not present!"
41
fi
42

  
43
floppy=$(mktemp -d --tmpdir floppy.XXXXXXXX)
44
CLEANUP+=("rmdir $floppy")
45

  
46
mount $FLOPPY_DEV $floppy
47
CLEANUP+=("umount $floppy")
48

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

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

  
59
export SNF_IMAGE_TARGET=$target
60

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

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

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

  
73
echo "SUCCESS" > $RESULT
74

  
75
cleanup
76
trap - EXIT
77

  
78
# never called...
79
exit 0
80

  
81
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
b/helper/snf-image-helper.in
1
#!/bin/bash
2

  
3
# Copyright 2011 GRNET S.A. All rights reserved.
4
#
5
# Redistribution and use in source and binary forms, with or without
6
# modification, are permitted provided that the following conditions
7
# are met:
8
#
9
#   1. Redistributions of source code must retain the above copyright
10
#      notice, this list of conditions and the following disclaimer.
11
#
12
#  2. Redistributions in binary form must reproduce the above copyright
13
#     notice, this list of conditions and the following disclaimer in the
14
#     documentation and/or other materials provided with the distribution.
15
#
16
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26
# SUCH DAMAGE.
27
#
28
# The views and conclusions contained in the software and documentation are
29
# those of the authors and should not be interpreted as representing official
30
# policies, either expressed or implied, of GRNET S.A.
31

  
32
. @commondir@/common.sh
33

  
34
set -e
35

  
36
# terminate helper vm when the script exits
37
CLEANUP+=("telinit 0")
38

  
39
if [ ! -b $FLOPPY_DEV ]; then
40
    log_error "Floppy device is not present!"
41
fi
42

  
43
floppy=$(mktemp -d --tmpdir floppy.XXXXXXXX)
44
CLEANUP+=("rmdir $floppy")
45

  
46
mount $FLOPPY_DEV $floppy
47
CLEANUP+=("umount $floppy")
48

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

  
55
# Image mount point...
56
target=$(mktemp -d --tmpdir target.XXXXXXXX)
57
CLEANUP+=("rmdir $target")
58

  
59
export SNF_IMAGE_TARGET=$target
60

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

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

  
70
echo "Execute all snf-image tasks...." 
71
$RUN_PARTS -v --exit-on-error "@tasksdir@"
72

  
73
echo "SUCCESS" > $RESULT
74

  
75
cleanup
76
trap - EXIT
77

  
78
# never called...
79
exit 0
80

  
81
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
b/helper/tasks/Makefile.am
1
tasksdir=${libdir}/$(base_name)/tasks
1
tasksdir=$(libdir)/$(PACKAGE)/tasks
2 2

  
3 3
dist_tasks_SCRIPTS = \
4 4
		10ResizeUnmounted \
......
12 12
		50ChangePassword \
13 13
		80UmountImage
14 14

  
15

  
16 15
edit = sed \
17 16
	   -e 's|@sysconfdir[@]|$(sysconfdir)|g' \
18 17
	   -e 's|@localstatedir[@]|$(localstatedir)|g' \

Also available in: Unified diff