-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.sh
94 lines (91 loc) · 2.44 KB
/
run.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
#!/bin/bash
if [ "$1" != "secret" ]; then
echo "=================================================================="
echo " i3c.Cloud $i3cVersion $I3C_CNAME:${I3C_HOME}/run.sh"
#echo " On $(lsb_release -a | grep Description:)"
echo "=================================================================="
fi
#one command for all
alias i-apk='/r install';
case "$1" in
# read secret
secret)
cat /run/secrets/$2;
;;
# mount secret
secretMount)
#echo "ln -sf $3 /run/secrets/$2"
if [ ! -e /run/secrets ]; then
sudo ln -sf /i3c/.secrets/.secrets /run/secrets
else
echo "WARN: folder /run/secrets already exists... check if it's pointing to /i3c/.secrets/.secrets"
fi
sudo ln -sf $3 /run/secrets/$2
;;
# umount secret
secretUmount)
if [ -L $2 ]; then
sudo rm /run/secrets/$2
fi
;;
#install entrypoint in container
entrypoint)
if [ -e $2 ]; then
chmod a+x $2
if [ -e /r ]; then
rm -f /r
fi
ln -s $2 /r
else
echo "ERROR: file not found: $2";
fi
;;
startup)
while true; do
sleep 1000
done
;;
echo)
echo "Echo from /run.sh: ${@:2}"
;;
untar)
tar -xvzf "${@:2}"
;;
apt)
echo "==================!!!!!!!!!!!!!!!!!!======================================="
echo "[ i3c/run.sh ]$1 unhandled - add to Your local /run-xxx implementation"
echo "==================!!!!!!!!!!!!!!!!!!======================================="
./$0 help "$@"
;;
help)
echo "[i3cHome]i3c/r Usage:"
echo "======================================"
echo "- add run.sh script to Your project."
echo "- include or '. /run-xxx.sh' in the script"
echo "- add Your operations in Your run.sh"
echo "- add Your operation before including if You want to override"
echo "- add "
echo " COPY ./run-mydecent.sh /run-mydecent.sh && ln -sfn /run-mydecent.sh /r"
echo " RUN chmod a+x /run-mydecent.sh"
echo " to Your dockerfile."
echo "";
echo "======================================"
echo "Commands:"
echo " secret [name] - read secret contents"
echo " secretMount [name] [path] - mount secret file/dir as link"
echo " secretUmount [name] - remove link to secret file/dir"
case "$2" in
apt)
echo "apt OP [PACKAGE] [ARGS ...]"
echo "Install/remove/search given package. "
echo "OP=install - install package"
echo "OP=search - search"
echo "OP=remove - remove"
;;
*)
echo "[i3c/run.sh ] No help on $2 available..."
esac
;;
*)
echo "run '/r help' for help."
esac