15-initsetup: keep a backup of the original runlevel.conf file
[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 # keep a backup of the original runlevel.conf file for reference
13 # but only save it as /etc/runlevel.conf.original if it's not the
14 # according livecd version, this should prevent from overriding
15 # /etc/runlevel.conf.original if re-running grml-live -b ...
16 if ! cmp /etc/runlevel.conf /etc/runlevel.conf.livecd 1>/dev/null || \
17    ! cmp /etc/runlevel.conf /etc/runlevel.conf.livecd.small 1>/dev/null ; then
18
19    # make sure to store old backup files if they differ as well
20    if [ -r $target/etc/runlevel.conf.original ] ; then
21       if ! cmp $target/etc/runlevel.conf $target/etc/runlevel.conf.original 1>/dev/null ; then
22          cp $target/etc/runlevel.conf.original $target/etc/runlevel.conf.original."$(date +%Y%m%d_%k:%M:%S)"
23       fi
24    fi
25
26    cp $target/etc/runlevel.conf $target/etc/runlevel.conf.original
27 fi
28
29 # if we have a small ISO let's adjust runlevel.conf:
30 if [ -n "$GRML_NAME" ] ; then
31    if echo "$GRML_NAME" | grep -q small ; then
32       cp $target/etc/runlevel.conf.livecd.small $target/etc/runlevel.conf
33    else
34       cp $target/etc/runlevel.conf.livecd $target/etc/runlevel.conf
35    fi
36 fi
37
38 ## END OF FILE #################################################################
39 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3