15-initsetup: improve check for empty GRML_NAME variable to make it compatible with...
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 15-initsetup
1 #!/bin/sh
2 # Filename:      /etc/grml/fai/config/scripts/GRMLBASE/15-initsetup
3 # Purpose:       configure init system for the live-system
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 ################################################################################
8
9 set -u
10 set -e
11
12 GRML_NAME="${GRML_NAME:-grml}"
13
14 if ! [ -r $target/etc/runlevel.conf ] ; then
15    echo 'Warning: /etc/runlevel.conf does not exist...'
16    echo '... assuming we do not have file-rc, skipping 15-initsetup'
17    exit 0
18 fi
19
20 # keep a backup of the original runlevel.conf file for reference
21 # but only save it as /etc/runlevel.conf.original if it's not the
22 # according live system version, this should prevent from overriding
23 # /etc/runlevel.conf.original if re-running grml-live with -b option.
24 if ! cmp $target/etc/runlevel.conf $target/etc/runlevel.conf.livecd 1>/dev/null || \
25    ! cmp $target/etc/runlevel.conf $target/etc/runlevel.conf.livecd.small 1>/dev/null ; then
26
27    # make sure to store old backup files if they differ as well
28    if [ -r $target/etc/runlevel.conf.original ] ; then
29       if ! cmp $target/etc/runlevel.conf $target/etc/runlevel.conf.original 1>/dev/null ; then
30          cp $target/etc/runlevel.conf.original $target/etc/runlevel.conf.original."$(date +%Y%m%d_%k:%M:%S)"
31       fi
32    fi
33
34    cp $target/etc/runlevel.conf $target/etc/runlevel.conf.original
35 fi
36
37 # if we have a small ISO let's adjust runlevel.conf:
38 if [ -n "$GRML_NAME" ] ; then
39    if echo "$GRML_NAME" | grep -q small ; then
40       cp $target/etc/runlevel.conf.livecd.small $target/etc/runlevel.conf
41    else
42       cp $target/etc/runlevel.conf.livecd $target/etc/runlevel.conf
43    fi
44 fi
45
46 ## END OF FILE #################################################################
47 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3