-
Notifications
You must be signed in to change notification settings - Fork 5
/
update_planet
executable file
·55 lines (37 loc) · 1.64 KB
/
update_planet
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
#!/bin/bash
BASE_DIR=$(dirname $(readlink -f $0))
EN_CONF=$BASE_DIR/data/planet.english.ini
BG_CONF=$BASE_DIR/data/planet.bulgarian.ini
echo "Checking for ephemeral storage configuration"
for ef in `curl -m 5 http://169.254.169.254/latest/meta-data/block-device-mapping/ 2>/dev/null | grep ephemeral`; do
disk=`curl http://169.254.169.254/latest/meta-data/block-device-mapping/$ef 2>/dev/null`
# check if /tmp is already mounted (assume on ephemeral storage)
if [ `mount | grep -c "/tmp "` == "0" ]; then
echo "/tmp not mounted"
echo "Unmounting /dev/$disk"
sudo umount -f /dev/$disk
echo "mkfs /dev/$disk"
sudo mkfs.ext4 -q /dev/$disk
echo "Mounting /dev/$disk on /tmp"
sudo mount -t ext4 /dev/$disk /tmp
sudo chmod 1777 /tmp
else
echo "/tmp is already mounted"
fi
done
pushd $BASE_DIR
# update local copy
git pull origin master && git fetch --tags
# activate virtualenv. NB: name is hard-coded
source ~/.virtualenvs/planet.sofiavalley.com/bin/activate
# update planet and push contents
$BASE_DIR/libs/venus/planet.py $EN_CONF
# first upload CSS and manually set Mime-Type b/c Magic guesses it wrong
s3cmd sync -c $BASE_DIR/data/s3.cfg -v -m text/css -P /tmp/svplanet/english/html/*.css s3://planet.sofiavalley.com/
s3cmd sync -c $BASE_DIR/data/s3.cfg -v -m text/html -P /tmp/svplanet/english/html/*.html s3://planet.sofiavalley.com/
# then update everything else
s3cmd sync -c $BASE_DIR/data/s3.cfg -v -P /tmp/svplanet/english/html/* s3://planet.sofiavalley.com/
# update bulgarian version of planet
#$BASE_DIR/libs/venus/planet.py $BG_CONF
# todo: upload
popd $BASE_DIR