#!/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 dash
    # bash /opt/scripts/update/dash_rand_logo.sh
    cp /root/.acme/rustle.cc_ecc/fullchain.cer '/opt/apps/syncthing/data/common/A_Program/nginx-1.24.0/certs/'
    cp /root/.acme/rustle.cc_ecc/rustle.cc.key '/opt/apps/syncthing/data/common/A_Program/nginx-1.24.0/certs/'
fi

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

docker exec -u www-data nextcloud php /var/www/html/occ files:scan --all
