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