@@ -39,6 +39,13 @@ _pkg_setupinitramfs() {
3939 return 1
4040}
4141
42+ # Do additional tweaks to the rootfs to be more user friendly, like creating a live user, etc.
43+ # Is redeclared depending of the package manager, with a noop declaration as fallback.
44+ _pkg_setup_livesys () {
45+ echo >&2 " WARNING: Not implemented"
46+ return 0
47+ }
48+
4249# ###### endregion INTERNAL_FUNCTIONS #######
4350
4451#
@@ -51,6 +58,7 @@ _pkg_setupinitramfs() {
5158# install
5259# remove
5360# setup-initramfs
61+ # setup-livesys
5462_command=$1
5563shift 2> /dev/null || {
5664 echo >&2 " ERROR: missing args"
@@ -87,6 +95,51 @@ elif [ -x "$(command -v dnf)" ]; then
8795 --force " $_initramfs_path " 2>&1 | grep -v -e " Operation not supported"
8896 unset -v _INSTALLED_KERNEL
8997 }
98+ _pkg_setuplivesys () {
99+ # DNF specific setup
100+ $_PKG_MANAGER_install livesys-scripts
101+ # Determine desktop environment. Must match one of /usr/libexec/livesys/sessions.d/livesys-{desktop_env}
102+ desktop_env=" "
103+ _session_file=" $( find /usr/share/wayland-sessions/ /usr/share/xsessions \
104+ -maxdepth 1 -type f -not -name ' *gamescope*.desktop' -and -name ' *.desktop' -printf ' %P' -quit) "
105+ case $_session_file in
106+ budgie* ) desktop_env=budgie ;;
107+ cosmic* ) desktop_env=cosmic ;;
108+ gnome* ) desktop_env=gnome ;;
109+ plasma* ) desktop_env=kde ;;
110+ sway* ) desktop_env=sway ;;
111+ xfce* ) desktop_env=xfce ;;
112+ * )
113+ echo >&2 " ERROR: No Livesys Environment Found"
114+ return 1
115+ ;;
116+ esac && unset -v _session_file
117+ sed -i " s/^livesys_session=.*/livesys_session=${desktop_env} /" /etc/sysconfig/livesys
118+ # Enable services
119+ systemctl enable livesys.service livesys-late.service
120+ # Set default time zone to prevent oddities with KDE clock
121+ cat > /usr/lib/tmpfiles.d/livesys-session-extra.conf << EOF
122+ C /var/lib/livesys/livesys-session-extra 0755 root root - /usr/share/factory/var/lib/livesys/livesys-session-extra
123+ EOF
124+ mkdir -p /usr/share/factory/var/lib/livesys
125+ cat > /usr/share/factory/var/lib/livesys/livesys-session-extra << 'EOF '
126+ #!/bin/bash
127+
128+ . /etc/os-release
129+
130+ usermod -c "$NAME User" liveuser
131+ hostnamectl hostname "$ID"
132+
133+ timedatectl set-timezone UTC
134+ ln -s /usr/share/zoneinfo/UTC /etc/localtime
135+
136+ if [ -d /var/lib/livesys/livesys-session-extra.d ]; then
137+ find /var/lib/livesys/livesys-session-extra.d -type f -exec /bin/bash {} \;
138+ fi
139+
140+ EOF
141+ chmod 0644 /usr/share/factory/var/lib/livesys/livesys-session-extra
142+ }
90143
91144elif [ -x " $( command -v pacman) " ]; then
92145
@@ -122,6 +175,10 @@ elif [ "$_command" = "setup-initramfs" ]; then
122175
123176 _pkg_setupinitramfs $_args
124177
178+ elif [ " $_command " = " setup-livesys" ]; then
179+
180+ _pkg_setuplivesys $_args
181+
125182else
126183 echo >&2 " ERROR: unknown command"
127184 exit 1
0 commit comments