aboutsummaryrefslogtreecommitdiffstats
path: root/preparechroot.sh
blob: 1d05e72678f1a7fba3da2eb9f12aae98ec79b483 (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
#!/bin/bash

source colors.sh

export LFS="$1"

if [ -f chrootprepared ]; then
	printf "%b" "${RED}CHROOT ${GRN}already prepared...\n${RST}"
	exit 0
fi

if [ -z "${LFS}" ]; then
	printf "%b" "${RED}Require first argument as path to LFS build!${RST}\n"
	exit 1
fi

if [ "${USER}" == "root" ]; then
	printf "%b" "${GRN}Changing ownership to root...${RST}\n"
	chown -R root:root "${LFS}"/bin
	chown -R root:root "${LFS}"/etc
	chown -R root:root "${LFS}"/lib
	chown -R root:root "${LFS}"/sbin
	chown -R root:root "${LFS}"/tools
	chown -R root:root "${LFS}"/usr
	chown -R root:root "${LFS}"/var

	case $(uname -m) in
		x86_64) chown -R root:root "${LFS}"/lib64 ;;
	esac

	printf "%b" "${GRN}Creating virtual kernel filesystem mountpoints...${RST}\n"
	mkdir -p "${LFS}"/dev
	mkdir -p "${LFS}"/proc
	mkdir -p "${LFS}"/run
	mkdir -p "${LFS}"/sys
	
	printf "%b" "${GRN}Creating initial device nodes...${RST}\n"
	mknod -m 600 "${LFS}"/dev/console c 5 1 >/dev/null 2>&1
	mknod -m 666 "${LFS}"/dev/null c 1 3 >/dev/null 2>&1
	
	source mountvirtfs.sh

	touch chrootprepared

else
	printf "%b" "${RED}preparechroot.sh must be ran as ${YLW}root${RED} user!${RST}\n"
fi