Drop support for lenny, squeeze, wheezy, jessie, stretch + buster Debian releases...
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 15-initsetup
1 #!/bin/bash
2 # Filename:      ${GRML_FAI_CONFIG}/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 . "$GRML_LIVE_CONFIG"
12
13 systemd_setup() {
14   fcopy -M -i -B -v -r /etc/systemd
15
16   echo "Enabling user '$USERNAME' for autologin"
17   sed -i "s/\$USERNAME/$USERNAME/" "$target"/etc/systemd/system/getty@tty*.service.d/override.conf
18
19   # workaround for #992847 to workaround /lib/systemd -> /usr/lib/systemd transition
20   $ROOTCMD rm -f /etc/systemd/system/syslog.service
21
22   $ROOTCMD systemctl preset-all
23   $ROOTCMD systemctl set-default grml-boot.target
24 }
25
26 file_rc_setup() {
27   if ! [ -r "${target}"/etc/runlevel.conf ] ; then
28      echo 'Warning: /etc/runlevel.conf does not exist...'
29      echo '... assuming we do not have file-rc, skipping 15-initsetup'
30      exit 0
31   fi
32
33   # keep a backup of the original runlevel.conf file for reference
34   if [ -r "${target}"/etc/runlevel.conf.original ] ; then
35     # make sure to store old backup files if they differ as well
36     if ! cmp "${target}"/etc/runlevel.conf "${target}"/etc/runlevel.conf.original >/dev/null ; then
37       cp "${target}"/etc/runlevel.conf.original "${target}/etc/runlevel.conf.original.$(date +%Y%m%d_%k:%M:%S)"
38     fi
39   fi
40
41   cp "${target}"/etc/runlevel.conf "${target}"/etc/runlevel.conf.original
42
43   # provide Grml's default file-rc configuration
44   fcopy -v /etc/runlevel.conf
45
46   # provide Grml's inittab configuration
47   fcopy -v /etc/inittab
48   sed -i "s/\$USERNAME\$/${USERNAME}/" "${target}"/etc/inittab
49
50   # provide Grml's bootlocal init scripts
51   fcopy -v -mroot,root,0755 /etc/init.d/bootlocal.first
52   fcopy -v -mroot,root,0755 /etc/init.d/bootlocal.middle
53   fcopy -v -mroot,root,0755 /etc/init.d/bootlocal.last
54 }
55
56 if ifclass FILE_RC ; then
57   file_rc_setup
58 else
59   systemd_setup
60 fi
61
62 ## END OF FILE #################################################################
63 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2