blob: 65f486b615b55c81394d90882c0871051738b6f4 (
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
|
#!/bin/sh
die()
{
echo "$*" >&2
exit 1
}
usage()
{
echo "Usage: run-linuxcnc-demo.sh [/path/to/linuxcnc]"
echo
echo " /path/to/linuxcnc: Path to 'linuxcnc' start script"
}
if [ $# -ge 1 ] && [ "$1" = "-h" -o "$1" = "--help" ]; then
usage
exit 0
fi
if [ $# -eq 0 ]; then
linuxcnc="linuxcnc"
elif [ $# -eq 1 ]; then
linuxcnc="$1"
else
usage
exit 1
fi
# basedir = directory where this script lives in
basedir="$(dirname "$0")"
[ "$(echo "$basedir" | cut -c1)" = '/' ] || basedir="$PWD/$basedir"
# rootdir = root of the pyprofibus repository
rootdir="$basedir/.."
[ -x "$rootdir/pyprofibus-linuxcnc-hal" ] || die "pyprofibus-linuxcnc-hal not found"
cleanup()
{
rm -f "/tmp/linuxcnc-demo.ngc"
}
cleanup
trap cleanup EXIT
cp "$basedir/linuxcnc-demo.ngc" /tmp/ || die "Failed to copy linuxcnc-demo.ngc"
# Start LinuxCNC
(
cd "$basedir" || die "Failed to 'cd $basedir'"
PATH="$rootdir/:$PATH"\
PYTHONPATH="$rootdir/:$PYTHONPATH"\
"$linuxcnc" "$basedir/linuxcnc-demo.ini" ||\
die "LinuxCNC exited with an error"
)
|