summarylogtreecommitdiffstats
path: root/lbe.sh
blob: b7be2664c7464c1de6f330d447e50a8182f0a03f (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
#!/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 [ ! -t "$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

exec java -jar "$appdir/lbe.jar" "$@"