-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-tar-daemon.sh
executable file
·67 lines (55 loc) · 1.04 KB
/
deploy-tar-daemon.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
#!/bin/bash
WATCH_FILE="/tmp/site.tar"
SITE_PATH="/var/www/html/optimistic.ninja/public_html"
IMAGE_PATH="public/images"
IMAGE_PERMISSIONS="644"
SITE_USER="www-data"
SITE_GROUP="$SITE_USER"
SITE_USERGROUP="$SITE_USER:$SITE_GROUP"
stop_apache() {
echo "Stopping Apache...."
service apache2 stop
}
make_backup() {
echo "Creating backup..."
tar cvf site.tar *
mv site.tar ../backups/`date +"%m-%d-%y-%H%M"`-archive.tar
}
remove_old() {
echo "Removing old static pages..."
rm -rf *
}
extract_new() {
echo "Extracting new static pages..."
tar xvf $1
}
fix_ownership() {
echo "Fixing ownership..."
chown -R $SITE_USERGROUP *
}
fix_permissions() {
echo "Fixing image permissions..."
chmod $IMAGE_PERMISSIONS $IMAGE_PATH/*
}
start_apache() {
echo "Starting apache..."
service apache2 start
}
cleanup() {
rm -rf $WATCH_FILE
}
# $1 == The location of your tar.
main() {
if [ -f "$WATCH_FILE" ]; then
stop_apache
cd $SITE_PATH
make_backup
remove_old
extract_new $1
fix_ownership
fix_permissions
start_apache
cleanup
fi
}
main