forked from luga-ev/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·84 lines (64 loc) · 2.42 KB
/
deploy.sh
File metadata and controls
executable file
·84 lines (64 loc) · 2.42 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
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
set -e
root="$(dirname -- $(readlink -f "$0"))"
repo="https://github.com/luga-ev/website.git"
[ -n "$1" ] && repo="$1"
builddir="$HOME/.luga-website-cache"
###############################################################################
echo "* Installing and configuring Apache..." >&2
{ which apache2 >/dev/null && [ -e "/etc/apache2/mods-available/php5.load" ]; } || \
sudo apt-get install apache2 libapache2-mod-php5
[ -e "/etc/apache2/mods-enabled/php5.load" ] || sudo a2enmod php5
[ -e "/etc/apache2/mods-enabled/rewrite.load" ] || sudo a2enmod rewrite
sudo tee /etc/apache2/sites-enabled/luga-dummy.conf >/dev/null <<EOF
# Diese Datei wurde durch deploy.sh automatisch generiert.
# Eigene Änderungen gehen beim nächsten Aufruf verloren!
<VirtualHost *:80>
ServerAdmin webmaster@luga.de
ServerName luga-dummy
DocumentRoot $root/html
<Directory $root/html>
Options FollowSymLinks
AllowOverride ALL
<IfModule mod_authz_core.c>
Require ip 127.0.0.1 ::1
</IfModule>
</Directory>
</VirtualHost>
EOF
grep luga-dummy /etc/hosts >/dev/null || \
echo "127.0.0.1 luga-dummy" | sudo tee -a /etc/hosts >/dev/null
sudo service apache2 restart
# "restart" statt "reload" wegen der Modulaktivierung oben
if [ "$repo" = "live-only" ]; then
echo "Live-only mode; not mirroring website." >&2
echo "Check out the website at http://luga-dummy/." >&2
exit 0
fi
###############################################################################
echo "* Checking out current gh-pages branch..." >&2
mkdir -p "$builddir"
cd "$builddir"
if [ -d .git ]; then
git reset --hard origin/gh-pages
git pull
else
git clone --single-branch -b gh-pages --depth 1 "$repo" .
fi
find -not -path "./.git/*" -not -name ".git" -delete
###############################################################################
echo "* Mirroring website..." >&2
wget -nv -D luga-dummy -r -l inf -p http://luga-dummy/ || true
mv luga-dummy/* .
rmdir luga-dummy
###############################################################################
echo "* Committing and pushing..." >&2
echo luga-preview.mooo.com > CNAME
git add --all
git commit -m "Webseite neu generiert ($(date '+%Y-%m-%d %H:%M'))" || true
if [ -z "$1" ]; then
echo "No target repository specified, not pushing." >&2
echo "Check out the result at $builddir or at http://luga-dummy/." >&2
exit 0
fi
git push "$repo" gh-pages