summaryrefslogtreecommitdiff
path: root/ohmd/run-ohm.sh
blob: dd94017b465303697afdf78876074a0dfea5fb8c (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
#!/bin/sh

OHM_TMPDIR=/tmp/run-ohmd-$USER

if [ "$1" = "--help" ]; then
	echo "Usage:"
	echo "  $0 [run-options] [ohm-options]"
	echo
	echo "Run Options:"
	echo "  --skip-plugin-install: Don't do a temporary install of the plugins."
	echo "                         Only use this if $0 has already been run"
	echo "                         without this option"
	echo "  --time:                Time OHMd startup"
	echo "  --debug:               Run with gdb"
	echo "  --memcheck:            Run with valgrind memcheck tool"
	echo "  --massif:              Run with valgrind massif heap-profiling tool"
	echo "  --efence:              Run with electric-fence chedking for overruns"
	echo "  --underfence:          Run with electric-fence checking for underruns"
	echo
	./ohmd --help
	exit 0
fi

if [ "$1" = "--skip-plugin-install" ] ; then
	shift
else
	rm -rf $OHM_TMPDIR
	make -C ../etc install DESTDIR=$OHM_TMPDIR prefix=/
	make -C ../plugins install DESTDIR=$OHM_TMPDIR prefix=/
fi

extra='--no-daemon --verbose --g-fatal-critical'

if [ "$1" = "--time" ] ; then
	shift
	prefix="time -p"
	extra="--no-daemon --timed-exit"
elif [ "$1" = "--debug" ] ; then
	shift
	prefix="gdb --args"
elif [ "$1" = "--memcheck" ] ; then
	shift
	prefix="valgrind --show-reachable=yes --leak-check=full --tool=memcheck --suppressions=./valgrind.supp $VALGRIND_EXTRA"
	export G_SLICE="always-malloc"
elif [ "$1" = "--massif" ] ; then
	shift
	prefix="valgrind --tool=massif --suppressions=./valgrind.supp $VALGRIND_EXTRA"
	export G_SLICE="always-malloc"
elif [ "$1" = "--efence" ] ; then
	shift
	prefix="gdb -x ./efence.gdb --args"
	export G_SLICE="always-malloc"
elif [ "$1" = "--underfence" ] ; then
	shift
	prefix="gdb -x ./underfence.gdb --args"
	export G_SLICE="always-malloc"
fi

export OHM_CONF_DIR=$OHM_TMPDIR/etc/ohm
export OHM_PLUGIN_DIR=$OHM_TMPDIR/lib/ohm

echo "Execing: $prefix ./ohmd $extra $@"
sudo $prefix ./ohmd $extra $@