Jump to content

Intel® Core™ i9-13900 and HW encoing


Recommended Posts

Posted

ps -ef|grep Emby

 

 

grahamcoyswanst
Posted

bear with me trying to work out how to copy and paste all that info for you.

grahamcoyswanst
Posted
  ps -ef|grep Emby
judgey    180033       1  2 12:25 ?        00:00:08 /opt/judgey/emby-server/syst                                                                                                                                                             em/EmbyServer -programdata /home/judgey/.config/Emby -ffdetect /opt/judgey/emby-                                                                                                                                                             server/bin/ffdetect -ffmpeg /opt/judgey/emby-server/bin/ffmpeg -ffprobe /opt/jud                                                                                                                                                             gey/emby-server/bin/ffprobe -restartexitcode 3 -updatepackage emby-server-deb_{v                                                                                                                                                             ersion}_amd64.deb
root      188538  186135  0 12:30 ?        00:00:00 /opt/quickbox/system/manage                                                                                                                                                              -c                                                                             



#!/bin/bash #################################################                                                                                                                                                             ############################### # <START METADATA> # @file_name: manage # @versi                                                                                                                                                             on: 1.0.452 # @project_name: quickbox_pro_v3 # @description: collection of manag                                                                                                                                                             e scripts # # @save_tasks: #  automated_versioning: true #  automated_documentat                                                                                                                                                             ion: true # # @build_tasks: #  automated_comment_strip: true #  automated_encryp                                                                                                                                                             tion: true # # @author: Jason Matthews (JMSolo) # @author_contact: support@quick                                                                                                                                                             box.io # @author: Jamie Dobbs (mschf) # @author_contact: jamie.dobbs@mschf.dev #                                                                                                                                                              # @license: BSD-3 Clause (Included in LICENSE) # Copyright (C) 2019-2023, Quick                                                                                                                                                             Box.IO # All rights reserved. # <END METADATA> # shellcheck disable=SC1091,SC203                                                                                                                                                             4,SC2140,SC2165,SC2167,SC2312 ##################################################                                                                                                                                                             ##############################  ################################################                                                                                                                                                             ################################ # @description: sets up environment for command                                                                                                                                                             s # @noargs # @internal # @return_code: 1 script should be run via qb ##########                                                                                                                                                             ###################################################################### manage::e                                                                                                                                                             nvironment::init() { ?declare script_name ?script_name=$(basename -- "$0") ?[[ $                                                                                                                                                             {qb_invoked:-0} -eq 0 ]] && { echo -ne "\033[38;5;203merror\e[0m[1]: ${script_na                                                                                                                                                             me} should be run via qb\n" >&2 && exit 1; } ?. "/opt/mflibs/src/init.sh" ?mflib                                                                                                                                                             s::import shell,quickbox,status,log,info }  quickbox::dashboard::log() { ?admin_                                                                                                                                                             name="$(quickbox::database "SELECT username FROM user_information WHERE user_lev                                                                                                                                                             el = '10';")" ?if [[ ! -f "/srv/quickbox/logs/dashboard" ]]; then ??mkdir -p /sr                                                                                                                                                             v/quickbox/logs ??touch /srv/quickbox/logs/dashboard ??chown www-data:www-data /                                                                                                                                                             srv/quickbox/logs/dashboard ?fi ?if [[ ! -f "/srv/quickbox/logs/${username:-${ad                                                                                                                                                             min_name}}.dashboard" ]]; then ??mkdir -p /srv/quickbox/logs ??touch "/srv/quick                                                                                                                                                             box/logs/${username:-${admin_name}}.dashboard" ??chown www-data:www-data "/srv/q                                                                                                                                                             uickbox/logs/${username:-${admin_name}}.dashboard" ?fi ?if [[ -n ${username} ]];                                                                                                                                                              then ??echo "${1:-null}" | sed -z "s/\n/\n<br>/" >"/srv/quickbox/logs/${usernam                                                                                                                                                             e:-}.dashboard" ?else ??echo "${1:-null}" | sed -z "s/\n/\n<br>/" >"/srv/quickbo                                                                                                                                                             x/logs/${admin_name:-}.dashboard" ?fi ?echo "${1:-null}" }  ####################                                                                                                                                                             ############################################################ # @description: man                                                                                                                                                             ages api key activation and deactivation # @noargs #############################                                                                                                                                                             ################################################### api::settings() {  ?########                                                                                                                                                             ######################################################################## ?# @des                                                                                                                                                             cription: pulls information from database and quickbox.io ?# @noargs ?##########                                                                                                                                                             ###################################################################### ?api::var                                                                                                                                                             iable::assign() { ??declare mflibs_log_location="${quickbox_base_path:="/opt/qui                                                                                                                                                             ckbox"}/logs/system_log" ??declare -g api_activated api_activated_date api_key a                                                                                                                                                             pi_instance api_ip api_product_id api_code api_execution api_status api_activate                                                                                                                                                             d api_activations_remaining api_total_activations api_total_activations_purchase                                                                                                                                                             d ??declare api_json ??IFS=$'\n' read -d '' -ra api_array <<<"$(quickbox::databa                                                                                                                                                             se "SELECT configuration_name,configuration_value FROM system_configuration WHER                                                                                                                                                             E configuration_name = 'api_key' OR configuration_name = 'api_instance' OR confi                                                                                                                                                             guration_name = 'api_activated_date' OR configuration_name = 'api_product_id' OR                                                                                                                                                              configuration_name = 'api_activated' OR configuration_name = 'api_ip'")" ??for                                                                                                                                                              i in "${api_array[@]}"; do ???array_configuration_name="$(echo "${i}" | cut -d '                                                                                                                                                             |' -f1)" ???array_configuration_value="$(echo "${i}" | cut -d '|' -f2-)" ???case                                                                                                                                                              "${array_configuration_name}" in ???api_key) api_key="${array_configuration_val                                                                                                                                                             ue}" ;; ???api_ip) api_ip="${array_configuration_value}" ;; ???api_product_id) a                                                                                                                                                             pi_product_id="${array_configuration_value}" ;; ???api_instance) api_instance="$                                                                                                                                                             {array_configuration_value}" ;; ???api_activated_date) api_activated_date="${arr                                                                                                                                                             ay_configuration_value}" ;; ???*) ;; ???esac ??done ??api_json=$(curl -s4 -k "ht                                                                                                                                                             tps://quickbox.io/?wc-api=wc-am-api&product_id=${api_product_id}&object=${api_ip                                                                                                                                                             }&instance=${api_instance}&api_key=${api_key}&request=status") ??for value in $(                                                                                                                                                             jq 'keys | .[]' <<<"${api_json}"); do ???if [[ ${value} == '"code"' ]]; then ???                                                                                                                                                             ?mflibs::shell::text::red "invalid response" ????api_code=$(jq -r ".${value}" <<                                                                                                                                                             <"${api_json}") ????break ???elif [[ ${value} == '"api_call_execution_time"' ]];                                                                                                                                                              then ????api_execution=$(jq -r ".${value}" <<<"${api_json}") ???elif [[ ${value                                                                                                                                                             } == '"status_check"' ]]; then ????api_status=$(jq -r ".${value}" <<<"${api_json                                                                                                                                                             }") ???elif [[ ${value} == '"data"' ]]; then ????for data_value in $(jq '.data |                                                                                                                                                              keys | .[]' <<<"${api_json}"); do ?????if [[ ${data_value} == '"activated"' ]];                                                                                                                                                              then ??????api_activated=$(jq -r ".data.${data_value}" <<<"${api_json}") ?????e                                                                                                                                                             lif [[ ${data_value} == '"activations_remaining"' ]]; then ??????api_activations                                                                                                                                                             _remaining=$(jq -r ".data.${data_value}" <<<"${api_json}") ?????elif [[ ${data_v                                                                                                                                                             alue} == '"total_activations"' ]]; then ??????api_total_activations=$(jq -r ".da                                                                                                                                                             ta.${data_value}" <<<"${api_json}") ?????elif [[ ${data_value} == '"total_activa                                                                                                                                                             tions_purchased"' ]]; then ??????api_total_activations_purchased=$(jq -r ".data.                                                                                                                                                             ${data_value}" <<<"${api_json}") ?????fi ????done ???fi ??done ?}  ?############                                                                                                                                                             #################################################################### ?# @descrip                                                                                                                                                             tion: outputs api status in terminal window ?# @noargs ?########################                                                                                                                                                             ######################################################## ?api::status::view() {                                                                                                                                                              ??column -ts '|' <<<"$( ???mflibs::shell::text::yellow "local information|" ???m                                                                                                                                                             flibs::shell::text::white::sl "api execution time:|" ???mflibs::shell::text::gre                                                                                                                                                             en::bold "${api_execution}" ???mflibs::shell::text::white::sl "api key:|" ???mfl                                                                                                                                                             ibs::shell::text::green::bold "${api_key}" ???mflibs::shell::text::white::sl "ap                                                                                                                                                             i activation date:|" ???mflibs::shell::text::green::bold "${api_activated_date}"                                                                                                                                                              ???mflibs::shell::text::white::sl "api ip:|" ???mflibs::shell::text::green::bol                                                                                                                                                             d "${api_ip}" ???mflibs::shell::text::white::sl "product id:|" ???mflibs::shell:                                                                                                                                                             :text::green::bold "${api_product_id}" ???mflibs::shell::text::white::sl "instan                                                                                                                                                             ce id:|" ???mflibs::shell::text::green::bold "${api_instance}" ???mflibs::shell:                                                                                                                                                             :misc::nl ???mflibs::shell::text::yellow "remote information|" ???mflibs::shell:                                                                                                                                                             :text::white::sl "api total activations:|" ???mflibs::shell::text::green::bold "                                                                                                                                                             ${api_total_activations}" ???mflibs::shell::text::white::sl "api activations rem                                                                                                                                                             aining:|" ???mflibs::shell::text::green::bold "${api_activations_remaining}" ???                                                                                                                                                             mflibs::shell::text::white::sl "api activated:|" ???mflibs::shell::text::green::                                                                                                                                                             bold "${api_activated}" ???mflibs::shell::text::white::sl "api status:|" ???mfli                                                                                                                                                             bs::shell::text::green::bold "${api_status}" ??)" ?}  ?#########################                                                                                                                                                             ####################################################### ?# @description: deactiv                                                                                                                                                             ates api key ?# @noargs ?#######################################################                                                                                                                                                             ######################### ?api::key::deactivate() { ??declare deactivate_check ?                                                                                                                                                             ?if [[ ${api_force:-0} -eq "0" ]]; then ???mflibs::shell::misc::nl ???mflibs::sh                                                                                                                                                             ell::text::white::sl "deactivate api key? " ???mflibs::shell::text::green::sl "[                                                                                                                                                             y]" ???mflibs::shell::text::white::sl "es " ???mflibs::shell::text::white "or [n                                                                                                                                                             ]o:" ???mflibs::shell::icon::arrow::white ???read -r input ???case "${input,,}"                                                                                                                                                              in ???[y] | [y][e][s] | "") : ;; ???*) exit 0 ;; ???esac ??fi ??deactivate_check                                                                                                                                                             =$(curl -s4 -k "https://quickbox.io/?wc-api=wc-am-api&product_id=${api_product_i                                                                                                                                                             d}&object=${api_ip}&instance=${api_instance}&api_key=${api_key}&request=deactiva                                                                                                                                                             te" | jq -r ".deactivated") ??if [[ ${api_force} -eq "0" ]]; then ???if [[ ${dea                                                                                                                                                             ctivate_check} == "true" ]]; then ????quickbox::database "UPDATE system_configur                                                                                                                                                             ation set configuration_value = 'false' WHERE configuration_name='api_activated'                                                                                                                                                             ;" ???else ????mflibs::shell::text::red "unable to deactivate api key" ???fi ??f                                                                                                                                                             i ?}  ?#########################################################################                                                                                                                                                             ####### ?# @description: checks api key ?# @noargs ?############################                                                                                                                                                             #################################################### ?api::key::check() { ??decl                                                                                                                                                             are check_status ??check_status=$(curl -s4 -k "https://quickbox.io/?wc-api=wc-am                                                                                                                                                             -api&product_id=${api_product_id}&object=${api_ip}&instance=${api_instance}&api_                                                                                                                                                             key=${api_key}&request=status" | jq -r '.data."activated"') ??if [[ ${api_force}                                                                                                                                                              -eq "0" ]]; then ???if [[ ${check_status} == "true" ]]; then ????mflibs::shell:                                                                                                                                                             :text::green "api key is activated" ????quickbox::database "UPDATE system_config                                                                                                                                                             uration set configuration_value = 'true' WHERE configuration_name='api_activated                                                                                                                                                             ';" ????\cp -rf /opt/quickbox/dashboard/inc/plugins/nav/dash_navigation-pro.php                                                                                                                                                              /srv/quickbox/dash_navigation.php ???else ????mflibs::shell::text::red "api key                                                                                                                                                              is not activated" ????quickbox::database "UPDATE system_configuration set config                                                                                                                                                             uration_value = 'false' WHERE configuration_name='api_activated';" ????\cp -rf /                                                                                                                                                             opt/quickbox/dashboard/inc/plugins/nav/dash_navigation-community.php /srv/quickb                                                                                                                                                             ox/dash_navigation.php ???fi ??fi ?}  ?#########################################                                                                                                                                                             ####################################### ?# @description: activates api key ?# @n                                                                                                                                                             oargs ?#########################################################################                                                                                                                                                             ####### ?api::key::activate() { ??if [[ ${api_force:-0} -eq "0" ]]; then ???mfli                                                                                                                                                             bs::shell::misc::nl ???mflibs::shell::text::white::sl "activate api key? " ???mf                                                                                                                                                             libs::shell::text::green::sl "[y]" ???mflibs::shell::text::white::sl "es " ???mf                                                                                                                                                             libs::shell::text::white "or [n]o:" ???mflibs::shell::icon::arrow::white ???read                                                                                                                                                              -r input ???case "${input,,}" in ???[y] | [y][e][s] | "") : ;; ???*) exit 0 ;;                                                                                                                                                              ???esac ??fi ??declare -a product_codes ??declare api_instance api_date product                                                                                                                                                              public_ip api_key quickbox_version ??api_date=$(date +"%b %d, %Y %l:%M") ??publi                                                                                                                                                             c_ip=$(mflibs::info::ipv4::local) ??api_instance=$(date +%s | sha256sum | base64                                                                                                                                                              | head -c 16) ??product_codes=("13256" "24449" "24450" "24451" "24452" "13257"                                                                                                                                                              "24453" "24454" "24455" "24456" "13324" "349206") ??quickbox_version=$(quickbox:                                                                                                                                                             :database "SELECT configuration_value FROM system_configuration WHERE configurat                                                                                                                                                             ion_name = 'server_current_version'") ??if [[ -z ${man_api_key:-} ]]; then ???mf                                                                                                                                                             libs::shell::misc::nl ???mflibs::shell::text::white "enter api key: " ???mflibs:                                                                                                                                                             :shell::icon::arrow::white ???read -r api_key ??fi ??for product in "${product_c                                                                                                                                                             odes[@]}"; do ???api_activated=$(curl -s4 -k "https://quickbox.io/?wc-api=wc-am-                                                                                                                                                             api&product_id=${product}&object=${public_ip}&version=${quickbox_version}&instan                                                                                                                                                             ce=${api_instance}&api_key=${man_api_key:-${api_key}}&request=activate" | grep -                                                                                                                                                             Eoi '"activated":true' | cut -d: -f2-) ???if [[ ${api_activated} == "true" ]]; t                                                                                                                                                             hen ????api_product_id="${product}" ????break ???fi ??done ??[[ ${api_activated}                                                                                                                                                              != "true" ]] && mflibs::shell::text::red "invalid api key; please contact suppo                                                                                                                                                             rt" && api::environment::cleanup ??quickbox::database "WITH Tmp(configuration_na                                                                                                                                                             me, configuration_value) AS (VALUES ('api_activated', 'true'), ('api_activated_d                                                                                                                                                             ate', '${api_date}'),('api_key', '${man_api_key:-${api_key}}'), ('api_instance',                                                                                                                                                              '${api_instance}'), ('api_ip', '${public_ip}'), ('api_product_id', '${api_produ                                                                                                                                                             ct_id}')) UPDATE system_configuration SET configuration_value = (SELECT configur                                                                                                                                                             ation_value FROM Tmp WHERE system_configuration.configuration_name = Tmp.configu                                                                                                                                                             ration_name) WHERE configuration_name IN (SELECT configuration_name FROM Tmp);"                                                                                                                                                              ??if [[ -z ${api_force} ]]; then ???mflibs::shell::misc::nl ???mflibs::shell::te                                                                                                                                                             xt::green "api key has been activated" ???mflibs::shell::misc::nl ??fi ?}  ?api:                                                                                                                                                             :variable::assign ?if [[ ${qb_option[*]:-} == *"deactivate"* || -n ${man_api_key                                                                                                                                                             } ]]; then ??[[ ${qb_option[*]:-} == *"force"* || -n ${man_api_key} ]] && declar                                                                                                                                                             e -gi api_force=1 ??api::key::deactivate ??api::key::activate ??api::variable::a                                                                                                                                                             ssign ?elif [[ ${qb_option[*]:-} == *"check"* ]]; then ??api::key::check ?elif [                                                                                                                                                             [ ${api_code} != "100" ]]; then ??api::status::view ??api::key::deactivate ??api                                                                                                                                                             ::key::activate ?fi ?if [[ ${qb_option[*]:-} == *"deactivate"* ]]; then ??quickb                                                                                                                                                             ox::database "INSERT INTO system_log ("user_id", "log_source", "log_type", "log_                                                                                                                                                             operation", "timestamp") VALUES ('${user_id:-1}', 'qb manage api -o deactivate .                                                                                                                                                             ..', 'system', 'DEACTIVATE_QUICKBOX_API', '$(date +"%Y-%m-%d %H:%M:%S")');" ?eli                                                                                                                                                             f [[ ${qb_option[*]:-} == *"activate"* ]]; then ??quickbox::database "INSERT INT                                                                                                                                                             O system_log ("user_id", "log_source", "log_type", "log_operation", "timestamp")                                                                                                                                                              VALUES ('${user_id:-1}', 'qb manage api -o activate ...', 'system', 'ACTIVATE_Q                                                                                                                                                             UICKBOX_API', '$(date +"%Y-%m-%d %H:%M:%S")');" ?elif [[ ${qb_option[*]:-} == *"                                                                                                                                                             check"* ]]; then ??: ?else ??quickbox::database "INSERT INTO system_log ("user_i                                                                                                                                                             d", "log_source", "log_type", "log_operation", "timestamp") VALUES ('${user_id:-                                                                                                                                                             1}', 'qb manage api', 'system', 'ACTIVATION_INFO_STATS', '$(date +"%Y-%m-%d %H:%                                                                                                                                                             M:%S")');" ?fi }  ##############################################################                                                                                                                                                             ################## # @description: manages fail2ban settings on the server # @no                                                                                                                                                             args # @example: qb manage fail2ban -o [config|unban] # @null ##################                                                                                                                                                             ############################################################## fail2ban::setting                                                                                                                                                             s() { ?for option in "${qb_option[@]}"; do ??case "${option,,}" in ??"config") ?                                                                                                                                                             ??fail2ban_dir="/etc/fail2ban/" ???if [[ ! -d ${fail2ban_dir} ]]; then ????mflib                                                                                                                                                             s::shell::text::red "Fail2ban is not installed. Would you like to install this?                                                                                                                                                              [y/N]:" ????echo -en "> " ????read -r input ????case ${input} in ????[yY] | [yY]                                                                                                                                                             [Ee][Ss]) ?????/usr/local/bin/qb install fail2ban ?????exit 1 ?????;; ????[nN] |                                                                                                                                                              [nN][Oo]) ?????mflibs::shell::text::red "Exiting Script." && exit 1 ?????;; ???                                                                                                                                                             ?*) ?????mflibs::shell::text::red "Exiting Script." && exit 1 ?????;; ????esac ?                                                                                                                                                             ??fi ???mflibs::shell::text::white "Ban time for incorrect login (Default 10m) [                                                                                                                                                             5m/3h/12d]:" ???unset input ???echo -en "> " ???read -r input ???bantime="${inpu                                                                                                                                                             t//[^0-9]*/}" ???if [[ ${input} == "" ]]; then ????bantime=600 ???elif [[ ${inpu                                                                                                                                                             t} == *"m" ]]; then ????bantime=$((bantime * 60)) ???elif [[ ${input} == *"h" ]]                                                                                                                                                             ; then ????bantime=$((bantime * 60 * 60)) ???elif [[ ${input} == *"d" ]]; then ?                                                                                                                                                             ???bantime=$((bantime * 60 * 60 * 12)) ???fi ???mflibs::shell::text::white "Time                                                                                                                                                              between incorrect logins for ban (Default 10m) [5m/3h/12d]:" ???unset input ???                                                                                                                                                             echo -en "> " ???read -r input ???findtime="${input//[^0-9]*/}" ???if [[ ${input                                                                                                                                                             } == "" ]]; then ????findtime=600 ???elif [[ ${input} == *"m" ]]; then ????findt                                                                                                                                                             ime=$((findtime * 60)) ???elif [[ ${input} == *"h" ]]; then ????findtime=$((find                                                                                                                                                             time * 60 * 60)) ???elif [[ ${input} == *"d" ]]; then ????findtime=$((findtime *                                                                                                                                                              60 * 60 * 12)) ???fi ???mflibs::shell::text::white "Max number of retries withi                                                                                                                                                             n time (Default 5):" ???unset input ???echo -en "> " ???read -r input ???maxretr                                                                                                                                                             y="${input//[^0-9]*/}" ???if [[ ${input} == "" ]]; then ????maxretry=5 ???fi ???                                                                                                                                                             mflibs::shell::text::white "IPs ignored by fail2ban (Default none) [1.1.1.1,2.2.                                                                                                                                                             2.2]" ???mflibs::shell::text::green "Your IP is $(who am i | awk '{ print $5}' |                                                                                                                                                              tr -d '()'):" ???unset input ???echo -en "> " ???read -r input ???ignoreip="${i                                                                                                                                                             nput}" ???mflibs::shell::text::white "Monitor SSH Logins? ([y]/n):" ???unset inp                                                                                                                                                             ut ???echo -en "> " ???read -r input ???case ${input} in ???[yY] | [yY][Ee][Ss])                                                                                                                                                              ????SSH="true" ????;; ???[nN] | [nN][Oo]) ????SSH="false" ????;; ???*) ????SSH=                                                                                                                                                             "true" ????;; ???esac ???mflibs::shell::text::white "Monitor Nginx Logins? ([y]/                                                                                                                                                             n):" ???unset input ???echo -en "> " ???read -r input ???case ${input} in ???[yY                                                                                                                                                             ] | [yY][Ee][Ss]) ????nginx="true" ????;; ???[nN] | [nN][Oo]) ????nginx="false"                                                                                                                                                              ????;; ???*) ????nginx="true" ????;; ???esac ???mflibs::shell::text::white "Moni                                                                                                                                                             tor QuickBox Logins? ([y]/n):" ???unset input ???echo -en "> " ???read -r input                                                                                                                                                              ???case ${input} in ???[yY] | [yY][Ee][Ss]) ????quickbox="true" ????;; ???[nN] |                                                                                                                                                              [nN][Oo]) ????quickbox="false" ????;; ???*) ????quickbox="true" ????;; ???esac                                                                                                                                                              ???mflibs::shell::text::white "Applying Configuration..." ???\cp -f "/opt/quickb                                                                                                                                                             ox/config/software/fail2ban/quickbox.conf" "/etc/fail2ban/filter.d/quickbox.conf                                                                                                                                                             " ???if [[ -f "/etc/fail2ban/jail.local" ]]; then ????\cp -f "/etc/fail2ban/jail                                                                                                                                                             .local" "/etc/fail2ban/jail.bak" ???fi ???\cp -f "/opt/quickbox/config/software/                                                                                                                                                             fail2ban/jail.local" "/etc/fail2ban/jail.local" ???sed -i -e "s/IGNORE_CONFIG/${                                                                                                                                                             ignoreip}/g" /etc/fail2ban/jail.local -e "s/BANTIME_CONFIG/${bantime}/g" /etc/fa                                                                                                                                                             il2ban/jail.local -e "s/FINDTIME_CONFIG/${findtime}/g" /etc/fail2ban/jail.local                                                                                                                                                              -e "s/RETRY_CONFIG/${maxretry}/g" /etc/fail2ban/jail.local -e "s/SSHD_CONFIG/${S                                                                                                                                                             SH}/g" /etc/fail2ban/jail.local -e "s/NGINX_CONFIG/${nginx}/g" /etc/fail2ban/jai                                                                                                                                                             l.local -e "s/QUICKBOX_CONFIG/${quickbox}/g" /etc/fail2ban/jail.local ???mflibs:                                                                                                                                                             :log "systemctl restart fail2ban" ???mflibs::shell::text::green "Configuration a                                                                                                                                                             pplied" ???;; ??"unban") ???fail2ban_dir="/etc/fail2ban/" ???if [[ ! -d ${fail2b                                                                                                                                                             an_dir} ]]; then ????mflibs::shell::text::red "Fail2ban is not installed. Would                                                                                                                                                              you like to install this? [y/N]:" ????echo -en "> " ????read -r input ????case $                                                                                                                                                             {input} in ????[yY] | [yY][Ee][Ss]) ?????/usr/local/bin/qb install fail2ban ????                                                                                                                                                             ?exit 1 ?????;; ????[nN] | [nN][Oo]) ?????mflibs::shell::text::red "Exiting Scri                                                                                                                                                             pt." && exit 1 ?????;; ????*) ?????mflibs::shell::text::red "Exiting Script." &&                                                                                                                                                              exit 1 ?????;; ????esac ???fi ???fail2banjails=$(fail2ban-client status | grep                                                                                                                                                              "Jail list" | cut -f2- | sed 's/,//g') ???mflibs::shell::text::white "Unbanning                                                                                                                                                              ${option}..." ???for jails in ${fail2banjails}; do ????fail2ban-client set "${ja                                                                                                                                                             ils}" unbanip "${option}" >/dev/null 2>&1 ???done ???mflibs::shell::text::green                                                                                                                                                              "${option} unbanned." ???;; ??"inclog") ???# trunk-ignore(shellcheck/SC2001) ???                                                                                                                                                             ip=$(echo "${domain}" | sed 's/\s//g') ???echo "${ip} -- [$(date +%d)/$(date +%b                                                                                                                                                             )/$(date +%Y):$(date +%H):$(date +%M):$(date +%S)] -- Failed Login - ${username}                                                                                                                                                             " >>/srv/quickbox/logs/fail2ban.log ???;; ??*) ???mflibs::shell::text::red "Inva                                                                                                                                                             lid option: ${option}" ???;; ??esac ?done  }  ##################################                                                                                                                                                             ############################################## # @description: manages language                                                                                                                                                              settings on the server # @arg: -o [de|german|dk|danish|en|english|es|spanish|fr|                                                                                                                                                             french|pt|portuguese|zh-cn|chinese] # @example: qb manage lang -o en(or english)                                                                                                                                                              # @null #######################################################################                                                                                                                                                             ######### lang::settings() { ?declare language code_name ?declare -g quickbox_ba                                                                                                                                                             se_path="/opt/quickbox" ?code_name=$(lsb_release -cs) ?for lang in "${qb_option[                                                                                                                                                             @]}"; do ??case "${lang,,}" in ??de | german*) ???source /root/.bashrc ???declar                                                                                                                                                             e -g locale_sed quickbox_lang ???locale_sed=de_DE ???quickbox_lang=de ???cp -f "                                                                                                                                                             ${quickbox_base_path}/config/lang/${quickbox_lang}/locale" "/etc/default/locale"                                                                                                                                                              ???cp -f "${quickbox_base_path}/config/lang/${quickbox_lang}/localize.php" "/sr                                                                                                                                                             v/quickbox/inc/localize.php" ???sed -i -e '/da_DK.UTF-8/s/^#*/#/g' -e '/es_ES.UT                                                                                                                                                             F-8/s/^#*/#/g' -e '/fr_FR.UTF-8/s/^#*/#/g' -e '/pt_PT.UTF-8/s/^#*/#/g' -e '/zh_C                                                                                                                                                             N.UTF-8/s/^#*/#/g' -e 's/^#.*\(de_DE.UTF-8\)/\1/' /etc/locale.gen >/dev/null 2>&                                                                                                                                                             1 ???#sudo locale-gen --purge >/dev/null 2>&1 ???sudo update-locale --locale-fil                                                                                                                                                             e=/etc/default/locale >/dev/null 2>&1 ???sudo dpkg-reconfigure --frontend nonint                                                                                                                                                             eractive locales >/dev/null 2>&1 ???source /root/.bashrc ???;; ??dk | danish*) ?                                                                                                                                                             ??source /root/.bashrc ???declare -g locale_sed quickbox_lang ???locale_sed=da_D                                                                                                                                                             K ???quickbox_lang=dk ???cp -f "${quickbox_base_path}/config/lang/${quickbox_lan                                                                                                                                                             g}/locale" "/etc/default/locale" ???cp -f "${quickbox_base_path}/config/lang/${q                                                                                                                                                             uickbox_lang}/localize.php" "/srv/quickbox/inc/localize.php" ???sed -i -e '/de_D                                                                                                                                                             E.UTF-8/s/^#*/#/g' -e '/es_ES.UTF-8/s/^#*/#/g' -e '/fr_FR.UTF-8/s/^#*/#/g' -e '/                                                                                                                                                             pt_PT.UTF-8/s/^#*/#/g' -e '/zh_CN.UTF-8/s/^#*/#/g' -e 's/^#.*\(da_DK.UTF-8\)/\1/                                                                                                                                                             ' /etc/locale.gen >/dev/null 2>&1 ???#sudo locale-gen --purge >/dev/null 2>&1 ??                                                                                                                                                             ?sudo update-locale --locale-file=/etc/default/locale >/dev/null 2>&1 ???sudo dp                                                                                                                                                             kg-reconfigure --frontend noninteractive locales >/dev/null 2>&1 ???source /root                                                                                                                                                             /.bashrc ???;; ??en | english*) ???source /root/.bashrc ???declare -g locale_sed                                                                                                                                                              quickbox_lang ???locale_sed=en_US ???quickbox_lang=en ???cp -f "${quickbox_base                                                                                                                                                             _path}/config/lang/${quickbox_lang}/locale" "/etc/default/locale" ???cp -f "${qu                                                                                                                                                             ickbox_base_path}/config/lang/${quickbox_lang}/localize.php" "/srv/quickbox/inc/                                                                                                                                                             localize.php" ???sed -i -e '/de_DE.UTF-8/s/^#*/#/g' -e '/da_DK.UTF-8/s/^#*/#/g'                                                                                                                                                              -e '/es_ES.UTF-8/s/^#*/#/g' -e '/fr_FR.UTF-8/s/^#*/#/g' -e '/pt_PT.UTF-8/s/^#*/#                                                                                                                                                             /g' -e '/zh_CN.UTF-8/s/^#*/#/g' -e 's/^#.*\(en_US.UTF-8\)/\1/' /etc/locale.gen ?                                                                                                                                                             ??#sudo locale-gen --purge >/dev/null 2>&1 ???sudo update-locale --locale-file=/                                                                                                                                                             etc/default/locale >/dev/null 2>&1 ???sudo dpkg-reconfigure --frontend nonintera                                                                                                                                                             ctive locales >/dev/null 2>&1 ???source /root/.bashrc ???;; ??es | spanish*) ???                                                                                                                                                             source /root/.bashrc ???declare -g locale_sed quickbox_lang ???locale_sed=es_ES                                                                                                                                                              ???quickbox_lang=es ???cp -f "${quickbox_base_path}/config/lang/${quickbox_lang}                                                                                                                                                             /locale" "/etc/default/locale" ???cp -f "${quickbox_base_path}/config/lang/${qui                                                                                                                                                             ckbox_lang}/localize.php" "/srv/quickbox/inc/localize.php" ???sed -i -e '/de_DE.                                                                                                                                                             UTF-8/s/^#*/#/g' -e '/da_DK.UTF-8/s/^#*/#/g' -e '/fr_FR.UTF-8/s/^#*/#/g' -e '/pt                                                                                                                                                             _PT.UTF-8/s/^#*/#/g' -e '/zh_CN.UTF-8/s/^#*/#/g' -e 's/^#.*\(es_ES.UTF-8\)/\1/'                                                                                                                                                              /etc/locale.gen >/dev/null 2>&1 ???#sudo locale-gen --purge >/dev/null 2>&1 ???s                                                                                                                                                             udo update-locale --locale-file=/etc/default/locale >/dev/null 2>&1 ???sudo dpkg                                                                                                                                                             -reconfigure --frontend noninteractive locales >/dev/null 2>&1 ???source /root/.                                                                                                                                                             bashrc ???;; ??fr | french*) ???source /root/.bashrc ???declare -g locale_sed qu                                                                                                                                                             ickbox_lang ???locale_sed=fr_FR ???quickbox_lang=fr ???cp -f "${quickbox_base_pa                                                                                                                                                             th}/config/lang/${quickbox_lang}/locale" "/etc/default/locale" ???cp -f "${quick                                                                                                                                                             box_base_path}/config/lang/${quickbox_lang}/localize.php" "/srv/quickbox/inc/loc                                                                                                                                                             alize.php" ???sed -i -e '/de_DE.UTF-8/s/^#*/#/g' -e '/da_DK.UTF-8/s/^#*/#/g' -e                                                                                                                                                              '/es_ES.UTF-8/s/^#*/#/g' -e '/pt_PT.UTF-8/s/^#*/#/g' -e '/zh_CN.UTF-8/s/^#*/#/g'                                                                                                                                                              -e 's/^#.*\(fr_FR.UTF-8\)/\1/' /etc/locale.gen >/dev/null 2>&1 ???#sudo locale-                                                                                                                                                             gen --purge >/dev/null 2>&1 ???sudo update-locale --locale-file=/etc/default/loc                                                                                                                                                             ale >/dev/null 2>&1 ???sudo dpkg-reconfigure --frontend noninteractive locales >                                                                                                                                                             /dev/null 2>&1 ???source /root/.bashrc ???;; ??pt | portuguese*) ???source /root                                                                                                                                                             /.bashrc ???declare -g locale_sed quickbox_lang ???locale_sed=pt_PT ???quickbox_                                                                                                                                                             lang=pt ???cp -f "${quickbox_base_path}/config/lang/${quickbox_lang}/locale" "/e                                                                                                                                                             tc/default/locale" ???cp -f "${quickbox_base_path}/config/lang/${quickbox_lang}/                                                                                                                                                             localize.php" "/srv/quickbox/inc/localize.php" ???sed -i -e '/de_DE.UTF-8/s/^#*/                                                                                                                                                             #/g' -e '/da_DK.UTF-8/s/^#*/#/g' -e '/es_ES.UTF-8/s/^#*/#/g' -e '/fr_FR.UTF-8/s/                                                                                                                                                             ^#*/#/g' -e '/zh_CN.UTF-8/s/^#*/#/g' -e 's/^#.*\(pt_PT.UTF-8\)/\1/' /etc/locale.                                                                                                                                                             gen >/dev/null 2>&1 ???#sudo locale-gen --purge >/dev/null 2>&1 ???sudo update-l                                                                                                                                                             ocale --locale-file=/etc/default/locale >/dev/null 2>&1 ???sudo dpkg-reconfigure                                                                                                                                                              --frontend noninteractive locales >/dev/null 2>&1 ???source /root/.bashrc ???;;                                                                                                                                                              ??zh-cn | chinese*) ???source /root/.bashrc ???declare -g locale_sed quickbox_l                                                                                                                                                             ang ???locale_sed=zh_CN ???quickbox_lang=zh-cn ???mflibs::log "apt-get -y instal                                                                                                                                                             l language-pack-zh-hans language-pack-zh-hans-base fonts-noto" ???cp -f "${quick                                                                                                                                                             box_base_path}/config/lang/${quickbox_lang}/locale" "/etc/default/locale" ???cp                                                                                                                                                              -f "${quickbox_base_path}/config/lang/${quickbox_lang}/localize.php" "/srv/quick                                                                                                                                                             box/inc/localize.php" ???sed -i -e '/de_DE.UTF-8/s/^#*/#/g' -e '/da_DK.UTF-8/s/^                                                                                                                                                             #*/#/g' -e '/es_ES.UTF-8/s/^#*/#/g' -e '/fr_FR.UTF-8/s/^#*/#/g' -e '/pt_PT.UTF-8                                                                                                                                                             /s/^#*/#/g' -e 's/^#.*\(zh_CN.UTF-8\)/\1/' /etc/locale.gen >/dev/null 2>&1 ???#s                                                                                                                                                             udo locale-gen --purge >/dev/null 2>&1 ???sudo update-locale --locale-file=/etc/                                                                                                                                                             default/locale >/dev/null 2>&1 ???sudo dpkg-reconfigure --frontend noninteractiv                                                                                                                                                             e locales >/dev/null 2>&1 ???source /root/.bashrc ???;; ??*) ;; ??esac ?done ?if                                                                                                                                                              [[ -n ${locale_sed} ]]; then ??sed -i -e 's/thousands_sep.*/thousands_sep                                                                                                                                                                          \"<U002C>\"/' "/usr/share/i18n/locales/${locale_sed}" ??[[ ${code_name} =                                                                                                                                                             = "stretch" ]] && sed -i -e 's/decimal_point.*/decimal_point             \"<U002                                                                                                                                                             C>\"/' "/usr/share/i18n/locales/${locale_sed}" ?fi ?chown www-data: /srv/quickbo                                                                                                                                                             x/inc/localize.php ?#mflibs::log "dpkg-reconfigure --frontend noninteractive loc                                                                                                                                                             ales" ?quickbox::database "UPDATE system_configuration set configuration_value =                                                                                                                                                              '${quickbox_lang}' WHERE configuration_name = 'server_language';" ?#mflibs::log                                                                                                                                                              "systemctl reload nginx" ?mflibs::log "systemctl reload php8.1-fpm > /dev/null                                                                                                                                                              2>&1 &" ?mflibs::log "systemctl reload memcached > /dev/null 2>&1 &" }  ########                                                                                                                                                             ######################################################################## # @desc                                                                                                                                                             ription: manages backup, restore, and restore default for software configs # @ar                                                                                                                                                             g: -o [disable|enable|backup|restore|default] -u [username] -s [software] # @exa                                                                                                                                                             mple: qb manage nginx -o backup -s softwarename -u username # @null ############                                                                                                                                                             #################################################################### nginx::sett                                                                                                                                                             ings() { ?if [[ ${software:?} == "netdata" || ${software:?} == "nextcloud" || ${                                                                                                                                                             software:?} == "rutorrent" || ${software:?} == "tautulli" || ${software:?} == "t                                                                                                                                                             helounge" || ${software:?} == "transmission" || ${software:?} == "webconsole" ||                                                                                                                                                              ${software:?} == "znc" ]]; then ??software_nginx="/etc/nginx/software/${softwar                                                                                                                                                             e:-}.conf" ??software_backup_nginx="/home/${username:?}/.QuickBox/software/${sof                                                                                                                                                             tware}/backup/nginx/${software}.conf" ??software_default_nginx="/home/${username                                                                                                                                                             }/.QuickBox/software/${software}/default/nginx/${software}.conf" ?else ??softwar                                                                                                                                                             e_nginx="/etc/nginx/software/${username:?}.${software:-}.conf" ??software_backup                                                                                                                                                             _nginx="/home/${username}/.QuickBox/software/${software}/backup/nginx/${username                                                                                                                                                             }.${software}.conf" ??software_default_nginx="/home/${username}/.QuickBox/softwa                                                                                                                                                             re/${software}/default/nginx/${username}.${software}.conf" ?fi ?for option in "$                                                                                                                                                             {qb_option[@]}"; do ??case "${option,,}" in ??disable) ???mflibs::shell::text::w                                                                                                                                                             hite "disabling auth login on ${software} nginx reverse." ???if [[ ! -f ${softwa                                                                                                                                                             re_nginx} ]]; then ????mflibs::shell::text::red "nginx file [${software_nginx}]                                                                                                                                                              does not exist." ???else ????sed -i '/auth_basic/s/^#*/#/g' "${software_nginx}"                                                                                                                                                              ????mflibs::log "systemctl reload nginx.service" ????mflibs::shell::text::green                                                                                                                                                              "nginx auth has been disabled." ???fi ???;; ??enable) ???mflibs::shell::text::wh                                                                                                                                                             ite "enabling auth login on ${software} nginx reverse." ???if [[ ! -f ${software                                                                                                                                                             _nginx} ]]; then ????mflibs::shell::text::red "nginx file [${software_nginx}] do                                                                                                                                                             es not exist." ???else ????sed -i '/auth_basic/s/^#*//g' "${software_nginx}" ???                                                                                                                                                             ?mflibs::log "systemctl reload nginx.service" ????mflibs::shell::text::green "ng                                                                                                                                                             inx auth has been enabled." ???fi ???;; ??backup) ???mflibs::shell::text::white                                                                                                                                                              "nginx file for ${software} is now being backed up." ???if [[ ! -f ${software_ng                                                                                                                                                             inx} ]]; then ????mflibs::shell::text::red "nginx file [${software_nginx}] does                                                                                                                                                              not exist." ???else ????mkdir -p "/home/${username}/.QuickBox/software/${softwar                                                                                                                                                             e}/backup/nginx/" ????\cp -pf "${software_nginx}" "${software_backup_nginx}" ???                                                                                                                                                             ?mflibs::shell::text::green "configuration file has been backed up." ???fi ???;;                                                                                                                                                              ??restore) ???if [[ ! -f ${software_backup_nginx} ]]; then ????mflibs::shell::t                                                                                                                                                             ext::red "nginx file [${software_backup_nginx}] does not exist." ???else ????\cp                                                                                                                                                              -pf "${software_backup_nginx}" "${software_nginx}" ????mflibs::shell::text::gre                                                                                                                                                             en "backed up configuration file has been restored." ???fi ???;; ??default) ???i                                                                                                                                                             f [[ ! -f ${software_default_nginx} ]]; then ????mflibs::shell::text::red "deful                                                                                                                                                             t nginx file [${software_default_nginx}] does not exist." ???else ????\cp -pf "$                                                                                                                                                             {software_default_nginx}" "${software_nginx}" ????mflibs::shell::text::green "de                                                                                                                                                             fault configuration file has been restored." ???fi ???;; ??*) ;; ??esac ?done }                                                                                                                                                               ###############################################################################                                                                                                                                                             # # @description: manages directory/mount checks # @arg: -o space -u [username]                                                                                                                                                              # @example: qb manage mount -o space -u username # @null #######################                                                                                                                                                             ######################################################### mount::settings() { ?f                                                                                                                                                             or option in "${qb_option[@]}"; do ??case "${option,,}" in ??space) ???read -d '                                                                                                                                                             ' -ra mount_path <<<"$(quickbox::database "SELECT mount FROM user_mounts WHERE u                                                                                                                                                             sername='${username}';")" ???for m in "${mount_path[@]}"; do ????# if mount path                                                                                                                                                              is '/' use `df -B1` instead ????[[ ${m} == "/" ]] && space_used=$(df -B1 | grep                                                                                                                                                              -w "/" | awk '{print $3}' | tail -n 1) ????[[ ${m} != "/" ]] && space_used=$(du                                                                                                                                                              -ac --bytes "${m}" | awk '{print $1}' | tail -n 1) ????mflibs::shell::text::gre                                                                                                                                                             en "updating ${m} with ${space_used}" ????quickbox::database "UPDATE user_mounts                                                                                                                                                              set space='${space_used}' WHERE username='${username}' AND mount='${m}';" ???do                                                                                                                                                             ne ???if [[ -d "/home/${username}/.config/rclone/" ]]; then ????mergerfs_service                                                                                                                                                             _mount=$(grep 'fuse.mergerfs' </proc/mounts | cut -d ' ' -f 2 | sed -e 's|/|-|g'                                                                                                                                                              | sed -ne 's|-||p' | grep "${username}") ????echo "${mergerfs_service_mount}" >                                                                                                                                                             "/home/${username}/.config/rclone/mergerfs_mount_service.txt" ????chown -R "${us                                                                                                                                                             ername}":"${username}" "/home/${username}/.config/rclone/" ????chmod 0664 "/home                                                                                                                                                             /${username}/.config/rclone/mergerfs_mount_service.txt" ???fi ???;; ??*) ;; ??es                                                                                                                                                             ac ?done }  ####################################################################                                                                                                                                                             ############ # @description: manages backup, restore, and restore default for so                                                                                                                                                             ftware configs. # additionally handles the install/uninstall of rutorrent plugin                                                                                                                                                             s (see second example) # # notes: # - rtorrent requires no additional arguments                                                                                                                                                              (such as -u) as it is a system-wide # install and not user-specific (see last ex                                                                                                                                                             ample) # @arg: -o [backup|restore|default|] -u [username] -s [software] # @arg:                                                                                                                                                              -o [rutorrent] -o [install|remove] -rup [rutorrent_plugin_name] # @example: qb m                                                                                                                                                             anage software -o backup -u username -s softwarename # qb manage software -o bac                                                                                                                                                             kup -o app -u username -s softwarename # qb manage software -o rollback -o app -                                                                                                                                                             u username -s softwarename # qb manage software -o restore -u username -s softwa                                                                                                                                                             rename # qb manage software -o default -u username -s softwarename # qb manage s                                                                                                                                                             oftware -o rutorrent -o install -rup _cloudflare # @null # @example: qb manage s                                                                                                                                                             oftware -o backup -s rtorrent # @null ##########################################                                                                                                                                                             ###################################### software::settings() { ?declare software_                                                                                                                                                             name ?software_name=$(quickbox::database "SELECT DISTINCT software_name from sof                                                                                                                                                             tware_information WHERE software_name = '${software:-}' LIMIT 1;") ?default_loca                                                                                                                                                             tion=$(quickbox::database "SELECT DISTINCT software_default_location from softwa                                                                                                                                                             re_information WHERE software_name = '${software:-}';") ?backup_location=$(quick                                                                                                                                                             box::database "SELECT DISTINCT software_backup_location from software_informatio                                                                                                                                                             n WHERE software_name = '${software_name}';") ?software_location=$(quickbox::dat                                                                                                                                                             abase "SELECT DISTINCT software_config_location from software_information WHERE                                                                                                                                                              software_name = '${software_name}';") ?software_title=$(quickbox::database "SELE                                                                                                                                                             CT DISTINCT software_title from software_information WHERE software_name = '${so                                                                                                                                                             ftware_name}';") ?# only set these variables if the software_name is not rtorren                                                                                                                                                             t OR rutorrent ?if [[ "${software_name}" != "rtorrent" ]]; then ??declare backup                                                                                                                                                             _version ??user_id=$(quickbox::database "SELECT id FROM user_information WHERE u                                                                                                                                                             sername='${username}';") ??backup_version=$(quickbox::database "SELECT DISTINCT                                                                                                                                                              software_version from user_software WHERE user_id = '${user_id:?}' AND software_                                                                                                                                                             name = '${software_name}' LIMIT 1;") ??defaultConf="/home/${username:-}/.QuickBo                                                                                                                                                             x/software${default_location}" ??backupConf="/home/${username}/.QuickBox/softwar                                                                                                                                                             e${backup_location}" ??softwareConf="/home/${username}${software_location}" ?fi                                                                                                                                                              ?for option in "${qb_option[@]}"; do ??case "${option,,}" in ??backup) ???[[ "${                                                                                                                                                             qb_option[*]}" =~ "vi=" ]] && declare skip_check=1 ???vi=$(grep -oP 'vi=\K.*' <<                                                                                                                                                             <"${qb_option[*]}") ???if [[ "${software_name}" =~ "rtorrent" ]]; then ????read                                                                                                                                                              -d '' -ra users_all <<<"$(quickbox::database "SELECT username FROM user_informat                                                                                                                                                             ion")" ????for user in "${users_all:-[@]}"; do ?????[[ -z ${skip_check} ]] && mf                                                                                                                                                             libs::shell::text::white "$(quickbox::lang::backup::configf)" ?????declare time_                                                                                                                                                             stamp ?????time_stamp=$(date '+%Y-%m-%d %H:%M') ?????package_date=${time_stamp//                                                                                                                                                              /_} ?????userid=$(quickbox::database "SELECT id FROM user_information WHERE use                                                                                                                                                             rname='${user}';") ?????backup_version=$(quickbox::database "SELECT DISTINCT sof                                                                                                                                                             tware_version from user_software WHERE user_id = '${userid:?}' AND software_name                                                                                                                                                              = '${software_name}' LIMIT 1;") ?????defaultConf="/home/${user:-}/.QuickBox/sof                                                                                                                                                             tware${default_location}" ?????backupConf="/home/${user}/.QuickBox/software${bac                                                                                                                                                             kup_location}" ?????softwareConf="/home/${user}${software_location}" ?????backup                                                                                                                                                             ="/home/${user}/.QuickBox/software/rtorrent/backup/" ?????mkdir -p "${backup}" &                                                                                                                                                             & cp -prf "${softwareConf}" "${backupConf}_${package_date}" && cp -prf "${backup                                                                                                                                                             Conf}_${package_date}" "${backupConf}" ?????find "/home/${user}/.QuickBox" -type                                                                                                                                                              d \( ! -user www-data -o ! -group www-data \) -print0 | xargs -0 chown www-data                                                                                                                                                             :www-data >/dev/null 2>&1 ?????find "/home/${user}/.QuickBox" -type d ! -perm 07                                                                                                                                                             55 -print0 | xargs -0 chmod 0755 >/dev/null 2>&1 ?????[[ -z ${skip_check} ]] &&                                                                                                                                                              mflibs::shell::text::green "$(quickbox::lang::backup::configf::success)" ????don                                                                                                                                                             e ???else ????[[ -z ${skip_check} ]] && mflibs::shell::text::white "$(quickbox::                                                                                                                                                             lang::backup::configf)" ????if [[ ! -f ${softwareConf} ]]; then ?????mflibs::she                                                                                                                                                             ll::text::red "$(quickbox::lang::backup::configf::error)" ?????exit 1 ????fi ???                                                                                                                                                             ?user_id=$(quickbox::database "SELECT id FROM user_information WHERE username='$                                                                                                                                                             {username}';") ????backup_version=$(quickbox::database "SELECT DISTINCT software                                                                                                                                                             _version from user_software WHERE user_id = '${user_id:?}' AND software_name = '                                                                                                                                                             ${software_name}' LIMIT 1;") ????defaultConf="/home/${username:-}/.QuickBox/soft                                                                                                                                                             ware${default_location}" ????backupConf="/home/${username}/.QuickBox/software${b                                                                                                                                                             ackup_location}" ????softwareConf="/home/${username}${software_location}" ????[[                                                                                                                                                              "${software_name}" =~ "deluged" ]] && backup="/home/${username}/.QuickBox/softw                                                                                                                                                             are/deluge/backup/" ????[[ "${software_name}" != "deluged" ]] && backup="/home/$                                                                                                                                                             {username}/.QuickBox/software/${software_name}/backup/" ????mkdir -p "${backup}"                                                                                                                                                              && cp -prf "${softwareConf}" "${backupConf}" ????find "/home/${username}/.Quick                                                                                                                                                             Box" -type d \( ! -user www-data -o ! -group www-data \) -print0 | xargs -0 chow                                                                                                                                                             n www-data:www-data >/dev/null 2>&1 ????find "/home/${username}/.QuickBox" -type                                                                                                                                                              d ! -perm 0755 -print0 | xargs -0 chmod 0755 >/dev/null 2>&1 ????[[ -z ${skip_c                                                                                                                                                             heck} ]] && mflibs::shell::text::green "$(quickbox::lang::backup::configf::succe                                                                                                                                                             ss)" ???fi ???# check if `-o app` is set, if so, backup the application install                                                                                                                                                              and config directories ???if [[ "${qb_option[*]}" =~ "app" ]]; then ????# set cu                                                                                                                                                             stom conditions for software installation directories ????if [[ "${software_name                                                                                                                                                             }" =~ "emby" ]]; then ?????install_directory="/opt/${username}/emby-server" ????                                                                                                                                                             elif [[ "${software_name}" =~ "plex" ]]; then ?????install_directory="/usr/lib/p                                                                                                                                                             lexmediaserver" ????else ?????install_directory=$(find "/opt/${username}" -maxde                                                                                                                                                             pth 1 -type d -name "${software_title}" -printf '%f\n') ????fi ????if [[ -z "${i                                                                                                                                                             nstall_directory}" ]]; then ?????mflibs::shell::text::red "$(quickbox::lang::bac                                                                                                                                                             kup::installdir::error)" ?????exit 1 ????fi ????backup="/home/${username}/.Quick                                                                                                                                                             Box/software/${software_name}/backup/" ????mkdir -p "${backup}" && cp -prf "${so                                                                                                                                                             ftwareConf}" "${backupConf}" ????declare time_stamp package_date ????time_stamp=                                                                                                                                                             $(date '+%Y-%m-%d %H:%M') ????package_date=${time_stamp// /_} ????mflibs::shell:                                                                                                                                                             :text::white "$(quickbox::lang::backup::installdir)" ????# create a tarball of t                                                                                                                                                             he software installation directory ????if [[ "${software_name}" =~ "emby" || "${                                                                                                                                                             software_name}" =~ "plex" ]]; then ?????tar -czf "${backup}/${software_name}-${b                                                                                                                                                             ackup_version}-application_${package_date}.tar.gz" -C "${install_directory}" . >                                                                                                                                                             /dev/null 2>&1 ????else ?????tar -czf "${backup}/${software_name}-${backup_versi                                                                                                                                                             on}-application_${package_date}.tar.gz" -C "/opt/${username}/${install_directory                                                                                                                                                             }" . >/dev/null 2>&1 ????fi ????mflibs::shell::text::white "$(quickbox::lang::ba                                                                                                                                                             ckup::configdir)" ????# create a tarball of the software configuration directory                                                                                                                                                              ????if [[ "${software_name}" =~ "emby" ]]; then ?????tar -czf "${backup}/${soft                                                                                                                                                             ware_name}-${backup_version}-config_${package_date}.tar.gz" -C "/home/${username                                                                                                                                                             }/.config/Emby" . >/dev/null 2>&1 ????elif [[ "${software_name}" =~ "plex" ]]; t                                                                                                                                                             hen ?????tar -czf "${backup}/${software_name}-${backup_version}-config_${package                                                                                                                                                             _date}.tar.gz" -C "/home/${username}/.config/Plex Media Server" . >/dev/null 2>&                                                                                                                                                             1 ????elif [[ "${software_name}" =~ "jellyseerr" ]]; then ?????tar -czf "${backu                                                                                                                                                             p}/${software_name}-${backup_version}-config_${package_date}.tar.gz" -C "/opt/${                                                                                                                                                             username}/Jellyseerr/config" . >/dev/null 2>&1 ????elif [[ "${software_name}" =~                                                                                                                                                              "overseerr" ]]; then ?????tar -czf "${backup}/${software_name}-${backup_version                                                                                                                                                             }-config_${package_date}.tar.gz" -C "/opt/${username}/Overseerr/config" . >/dev/                                                                                                                                                             null 2>&1 ????else ?????tar -czf "${backup}/${software_name}-${backup_version}-c                                                                                                                                                             onfig_${package_date}.tar.gz" -C "/home/${username}/.config/${software_title}" .                                                                                                                                                              >/dev/null 2>&1 ????fi ????find "/home/${username}/.QuickBox" -type d \( ! -use                                                                                                                                                             r www-data -o ! -group www-data \) -print0 | xargs -0 chown www-data:www-data >/                                                                                                                                                             dev/null 2>&1 ????find "/home/${username}/.QuickBox" -type d ! -perm 0755 -print                                                                                                                                                             0 | xargs -0 chmod 0755 >/dev/null 2>&1 ????chown www-data:www-data -R "${backup                                                                                                                                                             }/${software_name}"-*.tar.gz >/dev/null 2>&1 ????chown "${username}":"${username                                                                                                                                                             }" "${backupConf}" "${softwareConf}" ????quickbox::database "INSERT INTO softwar                                                                                                                                                             e_rollbacks ("username", "software_name", "software_version", "software_date") V                                                                                                                                                             ALUES ('${username}', '${software_name:-}', '${backup_version:-}', '${time_stamp                                                                                                                                                             :-}');" ????mflibs::shell::text::green "$(quickbox::lang::backup::installdir::su                                                                                                                                                             ccess)" ????unset time_stamp package_date backup_version software_name ???fi ???                                                                                                                                                             ;; ??restore) ???if [[ ! -f ${backupConf} ]]; then ????mflibs::shell::text::red                                                                                                                                                              "$(quickbox::lang::restore::configf::error)" ???else ????cp -prf "${backupConf}"                                                                                                                                                              "${softwareConf}" ????find "/home/${username}/.QuickBox" -type d \( ! -user www                                                                                                                                                             -data -o ! -group www-data \) -print0 | xargs -0 chown www-data:www-data >/dev/n                                                                                                                                                             ull 2>&1 ????find "/home/${username}/.QuickBox" -type d ! -perm 0755 -print0 | x                                                                                                                                                             args -0 chmod 0755 >/dev/null 2>&1 ????chown "${username}":"${username}" "${back                                                                                                                                                             upConf}" "${softwareConf}" ????mflibs::shell::text::green "$(quickbox::lang::res                                                                                                                                                             tore::configf::success)" ???fi ???;; ??default) ???if [[ ! -f ${defaultConf} ]];                                                                                                                                                              then ????mflibs::shell::text::red "$(quickbox::lang::default::configf::error)"                                                                                                                                                              ???else ????cp -prf "${defaultConf}" "${softwareConf}" ????find "/home/${usernam                                                                                                                                                             e}/.QuickBox" -type d \( ! -user www-data -o ! -group www-data \) -print0 | xarg                                                                                                                                                             s -0 chown www-data:www-data >/dev/null 2>&1 ????find "/home/${username}/.QuickB                                                                                                                                                             ox" -type d ! -perm 0755 -print0 | xargs -0 chmod 0755 >/dev/null 2>&1 ????chown                                                                                                                                                              "${username}":"${username}" "${backupConf}" "${softwareConf}" ????mflibs::shell                                                                                                                                                             ::text::green "$(quickbox::lang::default::configf::success)" ???fi ???;; ??rollb                                                                                                                                                             ack) ???if [[ "${qb_option[*]}" =~ "app" ]]; then ????user_id=$(quickbox::databa                                                                                                                                                             se "SELECT id FROM user_information WHERE username='${username}';") ????software                                                                                                                                                             _title=$(quickbox::database "SELECT DISTINCT software_title from software_inform                                                                                                                                                             ation WHERE software_name = '${software}';") ????software_service_name=$(quickbo                                                                                                                                                             x::database "SELECT DISTINCT software_service_name from software_information WHE                                                                                                                                                             RE software_name = '${software}';") ????backup_path="/home/${username}/.QuickBox                                                                                                                                                             /software/${software}/backup/" ????[[ -f "/etc/systemd/system/${software_service                                                                                                                                                             _name}@${username}.service" ]] && systemctl stop "${software_service_name}"@"${u                                                                                                                                                             sername}" >/dev/null 2>&1 ????[[ -f "/etc/systemd/system/${software_service_name                                                                                                                                                             }.service" ]] && systemctl stop "${software_service_name}" >/dev/null 2>&1 ????#                                                                                                                                                              set custom conditions for software directories on rollback ????if [[ "${softwar                                                                                                                                                             e}" =~ "emby" ]]; then ?????install_directory="/opt/${username}/emby-server" ???                                                                                                                                                             ?elif [[ "${software}" =~ "plex" ]]; then ?????install_directory="/usr/lib/plexm                                                                                                                                                             ediaserver" ????else ?????install_directory=$(find "/opt/${username}" -maxdepth                                                                                                                                                              1 -type d -name "${software_title}" -printf '%f\n') ????fi ????if [[ -z "${insta                                                                                                                                                             ll_directory}" ]]; then ?????mflibs::shell::text::red "$(quickbox::lang::rollbac                                                                                                                                                             k::installdir::error)" ?????exit 1 ????fi ????[[ "${qb_option[*]}" =~ "vi=" ]] &                                                                                                                                                             & declare skip_check=1 ????swvi=1 ????IFS=$'\n' read -d '' -ra backups <<<"$(qui                                                                                                                                                             ckbox::database "SELECT software_version,software_date from software_rollbacks W                                                                                                                                                             HERE software_name = '${software}' AND username = '${username}';")" ????backup_m                                                                                                                                                             enu=() ????for i in "${backups[@]}"; do ?????backup_version="$(echo "${i}" | cut                                                                                                                                                              -d '|' -f1)" ?????backup_date="$(echo "${i}" | cut -d '|' -f2-)" ?????backup_me                                                                                                                                                             nu+=("  ${swvi})    $(quickbox::lang::rollback::selection::version) ${backup_ver                                                                                                                                                             sion}    $(quickbox::lang::rollback::selection::date) ${backup_date}") ?????swvi                                                                                                                                                             =$((swvi + 1)) ????done ????# display the menu ????mflibs::shell::text::white "$                                                                                                                                                             (quickbox::lang::rollback::selection)" ????for backup_display in "${backup_menu[                                                                                                                                                             @]}"; do ?????echo "${backup_display}" ????done ????# set the version from the s                                                                                                                                                             election ????declare -gi vi ????declare version ????if [[ ${skip_check} == 1 ]];                                                                                                                                                              then ?????# set the vi= to the value in the -o vi= option ?????vi=$(grep -oP 'v                                                                                                                                                             i=\K.*' <<<"${qb_option[*]}") ????else ?????IFS=$'\n' read -r version_selection                                                                                                                                                              ?????vi=$(grep -oP "${version_selection}" <<<"${backup_menu[@]}" | grep -oP '[0-                                                                                                                                                             9]*' | head -n 1) ????fi ????version=$(grep -oP 'version: \K.*(?=    date)' <<<"                                                                                                                                                             ${backup_menu[$((vi - 1))]}") ????# set confirmation if input provided is correc                                                                                                                                                             t ????if [[ -z "${version}" ]]; then ?????mflibs::shell::text::red "$(quickbox::                                                                                                                                                             lang::rollback::selection::invalid)" ?????IFS=$'\n' read -r version_selection ??                                                                                                                                                             ??else ?????# show selection and confirmation request ?????declare selected_date                                                                                                                                                              app_package config_package ?????selected_date=$(grep -oP 'date: \K.*' <<<"${bac                                                                                                                                                             kup_menu[$((vi - 1))]}") ?????package_date=${selected_date// /_} ?????app_packag                                                                                                                                                             e=$(find "${backup_path}" -maxdepth 1 -type f -name "${software}-${version}-appl                                                                                                                                                             ication_${package_date}.tar.gz" -printf '%f\n') ?????if [[ -z "${app_package}" ]                                                                                                                                                             ]; then ??????mflibs::shell::text::red "$(quickbox::lang::rollback::software::er                                                                                                                                                             ror)" ??????exit 1 ?????fi ?????config_package=$(find "${backup_path}" -maxdepth                                                                                                                                                              1 -type f -name "${software}-${version}-config_${package_date}.tar.gz" -printf                                                                                                                                                              '%f\n') ?????if [[ -z "${config_package}" ]]; then ??????mflibs::shell::text::re                                                                                                                                                             d "$(quickbox::lang::rollback::config::error)" ??????exit 1 ?????fi ?????mflibs:                                                                                                                                                             :shell::text::white "$(quickbox::lang::rollback::selection::display)" ?????if [[                                                                                                                                                              -z ${skip_check} ]]; then ??????mflibs::shell::text::white "$(quickbox::lang::r                                                                                                                                                             ollback::selection::confirm)" ??????IFS=$'\n' read -r version_confirm ??????# lo                                                                                                                                                             op until a valid selection is made ??????while [[ "${version_confirm}" != "y" ]]                                                                                                                                                              && [[ "${version_confirm}" != "n" ]]; do ???????mflibs::shell::text::red "$(qui                                                                                                                                                             ckbox::lang::rollback::selection::invalid)" ???????IFS=$'\n' read -r version_con                                                                                                                                                             firm ??????done ??????# if the selection is no, exit the script ??????if [[ "${v                                                                                                                                                             ersion_confirm}" == "n" ]]; then ???????mflibs::shell::text::red "$(quickbox::la                                                                                                                                                             ng::rollback::cancelled)" ???????exit 0 ??????fi ?????fi ????fi ????# display co                                                                                                                                                             nfirmation of the version selection and proceed with the rollback ????mflibs::sh                                                                                                                                                             ell::text::white "$(quickbox::lang::rollback::continue)" ????# extract the tarba                                                                                                                                                             ll of the software installation directory ????if [[ "${software}" =~ "emby" || "                                                                                                                                                             ${software}" =~ "plex" ]]; then ?????tar -xzf "${backup_path}/${app_package}" -C                                                                                                                                                              "${install_directory}" >/dev/null 2>&1 ????else ?????tar -xzf "${backup_path}/$                                                                                                                                                             {app_package}" -C "/opt/${username}/${install_directory}" >/dev/null 2>&1 ????fi                                                                                                                                                              ????# extract the tarball of the software configuration directory ????if [[ "${                                                                                                                                                             software}" =~ "emby" ]]; then ?????tar -xzf "${backup_path}/${config_package}" -                                                                                                                                                             C "/home/${username}/.config/Emby" >/dev/null 2>&1 ?????chown "${username}":"${u                                                                                                                                                             sername}" -R "${install_directory}" "/home/${username}/.config/Emby" 2>&1 ????el                                                                                                                                                             if [[ "${software}" =~ "plex" ]]; then ?????tar -xzf "${backup_path}/${config_pa                                                                                                                                                             ckage}" -C "/home/${username}/.config/Plex Media Server" >/dev/null 2>&1 ?????ch                                                                                                                                                             own "${username}":"${username}" -R "${install_directory}" "/home/${username}/.co                                                                                                                                                             nfig/Plex Media Server" 2>&1 ????elif [[ "${software_name}" =~ "jellyseerr" ]];                                                                                                                                                              then ?????tar -xzf "${backup_path}/${config_package}" -C "/opt/${username}/Jelly                                                                                                                                                             seerr/config" >/dev/null 2>&1 ?????chown "${username}":"${username}" -R "${insta                                                                                                                                                             ll_directory}" "/home/${username}/.config/Jellyseerr" 2>&1 ????elif [[ "${softwa                                                                                                                                                             re_name}" =~ "overseerr" ]]; then ?????tar -xzf "${backup_path}/${config_package                                                                                                                                                             }" -C "/opt/${username}/Overseerr/config" >/dev/null 2>&1 ?????chown "${username                                                                                                                                                             }":"${username}" -R "${install_directory}" "/home/${username}/.config/Overseerr"                                                                                                                                                              2>&1 ????else ?????tar -xzf "${backup_path}/${config_package}" -C "/home/${user                                                                                                                                                             name}/.config/${software_title}" >/dev/null 2>&1 ?????chown "${username}":"${use                                                                                                                                                             rname}" -R "/opt/${username}/${install_directory}" "/home/${username}/.config/${                                                                                                                                                             software_title}" 2>&1 ????fi ????quickbox::database "UPDATE user_software SET so                                                                                                                                                             ftware_version='${version}' WHERE software_name='${software}' AND user_id='${use                                                                                                                                                             r_id:?}';" ????[[ -f "/etc/systemd/system/${software_service_name}@${username}.s                                                                                                                                                             ervice" ]] && systemctl start "${software_service_name}"@"${username}" >/dev/nul                                                                                                                                                             l 2>&1 ????[[ -f "/etc/systemd/system/${software_service_name}.service" ]] && sy                                                                                                                                                             stemctl start "${software_service_name}" >/dev/null 2>&1 ????/usr/local/bin/qb s                                                                                                                                                             oftware check >/dev/null 2>&1 ????mflibs::shell::text::green "$(quickbox::lang::                                                                                                                                                             rollback::complete)" ????unset version version_selection vi selected_date app_pa                                                                                                                                                             ckage config_package ???fi ???;; ??delete) ???if [[ "${qb_option[*]}" =~ "app" ]                                                                                                                                                             ]; then ????user_id=$(quickbox::database "SELECT id FROM user_information WHERE                                                                                                                                                              username='${username}';") ????software_title=$(quickbox::database "SELECT DISTIN                                                                                                                                                             CT software_title from software_information WHERE software_name = '${software}';                                                                                                                                                             ") ????software_service_name=$(quickbox::database "SELECT DISTINCT software_serv                                                                                                                                                             ice_name from software_information WHERE software_name = '${software}';") ????ba                                                                                                                                                             ckup_path="/home/${username}/.QuickBox/software/${software}/backup/" ????install                                                                                                                                                             _directory=$(find "/opt/${username}" -maxdepth 1 -type d -name "${software_title                                                                                                                                                             }*" -printf '%f\n') ????config_directory=$(find "/home/${username}/.config" -max                                                                                                                                                             depth 1 -type d -name "${software_title}*" -printf '%f\n') ????[[ "${qb_option[*                                                                                                                                                             ]}" =~ "vi=" ]] && declare skip_check=1 ????swvi=1 ????IFS=$'\n' read -d '' -ra                                                                                                                                                              backups <<<"$(quickbox::database "SELECT software_version,software_date from sof                                                                                                                                                             tware_rollbacks WHERE software_name = '${software}' AND username = '${username}'                                                                                                                                                             ;")" ????backup_menu=() ????for i in "${backups[@]}"; do ?????backup_version="$(                                                                                                                                                             echo "${i}" | cut -d '|' -f1)" ?????backup_date="$(echo "${i}" | cut -d '|' -f2-                                                                                                                                                             )" ?????backup_menu+=("  ${swvi})    $(quickbox::lang::delete::selection::versio                                                                                                                                                             n) ${backup_version}    $(quickbox::lang::delete::selection::date) ${backup_date                                                                                                                                                             }") ?????swvi=$((swvi + 1)) ????done ????# display the menu ????mflibs::shell::t                                                                                                                                                             ext::white "$(quickbox::lang::delete::selection)" ????for backup_display in "${b                                                                                                                                                             ackup_menu[@]}"; do ?????echo "${backup_display}" ????done ????# set the version                                                                                                                                                              from the selection ????declare -gi vi ????declare version ????if [[ ${skip_chec                                                                                                                                                             k} == 1 ]]; then ?????# set the vi= to the value in the -o vi= option ?????vi=$(                                                                                                                                                             grep -oP 'vi=\K.*' <<<"${qb_option[*]}") ????else ?????IFS=$'\n' read -r version                                                                                                                                                             _selection ?????vi=$(grep -oP "${version_selection}" <<<"${backup_menu[@]}" | gr                                                                                                                                                             ep -oP '[0-9]*' | head -n 1) ????fi ????version=$(grep -oP 'version: \K.*(?=                                                                                                                                                                 date)' <<<"${backup_menu[$((vi - 1))]}") ????# set confirmation if input provide                                                                                                                                                             d is correct ????if [[ -z "${version}" ]]; then ?????mflibs::shell::text::red "$                                                                                                                                                             (quickbox::lang::delete::selection::invalid)" ?????IFS=$'\n' read -r version_sel                                                                                                                                                             ection ????else ?????# show selection and confirmation request ?????declare sele                                                                                                                                                             cted_date app_package config_package ?????selected_date=$(grep -oP 'date: \K.*'                                                                                                                                                              <<<"${backup_menu[$((vi - 1))]}") ?????package_date=${selected_date// /_} ?????a                                                                                                                                                             pp_package=$(find "${backup_path}" -maxdepth 1 -type f -name "${software}-${vers                                                                                                                                                             ion}-application_${package_date}.tar.gz" -printf '%f\n') ?????config_package=$(f                                                                                                                                                             ind "${backup_path}" -maxdepth 1 -type f -name "${software}-${version}-config_${                                                                                                                                                             package_date}.tar.gz" -printf '%f\n') ?????mflibs::shell::text::white "$(quickbo                                                                                                                                                             x::lang::delete::selection::display)" ?????if [[ -z ${skip_check} ]]; then ?????                                                                                                                                                             ?mflibs::shell::text::white "$(quickbox::lang::delete::selection::confirm)" ????                                                                                                                                                             ??IFS=$'\n' read -r version_confirm ??????# loop until a valid selection is made                                                                                                                                                              ??????while [[ "${version_confirm}" != "y" ]] && [[ "${version_confirm}" != "n"                                                                                                                                                              ]]; do ???????mflibs::shell::text::red "$(quickbox::lang::delete::selection::in                                                                                                                                                             valid)" ???????IFS=$'\n' read -r version_confirm ??????done ??????# if the selec                                                                                                                                                             tion is no, exit the script ??????if [[ "${version_confirm}" == "n" ]]; then ???                                                                                                                                                             ????mflibs::shell::text::red "$(quickbox::lang::delete::cancelled)" ???????exit                                                                                                                                                              0 ??????fi ?????fi ????fi ????# display confirmation of the version selection an                                                                                                                                                             d proceed with the rollback ????mflibs::shell::text::white "$(quickbox::lang::de                                                                                                                                                             lete::continue)" && sleep 2 ????# remove the selected tarball of the software in                                                                                                                                                             stallation backup directory ????rm -f "${backup_path}/${app_package}" >/dev/null                                                                                                                                                              2>&1 ????# remove the selected tarball of the software configuration backup dir                                                                                                                                                             ectory ????rm -f "${backup_path}/${config_package}" >/dev/null 2>&1 ????# remove                                                                                                                                                              the selected version/date from the database ????quickbox::database "DELETE FROM                                                                                                                                                              software_rollbacks WHERE software_name='${software}' AND username='${username}'                                                                                                                                                              AND software_version='${version}' AND software_date='${selected_date}';" ????mf                                                                                                                                                             libs::shell::text::green "$(quickbox::lang::delete::complete)" ????unset version                                                                                                                                                              version_selection vi selected_date app_package config_package ???fi ???;; ??rut                                                                                                                                                             orrent) ???plugin_vault_directory="/opt/quickbox/bin/software/rutorrent/plugins/                                                                                                                                                             " ???plugin_install_directory="/srv/rutorrent/plugins" ???for option in "${qb_op                                                                                                                                                             tion[@]}"; do ????case "${option,,}" in ????install) ?????echo "accessing ${ruto                                                                                                                                                             rrent_plugin:-} in the plugin vault ... " ?????cd "${plugin_install_directory:-}                                                                                                                                                             " || { echo "${plugin_install_directory:-} does not exist" && exit; } ?????echo                                                                                                                                                              "installing ${rutorrent_plugin:-} plugin ... " ?????if [[ ${rutorrent_plugin:-}                                                                                                                                                              == "autodl-irssi" ]]; then ??????if [[ $(quickbox::software::count autodl) -eq 1                                                                                                                                                              ]]; then ???????rm -rf "${plugin_vault_directory:-}autodl-irssi" ???????git clo                                                                                                                                                             ne https://lab.quickbox.io/jmsolo/autodl-rutorrent.git "${plugin_vault_directory                                                                                                                                                             :-}autodl-irssi" ??????else ???????echo "AutoDL-iRSSi is not installed on the sy                                                                                                                                                             stem, skipping." ??????fi ?????fi ?????for i in ${rutorrent_plugin:-}; do ??????                                                                                                                                                             \cp -rf "${plugin_vault_directory:-}${i}" . ?????done ?????if [[ ${rutorrent_plu                                                                                                                                                             gin:-} == "_cloudflare" ]]; then ??????/usr/bin/python3 -m pip install --upgrade                                                                                                                                                              --exists-action s cloudscraper python_anticaptcha >/dev/null 2>&1 ??????\cp -f                                                                                                                                                              "/opt/quickbox/config/software/rutorrent/plugins/${rutorrent_plugin:-}/conf.php"                                                                                                                                                              "${plugin_install_directory:-}/${rutorrent_plugin:-}/conf.php" ?????fi ?????if                                                                                                                                                              [[ ${rutorrent_plugin:-} == "diskspace" ]]; then ??????\cp -f "/opt/quickbox/con                                                                                                                                                             fig/software/rutorrent/plugins/${rutorrent_plugin:-}/action.php" "${plugin_insta                                                                                                                                                             ll_directory:-}/${rutorrent_plugin:-}/action.php" ?????fi ?????if [[ ${rutorrent                                                                                                                                                             _plugin:-} == "filemanager-share" ]]; then ??????\cp -f "/opt/quickbox/config/so                                                                                                                                                             ftware/rutorrent/plugins/${rutorrent_plugin:-}/conf.php" "${plugin_install_direc                                                                                                                                                             tory:-}/${rutorrent_plugin:-}/conf.php" ?????fi ?????echo "adjusting permissions                                                                                                                                                              ... " ?????chown -R www-data: "${plugin_install_directory:-}/${rutorrent_plugin                                                                                                                                                             :-}" ?????echo "${rutorrent_plugin:-} plugin install complete!" ?????[[ ${qb_opt                                                                                                                                                             ion[*]} != *"web"* ]] && systemctl reload php8.1-fpm >/dev/null 2>&1 & ?????exit                                                                                                                                                              ?????;; ????remove) ?????echo "uninstalling the ${rutorrent_plugin:?} plugin ..                                                                                                                                                             . " ?????for i in ${rutorrent_plugin:-}; do ??????rm -rf "${plugin_install_direc                                                                                                                                                             tory:?}/${i}" ?????done ?????echo "${rutorrent_plugin:-} plugin uninstall comple                                                                                                                                                             te!" ?????[[ ${qb_option[*]} != *"web"* ]] && systemctl reload php8.1-fpm >/dev/                                                                                                                                                             null 2>&1 & ?????exit ?????;; ????*) ;; ????esac ???done ???;; ??*) ;; ??esac ?d                                                                                                                                                             one }  #########################################################################                                                                                                                                                             ####### # @description: dashboard theme switching # @arg: -o [defaulted|smoked]                                                                                                                                                              # @example: qb manage theme -o smoked # @null ##################################                                                                                                                                                             ############################################## theme::settings() { ?for option i                                                                                                                                                             n "${qb_option[@]}"; do ??case "${option,,}" in ??smoked) ???sed -i -r 's/defaul                                                                                                                                                             ted.css/smoked.css/g' /srv/quickbox/assets/css/plugins.css ???sed -i -r 's/defau                                                                                                                                                             lted.css/smoked.css/g' /srv/quickbox/dash_header.php ???sed -i -r 's/defaulted.c                                                                                                                                                             ss/smoked.css/g' /srv/quickbox/assets/css/plugins_1.css ???rm -rf /srv/quickbox/                                                                                                                                                             db/.theme_defaulted.lock ???printf "" >/srv/quickbox/db/.theme_smoked.lock ???ch                                                                                                                                                             own www-data:www-data /srv/quickbox/db/.theme_smoked.lock ???[[ ${qb_option[*]}                                                                                                                                                              != *"web"* ]] && systemctl reload php8.1-fpm >/dev/null 2>&1 & ???;; ??defaulted                                                                                                                                                             ) ???sed -i -r 's/smoked.css/defaulted.css/g' /srv/quickbox/assets/css/plugins.c                                                                                                                                                             ss ???sed -i -r 's/smoked.css/defaulted.css/g' /srv/quickbox/dash_header.php ???                                                                                                                                                             sed -i -r 's/smoked.css/defaulted.css/g' /srv/quickbox/assets/css/plugins_1.css                                                                                                                                                              ???rm -rf /srv/quickbox/db/.theme_smoked.lock ???printf "" >/srv/quickbox/db/.th                                                                                                                                                             eme_defaulted.lock ???chown www-data:www-data /srv/quickbox/db/.theme_defaulted.                                                                                                                                                             lock ???[[ ${qb_option[*]} != *"web"* ]] && systemctl reload php8.1-fpm >/dev/nu                                                                                                                                                             ll 2>&1 & ???;; ??*) ;; ??esac ?done }  ########################################                                                                                                                                                             ######################################## # @description: manages blocking and al                                                                                                                                                             lowing of public trackers # @noargs ############################################                                                                                                                                                             #################################### tracker::settings() { ?for option in "${qb_                                                                                                                                                             option[@]}"; do ??case "${option,,}" in ??enable) ???mflibs::shell::text::red "$                                                                                                                                                             (quickbox::lang::trackers::enable)" ???mflibs::log "/sbin/iptables -F qb-public-                                                                                                                                                             trackers" && mflibs::log "/sbin/iptables -X qb-public-trackers" ???awk 'NR==FNR{                                                                                                                                                             a[$0];next} !($0 in a){print > FILENAME".filtered"}' "${quickbox_base_path}/conf                                                                                                                                                             ig/system/trackers/host_trackers" /etc/hosts ???mv -f "/etc/hosts.filtered" "/et                                                                                                                                                             c/hosts" ???rm -f /etc/cron.daily/deny_public ???;; ??disable) ???declare line ?                                                                                                                                                             ??mflibs::shell::text::green "$(quickbox::lang::trackers::disable)" ???cp -f "${                                                                                                                                                             quickbox_base_path:="/opt/quickbox"}/config/system/trackers/deny_public" "/etc/c                                                                                                                                                             ron.daily/" ???chmod +x /etc/cron.daily/deny_public ???mflibs::log "/sbin/iptabl                                                                                                                                                             es -N qb-public-trackers" ???while IFS= read -r line; do ????mflibs::log "/sbin/                                                                                                                                                             iptables -A qb-public-trackers -s ${line} -j DROP" ???done < <(grep -v '^ *#' <"                                                                                                                                                             ${quickbox_base_path:="/opt/quickbox"}/config/system/trackers/tracker_list") ???                                                                                                                                                             awk 'NR==FNR{a[$0];next} !($0 in a){print > FILENAME".filtered"}' "${quickbox_ba                                                                                                                                                             se_path}/config/system/trackers/host_trackers" /etc/hosts ???mv -f "/etc/hosts.f                                                                                                                                                             iltered" "/etc/hosts" ???cat "${quickbox_base_path}/config/system/trackers/host_                                                                                                                                                             trackers" >>/etc/hosts ???;; ??*) ;; ??esac ?done }  ###########################                                                                                                                                                             ##################################################### # @description: sets the s                                                                                                                                                             erver web root for dashboard access # @arg: -o [server_ip (or) domain] # @exampl                                                                                                                                                             e: qb manage webroot -o 192.168.0.1 (or) myawesomedomain.com # @null ###########                                                                                                                                                             ##################################################################### webroot::s                                                                                                                                                             ettings() { ?quickbox::database "UPDATE system_configuration set configuration_v                                                                                                                                                             alue = 'https://${qb_option[*]:-}/' WHERE configuration_name='server_web_root';"                                                                                                                                                              ?mflibs::log "systemctl restart nginx.service" ?mflibs::log "systemctl reload p                                                                                                                                                             hp8.1-fpm.service" }  ##########################################################                                                                                                                                                             ###################### # @description: calls functions in the required order ###                                                                                                                                                             ############################################################################# ma                                                                                                                                                             nage::environment::init "$@" # shellcheck disable=SC2068 quickbox::args::process                                                                                                                                                              $@ case "${1}" in api) ?api::settings ?;; fail2ban) ?fail2ban::settings ?;; lan                                                                                                                                                             g) ?lang::settings ?;; nginx) ?nginx::settings ?;; mount) ?mount::settings ?;; s                                                                                                                                                             oftware) ?software::settings ?;; trackers) ?tracker::settings ?;; theme) ?theme:                                                                                                                                                             :settings ?;; webroot) ?webroot::settings ?;; *) ;; esac  /opt/quickbox/system/m                                                                                                                                                             anage mount manage mount -o space -u judgey
root      188575  188538  0 12:30 ?        00:00:00 /opt/quickbox/system/manage                                                                                                                                                              -c     

                                                                                                                                                                                                                                              #!/bin/bash #################################################                                                                                                                                                             ############################### # <START METADATA> # @file_name: manage # @versi                                                                                                                                                             on: 1.0.452 # @project_name: quickbox_pro_v3 # @description: collection of manag                                                                                                                                                             e scripts # # @save_tasks: #  automated_versioning: true #  automated_documentat                                                                                                                                                             ion: true # # @build_tasks: #  automated_comment_strip: true #  automated_encryp                                                                                                                                                             tion: true # # @author: Jason Matthews (JMSolo) # @author_contact: support@quick                                                                                                                                                             box.io # @author: Jamie Dobbs (mschf) # @author_contact: jamie.dobbs@mschf.dev #                                                                                                                                                              # @license: BSD-3 Clause (Included in LICENSE) # Copyright (C) 2019-2023, Quick                                                                                                                                                             Box.IO # All rights reserved. # <END METADATA> # shellcheck disable=SC1091,SC203                                                                                                                                                             4,SC2140,SC2165,SC2167,SC2312 ##################################################                                                                                                                                                             ##############################  ################################################                                                                                                                                                             ################################ # @description: sets up environment for command                                                                                                                                                             s # @noargs # @internal # @return_code: 1 script should be run via qb ##########                                                                                                                                                             ###################################################################### manage::e                                                                                                                                                             nvironment::init() { ?declare script_name ?script_name=$(basename -- "$0") ?[[ $                                                                                                                                                             {qb_invoked:-0} -eq 0 ]] && { echo -ne "\033[38;5;203merror\e[0m[1]: ${script_na                                                                                                                                                             me} should be run via qb\n" >&2 && exit 1; } ?. "/opt/mflibs/src/init.sh" ?mflib                                                                                                                                                             s::import shell,quickbox,status,log,info }  quickbox::dashboard::log() { ?admin_                                                                                                                                                             name="$(quickbox::database "SELECT username FROM user_information WHERE user_lev                                                                                                                                                             el = '10';")" ?if [[ ! -f "/srv/quickbox/logs/dashboard" ]]; then ??mkdir -p /sr                                                                                                                                                             v/quickbox/logs ??touch /srv/quickbox/logs/dashboard ??chown www-data:www-data /                                                                                                                                                             srv/quickbox/logs/dashboard ?fi ?if [[ ! -f "/srv/quickbox/logs/${username:-${ad                                                                                                                                                             min_name}}.dashboard" ]]; then ??mkdir -p /srv/quickbox/logs ??touch "/srv/quick                                                                                                                                                             box/logs/${username:-${admin_name}}.dashboard" ??chown www-data:www-data "/srv/q                                                                                                                                                             uickbox/logs/${username:-${admin_name}}.dashboard" ?fi ?if [[ -n ${username} ]];                                                                                                                                                              then ??echo "${1:-null}" | sed -z "s/\n/\n<br>/" >"/srv/quickbox/logs/${usernam                                                                                                                                                             e:-}.dashboard" ?else ??echo "${1:-null}" | sed -z "s/\n/\n<br>/" >"/srv/quickbo                                                                                                                                                             x/logs/${admin_name:-}.dashboard" ?fi ?echo "${1:-null}" }  ####################                                                                                                                                                             ############################################################ # @description: man                                                                                                                                                             ages api key activation and deactivation # @noargs #############################                                                                                                                                                             ################################################### api::settings() {  ?########                                                                                                                                                             ######################################################################## ?# @des                                                                                                                                                             cription: pulls information from database and quickbox.io ?# @noargs ?##########                                                                                                                                                             ###################################################################### ?api::var                                                                                                                                                             iable::assign() { ??declare mflibs_log_location="${quickbox_base_path:="/opt/qui                                                                                                                                                             ckbox"}/logs/system_log" ??declare -g api_activated api_activated_date api_key a                                                                                                                                                             pi_instance api_ip api_product_id api_code api_execution api_status api_activate                                                                                                                                                             d api_activations_remaining api_total_activations api_total_activations_purchase                                                                                                                                                             d ??declare api_json ??IFS=$'\n' read -d '' -ra api_array <<<"$(quickbox::databa                                                                                                                                                             se "SELECT configuration_name,configuration_value FROM system_configuration WHER                                                                                                                                                             E configuration_name = 'api_key' OR configuration_name = 'api_instance' OR confi                                                                                                                                                             guration_name = 'api_activated_date' OR configuration_name = 'api_product_id' OR                                                                                                                                                              configuration_name = 'api_activated' OR configuration_name = 'api_ip'")" ??for                                                                                                                                                              i in "${api_array[@]}"; do ???array_configuration_name="$(echo "${i}" | cut -d '                                                                                                                                                             |' -f1)" ???array_configuration_value="$(echo "${i}" | cut -d '|' -f2-)" ???case                                                                                                                                                              "${array_configuration_name}" in ???api_key) api_key="${array_configuration_val                                                                                                                                                             ue}" ;; ???api_ip) api_ip="${array_configuration_value}" ;; ???api_product_id) a                                                                                                                                                             pi_product_id="${array_configuration_value}" ;; ???api_instance) api_instance="$                                                                                                                                                             {array_configuration_value}" ;; ???api_activated_date) api_activated_date="${arr                                                                                                                                                             ay_configuration_value}" ;; ???*) ;; ???esac ??done ??api_json=$(curl -s4 -k "ht                                                                                                                                                             tps://quickbox.io/?wc-api=wc-am-api&product_id=${api_product_id}&object=${api_ip                                                                                                                                                             }&instance=${api_instance}&api_key=${api_key}&request=status") ??for value in $(                                                                                                                                                             jq 'keys | .[]' <<<"${api_json}"); do ???if [[ ${value} == '"code"' ]]; then ???                                                                                                                                                             ?mflibs::shell::text::red "invalid response" ????api_code=$(jq -r ".${value}" <<                                                                                                                                                             <"${api_json}") ????break ???elif [[ ${value} == '"api_call_execution_time"' ]];                                                                                                                                                              then ????api_execution=$(jq -r ".${value}" <<<"${api_json}") ???elif [[ ${value                                                                                                                                                             } == '"status_check"' ]]; then ????api_status=$(jq -r ".${value}" <<<"${api_json                                                                                                                                                             }") ???elif [[ ${value} == '"data"' ]]; then ????for data_value in $(jq '.data |                                                                                                                                                              keys | .[]' <<<"${api_json}"); do ?????if [[ ${data_value} == '"activated"' ]];                                                                                                                                                              then ??????api_activated=$(jq -r ".data.${data_value}" <<<"${api_json}") ?????e                                                                                                                                                             lif [[ ${data_value} == '"activations_remaining"' ]]; then ??????api_activations                                                                                                                                                             _remaining=$(jq -r ".data.${data_value}" <<<"${api_json}") ?????elif [[ ${data_v                                                                                                                                                             alue} == '"total_activations"' ]]; then ??????api_total_activations=$(jq -r ".da                                                                                                                                                             ta.${data_value}" <<<"${api_json}") ?????elif [[ ${data_value} == '"total_activa                                                                                                                                                             tions_purchased"' ]]; then ??????api_total_activations_purchased=$(jq -r ".data.                                                                                                                                                             ${data_value}" <<<"${api_json}") ?????fi ????done ???fi ??done ?}  ?############                                                                                                                                                             #################################################################### ?# @descrip                                                                                                                                                             tion: outputs api status in terminal window ?# @noargs ?########################                                                                                                                                                             ######################################################## ?api::status::view() {                                                                                                                                                              ??column -ts '|' <<<"$( ???mflibs::shell::text::yellow "local information|" ???m                                                                                                                                                             flibs::shell::text::white::sl "api execution time:|" ???mflibs::shell::text::gre                                                                                                                                                             en::bold "${api_execution}" ???mflibs::shell::text::white::sl "api key:|" ???mfl                                                                                                                                                             ibs::shell::text::green::bold "${api_key}" ???mflibs::shell::text::white::sl "ap                                                                                                                                                             i activation date:|" ???mflibs::shell::text::green::bold "${api_activated_date}"                                                                                                                                                              ???mflibs::shell::text::white::sl "api ip:|" ???mflibs::shell::text::green::bol                                                                                                                                                             d "${api_ip}" ???mflibs::shell::text::white::sl "product id:|" ???mflibs::shell:                                                                                                                                                             :text::green::bold "${api_product_id}" ???mflibs::shell::text::white::sl "instan                                                                                                                                                             ce id:|" ???mflibs::shell::text::green::bold "${api_instance}" ???mflibs::shell:                                                                                                                                                             :misc::nl ???mflibs::shell::text::yellow "remote information|" ???mflibs::shell:                                                                                                                                                             :text::white::sl "api total activations:|" ???mflibs::shell::text::green::bold "                                                                                                                                                             ${api_total_activations}" ???mflibs::shell::text::white::sl "api activations rem                                                                                                                                                             aining:|" ???mflibs::shell::text::green::bold "${api_activations_remaining}" ???                                                                                                                                                             mflibs::shell::text::white::sl "api activated:|" ???mflibs::shell::text::green::                                                                                                                                                             bold "${api_activated}" ???mflibs::shell::text::white::sl "api status:|" ???mfli                                                                                                                                                             bs::shell::text::green::bold "${api_status}" ??)" ?}  ?#########################                                                                                                                                                             ####################################################### ?# @description: deactiv                                                                                                                                                             ates api key ?# @noargs ?#######################################################                                                                                                                                                             ######################### ?api::key::deactivate() { ??declare deactivate_check ?                                                                                                                                                             ?if [[ ${api_force:-0} -eq "0" ]]; then ???mflibs::shell::misc::nl ???mflibs::sh                                                                                                                                                             ell::text::white::sl "deactivate api key? " ???mflibs::shell::text::green::sl "[                                                                                                                                                             y]" ???mflibs::shell::text::white::sl "es " ???mflibs::shell::text::white "or [n                                                                                                                                                             ]o:" ???mflibs::shell::icon::arrow::white ???read -r input ???case "${input,,}"                                                                                                                                                              in ???[y] | [y][e][s] | "") : ;; ???*) exit 0 ;; ???esac ??fi ??deactivate_check                                                                                                                                                             =$(curl -s4 -k "https://quickbox.io/?wc-api=wc-am-api&product_id=${api_product_i                                                                                                                                                             d}&object=${api_ip}&instance=${api_instance}&api_key=${api_key}&request=deactiva                                                                                                                                                             te" | jq -r ".deactivated") ??if [[ ${api_force} -eq "0" ]]; then ???if [[ ${dea                                                                                                                                                             ctivate_check} == "true" ]]; then ????quickbox::database "UPDATE system_configur                                                                                                                                                             ation set configuration_value = 'false' WHERE configuration_name='api_activated'                                                                                                                                                             ;" ???else ????mflibs::shell::text::red "unable to deactivate api key" ???fi ??f                                                                                                                                                             i ?}  ?#########################################################################                                                                                                                                                             ####### ?# @description: checks api key ?# @noargs ?############################                                                                                                                                                             #################################################### ?api::key::check() { ??decl                                                                                                                                                             are check_status ??check_status=$(curl -s4 -k "https://quickbox.io/?wc-api=wc-am                                                                                                                                                             -api&product_id=${api_product_id}&object=${api_ip}&instance=${api_instance}&api_                                                                                                                                                             key=${api_key}&request=status" | jq -r '.data."activated"') ??if [[ ${api_force}                                                                                                                                                              -eq "0" ]]; then ???if [[ ${check_status} == "true" ]]; then ????mflibs::shell:                                                                                                                                                             :text::green "api key is activated" ????quickbox::database "UPDATE system_config                                                                                                                                                             uration set configuration_value = 'true' WHERE configuration_name='api_activated                                                                                                                                                             ';" ????\cp -rf /opt/quickbox/dashboard/inc/plugins/nav/dash_navigation-pro.php                                                                                                                                                              /srv/quickbox/dash_navigation.php ???else ????mflibs::shell::text::red "api key                                                                                                                                                              is not activated" ????quickbox::database "UPDATE system_configuration set config                                                                                                                                                             uration_value = 'false' WHERE configuration_name='api_activated';" ????\cp -rf /                                                                                                                                                             opt/quickbox/dashboard/inc/plugins/nav/dash_navigation-community.php /srv/quickb                                                                                                                                                             ox/dash_navigation.php ???fi ??fi ?}  ?#########################################                                                                                                                                                             ####################################### ?# @description: activates api key ?# @n                                                                                                                                                             oargs ?#########################################################################                                                                                                                                                             ####### ?api::key::activate() { ??if [[ ${api_force:-0} -eq "0" ]]; then ???mfli                                                                                                                                                             bs::shell::misc::nl ???mflibs::shell::text::white::sl "activate api key? " ???mf                                                                                                                                                             libs::shell::text::green::sl "[y]" ???mflibs::shell::text::white::sl "es " ???mf                                                                                                                                                             libs::shell::text::white "or [n]o:" ???mflibs::shell::icon::arrow::white ???read                                                                                                                                                              -r input ???case "${input,,}" in ???[y] | [y][e][s] | "") : ;; ???*) exit 0 ;;                                                                                                                                                              ???esac ??fi ??declare -a product_codes ??declare api_instance api_date product                                                                                                                                                              public_ip api_key quickbox_version ??api_date=$(date +"%b %d, %Y %l:%M") ??publi                                                                                                                                                             c_ip=$(mflibs::info::ipv4::local) ??api_instance=$(date +%s | sha256sum | base64                                                                                                                                                              | head -c 16) ??product_codes=("13256" "24449" "24450" "24451" "24452" "13257"                                                                                                                                                              "24453" "24454" "24455" "24456" "13324" "349206") ??quickbox_version=$(quickbox:                                                                                                                                                             :database "SELECT configuration_value FROM system_configuration WHERE configurat                                                                                                                                                             ion_name = 'server_current_version'") ??if [[ -z ${man_api_key:-} ]]; then ???mf                                                                                                                                                             libs::shell::misc::nl ???mflibs::shell::text::white "enter api key: " ???mflibs:                                                                                                                                                             :shell::icon::arrow::white ???read -r api_key ??fi ??for product in "${product_c                                                                                                                                                             odes[@]}"; do ???api_activated=$(curl -s4 -k "https://quickbox.io/?wc-api=wc-am-                                                                                                                                                             api&product_id=${product}&object=${public_ip}&version=${quickbox_version}&instan                                                                                                                                                             ce=${api_instance}&api_key=${man_api_key:-${api_key}}&request=activate" | grep -                                                                                                                                                             Eoi '"activated":true' | cut -d: -f2-) ???if [[ ${api_activated} == "true" ]]; t                                                                                                                                                             hen ????api_product_id="${product}" ????break ???fi ??done ??[[ ${api_activated}                                                                                                                                                              != "true" ]] && mflibs::shell::text::red "invalid api key; please contact suppo                                                                                                                                                             rt" && api::environment::cleanup ??quickbox::database "WITH Tmp(configuration_na                                                                                                                                                             me, configuration_value) AS (VALUES ('api_activated', 'true'), ('api_activated_d                                                                                                                                                             ate', '${api_date}'),('api_key', '${man_api_key:-${api_key}}'), ('api_instance',                                                                                                                                                              '${api_instance}'), ('api_ip', '${public_ip}'), ('api_product_id', '${api_produ                                                                                                                                                             ct_id}')) UPDATE system_configuration SET configuration_value = (SELECT configur                                                                                                                                                             ation_value FROM Tmp WHERE system_configuration.configuration_name = Tmp.configu                                                                                                                                                             ration_name) WHERE configuration_name IN (SELECT configuration_name FROM Tmp);"                                                                                                                                                              ??if [[ -z ${api_force} ]]; then ???mflibs::shell::misc::nl ???mflibs::shell::te                                                                                                                                                             xt::green "api key has been activated" ???mflibs::shell::misc::nl ??fi ?}  ?api:                                                                                                                                                             :variable::assign ?if [[ ${qb_option[*]:-} == *"deactivate"* || -n ${man_api_key                                                                                                                                                             } ]]; then ??[[ ${qb_option[*]:-} == *"force"* || -n ${man_api_key} ]] && declar                                                                                                                                                             e -gi api_force=1 ??api::key::deactivate ??api::key::activate ??api::variable::a                                                                                                                                                             ssign ?elif [[ ${qb_option[*]:-} == *"check"* ]]; then ??api::key::check ?elif [                                                                                                                                                             [ ${api_code} != "100" ]]; then ??api::status::view ??api::key::deactivate ??api                                                                                                                                                             ::key::activate ?fi ?if [[ ${qb_option[*]:-} == *"deactivate"* ]]; then ??quickb                                                                                                                                                             ox::database "INSERT INTO system_log ("user_id", "log_source", "log_type", "log_                                                                                                                                                             operation", "timestamp") VALUES ('${user_id:-1}', 'qb manage api -o deactivate .                                                                                                                                                             ..', 'system', 'DEACTIVATE_QUICKBOX_API', '$(date +"%Y-%m-%d %H:%M:%S")');" ?eli                                                                                                                                                             f [[ ${qb_option[*]:-} == *"activate"* ]]; then ??quickbox::database "INSERT INT                                                                                                                                                             O system_log ("user_id", "log_source", "log_type", "log_operation", "timestamp")                                                                                                                                                              VALUES ('${user_id:-1}', 'qb manage api -o activate ...', 'system', 'ACTIVATE_Q                                                                                                                                                             UICKBOX_API', '$(date +"%Y-%m-%d %H:%M:%S")');" ?elif [[ ${qb_option[*]:-} == *"                                                                                                                                                             check"* ]]; then ??: ?else ??quickbox::database "INSERT INTO system_log ("user_i                                                                                                                                                             d", "log_source", "log_type", "log_operation", "timestamp") VALUES ('${user_id:-                                                                                                                                                             1}', 'qb manage api', 'system', 'ACTIVATION_INFO_STATS', '$(date +"%Y-%m-%d %H:%                                                                                                                                                             M:%S")');" ?fi }  ##############################################################                                                                                                                                                             ################## # @description: manages fail2ban settings on the server # @no                                                                                                                                                             args # @example: qb manage fail2ban -o [config|unban] # @null ##################                                                                                                                                                             ############################################################## fail2ban::setting                                                                                                                                                             s() { ?for option in "${qb_option[@]}"; do ??case "${option,,}" in ??"config") ?                                                                                                                                                             ??fail2ban_dir="/etc/fail2ban/" ???if [[ ! -d ${fail2ban_dir} ]]; then ????mflib                                                                                                                                                             s::shell::text::red "Fail2ban is not installed. Would you like to install this?                                                                                                                                                              [y/N]:" ????echo -en "> " ????read -r input ????case ${input} in ????[yY] | [yY]                                                                                                                                                             [Ee][Ss]) ?????/usr/local/bin/qb install fail2ban ?????exit 1 ?????;; ????[nN] |                                                                                                                                                              [nN][Oo]) ?????mflibs::shell::text::red "Exiting Script." && exit 1 ?????;; ???                                                                                                                                                             ?*) ?????mflibs::shell::text::red "Exiting Script." && exit 1 ?????;; ????esac ?                                                                                                                                                             ??fi ???mflibs::shell::text::white "Ban time for incorrect login (Default 10m) [                                                                                                                                                             5m/3h/12d]:" ???unset input ???echo -en "> " ???read -r input ???bantime="${inpu                                                                                                                                                             t//[^0-9]*/}" ???if [[ ${input} == "" ]]; then ????bantime=600 ???elif [[ ${inpu                                                                                                                                                             t} == *"m" ]]; then ????bantime=$((bantime * 60)) ???elif [[ ${input} == *"h" ]]                                                                                                                                                             ; then ????bantime=$((bantime * 60 * 60)) ???elif [[ ${input} == *"d" ]]; then ?                                                                                                                                                             ???bantime=$((bantime * 60 * 60 * 12)) ???fi ???mflibs::shell::text::white "Time                                                                                                                                                              between incorrect logins for ban (Default 10m) [5m/3h/12d]:" ???unset input ???                                                                                                                                                             echo -en "> " ???read -r input ???findtime="${input//[^0-9]*/}" ???if [[ ${input                                                                                                                                                             } == "" ]]; then ????findtime=600 ???elif [[ ${input} == *"m" ]]; then ????findt                                                                                                                                                             ime=$((findtime * 60)) ???elif [[ ${input} == *"h" ]]; then ????findtime=$((find                                                                                                                                                             time * 60 * 60)) ???elif [[ ${input} == *"d" ]]; then ????findtime=$((findtime *                                                                                                                                                              60 * 60 * 12)) ???fi ???mflibs::shell::text::white "Max number of retries withi                                                                                                                                                             n time (Default 5):" ???unset input ???echo -en "> " ???read -r input ???maxretr                                                                                                                                                             y="${input//[^0-9]*/}" ???if [[ ${input} == "" ]]; then ????maxretry=5 ???fi ???                                                                                                                                                             mflibs::shell::text::white "IPs ignored by fail2ban (Default none) [1.1.1.1,2.2.                                                                                                                                                             2.2]" ???mflibs::shell::text::green "Your IP is $(who am i | awk '{ print $5}' |                                                                                                                                                              tr -d '()'):" ???unset input ???echo -en "> " ???read -r input ???ignoreip="${i                                                                                                                                                             nput}" ???mflibs::shell::text::white "Monitor SSH Logins? ([y]/n):" ???unset inp                                                                                                                                                             ut ???echo -en "> " ???read -r input ???case ${input} in ???[yY] | [yY][Ee][Ss])                                                                                                                                                              ????SSH="true" ????;; ???[nN] | [nN][Oo]) ????SSH="false" ????;; ???*) ????SSH=                                                                                                                                                             "true" ????;; ???esac ???mflibs::shell::text::white "Monitor Nginx Logins? ([y]/                                                                                                                                                             n):" ???unset input ???echo -en "> " ???read -r input ???case ${input} in ???[yY                                                                                                                                                             ] | [yY][Ee][Ss]) ????nginx="true" ????;; ???[nN] | [nN][Oo]) ????nginx="false"                                                                                                                                                              ????;; ???*) ????nginx="true" ????;; ???esac ???mflibs::shell::text::white "Moni                                                                                                                                                             tor QuickBox Logins? ([y]/n):" ???unset input ???echo -en "> " ???read -r input                                                                                                                                                              ???case ${input} in ???[yY] | [yY][Ee][Ss]) ????quickbox="true" ????;; ???[nN] |                                                                                                                                                              [nN][Oo]) ????quickbox="false" ????;; ???*) ????quickbox="true" ????;; ???esac                                                                                                                                                              ???mflibs::shell::text::white "Applying Configuration..." ???\cp -f "/opt/quickb                                                                                                                                                             ox/config/software/fail2ban/quickbox.conf" "/etc/fail2ban/filter.d/quickbox.conf                                                                                                                                                             " ???if [[ -f "/etc/fail2ban/jail.local" ]]; then ????\cp -f "/etc/fail2ban/jail                                                                                                                                                             .local" "/etc/fail2ban/jail.bak" ???fi ???\cp -f "/opt/quickbox/config/software/                                                                                                                                                             fail2ban/jail.local" "/etc/fail2ban/jail.local" ???sed -i -e "s/IGNORE_CONFIG/${                                                                                                                                                             ignoreip}/g" /etc/fail2ban/jail.local -e "s/BANTIME_CONFIG/${bantime}/g" /etc/fa                                                                                                                                                             il2ban/jail.local -e "s/FINDTIME_CONFIG/${findtime}/g" /etc/fail2ban/jail.local                                                                                                                                                              -e "s/RETRY_CONFIG/${maxretry}/g" /etc/fail2ban/jail.local -e "s/SSHD_CONFIG/${S                                                                                                                                                             SH}/g" /etc/fail2ban/jail.local -e "s/NGINX_CONFIG/${nginx}/g" /etc/fail2ban/jai                                                                                                                                                             l.local -e "s/QUICKBOX_CONFIG/${quickbox}/g" /etc/fail2ban/jail.local ???mflibs:                                                                                                                                                             :log "systemctl restart fail2ban" ???mflibs::shell::text::green "Configuration a                                                                                                                                                             pplied" ???;; ??"unban") ???fail2ban_dir="/etc/fail2ban/" ???if [[ ! -d ${fail2b                                                                                                                                                             an_dir} ]]; then ????mflibs::shell::text::red "Fail2ban is not installed. Would                                                                                                                                                              you like to install this? [y/N]:" ????echo -en "> " ????read -r input ????case $                                                                                                                                                             {input} in ????[yY] | [yY][Ee][Ss]) ?????/usr/local/bin/qb install fail2ban ????                                                                                                                                                             ?exit 1 ?????;; ????[nN] | [nN][Oo]) ?????mflibs::shell::text::red "Exiting Scri                                                                                                                                                             pt." && exit 1 ?????;; ????*) ?????mflibs::shell::text::red "Exiting Script." &&                                                                                                                                                              exit 1 ?????;; ????esac ???fi ???fail2banjails=$(fail2ban-client status | grep                                                                                                                                                              "Jail list" | cut -f2- | sed 's/,//g') ???mflibs::shell::text::white "Unbanning                                                                                                                                                              ${option}..." ???for jails in ${fail2banjails}; do ????fail2ban-client set "${ja                                                                                                                                                             ils}" unbanip "${option}" >/dev/null 2>&1 ???done ???mflibs::shell::text::green                                                                                                                                                              "${option} unbanned." ???;; ??"inclog") ???# trunk-ignore(shellcheck/SC2001) ???                                                                                                                                                             ip=$(echo "${domain}" | sed 's/\s//g') ???echo "${ip} -- [$(date +%d)/$(date +%b                                                                                                                                                             )/$(date +%Y):$(date +%H):$(date +%M):$(date +%S)] -- Failed Login - ${username}                                                                                                                                                             " >>/srv/quickbox/logs/fail2ban.log ???;; ??*) ???mflibs::shell::text::red "Inva                                                                                                                                                             lid option: ${option}" ???;; ??esac ?done  }  ##################################                                                                                                                                                             ############################################## # @description: manages language                                                                                                                                                              settings on the server # @arg: -o [de|german|dk|danish|en|english|es|spanish|fr|                                                                                                                                                             french|pt|portuguese|zh-cn|chinese] # @example: qb manage lang -o en(or english)                                                                                                                                                              # @null #######################################################################                                                                                                                                                             ######### lang::settings() { ?declare language code_name ?declare -g quickbox_ba                                                                                                                                                             se_path="/opt/quickbox" ?code_name=$(lsb_release -cs) ?for lang in "${qb_option[                                                                                                                                                             @]}"; do ??case "${lang,,}" in ??de | german*) ???source /root/.bashrc ???declar                                                                                                                                                             e -g locale_sed quickbox_lang ???locale_sed=de_DE ???quickbox_lang=de ???cp -f "                                                                                                                                                             ${quickbox_base_path}/config/lang/${quickbox_lang}/locale" "/etc/default/locale"                                                                                                                                                              ???cp -f "${quickbox_base_path}/config/lang/${quickbox_lang}/localize.php" "/sr                                                                                                                                                             v/quickbox/inc/localize.php" ???sed -i -e '/da_DK.UTF-8/s/^#*/#/g' -e '/es_ES.UT                                                                                                                                                             F-8/s/^#*/#/g' -e '/fr_FR.UTF-8/s/^#*/#/g' -e '/pt_PT.UTF-8/s/^#*/#/g' -e '/zh_C                                                                                                                                                             N.UTF-8/s/^#*/#/g' -e 's/^#.*\(de_DE.UTF-8\)/\1/' /etc/locale.gen >/dev/null 2>&                                                                                                                                                             1 ???#sudo locale-gen --purge >/dev/null 2>&1 ???sudo update-locale --locale-fil                                                                                                                                                             e=/etc/default/locale >/dev/null 2>&1 ???sudo dpkg-reconfigure --frontend nonint                                                                                                                                                             eractive locales >/dev/null 2>&1 ???source /root/.bashrc ???;; ??dk | danish*) ?                                                                                                                                                             ??source /root/.bashrc ???declare -g locale_sed quickbox_lang ???locale_sed=da_D                                                                                                                                                             K ???quickbox_lang=dk ???cp -f "${quickbox_base_path}/config/lang/${quickbox_lan                                                                                                                                                             g}/locale" "/etc/default/locale" ???cp -f "${quickbox_base_path}/config/lang/${q                                                                                                                                                             uickbox_lang}/localize.php" "/srv/quickbox/inc/localize.php" ???sed -i -e '/de_D                                                                                                                                                             E.UTF-8/s/^#*/#/g' -e '/es_ES.UTF-8/s/^#*/#/g' -e '/fr_FR.UTF-8/s/^#*/#/g' -e '/                                                                                                                                                             pt_PT.UTF-8/s/^#*/#/g' -e '/zh_CN.UTF-8/s/^#*/#/g' -e 's/^#.*\(da_DK.UTF-8\)/\1/                                                                                                                                                             ' /etc/locale.gen >/dev/null 2>&1 ???#sudo locale-gen --purge >/dev/null 2>&1 ??                                                                                                                                                             ?sudo update-locale --locale-file=/etc/default/locale >/dev/null 2>&1 ???sudo dp                                                                                                                                                             kg-reconfigure --frontend noninteractive locales >/dev/null 2>&1 ???source /root                                                                                                                                                             /.bashrc ???;; ??en | english*) ???source /root/.bashrc ???declare -g locale_sed                                                                                                                                                              quickbox_lang ???locale_sed=en_US ???quickbox_lang=en ???cp -f "${quickbox_base                                                                                                                                                             _path}/config/lang/${quickbox_lang}/locale" "/etc/default/locale" ???cp -f "${qu                                                                                                                                                             ickbox_base_path}/config/lang/${quickbox_lang}/localize.php" "/srv/quickbox/inc/                                                                                                                                                             localize.php" ???sed -i -e '/de_DE.UTF-8/s/^#*/#/g' -e '/da_DK.UTF-8/s/^#*/#/g'                                                                                                                                                              -e '/es_ES.UTF-8/s/^#*/#/g' -e '/fr_FR.UTF-8/s/^#*/#/g' -e '/pt_PT.UTF-8/s/^#*/#                                                                                                                                                             /g' -e '/zh_CN.UTF-8/s/^#*/#/g' -e 's/^#.*\(en_US.UTF-8\)/\1/' /etc/locale.gen ?                                                                                                                                                             ??#sudo locale-gen --purge >/dev/null 2>&1 ???sudo update-locale --locale-file=/                                                                                                                                                             etc/default/locale >/dev/null 2>&1 ???sudo dpkg-reconfigure --frontend nonintera                                                                                                                                                             ctive locales >/dev/null 2>&1 ???source /root/.bashrc ???;; ??es | spanish*) ???                                                                                                                                                             source /root/.bashrc ???declare -g locale_sed quickbox_lang ???locale_sed=es_ES                                                                                                                                                              ???quickbox_lang=es ???cp -f "${quickbox_base_path}/config/lang/${quickbox_lang}                                                                                                                                                             /locale" "/etc/default/locale" ???cp -f "${quickbox_base_path}/config/lang/${qui                                                                                                                                                             ckbox_lang}/localize.php" "/srv/quickbox/inc/localize.php" ???sed -i -e '/de_DE.                                                                                                                                                             UTF-8/s/^#*/#/g' -e '/da_DK.UTF-8/s/^#*/#/g' -e '/fr_FR.UTF-8/s/^#*/#/g' -e '/pt                                                                                                                                                             _PT.UTF-8/s/^#*/#/g' -e '/zh_CN.UTF-8/s/^#*/#/g' -e 's/^#.*\(es_ES.UTF-8\)/\1/'                                                                                                                                                              /etc/locale.gen >/dev/null 2>&1 ???#sudo locale-gen --purge >/dev/null 2>&1 ???s                                                                                                                                                             udo update-locale --locale-file=/etc/default/locale >/dev/null 2>&1 ???sudo dpkg                                                                                                                                                             -reconfigure --frontend noninteractive locales >/dev/null 2>&1 ???source /root/.                                                                                                                                                             bashrc ???;; ??fr | french*) ???source /root/.bashrc ???declare -g locale_sed qu                                                                                                                                                             ickbox_lang ???locale_sed=fr_FR ???quickbox_lang=fr ???cp -f "${quickbox_base_pa                                                                                                                                                             th}/config/lang/${quickbox_lang}/locale" "/etc/default/locale" ???cp -f "${quick                                                                                                                                                             box_base_path}/config/lang/${quickbox_lang}/localize.php" "/srv/quickbox/inc/loc                                                                                                                                                             alize.php" ???sed -i -e '/de_DE.UTF-8/s/^#*/#/g' -e '/da_DK.UTF-8/s/^#*/#/g' -e                                                                                                                                                              '/es_ES.UTF-8/s/^#*/#/g' -e '/pt_PT.UTF-8/s/^#*/#/g' -e '/zh_CN.UTF-8/s/^#*/#/g'                                                                                                                                                              -e 's/^#.*\(fr_FR.UTF-8\)/\1/' /etc/locale.gen >/dev/null 2>&1 ???#sudo locale-                                                                                                                                                             gen --purge >/dev/null 2>&1 ???sudo update-locale --locale-file=/etc/default/loc                                                                                                                                                             ale >/dev/null 2>&1 ???sudo dpkg-reconfigure --frontend noninteractive locales >                                                                                                                                                             /dev/null 2>&1 ???source /root/.bashrc ???;; ??pt | portuguese*) ???source /root                                                                                                                                                             /.bashrc ???declare -g locale_sed quickbox_lang ???locale_sed=pt_PT ???quickbox_                                                                                                                                                             lang=pt ???cp -f "${quickbox_base_path}/config/lang/${quickbox_lang}/locale" "/e                                                                                                                                                             tc/default/locale" ???cp -f "${quickbox_base_path}/config/lang/${quickbox_lang}/                                                                                                                                                             localize.php" "/srv/quickbox/inc/localize.php" ???sed -i -e '/de_DE.UTF-8/s/^#*/                                                                                                                                                             #/g' -e '/da_DK.UTF-8/s/^#*/#/g' -e '/es_ES.UTF-8/s/^#*/#/g' -e '/fr_FR.UTF-8/s/                                                                                                                                                             ^#*/#/g' -e '/zh_CN.UTF-8/s/^#*/#/g' -e 's/^#.*\(pt_PT.UTF-8\)/\1/' /etc/locale.                                                                                                                                                             gen >/dev/null 2>&1 ???#sudo locale-gen --purge >/dev/null 2>&1 ???sudo update-l                                                                                                                                                             ocale --locale-file=/etc/default/locale >/dev/null 2>&1 ???sudo dpkg-reconfigure                                                                                                                                                              --frontend noninteractive locales >/dev/null 2>&1 ???source /root/.bashrc ???;;                                                                                                                                                              ??zh-cn | chinese*) ???source /root/.bashrc ???declare -g locale_sed quickbox_l                                                                                                                                                             ang ???locale_sed=zh_CN ???quickbox_lang=zh-cn ???mflibs::log "apt-get -y instal                                                                                                                                                             l language-pack-zh-hans language-pack-zh-hans-base fonts-noto" ???cp -f "${quick                                                                                                                                                             box_base_path}/config/lang/${quickbox_lang}/locale" "/etc/default/locale" ???cp                                                                                                                                                              -f "${quickbox_base_path}/config/lang/${quickbox_lang}/localize.php" "/srv/quick                                                                                                                                                             box/inc/localize.php" ???sed -i -e '/de_DE.UTF-8/s/^#*/#/g' -e '/da_DK.UTF-8/s/^                                                                                                                                                             #*/#/g' -e '/es_ES.UTF-8/s/^#*/#/g' -e '/fr_FR.UTF-8/s/^#*/#/g' -e '/pt_PT.UTF-8                                                                                                                                                             /s/^#*/#/g' -e 's/^#.*\(zh_CN.UTF-8\)/\1/' /etc/locale.gen >/dev/null 2>&1 ???#s                                                                                                                                                             udo locale-gen --purge >/dev/null 2>&1 ???sudo update-locale --locale-file=/etc/                                                                                                                                                             default/locale >/dev/null 2>&1 ???sudo dpkg-reconfigure --frontend noninteractiv                                                                                                                                                             e locales >/dev/null 2>&1 ???source /root/.bashrc ???;; ??*) ;; ??esac ?done ?if                                                                                                                                                              [[ -n ${locale_sed} ]]; then ??sed -i -e 's/thousands_sep.*/thousands_sep                                                                                                                                                                          \"<U002C>\"/' "/usr/share/i18n/locales/${locale_sed}" ??[[ ${code_name} =                                                                                                                                                             = "stretch" ]] && sed -i -e 's/decimal_point.*/decimal_point             \"<U002                                                                                                                                                             C>\"/' "/usr/share/i18n/locales/${locale_sed}" ?fi ?chown www-data: /srv/quickbo                                                                                                                                                             x/inc/localize.php ?#mflibs::log "dpkg-reconfigure --frontend noninteractive loc                                                                                                                                                             ales" ?quickbox::database "UPDATE system_configuration set configuration_value =                                                                                                                                                              '${quickbox_lang}' WHERE configuration_name = 'server_language';" ?#mflibs::log                                                                                                                                                              "systemctl reload nginx" ?mflibs::log "systemctl reload php8.1-fpm > /dev/null                                                                                                                                                              2>&1 &" ?mflibs::log "systemctl reload memcached > /dev/null 2>&1 &" }  ########                                                                                                                                                             ######################################################################## # @desc                                                                                                                                                             ription: manages backup, restore, and restore default for software configs # @ar                                                                                                                                                             g: -o [disable|enable|backup|restore|default] -u [username] -s [software] # @exa                                                                                                                                                             mple: qb manage nginx -o backup -s softwarename -u username # @null ############                                                                                                                                                             #################################################################### nginx::sett                                                                                                                                                             ings() { ?if [[ ${software:?} == "netdata" || ${software:?} == "nextcloud" || ${                                                                                                                                                             software:?} == "rutorrent" || ${software:?} == "tautulli" || ${software:?} == "t                                                                                                                                                             helounge" || ${software:?} == "transmission" || ${software:?} == "webconsole" ||                                                                                                                                                              ${software:?} == "znc" ]]; then ??software_nginx="/etc/nginx/software/${softwar                                                                                                                                                             e:-}.conf" ??software_backup_nginx="/home/${username:?}/.QuickBox/software/${sof                                                                                                                                                             tware}/backup/nginx/${software}.conf" ??software_default_nginx="/home/${username                                                                                                                                                             }/.QuickBox/software/${software}/default/nginx/${software}.conf" ?else ??softwar                                                                                                                                                             e_nginx="/etc/nginx/software/${username:?}.${software:-}.conf" ??software_backup                                                                                                                                                             _nginx="/home/${username}/.QuickBox/software/${software}/backup/nginx/${username                                                                                                                                                             }.${software}.conf" ??software_default_nginx="/home/${username}/.QuickBox/softwa                                                                                                                                                             re/${software}/default/nginx/${username}.${software}.conf" ?fi ?for option in "$                                                                                                                                                             {qb_option[@]}"; do ??case "${option,,}" in ??disable) ???mflibs::shell::text::w                                                                                                                                                             hite "disabling auth login on ${software} nginx reverse." ???if [[ ! -f ${softwa                                                                                                                                                             re_nginx} ]]; then ????mflibs::shell::text::red "nginx file [${software_nginx}]                                                                                                                                                              does not exist." ???else ????sed -i '/auth_basic/s/^#*/#/g' "${software_nginx}"                                                                                                                                                              ????mflibs::log "systemctl reload nginx.service" ????mflibs::shell::text::green                                                                                                                                                              "nginx auth has been disabled." ???fi ???;; ??enable) ???mflibs::shell::text::wh                                                                                                                                                             ite "enabling auth login on ${software} nginx reverse." ???if [[ ! -f ${software                                                                                                                                                             _nginx} ]]; then ????mflibs::shell::text::red "nginx file [${software_nginx}] do                                                                                                                                                             es not exist." ???else ????sed -i '/auth_basic/s/^#*//g' "${software_nginx}" ???                                                                                                                                                             ?mflibs::log "systemctl reload nginx.service" ????mflibs::shell::text::green "ng                                                                                                                                                             inx auth has been enabled." ???fi ???;; ??backup) ???mflibs::shell::text::white                                                                                                                                                              "nginx file for ${software} is now being backed up." ???if [[ ! -f ${software_ng                                                                                                                                                             inx} ]]; then ????mflibs::shell::text::red "nginx file [${software_nginx}] does                                                                                                                                                              not exist." ???else ????mkdir -p "/home/${username}/.QuickBox/software/${softwar                                                                                                                                                             e}/backup/nginx/" ????\cp -pf "${software_nginx}" "${software_backup_nginx}" ???                                                                                                                                                             ?mflibs::shell::text::green "configuration file has been backed up." ???fi ???;;                                                                                                                                                              ??restore) ???if [[ ! -f ${software_backup_nginx} ]]; then ????mflibs::shell::t                                                                                                                                                             ext::red "nginx file [${software_backup_nginx}] does not exist." ???else ????\cp                                                                                                                                                              -pf "${software_backup_nginx}" "${software_nginx}" ????mflibs::shell::text::gre                                                                                                                                                             en "backed up configuration file has been restored." ???fi ???;; ??default) ???i                                                                                                                                                             f [[ ! -f ${software_default_nginx} ]]; then ????mflibs::shell::text::red "deful                                                                                                                                                             t nginx file [${software_default_nginx}] does not exist." ???else ????\cp -pf "$                                                                                                                                                             {software_default_nginx}" "${software_nginx}" ????mflibs::shell::text::green "de                                                                                                                                                             fault configuration file has been restored." ???fi ???;; ??*) ;; ??esac ?done }                                                                                                                                                               ###############################################################################                                                                                                                                                             # # @description: manages directory/mount checks # @arg: -o space -u [username]                                                                                                                                                              # @example: qb manage mount -o space -u username # @null #######################                                                                                                                                                             ######################################################### mount::settings() { ?f                                                                                                                                                             or option in "${qb_option[@]}"; do ??case "${option,,}" in ??space) ???read -d '                                                                                                                                                             ' -ra mount_path <<<"$(quickbox::database "SELECT mount FROM user_mounts WHERE u                                                                                                                                                             sername='${username}';")" ???for m in "${mount_path[@]}"; do ????# if mount path                                                                                                                                                              is '/' use `df -B1` instead ????[[ ${m} == "/" ]] && space_used=$(df -B1 | grep                                                                                                                                                              -w "/" | awk '{print $3}' | tail -n 1) ????[[ ${m} != "/" ]] && space_used=$(du                                                                                                                                                              -ac --bytes "${m}" | awk '{print $1}' | tail -n 1) ????mflibs::shell::text::gre                                                                                                                                                             en "updating ${m} with ${space_used}" ????quickbox::database "UPDATE user_mounts                                                                                                                                                              set space='${space_used}' WHERE username='${username}' AND mount='${m}';" ???do                                                                                                                                                             ne ???if [[ -d "/home/${username}/.config/rclone/" ]]; then ????mergerfs_service                                                                                                                                                             _mount=$(grep 'fuse.mergerfs' </proc/mounts | cut -d ' ' -f 2 | sed -e 's|/|-|g'                                                                                                                                                              | sed -ne 's|-||p' | grep "${username}") ????echo "${mergerfs_service_mount}" >                                                                                                                                                             "/home/${username}/.config/rclone/mergerfs_mount_service.txt" ????chown -R "${us                                                                                                                                                             ername}":"${username}" "/home/${username}/.config/rclone/" ????chmod 0664 "/home                                                                                                                                                             /${username}/.config/rclone/mergerfs_mount_service.txt" ???fi ???;; ??*) ;; ??es                                                                                                                                                             ac ?done }  ####################################################################                                                                                                                                                             ############ # @description: manages backup, restore, and restore default for so                                                                                                                                                             ftware configs. # additionally handles the install/uninstall of rutorrent plugin                                                                                                                                                             s (see second example) # # notes: # - rtorrent requires no additional arguments                                                                                                                                                              (such as -u) as it is a system-wide # install and not user-specific (see last ex                                                                                                                                                             ample) # @arg: -o [backup|restore|default|] -u [username] -s [software] # @arg:                                                                                                                                                              -o [rutorrent] -o [install|remove] -rup [rutorrent_plugin_name] # @example: qb m                                                                                                                                                             anage software -o backup -u username -s softwarename # qb manage software -o bac                                                                                                                                                             kup -o app -u username -s softwarename # qb manage software -o rollback -o app -                                                                                                                                                             u username -s softwarename # qb manage software -o restore -u username -s softwa                                                                                                                                                             rename # qb manage software -o default -u username -s softwarename # qb manage s                                                                                                                                                             oftware -o rutorrent -o install -rup _cloudflare # @null # @example: qb manage s                                                                                                                                                             oftware -o backup -s rtorrent # @null ##########################################                                                                                                                                                             ###################################### software::settings() { ?declare software_                                                                                                                                                             name ?software_name=$(quickbox::database "SELECT DISTINCT software_name from sof                                                                                                                                                             tware_information WHERE software_name = '${software:-}' LIMIT 1;") ?default_loca                                                                                                                                                             tion=$(quickbox::database "SELECT DISTINCT software_default_location from softwa                                                                                                                                                             re_information WHERE software_name = '${software:-}';") ?backup_location=$(quick                                                                                                                                                             box::database "SELECT DISTINCT software_backup_location from software_informatio                                                                                                                                                             n WHERE software_name = '${software_name}';") ?software_location=$(quickbox::dat                                                                                                                                                             abase "SELECT DISTINCT software_config_location from software_information WHERE                                                                                                                                                              software_name = '${software_name}';") ?software_title=$(quickbox::database "SELE                                                                                                                                                             CT DISTINCT software_title from software_information WHERE software_name = '${so                                                                                                                                                             ftware_name}';") ?# only set these variables if the software_name is not rtorren                                                                                                                                                             t OR rutorrent ?if [[ "${software_name}" != "rtorrent" ]]; then ??declare backup                                                                                                                                                             _version ??user_id=$(quickbox::database "SELECT id FROM user_information WHERE u                                                                                                                                                             sername='${username}';") ??backup_version=$(quickbox::database "SELECT DISTINCT                                                                                                                                                              software_version from user_software WHERE user_id = '${user_id:?}' AND software_                                                                                                                                                             name = '${software_name}' LIMIT 1;") ??defaultConf="/home/${username:-}/.QuickBo                                                                                                                                                             x/software${default_location}" ??backupConf="/home/${username}/.QuickBox/softwar                                                                                                                                                             e${backup_location}" ??softwareConf="/home/${username}${software_location}" ?fi                                                                                                                                                              ?for option in "${qb_option[@]}"; do ??case "${option,,}" in ??backup) ???[[ "${                                                                                                                                                             qb_option[*]}" =~ "vi=" ]] && declare skip_check=1 ???vi=$(grep -oP 'vi=\K.*' <<                                                                                                                                                             <"${qb_option[*]}") ???if [[ "${software_name}" =~ "rtorrent" ]]; then ????read                                                                                                                                                              -d '' -ra users_all <<<"$(quickbox::database "SELECT username FROM user_informat                                                                                                                                                             ion")" ????for user in "${users_all:-[@]}"; do ?????[[ -z ${skip_check} ]] && mf                                                                                                                                                             libs::shell::text::white "$(quickbox::lang::backup::configf)" ?????declare time_                                                                                                                                                             stamp ?????time_stamp=$(date '+%Y-%m-%d %H:%M') ?????package_date=${time_stamp//                                                                                                                                                              /_} ?????userid=$(quickbox::database "SELECT id FROM user_information WHERE use                                                                                                                                                             rname='${user}';") ?????backup_version=$(quickbox::database "SELECT DISTINCT sof                                                                                                                                                             tware_version from user_software WHERE user_id = '${userid:?}' AND software_name                                                                                                                                                              = '${software_name}' LIMIT 1;") ?????defaultConf="/home/${user:-}/.QuickBox/sof                                                                                                                                                             tware${default_location}" ?????backupConf="/home/${user}/.QuickBox/software${bac                                                                                                                                                             kup_location}" ?????softwareConf="/home/${user}${software_location}" ?????backup                                                                                                                                                             ="/home/${user}/.QuickBox/software/rtorrent/backup/" ?????mkdir -p "${backup}" &                                                                                                                                                             & cp -prf "${softwareConf}" "${backupConf}_${package_date}" && cp -prf "${backup                                                                                                                                                             Conf}_${package_date}" "${backupConf}" ?????find "/home/${user}/.QuickBox" -type                                                                                                                                                              d \( ! -user www-data -o ! -group www-data \) -print0 | xargs -0 chown www-data                                                                                                                                                             :www-data >/dev/null 2>&1 ?????find "/home/${user}/.QuickBox" -type d ! -perm 07                                                                                                                                                             55 -print0 | xargs -0 chmod 0755 >/dev/null 2>&1 ?????[[ -z ${skip_check} ]] &&                                                                                                                                                              mflibs::shell::text::green "$(quickbox::lang::backup::configf::success)" ????don                                                                                                                                                             e ???else ????[[ -z ${skip_check} ]] && mflibs::shell::text::white "$(quickbox::                                                                                                                                                             lang::backup::configf)" ????if [[ ! -f ${softwareConf} ]]; then ?????mflibs::she                                                                                                                                                             ll::text::red "$(quickbox::lang::backup::configf::error)" ?????exit 1 ????fi ???                                                                                                                                                             ?user_id=$(quickbox::database "SELECT id FROM user_information WHERE username='$                                                                                                                                                             {username}';") ????backup_version=$(quickbox::database "SELECT DISTINCT software                                                                                                                                                             _version from user_software WHERE user_id = '${user_id:?}' AND software_name = '                                                                                                                                                             ${software_name}' LIMIT 1;") ????defaultConf="/home/${username:-}/.QuickBox/soft                                                                                                                                                             ware${default_location}" ????backupConf="/home/${username}/.QuickBox/software${b                                                                                                                                                             ackup_location}" ????softwareConf="/home/${username}${software_location}" ????[[                                                                                                                                                              "${software_name}" =~ "deluged" ]] && backup="/home/${username}/.QuickBox/softw                                                                                                                                                             are/deluge/backup/" ????[[ "${software_name}" != "deluged" ]] && backup="/home/$                                                                                                                                                             {username}/.QuickBox/software/${software_name}/backup/" ????mkdir -p "${backup}"                                                                                                                                                              && cp -prf "${softwareConf}" "${backupConf}" ????find "/home/${username}/.Quick                                                                                                                                                             Box" -type d \( ! -user www-data -o ! -group www-data \) -print0 | xargs -0 chow                                                                                                                                                             n www-data:www-data >/dev/null 2>&1 ????find "/home/${username}/.QuickBox" -type                                                                                                                                                              d ! -perm 0755 -print0 | xargs -0 chmod 0755 >/dev/null 2>&1 ????[[ -z ${skip_c                                                                                                                                                             heck} ]] && mflibs::shell::text::green "$(quickbox::lang::backup::configf::succe                                                                                                                                                             ss)" ???fi ???# check if `-o app` is set, if so, backup the application install                                                                                                                                                              and config directories ???if [[ "${qb_option[*]}" =~ "app" ]]; then ????# set cu                                                                                                                                                             stom conditions for software installation directories ????if [[ "${software_name                                                                                                                                                             }" =~ "emby" ]]; then ?????install_directory="/opt/${username}/emby-server" ????                                                                                                                                                             elif [[ "${software_name}" =~ "plex" ]]; then ?????install_directory="/usr/lib/p                                                                                                                                                             lexmediaserver" ????else ?????install_directory=$(find "/opt/${username}" -maxde                                                                                                                                                             pth 1 -type d -name "${software_title}" -printf '%f\n') ????fi ????if [[ -z "${i                                                                                                                                                             nstall_directory}" ]]; then ?????mflibs::shell::text::red "$(quickbox::lang::bac                                                                                                                                                             kup::installdir::error)" ?????exit 1 ????fi ????backup="/home/${username}/.Quick                                                                                                                                                             Box/software/${software_name}/backup/" ????mkdir -p "${backup}" && cp -prf "${so                                                                                                                                                             ftwareConf}" "${backupConf}" ????declare time_stamp package_date ????time_stamp=                                                                                                                                                             $(date '+%Y-%m-%d %H:%M') ????package_date=${time_stamp// /_} ????mflibs::shell:                                                                                                                                                             :text::white "$(quickbox::lang::backup::installdir)" ????# create a tarball of t                                                                                                                                                             he software installation directory ????if [[ "${software_name}" =~ "emby" || "${                                                                                                                                                             software_name}" =~ "plex" ]]; then ?????tar -czf "${backup}/${software_name}-${b                                                                                                                                                             ackup_version}-application_${package_date}.tar.gz" -C "${install_directory}" . >                                                                                                                                                             /dev/null 2>&1 ????else ?????tar -czf "${backup}/${software_name}-${backup_versi                                                                                                                                                             on}-application_${package_date}.tar.gz" -C "/opt/${username}/${install_directory                                                                                                                                                             }" . >/dev/null 2>&1 ????fi ????mflibs::shell::text::white "$(quickbox::lang::ba                                                                                                                                                             ckup::configdir)" ????# create a tarball of the software configuration directory                                                                                                                                                              ????if [[ "${software_name}" =~ "emby" ]]; then ?????tar -czf "${backup}/${soft                                                                                                                                                             ware_name}-${backup_version}-config_${package_date}.tar.gz" -C "/home/${username                                                                                                                                                             }/.config/Emby" . >/dev/null 2>&1 ????elif [[ "${software_name}" =~ "plex" ]]; t                                                                                                                                                             hen ?????tar -czf "${backup}/${software_name}-${backup_version}-config_${package                                                                                                                                                             _date}.tar.gz" -C "/home/${username}/.config/Plex Media Server" . >/dev/null 2>&                                                                                                                                                             1 ????elif [[ "${software_name}" =~ "jellyseerr" ]]; then ?????tar -czf "${backu                                                                                                                                                             p}/${software_name}-${backup_version}-config_${package_date}.tar.gz" -C "/opt/${                                                                                                                                                             username}/Jellyseerr/config" . >/dev/null 2>&1 ????elif [[ "${software_name}" =~                                                                                                                                                              "overseerr" ]]; then ?????tar -czf "${backup}/${software_name}-${backup_version                                                                                                                                                             }-config_${package_date}.tar.gz" -C "/opt/${username}/Overseerr/config" . >/dev/                                                                                                                                                             null 2>&1 ????else ?????tar -czf "${backup}/${software_name}-${backup_version}-c                                                                                                                                                             onfig_${package_date}.tar.gz" -C "/home/${username}/.config/${software_title}" .                                                                                                                                                              >/dev/null 2>&1 ????fi ????find "/home/${username}/.QuickBox" -type d \( ! -use                                                                                                                                                             r www-data -o ! -group www-data \) -print0 | xargs -0 chown www-data:www-data >/                                                                                                                                                             dev/null 2>&1 ????find "/home/${username}/.QuickBox" -type d ! -perm 0755 -print                                                                                                                                                             0 | xargs -0 chmod 0755 >/dev/null 2>&1 ????chown www-data:www-data -R "${backup                                                                                                                                                             }/${software_name}"-*.tar.gz >/dev/null 2>&1 ????chown "${username}":"${username                                                                                                                                                             }" "${backupConf}" "${softwareConf}" ????quickbox::database "INSERT INTO softwar                                                                                                                                                             e_rollbacks ("username", "software_name", "software_version", "software_date") V                                                                                                                                                             ALUES ('${username}', '${software_name:-}', '${backup_version:-}', '${time_stamp                                                                                                                                                             :-}');" ????mflibs::shell::text::green "$(quickbox::lang::backup::installdir::su                                                                                                                                                             ccess)" ????unset time_stamp package_date backup_version software_name ???fi ???                                                                                                                                                             ;; ??restore) ???if [[ ! -f ${backupConf} ]]; then ????mflibs::shell::text::red                                                                                                                                                              "$(quickbox::lang::restore::configf::error)" ???else ????cp -prf "${backupConf}"                                                                                                                                                              "${softwareConf}" ????find "/home/${username}/.QuickBox" -type d \( ! -user www                                                                                                                                                             -data -o ! -group www-data \) -print0 | xargs -0 chown www-data:www-data >/dev/n                                                                                                                                                             ull 2>&1 ????find "/home/${username}/.QuickBox" -type d ! -perm 0755 -print0 | x                                                                                                                                                             args -0 chmod 0755 >/dev/null 2>&1 ????chown "${username}":"${username}" "${back                                                                                                                                                             upConf}" "${softwareConf}" ????mflibs::shell::text::green "$(quickbox::lang::res                                                                                                                                                             tore::configf::success)" ???fi ???;; ??default) ???if [[ ! -f ${defaultConf} ]];                                                                                                                                                              then ????mflibs::shell::text::red "$(quickbox::lang::default::configf::error)"                                                                                                                                                              ???else ????cp -prf "${defaultConf}" "${softwareConf}" ????find "/home/${usernam                                                                                                                                                             e}/.QuickBox" -type d \( ! -user www-data -o ! -group www-data \) -print0 | xarg                                                                                                                                                             s -0 chown www-data:www-data >/dev/null 2>&1 ????find "/home/${username}/.QuickB                                                                                                                                                             ox" -type d ! -perm 0755 -print0 | xargs -0 chmod 0755 >/dev/null 2>&1 ????chown                                                                                                                                                              "${username}":"${username}" "${backupConf}" "${softwareConf}" ????mflibs::shell                                                                                                                                                             ::text::green "$(quickbox::lang::default::configf::success)" ???fi ???;; ??rollb                                                                                                                                                             ack) ???if [[ "${qb_option[*]}" =~ "app" ]]; then ????user_id=$(quickbox::databa                                                                                                                                                             se "SELECT id FROM user_information WHERE username='${username}';") ????software                                                                                                                                                             _title=$(quickbox::database "SELECT DISTINCT software_title from software_inform                                                                                                                                                             ation WHERE software_name = '${software}';") ????software_service_name=$(quickbo                                                                                                                                                             x::database "SELECT DISTINCT software_service_name from software_information WHE                                                                                                                                                             RE software_name = '${software}';") ????backup_path="/home/${username}/.QuickBox                                                                                                                                                             /software/${software}/backup/" ????[[ -f "/etc/systemd/system/${software_service                                                                                                                                                             _name}@${username}.service" ]] && systemctl stop "${software_service_name}"@"${u                                                                                                                                                             sername}" >/dev/null 2>&1 ????[[ -f "/etc/systemd/system/${software_service_name                                                                                                                                                             }.service" ]] && systemctl stop "${software_service_name}" >/dev/null 2>&1 ????#                                                                                                                                                              set custom conditions for software directories on rollback ????if [[ "${softwar                                                                                                                                                             e}" =~ "emby" ]]; then ?????install_directory="/opt/${username}/emby-server" ???                                                                                                                                                             ?elif [[ "${software}" =~ "plex" ]]; then ?????install_directory="/usr/lib/plexm                                                                                                                                                             ediaserver" ????else ?????install_directory=$(find "/opt/${username}" -maxdepth                                                                                                                                                              1 -type d -name "${software_title}" -printf '%f\n') ????fi ????if [[ -z "${insta                                                                                                                                                             ll_directory}" ]]; then ?????mflibs::shell::text::red "$(quickbox::lang::rollbac                                                                                                                                                             k::installdir::error)" ?????exit 1 ????fi ????[[ "${qb_option[*]}" =~ "vi=" ]] &                                                                                                                                                             & declare skip_check=1 ????swvi=1 ????IFS=$'\n' read -d '' -ra backups <<<"$(qui                                                                                                                                                             ckbox::database "SELECT software_version,software_date from software_rollbacks W                                                                                                                                                             HERE software_name = '${software}' AND username = '${username}';")" ????backup_m                                                                                                                                                             enu=() ????for i in "${backups[@]}"; do ?????backup_version="$(echo "${i}" | cut                                                                                                                                                              -d '|' -f1)" ?????backup_date="$(echo "${i}" | cut -d '|' -f2-)" ?????backup_me                                                                                                                                                             nu+=("  ${swvi})    $(quickbox::lang::rollback::selection::version) ${backup_ver                                                                                                                                                             sion}    $(quickbox::lang::rollback::selection::date) ${backup_date}") ?????swvi                                                                                                                                                             =$((swvi + 1)) ????done ????# display the menu ????mflibs::shell::text::white "$                                                                                                                                                             (quickbox::lang::rollback::selection)" ????for backup_display in "${backup_menu[                                                                                                                                                             @]}"; do ?????echo "${backup_display}" ????done ????# set the version from the s                                                                                                                                                             election ????declare -gi vi ????declare version ????if [[ ${skip_check} == 1 ]];                                                                                                                                                              then ?????# set the vi= to the value in the -o vi= option ?????vi=$(grep -oP 'v                                                                                                                                                             i=\K.*' <<<"${qb_option[*]}") ????else ?????IFS=$'\n' read -r version_selection                                                                                                                                                              ?????vi=$(grep -oP "${version_selection}" <<<"${backup_menu[@]}" | grep -oP '[0-                                                                                                                                                             9]*' | head -n 1) ????fi ????version=$(grep -oP 'version: \K.*(?=    date)' <<<"                                                                                                                                                             ${backup_menu[$((vi - 1))]}") ????# set confirmation if input provided is correc                                                                                                                                                             t ????if [[ -z "${version}" ]]; then ?????mflibs::shell::text::red "$(quickbox::                                                                                                                                                             lang::rollback::selection::invalid)" ?????IFS=$'\n' read -r version_selection ??                                                                                                                                                             ??else ?????# show selection and confirmation request ?????declare selected_date                                                                                                                                                              app_package config_package ?????selected_date=$(grep -oP 'date: \K.*' <<<"${bac                                                                                                                                                             kup_menu[$((vi - 1))]}") ?????package_date=${selected_date// /_} ?????app_packag                                                                                                                                                             e=$(find "${backup_path}" -maxdepth 1 -type f -name "${software}-${version}-appl                                                                                                                                                             ication_${package_date}.tar.gz" -printf '%f\n') ?????if [[ -z "${app_package}" ]                                                                                                                                                             ]; then ??????mflibs::shell::text::red "$(quickbox::lang::rollback::software::er                                                                                                                                                             ror)" ??????exit 1 ?????fi ?????config_package=$(find "${backup_path}" -maxdepth                                                                                                                                                              1 -type f -name "${software}-${version}-config_${package_date}.tar.gz" -printf                                                                                                                                                              '%f\n') ?????if [[ -z "${config_package}" ]]; then ??????mflibs::shell::text::re                                                                                                                                                             d "$(quickbox::lang::rollback::config::error)" ??????exit 1 ?????fi ?????mflibs:                                                                                                                                                             :shell::text::white "$(quickbox::lang::rollback::selection::display)" ?????if [[                                                                                                                                                              -z ${skip_check} ]]; then ??????mflibs::shell::text::white "$(quickbox::lang::r                                                                                                                                                             ollback::selection::confirm)" ??????IFS=$'\n' read -r version_confirm ??????# lo                                                                                                                                                             op until a valid selection is made ??????while [[ "${version_confirm}" != "y" ]]                                                                                                                                                              && [[ "${version_confirm}" != "n" ]]; do ???????mflibs::shell::text::red "$(qui                                                                                                                                                             ckbox::lang::rollback::selection::invalid)" ???????IFS=$'\n' read -r version_con                                                                                                                                                             firm ??????done ??????# if the selection is no, exit the script ??????if [[ "${v                                                                                                                                                             ersion_confirm}" == "n" ]]; then ???????mflibs::shell::text::red "$(quickbox::la                                                                                                                                                             ng::rollback::cancelled)" ???????exit 0 ??????fi ?????fi ????fi ????# display co                                                                                                                                                             nfirmation of the version selection and proceed with the rollback ????mflibs::sh                                                                                                                                                             ell::text::white "$(quickbox::lang::rollback::continue)" ????# extract the tarba                                                                                                                                                             ll of the software installation directory ????if [[ "${software}" =~ "emby" || "                                                                                                                                                             ${software}" =~ "plex" ]]; then ?????tar -xzf "${backup_path}/${app_package}" -C                                                                                                                                                              "${install_directory}" >/dev/null 2>&1 ????else ?????tar -xzf "${backup_path}/$                                                                                                                                                             {app_package}" -C "/opt/${username}/${install_directory}" >/dev/null 2>&1 ????fi                                                                                                                                                              ????# extract the tarball of the software configuration directory ????if [[ "${                                                                                                                                                             software}" =~ "emby" ]]; then ?????tar -xzf "${backup_path}/${config_package}" -                                                                                                                                                             C "/home/${username}/.config/Emby" >/dev/null 2>&1 ?????chown "${username}":"${u                                                                                                                                                             sername}" -R "${install_directory}" "/home/${username}/.config/Emby" 2>&1 ????el                                                                                                                                                             if [[ "${software}" =~ "plex" ]]; then ?????tar -xzf "${backup_path}/${config_pa                                                                                                                                                             ckage}" -C "/home/${username}/.config/Plex Media Server" >/dev/null 2>&1 ?????ch                                                                                                                                                             own "${username}":"${username}" -R "${install_directory}" "/home/${username}/.co                                                                                                                                                             nfig/Plex Media Server" 2>&1 ????elif [[ "${software_name}" =~ "jellyseerr" ]];                                                                                                                                                              then ?????tar -xzf "${backup_path}/${config_package}" -C "/opt/${username}/Jelly                                                                                                                                                             seerr/config" >/dev/null 2>&1 ?????chown "${username}":"${username}" -R "${insta                                                                                                                                                             ll_directory}" "/home/${username}/.config/Jellyseerr" 2>&1 ????elif [[ "${softwa                                                                                                                                                             re_name}" =~ "overseerr" ]]; then ?????tar -xzf "${backup_path}/${config_package                                                                                                                                                             }" -C "/opt/${username}/Overseerr/config" >/dev/null 2>&1 ?????chown "${username                                                                                                                                                             }":"${username}" -R "${install_directory}" "/home/${username}/.config/Overseerr"                                                                                                                                                              2>&1 ????else ?????tar -xzf "${backup_path}/${config_package}" -C "/home/${user                                                                                                                                                             name}/.config/${software_title}" >/dev/null 2>&1 ?????chown "${username}":"${use                                                                                                                                                             rname}" -R "/opt/${username}/${install_directory}" "/home/${username}/.config/${                                                                                                                                                             software_title}" 2>&1 ????fi ????quickbox::database "UPDATE user_software SET so                                                                                                                                                             ftware_version='${version}' WHERE software_name='${software}' AND user_id='${use                                                                                                                                                             r_id:?}';" ????[[ -f "/etc/systemd/system/${software_service_name}@${username}.s                                                                                                                                                             ervice" ]] && systemctl start "${software_service_name}"@"${username}" >/dev/nul                                                                                                                                                             l 2>&1 ????[[ -f "/etc/systemd/system/${software_service_name}.service" ]] && sy                                                                                                                                                             stemctl start "${software_service_name}" >/dev/null 2>&1 ????/usr/local/bin/qb s                                                                                                                                                             oftware check >/dev/null 2>&1 ????mflibs::shell::text::green "$(quickbox::lang::                                                                                                                                                             rollback::complete)" ????unset version version_selection vi selected_date app_pa                                                                                                                                                             ckage config_package ???fi ???;; ??delete) ???if [[ "${qb_option[*]}" =~ "app" ]                                                                                                                                                             ]; then ????user_id=$(quickbox::database "SELECT id FROM user_information WHERE                                                                                                                                                              username='${username}';") ????software_title=$(quickbox::database "SELECT DISTIN                                                                                                                                                             CT software_title from software_information WHERE software_name = '${software}';                                                                                                                                                             ") ????software_service_name=$(quickbox::database "SELECT DISTINCT software_serv                                                                                                                                                             ice_name from software_information WHERE software_name = '${software}';") ????ba                                                                                                                                                             ckup_path="/home/${username}/.QuickBox/software/${software}/backup/" ????install                                                                                                                                                             _directory=$(find "/opt/${username}" -maxdepth 1 -type d -name "${software_title                                                                                                                                                             }*" -printf '%f\n') ????config_directory=$(find "/home/${username}/.config" -max                                                                                                                                                             depth 1 -type d -name "${software_title}*" -printf '%f\n') ????[[ "${qb_option[*                                                                                                                                                             ]}" =~ "vi=" ]] && declare skip_check=1 ????swvi=1 ????IFS=$'\n' read -d '' -ra                                                                                                                                                              backups <<<"$(quickbox::database "SELECT software_version,software_date from sof                                                                                                                                                             tware_rollbacks WHERE software_name = '${software}' AND username = '${username}'                                                                                                                                                             ;")" ????backup_menu=() ????for i in "${backups[@]}"; do ?????backup_version="$(                                                                                                                                                             echo "${i}" | cut -d '|' -f1)" ?????backup_date="$(echo "${i}" | cut -d '|' -f2-                                                                                                                                                             )" ?????backup_menu+=("  ${swvi})    $(quickbox::lang::delete::selection::versio                                                                                                                                                             n) ${backup_version}    $(quickbox::lang::delete::selection::date) ${backup_date                                                                                                                                                             }") ?????swvi=$((swvi + 1)) ????done ????# display the menu ????mflibs::shell::t                                                                                                                                                             ext::white "$(quickbox::lang::delete::selection)" ????for backup_display in "${b                                                                                                                                                             ackup_menu[@]}"; do ?????echo "${backup_display}" ????done ????# set the version                                                                                                                                                              from the selection ????declare -gi vi ????declare version ????if [[ ${skip_chec                                                                                                                                                             k} == 1 ]]; then ?????# set the vi= to the value in the -o vi= option ?????vi=$(                                                                                                                                                             grep -oP 'vi=\K.*' <<<"${qb_option[*]}") ????else ?????IFS=$'\n' read -r version                                                                                                                                                             _selection ?????vi=$(grep -oP "${version_selection}" <<<"${backup_menu[@]}" | gr                                                                                                                                                             ep -oP '[0-9]*' | head -n 1) ????fi ????version=$(grep -oP 'version: \K.*(?=                                                                                                                                                                 date)' <<<"${backup_menu[$((vi - 1))]}") ????# set confirmation if input provide                                                                                                                                                             d is correct ????if [[ -z "${version}" ]]; then ?????mflibs::shell::text::red "$                                                                                                                                                             (quickbox::lang::delete::selection::invalid)" ?????IFS=$'\n' read -r version_sel                                                                                                                                                             ection ????else ?????# show selection and confirmation request ?????declare sele                                                                                                                                                             cted_date app_package config_package ?????selected_date=$(grep -oP 'date: \K.*'                                                                                                                                                              <<<"${backup_menu[$((vi - 1))]}") ?????package_date=${selected_date// /_} ?????a                                                                                                                                                             pp_package=$(find "${backup_path}" -maxdepth 1 -type f -name "${software}-${vers                                                                                                                                                             ion}-application_${package_date}.tar.gz" -printf '%f\n') ?????config_package=$(f                                                                                                                                                             ind "${backup_path}" -maxdepth 1 -type f -name "${software}-${version}-config_${                                                                                                                                                             package_date}.tar.gz" -printf '%f\n') ?????mflibs::shell::text::white "$(quickbo                                                                                                                                                             x::lang::delete::selection::display)" ?????if [[ -z ${skip_check} ]]; then ?????                                                                                                                                                             ?mflibs::shell::text::white "$(quickbox::lang::delete::selection::confirm)" ????                                                                                                                                                             ??IFS=$'\n' read -r version_confirm ??????# loop until a valid selection is made                                                                                                                                                              ??????while [[ "${version_confirm}" != "y" ]] && [[ "${version_confirm}" != "n"                                                                                                                                                              ]]; do ???????mflibs::shell::text::red "$(quickbox::lang::delete::selection::in                                                                                                                                                             valid)" ???????IFS=$'\n' read -r version_confirm ??????done ??????# if the selec                                                                                                                                                             tion is no, exit the script ??????if [[ "${version_confirm}" == "n" ]]; then ???                                                                                                                                                             ????mflibs::shell::text::red "$(quickbox::lang::delete::cancelled)" ???????exit                                                                                                                                                              0 ??????fi ?????fi ????fi ????# display confirmation of the version selection an                                                                                                                                                             d proceed with the rollback ????mflibs::shell::text::white "$(quickbox::lang::de                                                                                                                                                             lete::continue)" && sleep 2 ????# remove the selected tarball of the software in                                                                                                                                                             stallation backup directory ????rm -f "${backup_path}/${app_package}" >/dev/null                                                                                                                                                              2>&1 ????# remove the selected tarball of the software configuration backup dir                                                                                                                                                             ectory ????rm -f "${backup_path}/${config_package}" >/dev/null 2>&1 ????# remove                                                                                                                                                              the selected version/date from the database ????quickbox::database "DELETE FROM                                                                                                                                                              software_rollbacks WHERE software_name='${software}' AND username='${username}'                                                                                                                                                              AND software_version='${version}' AND software_date='${selected_date}';" ????mf                                                                                                                                                             libs::shell::text::green "$(quickbox::lang::delete::complete)" ????unset version                                                                                                                                                              version_selection vi selected_date app_package config_package ???fi ???;; ??rut                                                                                                                                                             orrent) ???plugin_vault_directory="/opt/quickbox/bin/software/rutorrent/plugins/                                                                                                                                                             " ???plugin_install_directory="/srv/rutorrent/plugins" ???for option in "${qb_op                                                                                                                                                             tion[@]}"; do ????case "${option,,}" in ????install) ?????echo "accessing ${ruto                                                                                                                                                             rrent_plugin:-} in the plugin vault ... " ?????cd "${plugin_install_directory:-}                                                                                                                                                             " || { echo "${plugin_install_directory:-} does not exist" && exit; } ?????echo                                                                                                                                                              "installing ${rutorrent_plugin:-} plugin ... " ?????if [[ ${rutorrent_plugin:-}                                                                                                                                                              == "autodl-irssi" ]]; then ??????if [[ $(quickbox::software::count autodl) -eq 1                                                                                                                                                              ]]; then ???????rm -rf "${plugin_vault_directory:-}autodl-irssi" ???????git clo                                                                                                                                                             ne https://lab.quickbox.io/jmsolo/autodl-rutorrent.git "${plugin_vault_directory                                                                                                                                                             :-}autodl-irssi" ??????else ???????echo "AutoDL-iRSSi is not installed on the sy                                                                                                                                                             stem, skipping." ??????fi ?????fi ?????for i in ${rutorrent_plugin:-}; do ??????                                                                                                                                                             \cp -rf "${plugin_vault_directory:-}${i}" . ?????done ?????if [[ ${rutorrent_plu                                                                                                                                                             gin:-} == "_cloudflare" ]]; then ??????/usr/bin/python3 -m pip install --upgrade                                                                                                                                                              --exists-action s cloudscraper python_anticaptcha >/dev/null 2>&1 ??????\cp -f                                                                                                                                                              "/opt/quickbox/config/software/rutorrent/plugins/${rutorrent_plugin:-}/conf.php"                                                                                                                                                              "${plugin_install_directory:-}/${rutorrent_plugin:-}/conf.php" ?????fi ?????if                                                                                                                                                              [[ ${rutorrent_plugin:-} == "diskspace" ]]; then ??????\cp -f "/opt/quickbox/con                                                                                                                                                             fig/software/rutorrent/plugins/${rutorrent_plugin:-}/action.php" "${plugin_insta                                                                                                                                                             ll_directory:-}/${rutorrent_plugin:-}/action.php" ?????fi ?????if [[ ${rutorrent                                                                                                                                                             _plugin:-} == "filemanager-share" ]]; then ??????\cp -f "/opt/quickbox/config/so                                                                                                                                                             ftware/rutorrent/plugins/${rutorrent_plugin:-}/conf.php" "${plugin_install_direc                                                                                                                                                             tory:-}/${rutorrent_plugin:-}/conf.php" ?????fi ?????echo "adjusting permissions                                                                                                                                                              ... " ?????chown -R www-data: "${plugin_install_directory:-}/${rutorrent_plugin                                                                                                                                                             :-}" ?????echo "${rutorrent_plugin:-} plugin install complete!" ?????[[ ${qb_opt                                                                                                                                                             ion[*]} != *"web"* ]] && systemctl reload php8.1-fpm >/dev/null 2>&1 & ?????exit                                                                                                                                                              ?????;; ????remove) ?????echo "uninstalling the ${rutorrent_plugin:?} plugin ..                                                                                                                                                             . " ?????for i in ${rutorrent_plugin:-}; do ??????rm -rf "${plugin_install_direc                                                                                                                                                             tory:?}/${i}" ?????done ?????echo "${rutorrent_plugin:-} plugin uninstall comple                                                                                                                                                             te!" ?????[[ ${qb_option[*]} != *"web"* ]] && systemctl reload php8.1-fpm >/dev/                                                                                                                                                             null 2>&1 & ?????exit ?????;; ????*) ;; ????esac ???done ???;; ??*) ;; ??esac ?d                                                                                                                                                             one }  #########################################################################                                                                                                                                                             ####### # @description: dashboard theme switching # @arg: -o [defaulted|smoked]                                                                                                                                                              # @example: qb manage theme -o smoked # @null ##################################                                                                                                                                                             ############################################## theme::settings() { ?for option i                                                                                                                                                             n "${qb_option[@]}"; do ??case "${option,,}" in ??smoked) ???sed -i -r 's/defaul                                                                                                                                                             ted.css/smoked.css/g' /srv/quickbox/assets/css/plugins.css ???sed -i -r 's/defau                                                                                                                                                             lted.css/smoked.css/g' /srv/quickbox/dash_header.php ???sed -i -r 's/defaulted.c                                                                                                                                                             ss/smoked.css/g' /srv/quickbox/assets/css/plugins_1.css ???rm -rf /srv/quickbox/                                                                                                                                                             db/.theme_defaulted.lock ???printf "" >/srv/quickbox/db/.theme_smoked.lock ???ch                                                                                                                                                             own www-data:www-data /srv/quickbox/db/.theme_smoked.lock ???[[ ${qb_option[*]}                                                                                                                                                              != *"web"* ]] && systemctl reload php8.1-fpm >/dev/null 2>&1 & ???;; ??defaulted                                                                                                                                                             ) ???sed -i -r 's/smoked.css/defaulted.css/g' /srv/quickbox/assets/css/plugins.c                                                                                                                                                             ss ???sed -i -r 's/smoked.css/defaulted.css/g' /srv/quickbox/dash_header.php ???                                                                                                                                                             sed -i -r 's/smoked.css/defaulted.css/g' /srv/quickbox/assets/css/plugins_1.css                                                                                                                                                              ???rm -rf /srv/quickbox/db/.theme_smoked.lock ???printf "" >/srv/quickbox/db/.th                                                                                                                                                             eme_defaulted.lock ???chown www-data:www-data /srv/quickbox/db/.theme_defaulted.                                                                                                                                                             lock ???[[ ${qb_option[*]} != *"web"* ]] && systemctl reload php8.1-fpm >/dev/nu                                                                                                                                                             ll 2>&1 & ???;; ??*) ;; ??esac ?done }  ########################################                                                                                                                                                             ######################################## # @description: manages blocking and al                                                                                                                                                             lowing of public trackers # @noargs ############################################                                                                                                                                                             #################################### tracker::settings() { ?for option in "${qb_                                                                                                                                                             option[@]}"; do ??case "${option,,}" in ??enable) ???mflibs::shell::text::red "$                                                                                                                                                             (quickbox::lang::trackers::enable)" ???mflibs::log "/sbin/iptables -F qb-public-                                                                                                                                                             trackers" && mflibs::log "/sbin/iptables -X qb-public-trackers" ???awk 'NR==FNR{                                                                                                                                                             a[$0];next} !($0 in a){print > FILENAME".filtered"}' "${quickbox_base_path}/conf                                                                                                                                                             ig/system/trackers/host_trackers" /etc/hosts ???mv -f "/etc/hosts.filtered" "/et                                                                                                                                                             c/hosts" ???rm -f /etc/cron.daily/deny_public ???;; ??disable) ???declare line ?                                                                                                                                                             ??mflibs::shell::text::green "$(quickbox::lang::trackers::disable)" ???cp -f "${                                                                                                                                                             quickbox_base_path:="/opt/quickbox"}/config/system/trackers/deny_public" "/etc/c                                                                                                                                                             ron.daily/" ???chmod +x /etc/cron.daily/deny_public ???mflibs::log "/sbin/iptabl                                                                                                                                                             es -N qb-public-trackers" ???while IFS= read -r line; do ????mflibs::log "/sbin/                                                                                                                                                             iptables -A qb-public-trackers -s ${line} -j DROP" ???done < <(grep -v '^ *#' <"                                                                                                                                                             ${quickbox_base_path:="/opt/quickbox"}/config/system/trackers/tracker_list") ???                                                                                                                                                             awk 'NR==FNR{a[$0];next} !($0 in a){print > FILENAME".filtered"}' "${quickbox_ba                                                                                                                                                             se_path}/config/system/trackers/host_trackers" /etc/hosts ???mv -f "/etc/hosts.f                                                                                                                                                             iltered" "/etc/hosts" ???cat "${quickbox_base_path}/config/system/trackers/host_                                                                                                                                                             trackers" >>/etc/hosts ???;; ??*) ;; ??esac ?done }  ###########################                                                                                                                                                             ##################################################### # @description: sets the s                                                                                                                                                             erver web root for dashboard access # @arg: -o [server_ip (or) domain] # @exampl                                                                                                                                                             e: qb manage webroot -o 192.168.0.1 (or) myawesomedomain.com # @null ###########                                                                                                                                                             ##################################################################### webroot::s                                                                                                                                                             ettings() { ?quickbox::database "UPDATE system_configuration set configuration_v                                                                                                                                                             alue = 'https://${qb_option[*]:-}/' WHERE configuration_name='server_web_root';"                                                                                                                                                              ?mflibs::log "systemctl restart nginx.service" ?mflibs::log "systemctl reload p                                                                                                                                                             hp8.1-fpm.service" }  ##########################################################                                                                                                                                                             ###################### # @description: calls functions in the required order ###                                                                                                                                                             ############################################################################# ma                                                                                                                                                             nage::environment::init "$@" # shellcheck disable=SC2068 quickbox::args::process                                                                                                                                                              $@ case "${1}" in api) ?api::settings ?;; fail2ban) ?fail2ban::settings ?;; lan                                                                                                                                                             g) ?lang::settings ?;; nginx) ?nginx::settings ?;; mount) ?mount::settings ?;; s                                                                                                                                                             oftware) ?software::settings ?;; trackers) ?tracker::settings ?;; theme) ?theme:                                                                                                                                                             :settings ?;; webroot) ?webroot::settings ?;; *) ;; esac  /opt/quickbox/system/m                                                                                                                                                             anage mount manage mount -o space -u judgey
