summarylogtreecommitdiffstats
path: root/lbe.sh
blob: ba32173f91881aa3737d297624607d746d65df82 (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
#!/bin/sh -e

: ${XDG_CONFIG_HOME:=~/.config}

appdir="/opt/lbe"

if [ -d "$HOME/.lbe" ]; then
	confdir="$HOME/.lbe"
else
	confdir="$XDG_CONFIG_HOME/lbe"
fi

if [ ! -d "$confdir" ]; then
	mkdir -pm0700 "$confdir"

	cat > "$confdir/lbe.properties" <<-EOF
	base=$confdir/
	session.dir=$confdir/
	cacert.file=$confdir/lbecacerts
	EOF

	cp -a "$appdir/help/uofmichigan.cfg.sample" "$confdir/U of Michigan.cfg"

	cp -a "$appdir/templates" "$confdir/"
fi

if [ ! -k "$appdir/attributes.config" ]; then
	cp -a "$appdir/attributes.config" "$confdir/"
fi

cd "$confdir" # FIXME: if we do this, we can ditch lbe.properties; any disadvantages?

umask 077 # protect session files

for jvm in /usr/lib/jvm/java-8-{openjdk,jre}; do
	if [ -d "$jvm" ]; then
		exec "$jvm"/jre/bin/java -jar "$appdir/lbe.jar" "$@"
	fi
done

echo "error: could not find a compatible JRE" >&2
exit 1