summaryrefslogtreecommitdiff
path: root/kogaionlive.sh
blob: 4f2bd25e2e353aeb7d02518073209179598452f8 (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
#!/usr/bin/env bash

export local liveuser="kogaion"

checkroot () {
	if [[ "$(whoami)" != root ]] ; then
		echo ""
		echo "You're not root?...No cookies for you, go away !!!"
		echo ""
		exit 1
	fi
}

kogaion_is_live() {
	if [[ ! -L "/dev/mapper/live-rw" ]] ; then
		echo ""
		echo "The system is not running in live mode, aborting!"
		exit 1
	fi
}

kogaion_add_live_user() {
	/usr/sbin/useradd -u 1000 -g 100 -o -m -s /bin/bash "$liveuser" > /dev/null 2>&1
}

kogaion_live_user_groups() {
	for group in tty disk lp wheel uucp console audio cdrom tape video cdrw usb plugdev messagebus portage ; do
		gpasswd -a "$liveuser" "$group" > /dev/null 2>&1
	done
}

kogaion_live_user_password () {
	/usr/bin/passwd --delete "$liveuser" > /dev/null 2>&1
}

kogaion_live_locale_switch () {
	export local keymap_toset="$(cat /proc/cmdline | cut -d " " -f12 | cut -d "=" -f2)"
	export local lang_toset="$(cat /proc/cmdline | cut -d " " -f13 | cut -d "=" -f2)"
	if [[ "$lang_toset" != "en_US.utf8" ]] || [[ "$keymap_toset" != "us" ]] ; then
		/usr/bin/localectl set-locale LANG="$lang_toset" > /dev/null 2>&1
		/usr/bin/localectl set-keymap "$keymap_toset" > /dev/null 2>&1
		/usr/sbin/env-update --no-ldconfig > /dev/null 2>&1
	fi
}


main () {
	if checkroot && kogaion_is_live ; then
		kogaion_add_live_user
		kogaion_live_user_groups
		kogaion_live_user_password
		kogaion_live_locale_switch
	fi
}

main
exit 0