Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
WoW
Talk
English
Views
Read
Edit
History
More
Search
Navigation
Home
Random page
Help using wiki
Editions
for WoW
for WildStar
for Solar2D
Documentation
for WoW
for WildStar
Reference
WoW
⦁ FrameXML
⦁ AddOns
⦁ API
⦁ WoW Lua
WildStar
⦁ AddOns
⦁ API
⦁ WildStar Lua
Engine
Tools
What links here
Related changes
Special pages
Page information
Site
Recent Changes
Editing
WoW:Migrate WTF script
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== migrateWTF.sh == <pre> #!/bin/sh SRC="/Applications/World of Warcraft" DST="${SRC}/WoWTest" NUM_OLD=0 NUM_NEW=0 # print the usage message then exit with error usage() { echo echo "${0#*/} by nemes" echo echo "wiki: http://www.wowwiki.com/MigrateWTFscript" echo echo "usage: ${0#*/} -a <account name> [-s <source dir>] [-d <destination dir>] -f <realm from> -t <realm to> {-o <old name> -n <new name>}" echo " -a account name in caps" echo " -s source directory of the WOW install, defaults to /Applications/World of Warcraft" echo " -d destination directory of the WOW install, defaults to /Applications/World of Warcraft/WoWTest" echo " -f realm migrating from" echo " -t realm migrating to" echo " -o character name on source" echo " -n character name on destination" echo echo "-o and -n must be specified in pairs; zero or many -o -n pairs may be specified" echo "when -s and -d are the same, the exiting configuration will be backed up to WTF.beforemigration" echo echo "e.g.: to migrate from your regular server to the test realm, renaming two characters:" echo " ./${0#*/} -a NEMES11 -s \"/Applications/World of Warcraft\" -d \"/Applications/World of Warcraft/WoWTest\" -f \"Dath'Remar\" -t \"Test Server (US PVE)\" -o Nemes -n Nemesey -o Rhadamanth -n Rhad" echo echo "e.g.: to migrate from Thunderhead to Privybush without renaming any characters:" echo " ./${0#*/} -a NEMES11 -s \"/Applications/World of Warcraft\" -d \"/Applications/World of Warcraft\" -f \"Thunderhead\" -t \"Privybush\"" echo exit 1 } # check the return code (first argument) and if it's not success, print the second argument and exit with error chkrc() { RC=${1} MSG=${2} if [[ ${RC} -ne 0 ]]; then echo "$MSG" echo "return code: ${RC}" exit 1 fi } # execute the sed script (first argument) on each lua file in the current directory modifyLUA() { SCRIPT=${1} PRINTED=0 echo "Modifying lua files in ${PWD}:" LUA_FILE_LIST=$(ls *.lua 2>&1 > /dev/null) if [[ ${?} -eq 0 ]]; then for F in *.lua; do if [[ ${PRINTED} -gt 2 ]]; then PRINTED=0 printf "\n" else PRINTED=$((${PRINTED}+1)) fi printf "\t${F}" sed -f "${SCRIPT}" "${F}" > "${F}.new" chkrc ${?} "\nError executing sed on ${F}, with command file ${SCRIPT}, exiting" mv "${F}.new" "${F}" done printf "\n" fi } # parse the command line options while getopts ":s:d:f:t:o:n:a:" OPT; do case ${OPT} in a) ACCT=${OPTARG} ;; s) SRC=${OPTARG} ;; d) DST=${OPTARG} ;; f) FROM=${OPTARG} ;; t) TO=${OPTARG} ;; o) OLD[${NUM_OLD}]=${OPTARG}; NUM_OLD=$((${NUM_OLD}+1)) ;; n) NEW[${NUM_NEW}]=${OPTARG}; NUM_NEW=$((${NUM_NEW}+1)) ;; \?) usage esac done shift $((${OPTIND} - 1)) # check from and to for existence if [[ ${FROM} == "" ]]; then usage fi if [[ ${TO} == "" ]]; then usage fi # check the source and dest for existence if [[ ! -d "${SRC}" ]]; then echo "${SRC} does not exist, exiting" exit 1 fi if [[ ! -d "${DST}" ]]; then echo "${DST} does not exist, exiting" exit 1 fi # check the account for existence if [[ ${ACCT} == "" ]]; then usage fi if [[ ! -d "${SRC}/WTF/Account/${ACCT}" ]]; then echo "${SRC}/WTF/Account/${ACCT} does not exist, exiting" exit 1 fi # check that the same number of old/new names are specified if [[ ${NUM_OLD} -ne ${NUM_NEW} ]]; then echo "Different number of old and new character names specified, exiting" exit 1 fi if [[ ${SRC} == ${DST} ]]; then SINGLEINSTALL=1 else SINGLEINSTALL=0 fi # tell the user what we're going to do and give them a chance to stop echo echo "========================================" if [[ ${SINGLEINSTALL} -eq 1 ]]; then echo "Performing migration for installation:" echo " ${SRC}" echo echo "Existing configuration will be stored in:" echo " ${SRC}/WTF.beforemigration" else echo "Preparing to migrate WTF from:" echo " ${SRC}/WTF" echo "to" echo " ${DST}/WTF" fi echo echo "Changes will be made to the World of Warcraft account: ${ACCT}" echo echo "Realm name will be changed:" echo " ${FROM} -> ${TO}" echo echo "Characters renamed:" I=0 while [[ ${I} -lt ${NUM_OLD} ]]; do echo " ${OLD[I]} -> ${NEW[I]}" I=$((${I}+1)) done echo "========================================" echo echo "Press any key to continue" read # create the temporary directory for a single installation if [[ ${SINGLEINSTALL} -eq 1 ]]; then DST="${SRC}/migtemp" mkdir "${DST}" chkrc ${?} "Error during creation of ${DST}, exiting" fi # copy the entire WTF folder, obliterating what was there if [[ -d "${DST}/WTF" ]]; then echo "Removing ${DST}/WTF" rm -rf "${DST}/WTF" chkrc ${?} "Error during remove, exiting" fi echo "Copying ${SRC}/WTF/config.wtf, ${SRC}/WTF/Account to ${DST}/WTF" mkdir "${DST}/WTF" cp -r "${SRC}/WTF/config.wtf" "${SRC}/WTF/Account" "${DST}/WTF" chkrc ${?} "Error during copy, exiting" # change the realm folder name echo "Changing realm folder name from ${FROM} to ${TO}" mv "${DST}/WTF/Account/${ACCT}/${FROM}" "${DST}/WTF/Account/${ACCT}/${TO}" chkrc ${?} "Error during rename, exiting" # change the character folder name I=0 while [[ ${I} -lt ${NUM_OLD} ]]; do echo "Changing character folder name from ${OLD[I]} to ${NEW[I]}" mv "${DST}/WTF/Account/${ACCT}/${TO}/${OLD[I]}" "${DST}/WTF/Account/${ACCT}/${TO}/${NEW[I]}" chkrc ${?} "Error during rename, exiting" I=$((${I}+1)) done # build a sed command file SED_FILE="${DST}/WTF/sed_cmd.txt" echo "s/\"${FROM}/\"${TO}/g" >> ${SED_FILE} echo "s/${FROM}\"/${TO}\"/g" >> ${SED_FILE} I=0 while [[ ${I} -lt ${NUM_OLD} ]]; do echo "s/\"${OLD[I]}/\"${NEW[I]}/g" >> ${SED_FILE} echo "s/${OLD[I]}\"/${NEW[I]}\"/g" >> ${SED_FILE} echo "s/\"char\/${OLD[I]}/\"char\/${NEW[I]}/g" >> ${SED_FILE} I=$((${I}+1)) done # perform replacements on each lua file in SavedVariables cd "${DST}/WTF/Account/${ACCT}/SavedVariables" modifyLUA "${SED_FILE}" # perform replacements for each character in the realm cd "${DST}/WTF/Account/${ACCT}/${TO}" for D in *; do if [[ -d ${D} ]]; then cd ${D} modifyLUA "${SED_FILE}" if [[ -d SavedVariables ]]; then cd SavedVariables modifyLUA "${SED_FILE}" cd .. fi cd .. fi done # create the temporary directory for a single installation if [[ ${SINGLEINSTALL} -eq 1 ]]; then echo "Moving orignal WTF to ${SRC}/WTF.beforemigration" mv "${SRC}/WTF" "${SRC}/WTF.beforemigration" chkrc ${?} "Error during rename, exiting" echo "Moving new WTF to ${SRC}/WTF" mv "${DST}/WTF" "${SRC}" chkrc ${?} "Error during move, exiting" rmdir "${DST}" chkrc ${?} "Error during removal of ${DST}, exiting" fi </pre> [[Category:Guides]]
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)