#!/bin/bash
#
# [Quick Box :: Set Defaulted Theme function]
#
# QuickLab REPOS
# QuickLab _ packages  :   https://github.com/QuickBox/QB/packages
# LOCAL REPOS
# Local _ packages   :   /etc/QuickBox/packages
# Author             :   QuickBox.IO | JMSolo
# URL                :   https://quickbox.io
#
# QuickBox Copyright (C) 2017 QuickBox.io
# Licensed under GNU General Public License v3.0 GPL-3 (in short)
#
#   You may copy, distribute and modify the software as long as you track
#   changes/dates in source files. Any modifications to our software
#   including (via compiler) GPL-licensed code must also be made available
#   under the GPL along with build & install instructions.
#
function _updatedashboard() {
  cd ${rutorrent}
  #  if [[ -n $(find /var/www/dashboard/db -name "branding-*.php") ]]; then
  #    rsync -aP --exclude=disk_*.php --exclude=branding-l.php --exclude=share.php --exclude=custom.menu.php --exclude=url.override.php --exclude=custom.css ${local_themes}smoked/* ${rutorrent}home
  #    rm -f /var/www/dashboard/lang/*.php
  #    rm -rf /var/www/dashboard/db/.defaulted.lock >/dev/null 2>&1
  #    printf "" > /var/www/dashboard/db/.smoked.lock
  #  else
  #    rsync -aP --exclude=disk_*.php --exclude=share.php --exclude=custom.menu.php --exclude=url.override.php --exclude=custom.css ${local_themes}smoked/* ${rutorrent}home
  #    rm -f /var/www/dashboard/lang/*.php
  #    rm -rf /var/www/dashboard/db/.defaulted.lock >/dev/null 2>&1
  #    printf "" > /var/www/dashboard/home/db/.smoked.lock
  #  fi

  \cp -fR  ${local_themes}smoked/skins/* ${rutorrent}skins
  \cp -fR  ${local_themes}smoked/inc/* ${rutorrent}inc
  rm -rf /var/www/dashboard/db/.defaulted.lock >/dev/null 2>&1
  printf "" > /var/www/dashboard/db/.smoked.lock
#  service apache2 reload
#  sleep 5

}

local_themes=/etc/QuickBox/themes/
rutorrent=/var/www/dashboard/

_updatedashboard