judgey    189975  167039  0 12:30 pts/2    00:00:00 grep --color=auto Emby

 

Posted

So emby is not running the server, it's judgey.

id judgey

And if missing then add video and render groups for judgey then restart Emby.

 

grahamcoyswanst
Posted

hey just so you know i really appreciate the help... i did do judgey with "sudo usermod -a -G render judgey" but its still the same for some reason mate all that's showing is the software no hw.

Sorry feel a pain is there anything else i could try ?

Posted

What about video?

 

grahamcoyswanst
Posted

Is there a cmd line i need to use for that, would it be "sudo usermod -a -G video judgey"

Posted

Did you check to see if judgey already has it? That's why the id command was given. 

Yes, if judgey does not have group video then the usermod command will add it.

These steps would take care of the basics but you have an atypical installation so there might be other things preventing HW access. The newer CPU can also be a factor but the OS, kernel and the beta version of Emby you are using should have those covered.

Posted

When you make the changes restart Emby and attach the newest hardware detection log.

grahamcoyswanst
Posted

Thanks loads i will do some more digging and get back to you. 

Thanks again

  • Thanks 1
grahamcoyswanst
Posted
 id emby
uid=999(emby) gid=995(emby) groups=995(emby),44(video),105(render),1001(judgey)
 id judgey
uid=1000(judgey) gid=1001(judgey) groups=1001(judgey),33(www-data),44(video),105(render),995(emby)

Here are the groups I'm sure it's right but if you can confirm I have posted logs after a reboot.

thanks 🙂

 

hardware_detection-63833479593.txt embyserver (5).txt

Posted

Those look right to me. At this point and unless you want to do a normal installation of Emby your best bet might be to see if Quickbox support can help you figure this out.

 

Posted

Another thought is if Quickbox supports Docker then you could try the Emby beta image instead.

 

grahamcoyswanst
Posted

It is a shame as the Quickboxs owner had a house fire and lost everything he currently trying to get access to everything (he locked out as he lost his phone and codes) but this has been a while now so I'm not sure if or when he will be back. I understand this is not your problem but just letting you know where I'm at. unfortunately no support for docker either. I was under the impression just from what i been told over the years iQuickbox is just an installer but again I'm not clued up enough to understand it fully. 

Thanks for all the help if you do think of anything would you ping me, again thanks so much really appreciate it.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...