Use GRML_FAI_CONFIG instead of FAI_CONFIGDIRl
[grml-live.git] / grml-live
1 #!/bin/sh
2 # Filename:      grml-live
3 # Purpose:       build process script for generating a (grml based) Linux Live-ISO
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2 or any later version.
7 # Latest change: Sat Sep 15 18:22:07 CEST 2007 [mika]
8 ################################################################################
9
10 # read configuration files, set some misc variables {{{
11
12 export LANG=C
13 export LC_ALL=C
14
15 # exit on any error:
16 set -e
17
18 # we need root permissions for the build-process:
19 if [ "$(id -u 2>/dev/null)" != 0 ] ; then
20    echo "Error: please run this script with uid 0 (root)." >&2
21    exit 1
22 fi
23
24 VERBOSE=''
25 FORCE=''
26 DEBUG='' # TODO / FIXME - not implemented yet
27
28 # source main configuration file:
29 . /etc/grml/grml-live.conf
30
31 PN=$(basename $0)
32 TMPFILE=$(mktemp)
33 # }}}
34
35 # clean exit {{{
36 bailout() {
37   rm -f "$TMPFILE"
38   [ -n "$1" ] && EXIT="$1" || EXIT="1"
39   [ -n "$2" ] && echo "$2">&2
40   exit "$EXIT"
41 }
42 trap bailout 1 2 3 15
43 # }}}
44
45 # check for important variables {{{
46 [ -n "$GRML_FAI_CONFIG" ] || GRML_FAI_CONFIG=/etc/grml/fai
47 [ -n "$HOSTNAME" ] || HOSTNAME=grml
48 [ -n "$USERNAME" ] || USERNAME=grml
49 [ -n "$CLASSES" ] || CLASSES="GRML"
50 [ -n "$TARGET" ] || bailout 1 "${PN}: \$TARGET not specified. Please adjust /etc/grml/grml-live.conf. Exiting."
51 # }}}
52
53 # usage information {{{
54 usage()
55 {
56   echo "
57 $PN - build process script for generating a (grml based) Linux Live-ISO
58
59 Usage: $PN [-c <classe[s]>] [-t <target_directory>] [-F] [-h|--help] [addiontalarguments_for_fai]
60
61 Usage examples:
62
63     $PN
64     $PN -c GRML -t /dev/shm/grml
65     $PN -c GRML,GRML_X -t /grml/chroot/grml_uncompressed
66     $PN -c GRML
67
68 More details: man grml-live
69               /usr/share/doc/grml-live/grml-live.html
70
71 Please send your bug reports, feedback,.. to the grml-team.
72 http://grml.org/bugs/
73 "
74 }
75 # }}}
76
77 # command line parsing {{{
78
79 while getopts ?c:f:t:Fhv: opt; do
80   case "$opt" in
81     c) CLASSES="$OPTARG" ;;
82     F) FORCE=1 ;;
83     h) usage ; bailout 0 ;;
84     t) TARGET="$OPTARG" ;;
85     v) VERBOSE=1 ;;
86     ?) echo "invalid option -$OPTARG" >&2; bailout 1 ;;
87   esac
88 done
89 shift $(($OPTIND - 1))  # set ARGV to the first not parsed commandline parameter
90 FAI_ARGS="$*"
91
92 # }}}
93
94 # some misc checks before executing FAI {{{
95 [ -n "$CLASSES" ] || bailout 1 "Error: \$CLASSES unset, please set it in /etc/grml/grml-live.conf or
96 specify it on the command line using the -c|--classes option."
97 [ -n "$TARGET" ] || bailout 1 "Error: \$TARGET unset, please set it in /etc/grml/grml-live.conf or
98 specify it on the command line using the -t|--target option."
99
100 if [ "$EXECUTE" != '1' ] ; then
101    echo "Error: please set EXECUTE=1 in /etc/grml/grml-live.conf to really execute grml-live.">&2
102    echo
103    echo "See 'man grml-live' for more details or execute '$PN --help'">&2
104    echo
105    bailout 1
106 fi
107 # }}}
108
109 # ask user whether the setup is ok {{{
110 if [ -z "$FORCE" ] ; then
111    echo
112    echo "$PN - check your configuration (or invoke using -F to force execution without prompting)"
113    echo
114    echo "  FAI classes:                  $CLASSES"
115    echo "  target / output directory:    $TARGET"
116    [ -n "$FAI_ARGS" ] && echo "  additional arguments for FAI: $FAI_ARGS"
117    echo
118    echo -n "Is this ok for you? [y/N] "
119    read a
120    if ! [ "$a" = 'y' -o "$a" = 'Y' ] ; then
121       bailout 1 "Exiting as requested."
122    fi
123    echo
124 fi
125 # }}}
126
127 if [ -n "$GRML_LIVE_SOURCES" ] ; then
128    echo "$GRML_LIVE_SOURCES" > /etc/grml/fai/apt/sources.list
129 fi
130
131 if [ -n "$FAI_DEBOOTSTRAP" ] ; then
132    sed -i "s#^FAI_DEBOOTSTRAP#FAI_DEBOOTSTRAP=$FAI_DEBOOTSTRAP#" /etc/grml/fai/make-fai-nfsroot.conf
133 fi
134
135 # execute FAI {{{
136 fai -v -C "$GRML_FAI_CONFIG" -c"$CLASSES" dirinstall "$TARGET" $FAI_ARGS
137 # }}}
138
139 ## END OF FILE #################################################################
140 # vim:foldmethod=marker ts=2 ft=sh ai expandtab tw=80 sw=2