diff --git a/PBSDiscordDark.sh b/PBSDiscordDark.sh index 655d609..c83282c 100644 --- a/PBSDiscordDark.sh +++ b/PBSDiscordDark.sh @@ -1,5 +1,5 @@ #!/bin/bash -# https://github.com/Weilbyte/PVEDiscordDark +# https://github.com/Luckyvb/PBSDiscordDark #region Consts RED='\033[0;31m' @@ -13,7 +13,7 @@ CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' TEMPLATE_FILE="/usr/share/javascript/proxmox-backup/index.hbs" SCRIPTPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" -REPO=${REPO:-"Weilbyte/PVEDiscordDark"} +REPO=${REPO:-"Luckyvb/PBSDiscordDark"} DEFAULT_TAG="master" TAG=${TAG:-$DEFAULT_TAG} BASE_URL="https://raw.githubusercontent.com/$REPO/$TAG" @@ -60,7 +60,7 @@ function checkSupported { local SUPPORTEDARR=($(echo "$SUPPORTED" | tr ',' '\n')) if ! (printf '%s\n' "${SUPPORTEDARR[@]}" | grep -q -P "$PBSVersionMajor"); then echo -e "${WARN}You might encounter issues because your version ($PBSVersionMajor) is not matching currently supported versions ($SUPPORTED)." - echo -e "If you do run into any issues on >newer< versions, please consider opening an issue at https://github.com/Weilbyte/PVEDiscordDark/issues.${REG}" + echo -e "If you do run into any issues on >newer< versions, please consider opening an issue at https://github.com/Luckyvb/PBSDiscordDark/issues.${REG}" fi fi } @@ -94,7 +94,7 @@ function usage { echo -e " 0 OK" echo -e " 1 Failure" echo -e " 2 Already installed, OR not installed (when using install/uninstall commands)\n" - echo -e "Report issues at: " + echo -e "Report issues at: " fi } @@ -128,10 +128,10 @@ function install { cp $TEMPLATE_FILE $TEMPLATE_FILE.bak if [ "$_silent" = false ]; then echo -e "${CHECKMARK} Downloading stylesheet"; fi - curl -s $BASE_URL/PVEDiscordDark/sass/PVEDiscordDark.css > /usr/share/javascript/proxmox-backup/css/dd_style.css + curl -s $BASE_URL/PBSDiscordDark/sass/PBSDiscordDark.css > /usr/share/javascript/proxmox-backup/css/dd_style.css if [ "$_silent" = false ]; then echo -e "${CHECKMARK} Downloading patcher"; fi - curl -s $BASE_URL/PVEDiscordDark/js/PVEDiscordDark.js > /usr/share/javascript/proxmox-backup/js/dd_patcher.js + curl -s $BASE_URL/PBSDiscordDark/js/PBSDiscordDark.js > /usr/share/javascript/proxmox-backup/js/dd_patcher.js if [ "$_silent" = false ]; then echo -e "${CHECKMARK} Applying changes to template file"; fi if !(grep -Fq "" $TEMPLATE_FILE); then @@ -147,7 +147,7 @@ function install { ITER=0 for image in "${IMAGELISTARR[@]}" do - curl -s $BASE_URL/PVEDiscordDark/images/$image > /usr/share/javascript/proxmox-backup/images/$image + curl -s $BASE_URL/PBSDiscordDark/images/$image > /usr/share/javascript/proxmox-backup/images/$image ((ITER++)) if [ "$_silent" = false ]; then echo -e "\e[1A\e[KDownloading images ($ITER/${#IMAGELISTARR[@]})"; fi done @@ -189,54 +189,54 @@ _noexit=false parse_cli() { - while test $# -gt -0 - do - _key="$1" - case "$_key" in - -h|--help) - usage - exit 0 - ;; - -s|--silent) - _silent=true - ;; - status) - if [ "$_command" = false ]; then - _command=true - status - fi - ;; - install) - if [ "$_command" = false ]; then - _command=true - install - exit 0 - fi - ;; - uninstall) - if [ "$_command" = false ]; then - _command=true - uninstall - exit 0 - fi - ;; - update) - if [ "$_command" = false ]; then - _command=true - _noexit=true - uninstall - install - exit 0 - fi - ;; - *) - echo -e "${BRED}Error: Got an unexpected argument \"$_key\"${REG}\n"; - usage; - exit 1; - ;; - esac - shift - done + while test $# -gt -0 + do + key="$1" + case "$_key" in + -h|--help) + usage + exit 0 + ;; + -s|--silent) + _silent=true + ;; + status) + if [ "$_command" = false ]; then + _command=true + status + fi + ;; + install) + if [ "$_command" = false ]; then + _command=true + install + exit 0 + fi + ;; + uninstall) + if [ "$_command" = false ]; then + _command=true + uninstall + exit 0 + fi + ;; + update) + if [ "$_command" = false ]; then + _command=true + _noexit=true + uninstall + install + exit 0 + fi + ;; + *) + echo -e "${BRED}Error: Got an unexpected argument \"$_key\"${REG}\n"; + usage; + exit 1; + ;; + esac + shift + done } parse_cli "$@" diff --git a/PVEDiscordDark/images/dd_arrows.png b/PBSDiscordDark/images/dd_arrows.png similarity index 100% rename from PVEDiscordDark/images/dd_arrows.png rename to PBSDiscordDark/images/dd_arrows.png diff --git a/PVEDiscordDark/images/dd_cephblurp.png b/PBSDiscordDark/images/dd_cephblurp.png similarity index 100% rename from PVEDiscordDark/images/dd_cephblurp.png rename to PBSDiscordDark/images/dd_cephblurp.png diff --git a/PVEDiscordDark/images/dd_cephwhite.png b/PBSDiscordDark/images/dd_cephwhite.png similarity index 100% rename from PVEDiscordDark/images/dd_cephwhite.png rename to PBSDiscordDark/images/dd_cephwhite.png diff --git a/PVEDiscordDark/images/dd_clear-trigger.png b/PBSDiscordDark/images/dd_clear-trigger.png similarity index 100% rename from PVEDiscordDark/images/dd_clear-trigger.png rename to PBSDiscordDark/images/dd_clear-trigger.png diff --git a/PVEDiscordDark/images/dd_default-toolbar-small-arrow.png b/PBSDiscordDark/images/dd_default-toolbar-small-arrow.png similarity index 100% rename from PVEDiscordDark/images/dd_default-toolbar-small-arrow.png rename to PBSDiscordDark/images/dd_default-toolbar-small-arrow.png diff --git a/PVEDiscordDark/images/dd_default-toolbar-small-s-arrow.png b/PBSDiscordDark/images/dd_default-toolbar-small-s-arrow.png similarity index 100% rename from PVEDiscordDark/images/dd_default-toolbar-small-s-arrow.png rename to PBSDiscordDark/images/dd_default-toolbar-small-s-arrow.png diff --git a/PVEDiscordDark/images/dd_icon-cd.png b/PBSDiscordDark/images/dd_icon-cd.png similarity index 100% rename from PVEDiscordDark/images/dd_icon-cd.png rename to PBSDiscordDark/images/dd_icon-cd.png diff --git a/PVEDiscordDark/images/dd_icon-cdblurp.png b/PBSDiscordDark/images/dd_icon-cdblurp.png similarity index 100% rename from PVEDiscordDark/images/dd_icon-cdblurp.png rename to PBSDiscordDark/images/dd_icon-cdblurp.png diff --git a/PVEDiscordDark/images/dd_icon-cloud.png b/PBSDiscordDark/images/dd_icon-cloud.png similarity index 100% rename from PVEDiscordDark/images/dd_icon-cloud.png rename to PBSDiscordDark/images/dd_icon-cloud.png diff --git a/PVEDiscordDark/images/dd_icon-cpu.png b/PBSDiscordDark/images/dd_icon-cpu.png similarity index 100% rename from PVEDiscordDark/images/dd_icon-cpu.png rename to PBSDiscordDark/images/dd_icon-cpu.png diff --git a/PVEDiscordDark/images/dd_icon-die.svg b/PBSDiscordDark/images/dd_icon-die.svg similarity index 100% rename from PVEDiscordDark/images/dd_icon-die.svg rename to PBSDiscordDark/images/dd_icon-die.svg diff --git a/PVEDiscordDark/images/dd_icon-display.png b/PBSDiscordDark/images/dd_icon-display.png similarity index 100% rename from PVEDiscordDark/images/dd_icon-display.png rename to PBSDiscordDark/images/dd_icon-display.png diff --git a/PVEDiscordDark/images/dd_icon-hdd.png b/PBSDiscordDark/images/dd_icon-hdd.png similarity index 100% rename from PVEDiscordDark/images/dd_icon-hdd.png rename to PBSDiscordDark/images/dd_icon-hdd.png diff --git a/PVEDiscordDark/images/dd_icon-network.png b/PBSDiscordDark/images/dd_icon-network.png similarity index 100% rename from PVEDiscordDark/images/dd_icon-network.png rename to PBSDiscordDark/images/dd_icon-network.png diff --git a/PVEDiscordDark/images/dd_icon-pci.png b/PBSDiscordDark/images/dd_icon-pci.png similarity index 100% rename from PVEDiscordDark/images/dd_icon-pci.png rename to PBSDiscordDark/images/dd_icon-pci.png diff --git a/PVEDiscordDark/images/dd_icon-ram.png b/PBSDiscordDark/images/dd_icon-ram.png similarity index 100% rename from PVEDiscordDark/images/dd_icon-ram.png rename to PBSDiscordDark/images/dd_icon-ram.png diff --git a/PVEDiscordDark/images/dd_icon-serial.png b/PBSDiscordDark/images/dd_icon-serial.png similarity index 100% rename from PVEDiscordDark/images/dd_icon-serial.png rename to PBSDiscordDark/images/dd_icon-serial.png diff --git a/PVEDiscordDark/images/dd_icon-swap.png b/PBSDiscordDark/images/dd_icon-swap.png similarity index 100% rename from PVEDiscordDark/images/dd_icon-swap.png rename to PBSDiscordDark/images/dd_icon-swap.png diff --git a/PVEDiscordDark/images/dd_icon-usb.png b/PBSDiscordDark/images/dd_icon-usb.png similarity index 100% rename from PVEDiscordDark/images/dd_icon-usb.png rename to PBSDiscordDark/images/dd_icon-usb.png diff --git a/PVEDiscordDark/images/dd_loading.svg b/PBSDiscordDark/images/dd_loading.svg similarity index 100% rename from PVEDiscordDark/images/dd_loading.svg rename to PBSDiscordDark/images/dd_loading.svg diff --git a/PVEDiscordDark/images/dd_logo.png b/PBSDiscordDark/images/dd_logo.png similarity index 100% rename from PVEDiscordDark/images/dd_logo.png rename to PBSDiscordDark/images/dd_logo.png diff --git a/PVEDiscordDark/images/dd_logo_blurp.png b/PBSDiscordDark/images/dd_logo_blurp.png similarity index 100% rename from PVEDiscordDark/images/dd_logo_blurp.png rename to PBSDiscordDark/images/dd_logo_blurp.png diff --git a/PVEDiscordDark/images/dd_mini-bottom.png b/PBSDiscordDark/images/dd_mini-bottom.png similarity index 100% rename from PVEDiscordDark/images/dd_mini-bottom.png rename to PBSDiscordDark/images/dd_mini-bottom.png diff --git a/PVEDiscordDark/images/dd_mini-top.png b/PBSDiscordDark/images/dd_mini-top.png similarity index 100% rename from PVEDiscordDark/images/dd_mini-top.png rename to PBSDiscordDark/images/dd_mini-top.png diff --git a/PBSDiscordDark/images/dd_readme b/PBSDiscordDark/images/dd_readme new file mode 100644 index 0000000..e068559 --- /dev/null +++ b/PBSDiscordDark/images/dd_readme @@ -0,0 +1,2 @@ +Images with 'dd' prefix are from the 'PBSDiscordDark' Proxmox theme which can be found here - https://github.com/Luckyvb/PBSDiscordDark +The theme does NOT replace any existing images but instead adds new images that the stylesheet will use. diff --git a/PVEDiscordDark/images/dd_tool-sprites.png b/PBSDiscordDark/images/dd_tool-sprites.png similarity index 100% rename from PVEDiscordDark/images/dd_tool-sprites.png rename to PBSDiscordDark/images/dd_tool-sprites.png diff --git a/PVEDiscordDark/images/dd_trigger.png b/PBSDiscordDark/images/dd_trigger.png similarity index 100% rename from PVEDiscordDark/images/dd_trigger.png rename to PBSDiscordDark/images/dd_trigger.png diff --git a/PVEDiscordDark/js/PBSDiscordDark.js b/PBSDiscordDark/js/PBSDiscordDark.js similarity index 100% rename from PVEDiscordDark/js/PBSDiscordDark.js rename to PBSDiscordDark/js/PBSDiscordDark.js diff --git a/PVEDiscordDark/sass/PBSDiscordDark.css b/PBSDiscordDark/sass/PBSDiscordDark.css similarity index 100% rename from PVEDiscordDark/sass/PBSDiscordDark.css rename to PBSDiscordDark/sass/PBSDiscordDark.css diff --git a/PVEDiscordDark/sass/PVEDiscordDark.sass b/PBSDiscordDark/sass/PBSDiscordDark.sass similarity index 100% rename from PVEDiscordDark/sass/PVEDiscordDark.sass rename to PBSDiscordDark/sass/PBSDiscordDark.sass diff --git a/PVEDiscordDark/sass/_vars.sass b/PBSDiscordDark/sass/_vars.sass similarity index 100% rename from PVEDiscordDark/sass/_vars.sass rename to PBSDiscordDark/sass/_vars.sass diff --git a/PVEDiscordDark/sass/proxmox/_proxmoxRRDChart.sass b/PBSDiscordDark/sass/proxmox/_proxmoxRRDChart.sass similarity index 100% rename from PVEDiscordDark/sass/proxmox/_proxmoxRRDChart.sass rename to PBSDiscordDark/sass/proxmox/_proxmoxRRDChart.sass diff --git a/PVEDiscordDark/sass/proxmox/_pveCeph.sass b/PBSDiscordDark/sass/proxmox/_pveCeph.sass similarity index 100% rename from PVEDiscordDark/sass/proxmox/_pveCeph.sass rename to PBSDiscordDark/sass/proxmox/_pveCeph.sass diff --git a/PVEDiscordDark/sass/proxmox/_pveDc.sass b/PBSDiscordDark/sass/proxmox/_pveDc.sass similarity index 100% rename from PVEDiscordDark/sass/proxmox/_pveDc.sass rename to PBSDiscordDark/sass/proxmox/_pveDc.sass diff --git a/PVEDiscordDark/sass/special/_borders.sass b/PBSDiscordDark/sass/special/_borders.sass similarity index 100% rename from PVEDiscordDark/sass/special/_borders.sass rename to PBSDiscordDark/sass/special/_borders.sass diff --git a/PVEDiscordDark/sass/special/_icons.sass b/PBSDiscordDark/sass/special/_icons.sass similarity index 100% rename from PVEDiscordDark/sass/special/_icons.sass rename to PBSDiscordDark/sass/special/_icons.sass diff --git a/PVEDiscordDark/sass/special/_proxmox.sass b/PBSDiscordDark/sass/special/_proxmox.sass similarity index 100% rename from PVEDiscordDark/sass/special/_proxmox.sass rename to PBSDiscordDark/sass/special/_proxmox.sass diff --git a/PVEDiscordDark/sass/special/_specific.sass b/PBSDiscordDark/sass/special/_specific.sass similarity index 100% rename from PVEDiscordDark/sass/special/_specific.sass rename to PBSDiscordDark/sass/special/_specific.sass diff --git a/PVEDiscordDark/sass/x/_autocontainer.sass b/PBSDiscordDark/sass/x/_autocontainer.sass similarity index 100% rename from PVEDiscordDark/sass/x/_autocontainer.sass rename to PBSDiscordDark/sass/x/_autocontainer.sass diff --git a/PVEDiscordDark/sass/x/_body.sass b/PBSDiscordDark/sass/x/_body.sass similarity index 100% rename from PVEDiscordDark/sass/x/_body.sass rename to PBSDiscordDark/sass/x/_body.sass diff --git a/PVEDiscordDark/sass/x/_boundlist.sass b/PBSDiscordDark/sass/x/_boundlist.sass similarity index 100% rename from PVEDiscordDark/sass/x/_boundlist.sass rename to PBSDiscordDark/sass/x/_boundlist.sass diff --git a/PVEDiscordDark/sass/x/_box.sass b/PBSDiscordDark/sass/x/_box.sass similarity index 100% rename from PVEDiscordDark/sass/x/_box.sass rename to PBSDiscordDark/sass/x/_box.sass diff --git a/PVEDiscordDark/sass/x/_btn.sass b/PBSDiscordDark/sass/x/_btn.sass similarity index 100% rename from PVEDiscordDark/sass/x/_btn.sass rename to PBSDiscordDark/sass/x/_btn.sass diff --git a/PVEDiscordDark/sass/x/_column.sass b/PBSDiscordDark/sass/x/_column.sass similarity index 100% rename from PVEDiscordDark/sass/x/_column.sass rename to PBSDiscordDark/sass/x/_column.sass diff --git a/PVEDiscordDark/sass/x/_component.sass b/PBSDiscordDark/sass/x/_component.sass similarity index 100% rename from PVEDiscordDark/sass/x/_component.sass rename to PBSDiscordDark/sass/x/_component.sass diff --git a/PVEDiscordDark/sass/x/_datepicker.sass b/PBSDiscordDark/sass/x/_datepicker.sass similarity index 100% rename from PVEDiscordDark/sass/x/_datepicker.sass rename to PBSDiscordDark/sass/x/_datepicker.sass diff --git a/PVEDiscordDark/sass/x/_form.sass b/PBSDiscordDark/sass/x/_form.sass similarity index 100% rename from PVEDiscordDark/sass/x/_form.sass rename to PBSDiscordDark/sass/x/_form.sass diff --git a/PVEDiscordDark/sass/x/_grid.sass b/PBSDiscordDark/sass/x/_grid.sass similarity index 100% rename from PVEDiscordDark/sass/x/_grid.sass rename to PBSDiscordDark/sass/x/_grid.sass diff --git a/PVEDiscordDark/sass/x/_legend.sass b/PBSDiscordDark/sass/x/_legend.sass similarity index 100% rename from PVEDiscordDark/sass/x/_legend.sass rename to PBSDiscordDark/sass/x/_legend.sass diff --git a/PVEDiscordDark/sass/x/_mask.sass b/PBSDiscordDark/sass/x/_mask.sass similarity index 100% rename from PVEDiscordDark/sass/x/_mask.sass rename to PBSDiscordDark/sass/x/_mask.sass diff --git a/PVEDiscordDark/sass/x/_menu.sass b/PBSDiscordDark/sass/x/_menu.sass similarity index 100% rename from PVEDiscordDark/sass/x/_menu.sass rename to PBSDiscordDark/sass/x/_menu.sass diff --git a/PVEDiscordDark/sass/x/_misc.sass b/PBSDiscordDark/sass/x/_misc.sass similarity index 100% rename from PVEDiscordDark/sass/x/_misc.sass rename to PBSDiscordDark/sass/x/_misc.sass diff --git a/PVEDiscordDark/sass/x/_panel.sass b/PBSDiscordDark/sass/x/_panel.sass similarity index 100% rename from PVEDiscordDark/sass/x/_panel.sass rename to PBSDiscordDark/sass/x/_panel.sass diff --git a/PVEDiscordDark/sass/x/_progress.sass b/PBSDiscordDark/sass/x/_progress.sass similarity index 100% rename from PVEDiscordDark/sass/x/_progress.sass rename to PBSDiscordDark/sass/x/_progress.sass diff --git a/PVEDiscordDark/sass/x/_splitter.sass b/PBSDiscordDark/sass/x/_splitter.sass similarity index 100% rename from PVEDiscordDark/sass/x/_splitter.sass rename to PBSDiscordDark/sass/x/_splitter.sass diff --git a/PVEDiscordDark/sass/x/_tab.sass b/PBSDiscordDark/sass/x/_tab.sass similarity index 100% rename from PVEDiscordDark/sass/x/_tab.sass rename to PBSDiscordDark/sass/x/_tab.sass diff --git a/PVEDiscordDark/sass/x/_tip.sass b/PBSDiscordDark/sass/x/_tip.sass similarity index 100% rename from PVEDiscordDark/sass/x/_tip.sass rename to PBSDiscordDark/sass/x/_tip.sass diff --git a/PVEDiscordDark/sass/x/_title.sass b/PBSDiscordDark/sass/x/_title.sass similarity index 100% rename from PVEDiscordDark/sass/x/_title.sass rename to PBSDiscordDark/sass/x/_title.sass diff --git a/PVEDiscordDark/sass/x/_toolbar.sass b/PBSDiscordDark/sass/x/_toolbar.sass similarity index 100% rename from PVEDiscordDark/sass/x/_toolbar.sass rename to PBSDiscordDark/sass/x/_toolbar.sass diff --git a/PVEDiscordDark/sass/x/_tree.sass b/PBSDiscordDark/sass/x/_tree.sass similarity index 100% rename from PVEDiscordDark/sass/x/_tree.sass rename to PBSDiscordDark/sass/x/_tree.sass diff --git a/PVEDiscordDark/sass/x/_treelist.sass b/PBSDiscordDark/sass/x/_treelist.sass similarity index 100% rename from PVEDiscordDark/sass/x/_treelist.sass rename to PBSDiscordDark/sass/x/_treelist.sass diff --git a/PVEDiscordDark/sass/x/_viewport.sass b/PBSDiscordDark/sass/x/_viewport.sass similarity index 100% rename from PVEDiscordDark/sass/x/_viewport.sass rename to PBSDiscordDark/sass/x/_viewport.sass diff --git a/PVEDiscordDark/sass/x/_window.sass b/PBSDiscordDark/sass/x/_window.sass similarity index 100% rename from PVEDiscordDark/sass/x/_window.sass rename to PBSDiscordDark/sass/x/_window.sass diff --git a/PVEDiscordDark.py b/PVEDiscordDark.py deleted file mode 100644 index 9e7729d..0000000 --- a/PVEDiscordDark.py +++ /dev/null @@ -1,191 +0,0 @@ -#!/usr/bin/python3 - -import os -import sys -import time -import subprocess -import urllib.request -import os.path -import shutil -import argparse - -ACTION = None - -images = [ - 'dd_cephblurp.png', 'dd_cephwhite.png', - 'dd_icon-cpu.png', 'dd_icon-hdd.png', - 'dd_icon-ram.png', 'dd_icon-swap.png', - 'dd_icon-cd.png', 'dd_icon-display.png', - 'dd_icon-network.png', 'dd_icon-cloud.png', - 'dd_icon-serial.png', 'dd_icon-usb.png', - 'dd_icon-pci.png', 'dd_logo.png', - 'dd_mini-bottom.png', 'dd_mini-top.png', - 'dd_readme', '/dd_tool-sprites.png', - 'dd_trigger.png', 'dd_loading.svg', - 'dd_icon-die.svg', 'dd_clear-trigger.png'] - -class colors: - HEADER = '\033[95m' - OKBLUE = '\033[94m' - OKGREEN = '\033[92m' - WARNING = '\033[93m' - FAIL = '\033[91m' - NORMAL = '\033[0m' - BOLD = '\033[1m' - UNDERLINE = '\033[4m' - -def clear(): - if ACTION == None: - print("\033c", end="") - -def cprint(color, text, bold=False, inline=False): - endc = '\n' - if inline: - endc = '' - if bold: - print(colors.BOLD) - print(color + text + colors.NORMAL, end=endc) - -def getPVEVersion(): - pv = subprocess.check_output('pveversion --verbose | grep pve-manager | cut -c 14- | cut -c -6', shell=True, stderr=open(os.devnull, 'w')) - pv = pv.decode('ascii').replace(" ", "").replace("\n","") - if (('/bin/' in pv) or (len(pv) > 7)): - return "" - else: - return pv - -def checkPVE(): - ver = getPVEVersion() - if (len(ver) < 1): - cprint(colors.FAIL, 'Unable to detect Proxmox.', True) - cprint(colors.NORMAL, 'A Proxmox installation could not be detected.') - exit(1) - else: - cprint(colors.OKGREEN, '\nPVE ' + ver + ' detected.') - -def checkConn(): - try: - urllib.request.urlopen('http://github.com') - return - except: - cprint(colors.FAIL, 'An Internet connection is required to install PVEDiscordDark.', True) - cprint(colors.NORMAL, 'Connect to the Internet and try again.') - exit(1) - -def themeIsInstalled(): - tplUsesTheme = False - tplFile = open('/usr/share/pve-manager/index.html.tpl') - tplLines = tplFile.readlines() - for line in tplLines: - if ("" in line or "" in line): - tplUsesTheme = True - if (os.path.isfile('/usr/share/pve-manager/css/dd_style.css') or tplUsesTheme): - return True - return False - -def installTheme(): - clear() - doHeader() - baseURL = os.getenv('BASEURL', 'https://github.com/Weilbyte/PVEDiscordDark/raw/' + os.getenv("BRANCH", "master")) - cprint(colors.NORMAL, '\nBacking up index template file..') - shutil.copyfile('/usr/share/pve-manager/index.html.tpl', '/usr/share/pve-manager/index.html.tpl.bak') - cprint(colors.NORMAL, 'Downloading stylesheet..') - urllib.request.urlretrieve(baseURL + '/PVEDiscordDark/sass/PVEDiscordDark.css', '/usr/share/pve-manager/css/dd_style.css') - cprint(colors.NORMAL, 'Downloading patcher..') - urllib.request.urlretrieve(baseURL + '/PVEDiscordDark/js/PVEDiscordDark.js', '/usr/share/pve-manager/js/dd_patcher.js') - cprint(colors.NORMAL, 'Applying stylesheet and patcher..') - with open('/usr/share/pve-manager/index.html.tpl', 'a') as tplFile: - tplFile.write("") - tplFile.write("") - for index, image in enumerate(images): - imageCurrent = index + 1 - cprint(colors.NORMAL, 'Downloading images [' + str(imageCurrent) + '/' + str(len(images)) + ']..\r', False, True) - urllib.request.urlretrieve(baseURL + '/PVEDiscordDark/images/' + image, '/usr/share/pve-manager/images/' + image) - cprint(colors.OKGREEN, '\nTheme installed successfully!', True) - if ACTION == None: - cprint(colors.NORMAL, 'Press [ENTER] to go back.') - input('') - doMainMenu() - -def uninstallTheme(): - clear() - doHeader() - cprint(colors.NORMAL, '\nCleaning up index template file..') - with open('/usr/share/pve-manager/index.html.tpl', 'r+') as tplFile: - tplLines = tplFile.readlines() - tplFile.seek(0) - for line in tplLines: - if ("" not in line or "" not in line): - tplFile.write(line) - tplFile.truncate() - if os.path.exists('/usr/share/javascript/extjs/charts.js.bak'): - cprint(colors.NORMAL, 'Reverting charts.js replacement..') - os.remove('/usr/share/javascript/extjs/charts.js') - shutil.copyfile('/usr/share/javascript/extjs/charts.js.bak', '/usr/share/javascript/extjs/charts.js') - os.remove('/usr/share/javascript/extjs/charts.js.bak') - if os.path.exists('/usr/share/pve-manager/css/dd_style.css'): - cprint(colors.NORMAL, 'Removing stylesheet..') - os.remove('/usr/share/pve-manager/css/dd_style.css') - if os.path.exists('/usr/share/pve-manager/js/dd_patcher.js'): - cprint(colors.NORMAL, 'Removing patcher..') - os.remove('/usr/share/pve-manager/js/dd_patcher.js') - cprint(colors.NORMAL, 'Removing images..') - for asset in os.listdir('/usr/share/pve-manager/images/'): - if asset.startswith('dd_'): - os.remove('/usr/share/pve-manager/images/' + asset) - cprint(colors.OKGREEN, '\n\nTheme uninstalled successfully!', True) - if ACTION == None: - cprint(colors.NORMAL, 'Press [ENTER] to go back.') - input('') - doMainMenu() - -def doHeader(): - cprint(colors.HEADER, '[~]', True, True) - cprint(colors.NORMAL, ' PVEDiscordDark Utility (DEPRECATED)\nThis installer is now deprecated, please use PVEDiscordDark.sh\n', False, True) - -def doMainMenu(): - clear() - doHeader() - isInstalled = themeIsInstalled() - cprint(colors.NORMAL, '[I]', True, True) - cprint(colors.NORMAL, ' Install theme', False, True) - if isInstalled: - cprint(colors.NORMAL, '[U]', True, True) - cprint(colors.NORMAL, ' Uninstall theme', False, True) - cprint(colors.NORMAL, '[Q]', True, True) - cprint(colors.NORMAL, ' Exit', False, True) - choice = input('\n\n>? ') - choice = choice.upper().replace(" ", "") - if choice == 'I': - installTheme() - elif (choice == 'U' and isInstalled): - uninstallTheme() - elif choice == 'Q': - exit(0) - else: - doMainMenu() - -def main(): - parser = argparse.ArgumentParser(description='PVEDiscordDark Theme Utility (DEPRECATED)') - parser.add_argument('--action', '-a', choices=['install', 'uninstall'], help='action for unattended mode') - args = parser.parse_args() - global ACTION - ACTION = args.action - checkPVE() - checkConn() - time.sleep(0.5) - if ACTION == None: - try: - doMainMenu() - except KeyboardInterrupt: - print('\n') - exit(0) - else: - if ACTION == 'install': - installTheme() - else: - if themeIsInstalled(): - uninstallTheme() - -if __name__ == "__main__": - main() diff --git a/PVEDiscordDark.sh b/PVEDiscordDark.sh deleted file mode 100644 index 9f765cd..0000000 --- a/PVEDiscordDark.sh +++ /dev/null @@ -1,241 +0,0 @@ -#!/bin/bash -# https://github.com/Weilbyte/PVEDiscordDark - -#region Consts -RED='\033[0;31m' -BRED='\033[0;31m\033[1m' -GRN='\033[92m' -WARN='\033[93m' -BOLD='\033[1m' -REG='\033[0m' -CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' - -TEMPLATE_FILE="/usr/share/pve-manager/index.html.tpl" -SCRIPTPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" - -REPO=${REPO:-"Weilbyte/PVEDiscordDark"} -DEFAULT_TAG="master" -TAG=${TAG:-$DEFAULT_TAG} -BASE_URL="https://raw.githubusercontent.com/$REPO/$TAG" -#endregion Consts - -#region Prerun checks -hash sed 2>/dev/null || { - echo -e >&2 "${BRED}sed is required but missing from your system${REG}"; - exit 1; -} - -hash curl 2>/dev/null || { - echo -e >&2 "${BRED}cURL is required but missing from your system${REG}"; - exit 1; -} - -hash pveversion 2>/dev/null || { - echo -e >&2 "${BRED}PVE installation required but missing from your system${REG}"; - exit 1; -} - -curl -sSf -f https://github.com/robots.txt &> /dev/null || { - echo -e >&2 "${BRED}Could not establish a connection to GitHub (github.com)${REG}"; - exit 1; -} - -if [ $TAG != $DEFAULT_TAG ]; then - if !([[ $TAG =~ [0-9] ]] && [ ${#TAG} -ge 7 ] && (! [[ $TAG =~ ['!@#$%^&*()_+.'] ]]) ); then - echo -e "${WARN}It appears like you are using a non-default tag. For security purposes, please use the SHA-1 hash of said tag instead${REG}" - fi -fi -#endregion Prerun checks - -PVEVersion=$(pveversion --verbose | grep pve-manager | cut -c 14- | cut -c -6) # Below pveversion pre-run check -PVEVersionMajor=$(echo $PVEVersion | cut -d'-' -f1) - -#region Helper functions -function checkSupported { - local SUPPORTED=$(curl -f -s "$BASE_URL/meta/supported") - if [ -z "$SUPPORTED" ]; then - echo -e "${WARN}Could not reach supported version file ($BASE_URL/meta/supported). Skipping support check.${REG}" - else - local SUPPORTEDARR=($(echo "$SUPPORTED" | tr ',' '\n')) - if ! (printf '%s\n' "${SUPPORTEDARR[@]}" | grep -q -P "$PVEVersionMajor"); then - echo -e "${WARN}You might encounter issues because your version ($PVEVersionMajor) is not matching currently supported versions ($SUPPORTED)." - echo -e "If you do run into any issues on >newer< versions, please consider opening an issue at https://github.com/Weilbyte/PVEDiscordDark/issues.${REG}" - fi - fi -} - -function isInstalled { - if (grep -Fq "" $TEMPLATE_FILE && - grep -Fq "" $TEMPLATE_FILE && - [ -f "/usr/share/pve-manager/css/dd_style.css" ] && [ -f "/usr/share/pve-manager/js/dd_patcher.js" ]); then - true - else - false - fi -} - -#endregion Helper functions - -#region Main functions -function usage { - if [ "$_silent" = false ]; then - echo -e "Usage: $0 [OPTIONS...] {COMMAND}\n" - echo -e "Manages the PVEDiscordDark theme." - echo -e " -h --help Show this help" - echo -e " -s --silent Silent mode\n" - echo -e "Commands:" - echo -e " status Check current theme status (in silent mode, returns 0 if installed, and 1 if not installed)" - echo -e " install Install the theme" - echo -e " uninstall Uninstall the theme" - echo -e " update Update the theme (runs uninstall, then install)" - # echo -e " utility-update Update this utility\n" (to be implemented) - echo -e "Exit status:" - echo -e " 0 OK" - echo -e " 1 Failure" - echo -e " 2 Already installed, OR not installed (when using install/uninstall commands)\n" - echo -e "Report issues at: " - fi -} - -function status { - if [ "$_silent" = false ]; then - echo -e "Theme" - if isInstalled; then - echo -e " Status: ${GRN}present${REG}" - else - echo -e " Status: ${RED}not present${REG}" - fi - echo -e " CSS: $(sha256sum /usr/share/pve-manager/css/dd_style.css 2>/dev/null || echo N/A)" - echo -e " JS: $(sha256sum /usr/share/pve-manager/js/dd_patcher.js 2>/dev/null || echo N/A)\n" - echo -e "PVE" - echo -e " Version: $PVEVersion (major $PVEVersionMajor)\n" - echo -e "Utility hash: $(sha256sum $SCRIPTPATH 2>/dev/null || echo N/A)" - exit 0 - else - if isInstalled; then exit 0; else exit 1; fi - fi -} - -function install { - if isInstalled; then - if [ "$_silent" = false ]; then echo -e "${RED}Theme already installed${REG}"; fi - exit 2 - else - if [ "$_silent" = false ]; then checkSupported; fi - - if [ "$_silent" = false ]; then echo -e "${CHECKMARK} Backing up template file"; fi - cp $TEMPLATE_FILE $TEMPLATE_FILE.bak - - if [ "$_silent" = false ]; then echo -e "${CHECKMARK} Downloading stylesheet"; fi - curl -s $BASE_URL/PVEDiscordDark/sass/PVEDiscordDark.css > /usr/share/pve-manager/css/dd_style.css - - if [ "$_silent" = false ]; then echo -e "${CHECKMARK} Downloading patcher"; fi - curl -s $BASE_URL/PVEDiscordDark/js/PVEDiscordDark.js > /usr/share/pve-manager/js/dd_patcher.js - - if [ "$_silent" = false ]; then echo -e "${CHECKMARK} Applying changes to template file"; fi - if !(grep -Fq "" $TEMPLATE_FILE); then - echo "" >> $TEMPLATE_FILE - fi - if !(grep -Fq "" $TEMPLATE_FILE); then - echo "" >> $TEMPLATE_FILE - fi - - local IMAGELIST=$(curl -f -s "$BASE_URL/meta/imagelist") - local IMAGELISTARR=($(echo "$IMAGELIST" | tr ',' '\n')) - if [ "$_silent" = false ]; then echo -e "Downloading images (0/${#IMAGELISTARR[@]})"; fi - ITER=0 - for image in "${IMAGELISTARR[@]}" - do - curl -s $BASE_URL/PVEDiscordDark/images/$image > /usr/share/pve-manager/images/$image - ((ITER++)) - if [ "$_silent" = false ]; then echo -e "\e[1A\e[KDownloading images ($ITER/${#IMAGELISTARR[@]})"; fi - done - if [ "$_silent" = false ]; then echo -e "\e[1A\e[K${CHECKMARK} Downloading images (${#IMAGELISTARR[@]}/${#IMAGELISTARR[@]})"; fi - - if [ "$_silent" = false ]; then echo -e "Theme installed."; fi - if [ "$_noexit" = false ]; then exit 0; fi - fi -} - -function uninstall { - if ! isInstalled; then - echo -e "${RED}Theme not installed${REG}" - exit 2 - else - if [ "$_silent" = false ]; then echo -e "${CHECKMARK} Removing stylesheet"; fi - rm /usr/share/pve-manager/css/dd_style.css - - if [ "$_silent" = false ]; then echo -e "${CHECKMARK} Removing patcher"; fi - rm /usr/share/pve-manager/js/dd_patcher.js - - if [ "$_silent" = false ]; then echo -e "${CHECKMARK} Reverting changes to template file"; fi - sed -i "//d" /usr/share/pve-manager/index.html.tpl - sed -i "/