summaryrefslogtreecommitdiff
path: root/setup-desktop.in
blob: ad2a269e87f751fd4297fbcf6dee5094ecaf0c11 (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
#!/bin/sh

PREFIX=@PREFIX@
: ${LIBDIR=$PREFIX/lib}
. "$LIBDIR/libalpine.sh"

usage() {
	cat <<-__EOF__
		usage: setup-desktop [-h] [xfce|gnome]

		Install a standard desktop

		options:
		 -h  Show this help

	__EOF__
	exit $1
}

while getopts "h" opt; do
	case $opt in
		h) usage 0;;
		'?') usage "1" >&2;;
	esac
done
shift $(($OPTIND - 1))

if [ $# -gt 1 ]; then
	usage "1" >&2
fi

de="$1"

valid_desktops="xfce gnome none"
if [ $# -eq 1 ] && ! isin "$de" $valid_desktops; then
	echo "$de is not a valid desktop" >&2
	usage "1" >&2
fi
shift

while ! isin "$de" $valid_desktops; do
	ask "Which desktop environment? ('gnome', 'xfce' or 'none')" none
	de="$resp"
done

case "$de" in
	none)
		exit 0
		;;
	xfce)
		setup-xorg-base xfce4 ${BROWSER:-firefox} \
			consolekit2 \
			gvfs \
			lightdm \
			lightdm-gtk-greeter \
			polkit \
			xfce4-terminal \
			"$@"
		rc-update add lightdm
		;;
	gnome)
		setup-xorg-base ${BROWSER:-firefox} gnome gnome-apps-core "$@"
		rc-update add gdm
		;;
	*)
		usage "1" >&2
		;;
esac

users=$(awk -F: '{if ($3<65000 && $3 >= 1000) print $1}' "$ROOT"/etc/passwd 2>/dev/null)
if [ -z "$users" ]; then
	echo "WARNING: You need to create a user account. Please run:" >&2
	echo "" >&2
	echo "  adduser -g 'Fistname Lastname' <username>" >&2
	echo "" >&2
fi