Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[bash] Move maps to a new copy of Nexuiz
06-02-2008, 08:24 PM (This post was last modified: 06-02-2008 08:32 PM by -z-.)
Post: #1
cool [bash] Move maps to a new copy of Nexuiz
[size=x-large]About[/size]

To make upgrading easier, I've created a bash script to move all pk3's except [b]common-spog.pk3[/b] and [b]data[0-9]{8}.pk3[/b] to a new copy of Nexuiz.

[size=x-large]Instructions[/size]

1. Save the following code as [url=http://nexuizninjaz.com/scripts/nn_map_copy.sh]nn_map_copy.sh[/url] in your [b]Nexuiz data directory[/b].

Code:
#!/bin/bash
# nn_map_copy.sh - 06/02/2008 - v0.8
# Tyler "-z-" Mulligan of www.nexuizninjaz.com
# Used to copy all packages minus the common spog and data pack to a new dir

# Destination folder name, should be in the same directory as this Nexuiz' parent directory
echo "Where are these bad boys going? (Name of the new Nexuiz directory)"
read destination

# Copying or Moving?
echo "What action would you like to perform?"
PS3='Enter a #: '

# bash select
select action in "Copy" "Move"
do
  echo "Preparing to $action!"
  break # Break, otherwise endless loop
done

# Check for valid folder name - nohacksplz
if [[ $destination =~ ^[a-zA-Z0-9_-][a-zA-Z0-9_-]*$ ]]; then

    # Prepend the double drop
    final_destination="../../$destination/data"

    # Check to see if the destination directory exists
        if [ -d "$final_destination" ]; then

        # Create temp directory for common-spog.pk3 and data pack
        if [ -d "temp" ]; then
            echo "/!\ Directory \"temp\" already exists (but that's okay!)"
        else
            `mkdir temp`
        fi

        # Get the name of the data pack and move it with common-spog.pk3
        datapack=`ls |grep 'data[0-9]\{8\}'`

        # If you already moved these, it'll break here.  Let the script do the work.
        `mv $datapack temp/`
        `mv common-spog.pk3 temp/`
        
        # Perform the action
        echo $action"ing pk3's to \"$final_destination\""
        if [ $action == "Move" ]; then
            mv *.pk3 "$final_destination"
        else
            cp *.pk3 "$final_destination"
        fi

        # Clean up - Move common-spog.pk3 and data pack back to the data dir
        echo "Removing temp files"
        `mv temp/* .`
        `rmdir temp`
    else
        "/!\ Destination does not exist \"$final_destination\""
    fi
else
    echo "/!\ The destination \"$destination\" failed the search pattern \"[a-zA-Z0-9_-]+\""
fi

exit 0

2. chmod it so you can run it
Code:
chmod +x nn_map_copy.sh

3. Grab a copy the latest Nexuiz build and extract it to the same parent as the one you're upgrading from:
Code:
my_nexuiz_servers
  old_server
  new_server

4. Run it
Code:
./nn_map_copy.sh

5. Answer the questions.
Code:
Where are these bad boys going? (Name of the new Nexuiz directory)
new_server
What action would you like to perfom?
1) Copy
2) Move
Enter a #: 1
Preparing to Copy!
Copying pk3's to "../../new_server"
Removing temp files

Yay!
Inspire your neighbor, they'll inspire you back.

[url=http://maps.nexuizninjaz.com]maps.nn[/url] | [url=http://pics.nexuizninjaz.com]pics.nn[/url] | [url=http://chat.nexuizninjaz.com]chat.nn[/url] | [url=http://toolz.nexuizninjaz.com/cvar]2.5 cvar browser[/url]
Visit this user's website Find all posts by this user
Quote this message in a reply
08-25-2008, 11:04 AM (This post was last modified: 08-25-2008 11:08 AM by esteel.)
Post: #2
RE: [bash] Move maps to a new copy of Nexuiz
In case the server is running on Linux/Mac one can also put all the .pk3 files into ~/.nexuiz/data that way those files will be used regardless of which server version you install. For windows it uses c:\Documents and Settings\User\My Games\Nexuiz (if i remember correctly) either when the current user can not write to Nexuiz\data or used the parameter -mygames at startup. Or you can specify a complete path to use for the 'nexuiz user directory' with -userdir PATH (this works for all three systems, mac, linux, windows)
[size=xx-large][/size]pirates
[url=http://xeno.planetnexuiz.com/forum][img]http://xeno.planetnexuiz.com/img/sigs/scarabRedux.png[/img][/url]
i support free software:http://www.fsfe.org/en/fellows/esteel
my nexuiz gallery:http://www.gamepn.com/galleries.php?gallery=302&view
Find all posts by this user
Quote this message in a reply
08-25-2008, 01:08 PM
Post: #3
RE: [bash] Move maps to a new copy of Nexuiz
To be honest, this script is quite outdated. It was written to help myself learn to script bash. I've science accumulated a wealth of knowledge and techniques that could help improve this script... but it's been over shadowed by my unreleased server management tool.

However, it's still a useful script.
Inspire your neighbor, they'll inspire you back.

[url=http://maps.nexuizninjaz.com]maps.nn[/url] | [url=http://pics.nexuizninjaz.com]pics.nn[/url] | [url=http://chat.nexuizninjaz.com]chat.nn[/url] | [url=http://toolz.nexuizninjaz.com/cvar]2.5 cvar browser[/url]
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


Contact Us | Nexuiz Ninjaz Home | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication