-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·48 lines (40 loc) · 1.02 KB
/
bootstrap.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
#!/bin/bash
# List of supported variables:
# URL to download, git, tar or zip files.
# SERVERNAME to configure to apache (for logging purposes)
# CAT /path/to/create=multiline\ncontent\t\n
# PREEXEC with raw commands to pass to bash
DOCROOT="/var/www/html"
APACHEUSER="www-data"
. /functions.sh
if [ -z "$URL" ]
then
echo "Bad usage, please provide the 'URL' environment variable"
exit 64
fi
cd $DOCROOT
rm -fr *
if [ "$(echo $URL| grep -c '^git=')" -eq 1 ]
then
gitdeploy "$(echo $URL| sed 's/^git.//')"
else
unpack "$URL"
fi
# Move subfolders if necessary
if [ $(ls | wc -l) -eq 1 ]
then
subfolder=$(ls)
mv $subfolder/* $subfolder/.* . 2>/dev/null
rmdir $subfolder
fi
chown -R $APACHEUSER: .
# Start Webserver
if [ -z "$SERVERNAME" ]
then
SERVERNAME="$(hostname --fqdn)"
fi
echo "ServerName $SERVERNAME" > /etc/apache2/conf-enabled/servername.conf
echo "$PREEXEC" | bash
echo "Removing innecessary binaries from runtime environment (bash, cp, rm ...)"
#rm -rf /bin /usr/bin /sbin /usr/sbin
/usr/sbin/apache2 -D FOREGROUND