#!/bin/bash

# get latest hosts for accelerate github visiting
curl https://raw.hellogithub.com/hosts >> /opt/logs/hosts

# renew images.json file for background picture of homepage
cd /opt/websites/homepage/
node assets/js/bing.js > /dev/null 2>&1

if [[ `date +%d` == '01' ]]; then
    # random logo for navigation
    bash /opt/scripts/update/nav_rand_logo.sh

    # random logo for dash
    bash /opt/scripts/update/dash_rand_logo.sh
fi

# logo renew
let numOfAvatar=`ls /opt/websites/nav/assets/images/logos/ | wc -l`
let randNumber=$RANDOM%$numOfAvatar
cp /opt/websites/nav/assets/images/logos/${randNumber}.jpg /opt/websites/nav/assets/images/logos/avatar.jpg
cp /opt/websites/nav/assets/images/logos/${randNumber}.jpg /opt/websites/homepage/assets/img/logo.jpg
cp /opt/websites/nav/assets/images/logos/${randNumber}.jpg /opt/apps/blog/img/avatar.jpg

