aboutsummaryrefslogtreecommitdiff
path: root/deploy.sh
blob: 31397b8eed9f2ac40769a932e6ea89b6ff387b60 (plain)
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
#!/bin/bash

if [ $(ssh-add -l | grep SHA | wc -l) -lt 1 ]
then
    ssh-add
else
    echo "Key already added"
fi

echo "Copying to staging..."
tar -czf blog.tar.gz blog-staging
scp blog.tar.gz root@fwei.tk:
ssh root@fwei.tk rm -rf /var/www/html/blog-staging
ssh root@fwei.tk tar -xzvf blog.tar.gz -C /var/www/html
rm -f blog.tar.gz

if [[ $# -ge 1 ]] && [[ $1 == "-p" ]]
then
    echo "Going gold..."
    ssh root@fwei.tk rm -rf /var/www/html/blog
    ssh root@fwei.tk mv /var/www/html/blog-staging /var/www/html/blog
    echo "Moved to production."
else
    echo "Files copied to staging site."
fi