#!/bin/bash
#
# [Quick Box :: Install erasedata plugin]
#
# GITHUB REPOS
# GitHub _ packages  :   https://github.com/QuickBox/quickbox_packages
# GitHub _ plugins   :   https://github.com/QuickBox/quickbox_rutorrent-plugins
# LOCAL REPOS
# Local _ packages   :   /etc/QuickBox/packages
# Local _ plugins    :   /etc/QuickBox/rtplugins
# 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.
#
OUTTO=/srv/rutorrent/home/db/output.log

function _installplugin-erasedata() {
  username=$(whoami);
  rutorrent="/srv/rutorrent/";
  echo "Accessing erasedata in the plugin vault ... " >>"${OUTTO}" 2>&1;
  PLUGINVAULT="/etc/QuickBox/rtplugins/"; cd "${rutorrent}plugins"
  sleep 5

  echo "Installing erasedata plugin ... " >>"${OUTTO}" 2>&1;
  PLUGIN="erasedata"
    for i in $PLUGIN; do
      cp -R "${PLUGINVAULT}$i" .
    done
  sleep 5

  echo "Adjusting permissions ... " >>"${OUTTO}" 2>&1;
  chown -R www-data: ${rutorrent}plugins/$PLUGIN
  echo "Erasedata Plugin Install Complete!" >>"${OUTTO}" 2>&1;
  
  sleep 5
  echo >>"${OUTTO}" 2>&1;
  echo >>"${OUTTO}" 2>&1;
  echo "Close this dialog box to refresh your browser" >>"${OUTTO}" 2>&1;

    exit
}

_installplugin-erasedata
