Saturday, November 26, 2011

How to Add User Accounts to a Pyspades Server

So you've been to a SuperCool Build server and you put in your dues.  Finally, you got your user account.  You have earned your independence.  Maybe you noticed some of your fellow builders have different abilities than you do.  Even the admins don't log in to a generic admin account.  That is the beauty and convenience of User Accounts in Pyspades.  I know all you server gurus want to know how its done.


If you haven't been to a SuperCool Server, get the latest Ace of Spades client at http://www.ace-spades.com/. Then you can find SuperCool III Build Goes On on the list of Servers or click here.

Before we get started with the user accounts you will need set up your computer to run Pyspades from the source code.  Until some capable python coder creates a way to load user accounts another way, this is our only option and this is how its done at SuperCool.  There are detail instructions in the Pyspades Wiki.

Follow all instructions exactly and make sure you have it running before you come back.  You will need about 2 hours, assuming you don't run into too many problems.


How to Install Pyspades Source for Win32

Okay, you have Pyspades running from the source, you have mostly recovered from that traumatic event and you have familiarized yourself with how to run and manage a build server using Pyspades.  Now you're ready to add the User Accounts customization.

You can use any text editor you like.  I use Notepad ++ because it is free and has great features for simple code editing.

Find commands.py in pyspades\feature_server\ and open it in your favorite editor.
Look toward the bottom and find this section of code around line 749.















Copy the entire highlighted section and create a New file.  
Paste it into the new file and save it as rights.py in the same feature_server folder like this:










Now go back to commands.py and replace the highlighted section you copied before like this:















This will effectively be loading everything from your new file rights.py into this section of the commands.py file as if it were written here, but its much easier to manage your user accounts in the external rights.py file.


That's most of it.  Now I will show you how to add user levels and individual user accounts.  Pay attention to how the following section is formatted.  I have added advbuilder as a user level and have given special permission to a user that goes by the name AwesomePossum.





















Notice each command is in single quotes and there is a comma after each command except for the last one.

It is the same format for the actual user accounts.  All commands are listed inside the [ ] brackets with a comma after each ] closing bracket except for the last one in the list.  The spacing or indentation is not important here except for the ability to easily read who has rights to which commands and to stay organized when you want to add or remove commands and users.

At this point, the only thing left to do is to edit the passwords section of config.txt which you should have seen when you configured your Pyspades server earlier.  It is also in the pyspades\feature_server folder.
Lets look at the passwords section of config.txt.














Notice the passwords by default are only for "admin" and "trusted".  Where the password for those accounts are "replaceme" and undefined for "trusted".  Let me show you how config.txt should be edited to match the rights.py file created in the example.



















You may see I kept "admin" and "trusted" because those are user levels built into Pyspades that have special permissions not defined in rights.py.  The admin account has access to every command in Pyspades.  The trusted account is just one that cannot be votekicked, but has no specific commands associated with it.


Take note of the format used here:
  • Keep the list of users in the same order as they are listed in rights.py so they're easy to find.
  • The usernames must be spelled EXACTLY the same, including capitalization in rights.py and config.txt.
  • Username and passwords are inside "" double quotes.
  • Each line ends with a , comma except the last one in the list.
  • There is a closing } bracket followed by a , comma that ends the passwords definitions.

Save your config and you're ready to run your Pyspades Server with user accounts.  This change will provide your visitors with a sense of independence and belonging.  But be careful who you give an account to because they will grief your server into oblivion and swear on their mother's grave they didn't do it.  Do not tolerate griefing or give second chances.  When a griefer or password leaker is known for sure, the only solution is a Perma-Ban.  They don't respect you or your users, they don't learn and they don't change their behavior.

Other points to keep in mind:
Any changes to User Accounts or Passwords require a server restart.
Don't tollerate begging or threats.  These people won't ever respect you if you give in.
If you do notice griefing on your server, do not allow any new users to have accounts until the problem is resolved.

If you have any unanswered questions or tips to improve this article, please feel free to contact the author and original creator of SuperCool Build - JohnRambozo at johnrambozosc@gmail.com.