-
Notifications
You must be signed in to change notification settings - Fork 11
/
get-launcher
executable file
·71 lines (65 loc) · 2.07 KB
/
get-launcher
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
#!/bin/bash
if [ "$CHAP_SERVICE_NAME" != "" ]; then
stty -onlcr 2>/dev/null # inhibits carriage return if -t was specified
fi
if [ "$CHAP_TASK_MODE" != "1" ]; then
echo "get-launcher' should only be run in chaperone --task mode from the docker host"
exit 1
fi
cat <<EOF
#################################################################################
#
# YOU SHOULD NOT BE SEEING THIS!!!!!!!!! IF SO, YOU ARE NOT PIPING INTO sh!
#
# Make sure you pipe the output of your docker command into sh, like this...
#
# docker run -i chapdev/chaperone-baseimage --command get-launcher | sh
# ^^^^
#################################################################################
EOF
function expand_template() { tpl_envcp - <$1; }
skel=$APPS_DIR/etc/skel
[ -d $skel/launcher ] && tplfiles=`find $skel/launcher -name '*.tpl'`
if [ "$tplfiles" == "" ]; then
cat <<EOF
echo "Sorry, this image does not define any launcher scripts."
EOF
else
source $skel/shell_vars.inc
for lf in $tplfiles; do
realname=$(transform_filename $lf)
echo "[ -f $realname ] && errors=1 && echo \"ALREADY EXISTS: $realname (won't overwrite)\""
done
echo "[ \"\$errors\" = "1" ] && { cat >/dev/null; exit 1; }"
for lf in $tplfiles; do
realname=$(transform_filename $lf)
contents=$(expand_template $lf)
cat <<EOF
echo "Extracting $realname ..."
cat >$realname <<"--EOF--"
$contents
--EOF--
chmod 755 $realname
EOF
done
if [ -f "$skel/help/LAUNCHER.tpl" ]; then
cat <<EOF
cat <<"--EOF--"
$(expand_template $skel/help/LAUNCHER.tpl)
--EOF--
EOF
else
echo "echo done."
fi
fi
cat <<EOF
#################################################################################
#
# YOU SHOULD NOT BE SEEING THIS!!!!!!!!! IF SO, YOU ARE NOT PIPING INTO sh!
#
# Make sure you pipe the output of your docker command into sh, like this...
#
# docker run -i chapdev/chaperone-baseimage --command get-launcher | sh
# ^^^^
#################################################################################
EOF