-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathinit_container.sh
More file actions
75 lines (61 loc) · 2.43 KB
/
init_container.sh
File metadata and controls
75 lines (61 loc) · 2.43 KB
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
#!/usr/bin/env bash
cat >/etc/motd <<EOL
_____
/ _ \ __________ _________ ____
/ /_\ \\___ / | \_ __ \_/ __ \
/ | \/ /| | /| | \/\ ___/
\____|__ /_____ \____/ |__| \___ >
\/ \/ \/
A P P S E R V I C E O N L I N U X
Documentation: http://aka.ms/webapp-linux
EOL
cat /etc/motd
sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config
service ssh start
# Get environment variables to show up in SSH session
eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile)
echo "$@" > /opt/startup/startupCommand
chmod 755 /opt/startup/startupCommand
oryxArgs="-appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv2.7 -defaultApp /opt/defaultsite -bindPort $PORT"
if [ $# -eq 0 ]; then
echo 'App Command Line not configured, will attempt auto-detect'
else
echo "Site's appCommandLine: $@"
if [ $# -eq 1 ]; then
echo "Checking of $1 is a file"
if [ -f $1 ]; then
echo 'App command line is a file on disk'
fileContents=$(head -1 $1)
#if the file ends with, check if this is a script (first two chars of the file)
if [ ${1: -3} == ".sh" ]; then
echo 'App command line is a shell script, will execute this script as startup script'
chmod +x $1
oryxArgs+=" -userStartupCommand $1"
else
echo "$1 file exists on disk, reading its contents to run as startup arguments"
echo "Contents of startupScript: $fileContents"
oryxArgs+=" -userStartupCommand '$fileContents'"
fi
else
echo 'App command line is not a file on disk, using it as the startup command.'
oryxArgs+=" -userStartupCommand '$1'"
fi
else
oryxArgs+=" -userStartupCommand '$@'"
fi
fi
debugArgs=""
if [ "$APPSVC_REMOTE_DEBUGGING" == "TRUE" ]; then
echo "App will launch in debug mode"
debugArgs="-debugAdapter ptvsd -debugPort $APPSVC_TUNNEL_PORT"
if [ "$APPSVC_REMOTE_DEBUGGING_BREAK" == "TRUE" ]; then
debugArgs+=" -debugWait"
fi
oryxArgs="$debugArgs $oryxArgs"
fi
echo "Launching oryx with: $oryxArgs"
#invoke oryx to generate startup script
eval "oryx $oryxArgs"
chmod +x /opt/startup/startup.sh
#launch startup script
/opt/startup/startup.sh