summaryrefslogtreecommitdiff
path: root/backend/modules/init
blob: 501cf30ab82687c4429c5e96748a0cec22c4696c (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
#!/bin/bash

function init_installer()
{
	[ -f /etc/default/distro ] && . /etc/default/distro
	export FLL_DISTRO_MODE FLL_DISTRO_NAME FLL_LIVE_USER
	mkdir -p /live/filesystem
	LOOPDEV="$(losetup --all | awk -F: '/\/live\/image\//&&/filesystem/{print $1}')"
    [ -z "$LOOPDEV" ] && LOOPDEV=$(losetup --all | awk -F: '/\/live\/medium\//&&/filesystem/{print $1}')
    [ -z "$LOOPDEV" ] && LOOPDEV=$(losetup --all | awk -F: '/\/live\/mount\/medium\//&&/filesystem/{print $1}')
	if [ -e /live/gfxoverlay.active ]; then
		mkdir -p /live/filesystem.main
		gfx="$(cat /live/gfxoverlay.active)"
		bit=32
		[ "$(uname -m)" = "x86_64" ] && bit=64
		if [ ! -d /live/filesystem.main/usr ]; then
			[ "$LOOPDEV" ] && mount -o ro "$LOOPDEV" /live/filesystem.main
			for dir in /live/gfxoverlay/overlay$bit-$gfx /live/gfxoverlay/$gfx /live/gfxoverlay
			do
				if [ -d $dir/lib ]; then
					mount -t aufs -o br:$dir:/live/filesystem.main none /live/filesystem
					break
				fi
			done
		fi
	fi
	if [ ! -d /live/filesystem/usr ]; then
		[ "$LOOPDEV" ] && mount -o ro "$LOOPDEV" /live/filesystem
	fi
        ESTIMATED_ROOT_MIN=$(df -m "$LOOPDEV" | tail -1 | gawk '{print $3}')
        grep -q squashfs /proc/mounts && ESTIMATED_ROOT_MIN=$(($ESTIMATED_ROOT_MIN*320/100))
        export ESTIMATED_ROOT_MIN
	cfg_set hostname "${FLL_DISTRO_NAME}Box"
}