Commit 5d32f001 authored by Armando Luescher's avatar Armando Luescher Committed by dmorley

Rewrite pull.sh and prettify output. (#125)

parent 146c18fb
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
TIME=`date +%k`
if [ -s /tmp/index.google ];then
echo "already running die"
exit;
else
echo "Checking for internet";
#!/usr/bin/env sh
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
FLAG_FILE="/tmp/poduptime.pulling"
HOUR=`date +%k`
HAPPY=" :-)"
SAD=" :-("
if [ -f "$FLAG_FILE" ]; then
echo "Already running pull"
exit 1
fi
touch "$FLAG_FILE"
# https://stackoverflow.com/a/26820300
printf "%s" "Checking for internet..."
if ! wget -q --spider --tries=2 --timeout=15 https://www.google.com; then
echo "$SAD"
echo "Could not update pods as no internet"
rm "$FLAG_FILE"
exit 1
fi
echo "$HAPPY"
wget -q --tries=2 --timeout=15 http://www.google.com -O /tmp/index.google
sleep 2
if [ ! -s /tmp/index.google ];then
echo "could not update pods as no internet"
rm /tmp/index.google
exit;
else
cd "$SCRIPT_DIR"
if [ $TIME = 6 ];then
echo "Pulling in master versions";
php pull-masterversions.php
echo "Update CA"
wget https://curl.haxx.se/ca/cacert.pem -O ../cacert.pem
if [ "$HOUR" = 6 ]; then
echo "Pulling in master versions...";
php pull-masterversions.php
echo
printf "%s" "Updating CA..."
if wget -q https://curl.haxx.se/ca/cacert.pem -O ../cacert.pem; then
echo "$HAPPY"
else
echo "$SAD"
fi
echo "Pulling in new pod data";
php pull.php
touch last.data
php backup.php
rm /tmp/index.google
fi
echo "Pulling in new pod data...";
php pull.php $1
touch last.data
echo "Finished pull!"
echo "Backing up..."
php backup.php
echo
rm "$FLAG_FILE"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment