-
Notifications
You must be signed in to change notification settings - Fork 4
/
SkillAegis.sh
executable file
·68 lines (51 loc) · 1.9 KB
/
SkillAegis.sh
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
64
65
66
67
68
#!/bin/bash
CONFIG_FILE="config.json"
function get_config_value() {
local path=$1
echo $(jq -r "$path" config.json)
}
usage() {
echo "Usage: $0 [--scenario_folder <folder>]"
exit 1
}
PARAM_SCENARIO_FOLDER=""
CONFIG_SCENARIO_FOLDER=$(get_config_value ".main.scenario_folder")
while [ "$#" -gt 0 ]; do
case "$1" in
--scenario_folder)
PARAM_SCENARIO_FOLDER="$2"
shift 2
;;
*)
usage
;;
esac
done
SESSION="SkillAegis"
APP_MAIN="Main"
MAIN_HOST=$(get_config_value ".main.host")
MAIN_PORT=$(get_config_value ".main.port")
if [ ! -z "$PARAM_SCENARIO_FOLDER" ]; then
SCENARIO_FOLDER="$PARAM_SCENARIO_FOLDER"
else
SCENARIO_FOLDER="$CONFIG_SCENARIO_FOLDER"
fi
SCENARIO_FOLDER_ABSOLUTE=$(realpath "$SCENARIO_FOLDER" 2>/dev/null)
if [ ! -d "$SCENARIO_FOLDER_ABSOLUTE" ]; then
echo "Error: The folder '$SCENARIO_FOLDER_ABSOLUTE' does not exist."
exit 1
fi
APP_EDITOR="Editor"
EDITOR_HOST=$(get_config_value ".editor.host")
EDITOR_PORT=$(get_config_value ".editor.port")
APP_DASHBOARD="Dashboard"
DASHBOARD_HOST=$(get_config_value ".dashboard.host")
DASHBOARD_PORT=$(get_config_value ".dashboard.port")
EDITOR_URL=$(get_config_value ".main.editor_url")
DASHBOARD_URL=$(get_config_value ".main.dashboard_url")
screen -dmS $SESSION
screen -S $SESSION -X screen -t "$APP_MAIN" bash -c "python3 app.py --host $MAIN_HOST --port $MAIN_PORT --editor_url $EDITOR_URL --dashboard_url $DASHBOARD_URL; read x;"
screen -S $SESSION -X screen -t "$APP_DASHBOARD" bash -c "cd SkillAegis-Dashboard && bash start.sh --host $DASHBOARD_HOST --port $DASHBOARD_PORT --exercise_folder $SCENARIO_FOLDER_ABSOLUTE; read x;"
screen -S $SESSION -X screen -t "$APP_EDITOR" bash -c "cd SkillAegis-Editor && bash start.sh --host $EDITOR_HOST --port $EDITOR_PORT --exercise_folder $SCENARIO_FOLDER_ABSOLUTE; read x;"
sleep 0.5
screen -d -r $SESSION -p $APP_MAIN