summaryrefslogtreecommitdiff
path: root/configs/profile/root-image/root/customize_root_image.sh
blob: cbcf86812a58e63d834f25c25cf5c4fec3df4f83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash

### post-install chroot customization script ###

set -e -u
source /root/customize_root_image-constants.inc


# configure timezone and locales
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
for locale in ${LOCALES} ; do sed -i "s/#${locale}/${locale}/" /etc/locale.gen ; done ;
locale-gen

# configure sudo
chmod 750 /etc/sudoers.d
chmod 440 /etc/sudoers.d/g_wheel

# configure pacman
sed -i "s|#Server|Server|" /etc/pacman.d/mirrorlist
# KLUDGE begin  # FIXME: https://labs.parabola.nu/issues/1527
if   [[ "${arch}" == "i686" ]]
then echo "Server = https://repo.parabola.nu/\$repo/os/\$arch" > /etc/pacman.d/mirrorlist
fi
# KLUDGE end
# KLUDGE begin temp until next calamares rebuild # FIXME:
cp /etc/pacman.conf /etc/pacman-offline.conf ; cp /etc/pacman.conf /etc/pacman-online.conf
sed -i 's|requiredStorage:.*|requiredStorage:    8.9|' /usr/share/calamares/modules/welcome.conf
# KLUDGE end

# configure services
if   [[ "${iso_init}" == 'systemd' ]]
then # delete files that are specific to other init systems
     rm ${SYSTEMD_DELETE_FILES}

     # enable services
     systemctl enable ${SYSTEMD_SERVICES}
elif [[ "${iso_init}" == 'openrc' ]]
then # delete files that are specific to other init systems
     rm ${OPENRC_DELETE_FILES}

     # enable services
     for service in ${OPENRC_SERVICES} ; do rc-update add ${service} default ; done ;

     # create the dbus user and group if it does not exist
     if [[ "$(grep 'dbus' /etc/group )" = "" ]] ; then groupadd -g 81 dbus ; fi ;
     if [[ "$(grep 'dbus' /etc/passwd)" = "" ]] ; then useradd -r -s /sbin/nologin -g 81 -u 81 dbus ; fi ;
else echo "invalid \$iso_init for services '${iso_init}'"
     exit 1
fi

# configure root user, system defaults, and login session
usermod -s ${DEFAULT_SHELL} root 2> /dev/null
sed -i "s|_EDITION_TITLE_|${iso_title}|"                                        /etc/motd
sed -i "s|_NETWORK_MOTD_MSG_|${NETWORK_MOTD_MSG}| ; s|^>>>>\(.*\)|    \1|g"     /etc/motd
sed -i "s|PRETTY_NAME=.*|PRETTY_NAME=\"${PRETTY_NAME}\"|"                       /usr/lib/os-release
echo "VERSION=\"$(   echo ${iso_title}   | cut -d ' ' -f  6             )\"" >> /usr/lib/os-release
echo "VERSION_ID=\"$(echo ${iso_title}   | cut -d ' ' -f  6             )\"" >> /usr/lib/os-release
echo "VARIANT=\"$(   echo ${PRETTY_NAME} | cut -d ' ' -f -3 --complement)\"" >> /usr/lib/os-release
echo "VARIANT_ID=\"${iso_init}-${iso_gui}\""                                 >> /usr/lib/os-release

# configure CLI login session
if   [[ "${iso_gui}" == 'cli' ]]
then cp ${ROOT_SKEL_FILES} /root/
     sed -i "s|_DESKTOP_SESSION_||" /root/.bash_profile

else # configure GUI login session and live user
     [[ -n "$(id ${LIVE_USER} 2> /dev/null)" ]] && userdel -r ${LIVE_USER} 2> /dev/null
     useradd -m -p "" -g users -G "${USER_GROUPS}" -s ${DEFAULT_SHELL} ${LIVE_USER}
     if   [[ "${iso_init}" == 'systemd' ]]
     then sed -i "s|--autologin root|--autologin ${LIVE_USER}|" /etc/systemd/system/getty@tty1.service.d/autologin.conf
     elif [[ "${iso_init}" == 'openrc' ]]
     then sed -i "s|--autologin root|--autologin ${LIVE_USER}|" /etc/conf.d/agetty.tty1
     else echo "invalid \$iso_init for --autologin '${iso_init}'"
     fi

     # configure desktop environment
     sed -i "s|_EDITION_TITLE_|${PRETTY_NAME}|" /home/${LIVE_USER}/.config/autostart/autostart.sh
     sed -i "s|--question|--info|"              /home/${LIVE_USER}/.config/autostart/autostart.sh
     sed -i "s|--cancel-label=.*|\&|"           /home/${LIVE_USER}/.config/autostart/autostart.sh
     sed -i "s|/issue-tracker/|/isos/|"         /home/${LIVE_USER}/Desktop/bug-tracker.desktop
     if   [[ "${iso_gui}" == 'lxde' ]]
     then rm -f /etc/xdg/autostart/octopi-notifier.desktop 2> /dev/null
          sed -i "s|_DESKTOP_SESSION_|LXDE|"    /home/${LIVE_USER}/.bash_profile
          sed -i "s|_DESKTOP_SESSION_|LXDE|"    /home/${LIVE_USER}/.dmrc
          touch /home/${LIVE_USER}/Desktop/parabola-installer.desktop ; sleep 2 ; # sort
          touch /home/${LIVE_USER}/Desktop/parabola-irc.desktop       ; sleep 2 ; # sort
          touch /home/${LIVE_USER}/Desktop/bug-tracker.desktop                    # sort
     elif [[ "${iso_gui}" == 'mate' ]]
     then sed -i "s|_DESKTOP_SESSION_|mate|"    /home/${LIVE_USER}/.bash_profile
          sed -i "s|_DESKTOP_SESSION_|mate|"    /home/${LIVE_USER}/.dmrc
     else echo "invalid \$iso_gui for _DESKTOP_SESSION_ '${iso_gui}'"
          exit 1
     fi
fi