-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvpl_execution
executable file
·46 lines (37 loc) · 1.3 KB
/
vpl_execution
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
#!/usr/bin/env bash
rm -f $0 # for security issue
if [ -f ./env.sh ] ; then
source ./env.sh
elif [ -f $HOME/env.sh ] ; then
source $HOME/env.sh
else
echo "⚠ Error: File \"env.sh\" is missing!" && exit 0
fi
[ -z "$MODE" ] && echo "⚠ Error: Variable \"MODE\" is not defined!" && exit 0
grep -w $MODE <<< "RUN DEBUG EVAL" &> /dev/null
[ $? -ne 0 ] && echo "⚠ Error: Invalid MODE \"$MODE\"!" && exit 0
[ -z "$RUNDIR" ] && echo "⚠ Error: Variable \"RUNDIR\" is not defined!" && exit 0
[ -z "$ENTRYPOINT" ] && echo "⚠ Error: Variable \"ENTRYPOINT\" is not defined!" && exit 0
CMD="$RUNDIR/$ENTRYPOINT"
[ ! -f "$CMD" ] && echo "⚠ Error: Entrypoint file \"$CMD\" not found!" && exit 0
### graphic mode ###
if [ $GRAPHIC -eq 1 ] ; then
xhost + # FIXME: try to be no so permissive!
[ -z "$DISPLAY" ] && echo "⚠ Error: DISPLAY variable is not set!" && exit 0
# export VNCPORT=${DISPLAY:1} # remove ':' from $DISPLAY
fi
#### START ####
# clean vpl script for security issues
rm -f vpl_run.sh vpl_debug.sh vpl_evaluate.sh &> /dev/null
SHELLCMD="bash"
cd $RUNDIR
echo "Run..."
if [ $GRAPHIC -eq 0 ] ; then
$SHELLCMD $CMD $ARGS
[ $DEBUG -eq 1 ] && bash
else
xterm -hold -e $SHELLCMD $CMD $ARGS
[ $DEBUG -eq 1 ] && xterm -hold -e bash
fi
echo "Terminated."
# EOF