From 4e3bf001b4efb32a42185cf0213ad4b270d71aa7 Mon Sep 17 00:00:00 2001 From: Dominik Polakovics Date: Sat, 30 Sep 2023 11:53:05 +0200 Subject: [PATCH] add wow-addon-manager --- hosts/steamdeck.cloonar.com/configuration.nix | 2 + .../modules/wow-addon-manager.nix | 128 ++++++++- hosts/steamdeck.cloonar.com/modules/wow.nix | 22 ++ utils/overlays/packages.nix | 1 + .../addons.classic.list.sample | 36 +++ .../pkgs/wow-addon-manager/addons.list.sample | 17 ++ utils/pkgs/wow-addon-manager/default.nix | 12 + .../pkgs/wow-addon-manager/wow-addon-manager | 256 ++++++++++++++++++ 8 files changed, 462 insertions(+), 12 deletions(-) create mode 100644 hosts/steamdeck.cloonar.com/modules/wow.nix create mode 100644 utils/pkgs/wow-addon-manager/addons.classic.list.sample create mode 100644 utils/pkgs/wow-addon-manager/addons.list.sample create mode 100644 utils/pkgs/wow-addon-manager/default.nix create mode 100755 utils/pkgs/wow-addon-manager/wow-addon-manager diff --git a/hosts/steamdeck.cloonar.com/configuration.nix b/hosts/steamdeck.cloonar.com/configuration.nix index 51c9e0b..91ee4f0 100644 --- a/hosts/steamdeck.cloonar.com/configuration.nix +++ b/hosts/steamdeck.cloonar.com/configuration.nix @@ -14,6 +14,8 @@ ./utils/bento.nix ./modules/sway/sway.nix + ./modules/wow-addon-manager.nix + ./modules/wow.nix ./hardware-configuration.nix ]; diff --git a/hosts/steamdeck.cloonar.com/modules/wow-addon-manager.nix b/hosts/steamdeck.cloonar.com/modules/wow-addon-manager.nix index 2c020a6..45cfa7e 100644 --- a/hosts/steamdeck.cloonar.com/modules/wow-addon-manager.nix +++ b/hosts/steamdeck.cloonar.com/modules/wow-addon-manager.nix @@ -1,16 +1,120 @@ -{ buildGoModule, fetchFromGitHub, ... }: +{ config, lib, pkgs, ... }: let - wow-addon-manager = buildGoModule rec { - src = fetchFromGitHub { - owner = "Gonzih"; - repo = "wow-addon-manager"; - rev = "b72bcf1fc62ce6b51f8d53997e92f0351f87ebb4"; - sha256 = "0rs9bxxrw4wscf4a8yl776a8g880m5gcm75q06yx2cn3lw2b7v22"; - }; - }; + cfg = config.programs.wow-addon-manager; in { - environment.systemPackages = [ - wow-addon-manager - ]; + options.programs.wow-addon-manager = { + enable = mkOption { + default = false; + description = lib.mdDoc '' + Whether to enable wow-addon-manager. + ''; + type = types.bool; + }; + startAt = mkOption { + type = with types; either str (listOf str); + default = "*:0/15"; + example = "*:0/15"; + description = lib.mdDoc '' + The time(s) to run wow-addon-manager updates. + Specified in systemd's time format; see + {manpage}`systemd.time(7)`. + ''; + }; + user = mkOption { + type = types.str; + default = "dominik"; + description = lib.mdDoc "User to run wow-addon-manager."; + }; + addonList = mkOption { + type = with types; nullOr lines;; + default = null; + description = lib.mdDoc '' + WoW Retail addons to load + ''; + example = literalExpression '' + https://wowinterface.com/downloads/info15636-tullaRange.html + https://addon.theunderminejournal.com/TheUndermineJournal.zip + https://github.com/TekNoLogic/VendorBait.git + https://github.com/ColbyWanShinobi/gsReloadUI.git + https://github.com/ColbyWanShinobi/gsNoGryphons.git + https://github.com/ColbyWanShinobi/gsQuestSounds.git + http://wowinterface.com/downloads/info12995-NPCScan.html + https://wowinterface.com/downloads/info5108-Clique.html + https://wowinterface.com/downloads/info20804-Grail.html + https://wowinterface.com/downloads/info7032-TomTom.html + https://wowinterface.com/downloads/info24910-WeakAuras2.html + https://wowinterface.com/downloads/info7296-Pawn.html + https://wowinterface.com/downloads/info20805-Wholly.html + https://wowinterface.com/downloads/info24802-ChampionCommander.html + https://www.wowinterface.com/downloads/info25313-Dejunk.html + https://www.wowinterface.com/downloads/info10089-ItemID.html + https://www.wowinterface.com/downloads/info24508-ImprovedNameplates.html + ''; + }; + classicAddonList = mkOption { + type = with types; nullOr lines;; + default = null; + description = lib.mdDoc '' + WoW Retail addons to load + ''; + example = literalExpression '' + https://github.com/RagedUnicorn/wow-vanilla-gearmenu.git + https://wowinterface.com/downloads/info15636-tullaRange.html + https://www.curseforge.com/wow/addons/bagsync/download + https://www.curseforge.com/wow/addons/quest_completist/download + http://www.curseforge.com/wow/addons/mmz/download + http://www.curseforge.com/wow/addons/clique/download + http://www.curseforge.com/wow/addons/grail/download + http://www.curseforge.com/wow/addons/tomtom/download + https://github.com/TekNoLogic/VendorBait.git + https://github.com/ColbyWanShinobi/gsReloadUI.git + https://github.com/ColbyWanShinobi/gsNoGryphons.git + https://github.com/ColbyWanShinobi/gsQuestSounds.git + https://www.curseforge.com/wow/addons/tradeskill-master/download + https://www.curseforge.com/wow/addons/monkey-speed/download + https://www.curseforge.com/wow/addons/cursortrail/download + http://wowinterface.com/downloads/info12995-NPCScan.html + https://www.curseforge.com/wow/addons/advancedinterfaceoptions/download + https://www.curseforge.com/wow/addons/weaponswingtimer/download + https://www.curseforge.com/wow/addons/azeroth-auto-pilot-classic/download + https://www.curseforge.com/wow/addons/details/download + https://www.curseforge.com/wow/addons/big-wigs/download + https://www.curseforge.com/wow/addons/bartender4/download + https://www.curseforge.com/wow/addons/little-wigs/download + https://www.curseforge.com/wow/addons/omni-cc/download + https://www.curseforge.com/wow/addons/questie/download + https://www.curseforge.com/wow/addons/atlaslootclassic/download + https://www.curseforge.com/wow/addons/mapster/download + https://www.curseforge.com/wow/addons/vendor-price/download + https://www.curseforge.com/wow/addons/leatrix-plus-classic/download + https://www.curseforge.com/wow/addons/inventorian/download + https://www.curseforge.com/wow/addons/bagnon/download + https://www.wowinterface.com/downloads/info25006-ClassicAuraDurations.html + https://www.wowinterface.com/downloads/info24958-AuctionatorClassicquickfix.html + https://www.wowinterface.com/downloads/info25036-DruidBarClassic.html + https://www.curseforge.com/wow/addons/outfitter/download + https://wowinterface.com/downloads/info24944-WeakAuras2Classic.html + ''; + }; + }; + + config = { + systemd.services."wow-addon-manager" = { + startAt = cfg.startAt; + script = '' + set -eu + ${pkgs.wow-addon-manager}/bin/wow-addon-manager + ${pkgs.wow-addon-manager}/bin/wow-addon-manager classic + ''; + serviceConfig = { + Type = "oneshot"; + User = cfg.user; + }; + }; + environment.etc = { + "wow-addon-manager/addon.list".text = cfg.addonList; + "wow-addon-manager/addon.classic.list".text = cfg.classicAddonList; + }; + }; } diff --git a/hosts/steamdeck.cloonar.com/modules/wow.nix b/hosts/steamdeck.cloonar.com/modules/wow.nix new file mode 100644 index 0000000..5820378 --- /dev/null +++ b/hosts/steamdeck.cloonar.com/modules/wow.nix @@ -0,0 +1,22 @@ +{ ... }: +{ + programs.wow-addon-manager = { + enable = true; + user = "dominik"; + addonList = '' + https://www.curseforge.com/wow/addons/console-port/download + https://www.curseforge.com/wow/addons/immersion/download + https://www.curseforge.com/wow/addons/dynamiccam/download + https://www.curseforge.com/wow/addons/bagnon/download + https://www.curseforge.com/wow/addons/guidelime/download + ''; + classicAddonList = '' + https://www.curseforge.com/wow/addons/console-port/download + https://www.curseforge.com/wow/addons/immersion/download + https://www.curseforge.com/wow/addons/dynamiccam/download + https://www.curseforge.com/wow/addons/bagnon/download + https://www.curseforge.com/wow/addons/guidelime/download + https://www.curseforge.com/wow/addons/guidelime_sage/download + ''; + } +} diff --git a/utils/overlays/packages.nix b/utils/overlays/packages.nix index 391853c..b449281 100644 --- a/utils/overlays/packages.nix +++ b/utils/overlays/packages.nix @@ -1,4 +1,5 @@ self: super: { bento = (super.callPackage ../pkgs/bento { }); ykfde = (super.callPackage ../pkgs/ykfde { }); + wow-addon-updater = (super.callPackage ../pkgs/wow-addon-updater { }); } diff --git a/utils/pkgs/wow-addon-manager/addons.classic.list.sample b/utils/pkgs/wow-addon-manager/addons.classic.list.sample new file mode 100644 index 0000000..24e0add --- /dev/null +++ b/utils/pkgs/wow-addon-manager/addons.classic.list.sample @@ -0,0 +1,36 @@ +https://github.com/RagedUnicorn/wow-vanilla-gearmenu.git +https://wowinterface.com/downloads/info15636-tullaRange.html +https://www.curseforge.com/wow/addons/bagsync/download +https://www.curseforge.com/wow/addons/quest_completist/download +http://www.curseforge.com/wow/addons/mmz/download +http://www.curseforge.com/wow/addons/clique/download +http://www.curseforge.com/wow/addons/grail/download +http://www.curseforge.com/wow/addons/tomtom/download +https://github.com/TekNoLogic/VendorBait.git +https://github.com/ColbyWanShinobi/gsReloadUI.git +https://github.com/ColbyWanShinobi/gsNoGryphons.git +https://github.com/ColbyWanShinobi/gsQuestSounds.git +https://www.curseforge.com/wow/addons/tradeskill-master/download +https://www.curseforge.com/wow/addons/monkey-speed/download +https://www.curseforge.com/wow/addons/cursortrail/download +http://wowinterface.com/downloads/info12995-NPCScan.html +https://www.curseforge.com/wow/addons/advancedinterfaceoptions/download +https://www.curseforge.com/wow/addons/weaponswingtimer/download +https://www.curseforge.com/wow/addons/azeroth-auto-pilot-classic/download +https://www.curseforge.com/wow/addons/details/download +https://www.curseforge.com/wow/addons/big-wigs/download +https://www.curseforge.com/wow/addons/bartender4/download +https://www.curseforge.com/wow/addons/little-wigs/download +https://www.curseforge.com/wow/addons/omni-cc/download +https://www.curseforge.com/wow/addons/questie/download +https://www.curseforge.com/wow/addons/atlaslootclassic/download +https://www.curseforge.com/wow/addons/mapster/download +https://www.curseforge.com/wow/addons/vendor-price/download +https://www.curseforge.com/wow/addons/leatrix-plus-classic/download +https://www.curseforge.com/wow/addons/inventorian/download +https://www.curseforge.com/wow/addons/bagnon/download +https://www.wowinterface.com/downloads/info25006-ClassicAuraDurations.html +https://www.wowinterface.com/downloads/info24958-AuctionatorClassicquickfix.html +https://www.wowinterface.com/downloads/info25036-DruidBarClassic.html +https://www.curseforge.com/wow/addons/outfitter/download +https://wowinterface.com/downloads/info24944-WeakAuras2Classic.html diff --git a/utils/pkgs/wow-addon-manager/addons.list.sample b/utils/pkgs/wow-addon-manager/addons.list.sample new file mode 100644 index 0000000..2e61bf5 --- /dev/null +++ b/utils/pkgs/wow-addon-manager/addons.list.sample @@ -0,0 +1,17 @@ +https://wowinterface.com/downloads/info15636-tullaRange.html +https://addon.theunderminejournal.com/TheUndermineJournal.zip +https://github.com/TekNoLogic/VendorBait.git +https://github.com/ColbyWanShinobi/gsReloadUI.git +https://github.com/ColbyWanShinobi/gsNoGryphons.git +https://github.com/ColbyWanShinobi/gsQuestSounds.git +http://wowinterface.com/downloads/info12995-NPCScan.html +https://wowinterface.com/downloads/info5108-Clique.html +https://wowinterface.com/downloads/info20804-Grail.html +https://wowinterface.com/downloads/info7032-TomTom.html +https://wowinterface.com/downloads/info24910-WeakAuras2.html +https://wowinterface.com/downloads/info7296-Pawn.html +https://wowinterface.com/downloads/info20805-Wholly.html +https://wowinterface.com/downloads/info24802-ChampionCommander.html +https://www.wowinterface.com/downloads/info25313-Dejunk.html +https://www.wowinterface.com/downloads/info10089-ItemID.html +https://www.wowinterface.com/downloads/info24508-ImprovedNameplates.html diff --git a/utils/pkgs/wow-addon-manager/default.nix b/utils/pkgs/wow-addon-manager/default.nix new file mode 100644 index 0000000..d946de3 --- /dev/null +++ b/utils/pkgs/wow-addon-manager/default.nix @@ -0,0 +1,12 @@ +{ pkgs, lib, stdenv, makeWrapper }: + +stdenv.mkDerivation { + name = "wow-addon-manager"; + src = "./"; + nativeBuildInputs = [ makeWrapper ]; + installPhase = '' + install -Dm555 wow-addon-manager $out/bin/ + install -Dm444 addons.list.sample $out/share/ + install -Dm444 addons.classic.list.sample $out/share/ + ''; +} diff --git a/utils/pkgs/wow-addon-manager/wow-addon-manager b/utils/pkgs/wow-addon-manager/wow-addon-manager new file mode 100755 index 0000000..8f6d9f2 --- /dev/null +++ b/utils/pkgs/wow-addon-manager/wow-addon-manager @@ -0,0 +1,256 @@ +#!/bin/bash +set -e + +function getAddonProvider { + #echo "Finding Addon Provider for URL: ${GREEN}$1${CRESET}" + local PROVIDER="$(echo $1 | grep -E -o '\w+\.com')" + echo $PROVIDER + #PROVIDER="$(echo $1 | grep -E -o 'w+.com')" + #echo $PROVIDER +} + +function printList { + ADDONCOUNT=0 + for i in "${ADDONS[@]}"; + do + echo "$ADDONCOUNT - $i" + ADDONCOUNT=$((ADDONCOUNT + 1)) + done + exit +} + +function parseFileName { + local FILENAME="$(echo $1 | grep -E -o '[^\/]+$')" + echo "$FILENAME" +} + +function parseCurseFileNameFromListURL { + local FILENAME="$(echo $1 | grep -E -o 'addons/.+/download' | cut -f2 -d'/')" + echo "${FILENAME}.zip" +} + +function parseDirName { + local DIRNAME="$(echo $1 | sed -E 's/.{4}$/ /g')" +} + +function parseAddonDirName { + echo "parse!" + #Get the name of the addon directory from the zip file + #local ADDONDIR="$(unzip -l /tmp/$ZFILE | grep -E -o ' \w+\/' | sort | uniq | grep -E -o '\w+')" + #echo "Searching Addon archive and found directory named: ${GREEN}$ADDONDIR${CRESET}" +} + +function dlCurseAddon { + echo "Updating Addon from curseforge.com..." + #Get the URL to download the file + local DOMAIN="https://www.curseforge.com" + local CURSELINK="$(wget --random-wait -q $1 -O - | grep -i "If your download" | grep -E -o 'href=\".+\"' | cut -f2 -d'"')" + echo "CurseLink: ${GREEN}$CURSELINK${CRESET}" + local DLURL="${DOMAIN}${CURSELINK}" + + #if [ "$DLURL" != '' ] + #then + echo "Download URL: ${GREEN}$DLURL${CRESET}" + + #Get the name of the file itself + local ZFILE=$(parseCurseFileNameFromListURL "$DLURL") + echo "Zip File: ${GREEN}$ZFILE${CRESET}" + + #Get the name of just the zip file + local ZDIRNAME=$(parseDirName $ZFILE) + + #Remove the temp dir if it exists + rm -rf /tmp/CoS/tmpAddon + + #Re-create the dir + mkdir -p /tmp/CoS/tmpAddon + + #Download the file + echo "Downloading file: ${GREEN}$DLURL${CRESET}" + cd /tmp/CoS + wget --random-wait -N -O ${ZFILE} "$DLURL" + + #Unzip the file to a temp directory + ZDIRNAME=tmpCurseDl + echo "Unzipping file: ${GREEN}/tmp/$ZFILE${CRESET} to ${GREEN}/tmp/$ZDIRNAME${CRESET}" + unzip -o "/tmp/CoS/$ZFILE" -d /tmp/CoS/tmpAddon + + #Copy only new files into the Addon directory + rsync -hvrPt /tmp/CoS/tmpAddon/ "$ADDONPATH" + #else + #echo "Download failed for: $1" + #fi +} + +function dlIndy { + echo "Updating Independent Addon..." + #Get the URL to download the file + local DLURL=$1 + echo "Download URL: ${GREEN}$DLURL${CRESET}" + + #Get the name of the file itself + local ZFILE=$(parseFileName "$DLURL") + echo "Zip File: ${GREEN}$ZFILE${CRESET}" + + #Get the name of just the zip file + local ZDIRNAME=$(parseDirName $ZFILE) + + #Remove the temp dir if it exists + rm -rf /tmp/CoS/tmpAddon + + #Re-create the dir + mkdir -p /tmp/CoS/tmpAddon + + #Download the file + echo "Downloading file: ${GREEN}$DLURL${CRESET}" + cd /tmp/CoS + wget --random-wait -N $DLURL + + #Unzip the file to a temp directory + ZDIRNAME=tmpCurseDl + echo "Unzipping file: ${GREEN}/tmp/$ZFILE${CRESET} to ${GREEN}/tmp/$ZDIRNAME${CRESET}" + unzip -o "/tmp/CoS/$ZFILE" -d /tmp/CoS/tmpAddon + + #Copy only new files into the Addon directory + rsync -hvrPt /tmp/CoS/tmpAddon/ "$ADDONPATH" +} + +function dlGitAddon { + echo "Updating Addon using git..." + #Get the URL to download the file + local DLURL=${1} + echo "Download URL: ${GREEN}${DLURL}${CRESET}" + + #Get the name of just the zip file + local GDIRNAME=$(echo ${DLURL} | grep -E -o '[-[:alnum:]]+.git' | cut -f1 -d.) + + if [ -d "${ADDONPATH}/${GDIRNAME}" ] + then + #Is this a healthy git folder? + if [ -d "${ADDONPATH}/${GDIRNAME}/.git" ] + then + echo "pull from healthy git directory (${ADDONPATH}/${GDIRNAME}) for : ${GREEN}$GDIRNAME${CRESET}" + git -C "${ADDONPATH}/${GDIRNAME}" pull ${DLURL} + else + echo "Removing git directory (${ADDONPATH}/${GDIRNAME}) for : ${GREEN}${GDIRNAME}${CRESET}" + rm -rfv "${ADDONPATH}/${GDIRNAME}" + echo "Cloning from git repository for : ${GREEN}${GDIRNAME}${CRESET}" + git -C "${ADDONPATH}" clone ${DLURL} + fi + else + echo "Removing git directory (${ADDONPATH}/${GDIRNAME}) for : ${GREEN}${GDIRNAME}${CRESET}" + rm -rfv "${ADDONPATH}/${GDIRNAME}" + echo "Cloning from git repository for : ${GREEN}${GDIRNAME}${CRESET}" + git -C "${ADDONPATH}" clone ${DLURL} + fi +} + +function dlWowIAddon { + echo "Updating Addon from wowinterface.com..." + + #Get the URL to download the file + local DLURL="https://www.wowinterface.com/downloads/getfile.php?id=$(wget --random-wait -q $1 -O - | grep landing | grep -E -o 'fileid=[[:digit:]]+' | uniq | cut -f2 -d=)" + echo "Download URL: ${GREEN}$DLURL${CRESET}" + + #Get the name of the file itself + local ZFILE=$(curl -Is $DLURL | grep content-disposition | cut -f2 -d\") + echo "Zip File: ${GREEN}$ZFILE${CRESET}" + + #Get the name of just the zip file + local ZDIRNAME=$(parseDirName $ZFILE) + + #Remove the temp dir if it exists + rm -rf /tmp/CoS/tmpAddon + + #Re-create the dir + mkdir -p /tmp/CoS/tmpAddon + + #Download the file + echo "Downloading file: ${GREEN}$DLURL${CRESET}" + cd /tmp/CoS + wget --content-disposition --random-wait -N $DLURL + + #Unzip the file to a temp directory + ZDIRNAME=tmpCurseDl + echo "Unzipping file: ${GREEN}/tmp/$ZFILE${CRESET} to ${GREEN}/tmp/$ZDIRNAME${CRESET}" + unzip -o "/tmp/CoS/$ZFILE" -d /tmp/CoS/tmpAddon + + #Copy only new files into the Addon directory + rsync -hvrPt /tmp/CoS/tmpAddon/ "$ADDONPATH" + +} + +function dlAddon { + echo "Finding Addon Provider for URL: ${GREEN}$1${CRESET}" + PROVIDER=$(getAddonProvider $1) + echo "Found Provider: ${GREEN}$PROVIDER${CRESET}" + + if [ "$PROVIDER" == "curseforge.com" ] + then + dlCurseAddon $1 + elif [ "$PROVIDER" == "wowinterface.com" ] + then + dlWowIAddon $1 + elif [ "$PROVIDER" == "github.com" ] + then + dlGitAddon $1 + else + dlIndy $1 + fi +} + + +REMEMBERPATH="$(pwd)" +SCRIPTDIR="$(echo $0 | sed 's/\/cullingOfStratholme.sh//g')" +ADDONLIST=addon.list +ADDONPATH=/home/dominik/.local/share/Steam/steamapps/compatdata/3525601306/pfx/drive_c/Program Files (x86)/World of Warcraft/_retail_/Interface/AddOns + +if [ "$1" == "classic" ] +then + echo "Install mods for classic..." + ADDONLIST=addon.classic.list + ADDONPATH=/home/dominik/.local/share/Steam/steamapps/compatdata/3525601306/pfx/drive_c/Program Files (x86)/World of Warcraft/_classic_/Interface/AddOns + echo ${ADDONLIST} + echo ${ADDONPATH} +fi + +ALFULL=/etc/wow-addon-manager/$ADDONLIST + +#Check to see if the text file exists +if [ ! -f $ALFULL ] +then + echo "Could not find file: $ADDONLIST" +fi + +declare -a ADDONS +ADDONCOUNT=0 +while IFS= read -r f || [ -n "${f}" ] +do + ADDONS[$ADDONCOUNT]=$f + ADDONCOUNT=$(($ADDONCOUNT + 1)) +done < $ALFULL + +GREEN="$(tput setaf 2)" +CRESET="$(tput sgr0)" + +if [ "$1" == "list" ] + then + printList + cd ${REMEMBERPATH} + exit +fi + +if [ "$1" == "test" ] + then + ADDONURL=${ADDONS[$1]} + dlAddon $ADDONURL + cd ${REMEMBERPATH} + exit +fi + +for i in "${ADDONS[@]}"; +do + dlAddon $i +done + +cd ${REMEMBERPATH}