-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime.sh
More file actions
executable file
·58 lines (50 loc) · 961 Bytes
/
runtime.sh
File metadata and controls
executable file
·58 lines (50 loc) · 961 Bytes
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
#!/bin/bash
set -e
if [ "$METADATA_JSON" = "" ]; then
export METADATA_JSON=/mnt/metadata.json
fi
if [ "$DOT_ENV" = "" ]; then
export DOT_ENV=/mnt/.env
fi
if [ "$CHALLENGE" = "yes" ]; then
chmod 700 $METADATA_JSON
chown root:root $METADATA_JSON
[ -f $DOT_ENV ] && {
chmod 400 $DOT_ENV
chown root:root $DOT_ENV
. $DOT_ENV
}
function execute() {
su -c "$*" ctf
}
else
function execute() {
sh -c "$*"
}
fi
function extract_field() {
cat $METADATA_JSON | jq "$1" -r
}
execute $*
exit
case $1 in
init)
execute "$(extract_field .tasks.init)"
;;
runtime)
execute "$(extract_field .tasks.runtime)"
;;
daemon)
execute "$(extract_field .tasks.daemon)"
;;
debug)
execute "exec $SHELL"
;;
root)
exec $SHELL
;;
*)
echo "Unknown command: $1"
exit 1
;;
esac