summaryrefslogtreecommitdiff
blob: 505a7e704df38b6128558333c347a3e966836085 (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
#
# Copyright (c) 2005, Petteri Räty <betelgeuse@gentoo.org>
# Copyright (c) 2004, Jochen Maes <sejo@gentoo.org>
# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
# Copyright (c) 2004, Gentoo Foundation
#
# Licensed under the GNU General Public License, v2

# The Azureus config dir has moved
olddotazudir="${HOME}/.Azureus"
oldgentoocfg="${olddotazudir}/gentoo.config"
dotazudir="${HOME}/.azureus"
gentoocfg="${dotazudir}/gentoo.config"

if [[ -f "${oldgentoocfg}" && -f "${gentoocfg}" ]]; then
	cat > /dev/stderr <<END
You have gentoo.config files in both 
${dotazudir} and
${olddotazudir}
${olddotazudir} is deprecated and you can delete this directory.

END
fi

create_initial_config() {
	if [[ ! -e "${dotazudir}" ]] ; then
		mkdir "${dotazudir}"
		echo "Creating ${dotazudir}" 
	fi

	[[ ${UI} ]] && UI="swt"

	echo "Creating ${gentoocfg}"

	# Create the config file
	cat > "${gentoocfg}" <<END
# User Interface options:
# console   - console based
# swt       - swt (GUI) based
UI="${UI}"

# Options you want to pass to the java binary
JAVA_OPTIONS=""
END
}

if [[ -f "${gentoocfg}" ]] ; then
	. "${gentoocfg}"
	echo "using ${gentoocfg}"
elif [[ -f "${oldgentoocfg}" ]]; then
	. "${oldgentoocfg}"
	echo "using ${oldgentoocfg}"
else
	create_initial_config
fi

if [[ -z "${UI}" && -n "${UI_OPTIONS}" ]]; then
	echo '${UI_OPTIONS} is no longer supported. ${UI} should be used instead instead' > /dev/stderr
	echo 'Unsetting ${UI_OPTIONS} and trying to migrate to ${UI}' > /dev/stderr
	if [[ ${UI_OPTIONS} = *--ui=console* ]]; then
		UI=console
	elif [[ ${UI_OPTIONS} = *--ui=swt* ]]; then
		UI=swt
	else
		echo 'Could not make $UI from $UI_OPTIONS' > /dev/stderr
	fi
	unset UI_OPTIONS
fi

if [[ -z "${UI}" ]]; then
	echo '$UI not set defaulting to swt' > /dev/stderr
	UI="swt"
fi

[[ ! -e "${dotazudir}" ]] && create_initial_config