-
Notifications
You must be signed in to change notification settings - Fork 10
/
toolbox_start.sh
executable file
·96 lines (81 loc) · 1.58 KB
/
toolbox_start.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
echo '
******************************************
* WELCOME TO TOOLBOX CONTAINER *
******************************************
'
echo OS: $(cat /etc/redhat-release)
echo Time: $(date)
echo '
******
* ID *
******
'
id
echo '
*********
* CAPSH *
*********
'
capsh --print
echo '
***************
* ENVIRONMENT *
***************
'
env
echo '
**********************
* NETWORK INTERFACES *
**********************
'
ip address
echo '
************************
* KUBERNETES API TOKEN *
************************
'
if [ -r /var/run/secrets/kubernetes.io/serviceaccount/token ]; then
jq -R 'gsub("-";"+") | gsub("_";"/") | split(".") | .[1] | @base64d | fromjson' \
/var/run/secrets/kubernetes.io/serviceaccount/token
else
echo "No token found!"
fi
# Add toolbox user entry to /etc/passwd and /etc/group
if ! whoami &> /dev/null; then
echo "toolbox:x:$(id -u):0:Toolbox user:$HOME:/bin/bash" >> /etc/passwd
echo "toolbox:x:$(id -u):" >> /etc/group
fi
custom_init=/toolbox/init.sh
if [ -r $custom_init ]; then
echo '
***********************
* CUSTOM INIT SCRIPT *
***********************
'
source $custom_init
exit_code=$?
echo
echo Init script completed with exit code $exit_code
if [ $exit_code -ne 0 ]; then
exit $exit_code
fi
fi
custom_run=/toolbox/run.sh
if [ -r $custom_run ]; then
echo '
***********************
* CUSTOM RUN SCRIPT *
***********************
'
source $custom_run
exit_code=$?
echo
echo Run script completed with exit code $exit_code
else
echo
echo Press Ctrl-C to exit ...
# block here
trap : TERM INT
sleep infinity & wait
fi