Grouping

If you have created a 3rd party module you'd like other people to use, post it here
Captank
Member
Posts: 77
Joined: Sun Sep 09, 2012 6:36 pm
antispam: Rimor
Location: irc.funcom.com #budabot

Grouping

Postby Captank » Thu Feb 27, 2014 9:43 pm

First of all: This isn't a module, what I'm talking about is to change some of the core stuff (slightly)

Unix-based systems has a damn nice feature: sym links.

I came to this problem, while I thought a long time about how to correctly hosting multiple bots.
Sure you can install budabot in anywhere and it just takes ~18-20mb of ur HDD ... but ... why?
It would be much better if you'd have one directory to install it and manage shit with sym links.
(I completly ignore the windows side of this now, admit it! Windows is shit for such stuff!)

Currently with some work u can make it that far, that config files, data stuff (like ur sqlite database) and even your logging directories are accessable by sym links.
Besides its damn annoying to set up the sym links and u just cant make some easy scripts creating that crap, there is a huge problem. Profiles ... profiles are damn good when u have more than one raid bot and org bot running (Like in Pack of Noobs/Pack of Neut Noobs + its raid bot + the private org leader bot, etc). To use them u need to save them. So u give them a name, org bots for example get the pre-config from the profile "orgbot", this is saved in ./data/profiles/orgbot.theFileExtensionIDontRemeber. Fine, now you are so kind that you host the bots for another org too. They wanna save their profile too, and ofc they have an org bot and a raid bot. So they save the "raidbot" profile and the "orgbot" profile. Shit, they start to overwrite the profiles ...

Thats why i want to implement some grouping. If you ever took a look into the /conf/config.php or what ever ur config file is named like, u see a lot of stuff like $vars["bla"] = "anything";

There I want another values: $vars["group"] (could be named differently as well)
So what is its value? Its a string value, to group several config files.
What will be different from now?
data stuff wont be saved into ./data, it will be saved into ./data/$groupName - this avoids overwriting profiles for different groups.
logs wont go into ./logs/$bot_name.$server_dimension, logs will end up in ./logs/$groupName/$bot_name.$server_dimension

Some used-to-linux-guys may still ask whats the point of it.
Imagine u got a user "budabot".
Its home directory is /home/budabot/. The budabot installation directory will be /home/budabot/system
in there you got the interesting directories, conf, data and logs.
Imagine you dont just throw the config files into /home/budabot/system/conf

Imagine you got another account, for example named "packofnoobs"
that user creates the following directories:
/home/packofnoobs/budabot/conf
/home/packofnoobs/budabot/data
/home/packofnoobs/budabot/logs

Remember the grouping parting im basically talking about?
the sqlite database wont be in /home/budabot/system/data, it will be in /home/budabot/system/data/packofnoobs, while /home/budabot/system/packofnoobs is just a sym link to /home/packofnoobs/budabot/data
and the same for the ./conf (to start the correct bot, e.g. screen -DmS pr0n ./conf/packofnoobs/pr0n),
the data directory wont be ./data, it will be ./data/$group (e.g. ./data/packofnoobs) which will be a sym link to /home/$group/budabot/data (e.g. /home/packofnoobs/budabot/data)
and so on for ./logs and ./data/profiles

So whats the benifits from it all in all:
besides describing the file permission stuff (if u do this shit, u should at least know about this stuff) there is this stuff:
ppl can get their own ssh access and change their bot data, create new bots, etc.
you can get backups for each group
groups dont overwrite data.

with the group stuff you could even do stuff like proprietary module directories, but all ppl are still using the same installation, which saves disk space, iirc php itself can translate this shit faster to byte code i+ cache if everything is comming from the same resource and more bla.


Im quite drunk, i think i mentioned at least the half of what i wanted to describe an now i wanna hear your opinion.
(And ofc the opinions of the gurus aka Tyrence and Marebone, since they/you know everthing about the current system!)

drunken cap \o
Tyrence
Posts: 1959
Joined: Sat Jan 09, 2010 1:32 am

Re: Grouping

Postby Tyrence » Fri Feb 28, 2014 6:37 am

It's not a bad idea. And certainly I can see the reason. I've hosted bots before and you do end up with lots of different copies of the bot floating around to keep things separate that need to be separate. And then when it comes time to upgrade, you have to upgrade each install separately, and make sure that none of the custom stuff (if you have custom stuff) is overwritten and so forth. Although, sometimes upgrading them individually is better because being forced to upgrade either all or none could put you in a bind. But anyway...

What if you came at this from the other way. Instead of having the user data sym-linked, what if you had the class files sym-linked.

So in your example, you'd have a master copy of the bot at: /home/budabot/system

Then you'd have a skeleton copy of the bot specific to a certain user: /home/packofnoobs/budabot and in there you'd have the startup script, and all the user data like the ./conf, ./data, and ./logs folders. But the lib, core, and modules folders would be sym-linked to /home/budabot/system/{lib, core, modules}. And then if you wanted certain bots to share a database, you would just put the startup script for those bots in the same skeleton copy.

I think this would meet all your criteria:
Captank wrote:besides describing the file permission stuff (if u do this shit, u should at least know about this stuff) there is this stuff:
ppl can get their own ssh access and change their bot data, create new bots, etc.
you can get backups for each group
groups dont overwrite data.


The benefits to doing it this way that I can think of are:
1. When the user logs in to configure his bot, it looks like a normal bot installation with all the files there. Assuming that he doesn't notice the sym-links, he wouldn't be able to tell the difference except that of course the lib, core, and modules directories would be read-only.
2. It's simpler in that you don't have to update the bot to handle this configuration.

The one downside I can think of to doing it this way is:
1. Your user data for all your bots are spread across multiple home directories where as with your solution all the user data can be accessed under /home/budabot/system in the group folders. You could create symlinks to access all the data from one place but that would be more work.

Anyway, that is my take on it. If you think groups would be a better solution and want to add it to the bot I say go for it. The only thing I would say is that if you do add groups, you should make it so that when $vars["group"] is empty the bot works like it does now.

P.S. Glad to hear someone is using profiles :)
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
Captank
Member
Posts: 77
Joined: Sun Sep 09, 2012 6:36 pm
antispam: Rimor
Location: irc.funcom.com #budabot

Re: Grouping

Postby Captank » Fri Feb 28, 2014 9:22 pm

The only thing I would say is that if you do add groups, you should make it so that when $vars["group"] is empty the bot works like it does now.

That was the plan :D

P.S. Glad to hear someone is using profiles

I got a lot of profiles, most of them are for testing stuff, but i got like 4-5 profiles just for basic setups :D

For now I guess I'll use the sym link skeleton stuff, that will make it possible how much have to change anyway.

cap
Captank
Member
Posts: 77
Joined: Sun Sep 09, 2012 6:36 pm
antispam: Rimor
Location: irc.funcom.com #budabot

Re: Grouping

Postby Captank » Sat Mar 01, 2014 4:48 pm

Guess I found a quite nice way to do it with a sym link skeleton.

Once I wrote all scripts (installing of the system, initializing the skeleton, inizializing proxies, boot script and back up script), I'll post all of them here.

Maybe some people are interested into that :D

cap
User avatar
Shelly
Member
Posts: 81
Joined: Wed Oct 05, 2011 1:51 am
antispam: Rimor
Location: Lost in Time
Contact:

Re: Grouping

Postby Shelly » Sun Mar 09, 2014 5:21 am

I use a group folder for each bot classes... org, raid, relay.

I have a start script for each like:

Code: Select all

#!/bin/bash
 
#
##
### Check for AO Bots and restart if necessary
##
#
# This script looks to see if your bot is actually running and does nothing if it is
# already running.
# If it is not running, it will email you the previous log, then compress it to concerve space.

# The BOT* items you will need to configure for your bot.
BOTHOME="/home/bot/RaidBots"
BOTNAME="Budanet"
BOTLOGS="/home/bot"
BOTLOG_Archive=${BOTLOGS}/logs
someone_who_cares="Someone@somewhere.com"

mdate=`date +%b-%d-%Y`;
hdate=`date +%b-%d-%Y_%H%M_hrs`;

z=`ps -ef |grep ${BOTNAME} |egrep -v "(grep|tail)"`;
if [[ $z == "" ]]
then {
  # comment this next line out if you don't want the previous log emailed to you.
  mailx -s "Starting ${BOTNAME} bot " ${someone_who_cares} <${BOTLOGS}/${BOTNAME}.log ;
  if [ -e "${BOTLOGS}/${BOTNAME}.log-${mdate}.gz" ]
  then {
    mv ${BOTLOGS}/${BOTNAME}.log ${BOTLOG_Archive}/${BOTNAME}.log-${mdate};
    /bin/gzip ${BOTLOG_Archive}/${BOTNAME}.log-${mdate};
  }
  else {
    mv ${BOTLOGS}/${BOTNAME}.log ${BOTLOG_Archive}/${BOTNAME}.log-${hdate};
    /bin/gzip ${BOTLOG_Archive}/${BOTNAME}.log-${hdate};
  };
  fi
# For BeBot use this line...
#  cd ${BOTHOME}; /usr/bin/php -f ${BOTHOME}/StartBot.php ${BOTNAME} 2>&1 > ${BOTLOGS}/${BOTNAME}.log &
# -or- for BudaBot...
  cd ${BOTHOME}; /usr/bin/php -f ${BOTHOME}/mainloop.php ${BOTHOME}/conf/${BOTNAME}_config.php 2>&1 > ${BOTLOGS}/${BOTNAME}.log &
}
fi

#EOF


I have a botname_config.php file for each bot in the appropriate folder. Hope this helps keep the clutter down. :)

Shelly
Your type personality is: SAEK
Breakdown: Socializer 73.33%, Achiever 60.00%, Explorer 60.00%, Killer 6.67%

http://en.wikipedia.org/wiki/Bartle_Test
Captank
Member
Posts: 77
Joined: Sun Sep 09, 2012 6:36 pm
antispam: Rimor
Location: irc.funcom.com #budabot

Re: Grouping

Postby Captank » Sun Mar 09, 2014 7:33 pm

Besides that i by mistake deleted ~10hrs of work:

My scripts will be quite different ;p

First of all the "system install" script, which will first of all checks if all needed stuff to run budabot is installed, if not it will do it (with confirmation ofc),
then it will create a group "budabot" (can get a different name by script parameter) and a user named "budabot" (can also be different by another parameter).
depending on other passed parameters it will set up a repository clone and/or 3.0_GA version, and a proxy.
budabot installations can be handled by additional scripts with a name pattern like <version>.install.sh

it will then provide a script other user can use to create the budabot installation by sym link skeleton.

also if u want to install aochatproxy it checks for acl, and if not it will install it (with confirmation ofc)
then it provides a script, to set up a proxy skeleton and modify a list, to get a unique port for each proxy

im rly planing on doing it mass hosting safe.

the script bundle will provide also some other stuff like scripts for backups, emailing on configurable events and even one for a failover server.

Your script will be helpful as well, i may steal some slices of it :D
(this also reminds me that i should dynamically generate the paths to binaries, or make set it in a config file, or default + parameterizable >.<)

cap
User avatar
Shelly
Member
Posts: 81
Joined: Wed Oct 05, 2011 1:51 am
antispam: Rimor
Location: Lost in Time
Contact:

Re: Grouping

Postby Shelly » Thu Mar 20, 2014 11:18 am

You are always welcome to "borrow" from my scripts. :) Just please give me honorable mention ^_^

Shelly

BTW: by doing it this way... I have one bot folder for each of orgs, raidbots, & relays... This way I only need to update max 3 folders when new items/modules/updates come out. Then I control what modules get loaded in each bot's configuration. No symlinks needed so it should work on windows too. :)
Your type personality is: SAEK
Breakdown: Socializer 73.33%, Achiever 60.00%, Explorer 60.00%, Killer 6.67%

http://en.wikipedia.org/wiki/Bartle_Test
Tyrence
Posts: 1959
Joined: Sat Jan 09, 2010 1:32 am

Re: Grouping

Postby Tyrence » Thu Mar 20, 2014 4:38 pm

I think the difference between what Cap is trying to do with his scripts and what you are do with your scripts, Shelly, is that Cap wants to allow the bot owners to log into his server and manage their bots themselves. At the same time, he doesn't want to have to update each bot individually, if I understand correctly.
"Those who expect to reap the blessings of freedom, must, like men, undergo the fatigues of supporting it." — Thomas Paine
"Nearly all men stand adversity, but if you want to test a man's character, give him power." — Abraham Lincoln
Budabot Releases and Downloads: https://github.com/Budabot/Budabot/releases
Captank
Member
Posts: 77
Joined: Sun Sep 09, 2012 6:36 pm
antispam: Rimor
Location: irc.funcom.com #budabot

Re: Grouping

Postby Captank » Fri Mar 21, 2014 11:20 am

Damn VL keeps me busy.

Ofc, i will mention all who I got code/help from, Shelly!
Tyrennce understands me correctly.

It will take a lot of time 'til i can work on the scripts/make them public, because VL keeps me busy currently (job, vocational school, etc).

cap

EDIT:
Also, there is no way to make my scripts platform indepentent, since its based on sym links.
User avatar
Shelly
Member
Posts: 81
Joined: Wed Oct 05, 2011 1:51 am
antispam: Rimor
Location: Lost in Time
Contact:

Re: Grouping

Postby Shelly » Fri Mar 21, 2014 12:45 pm

That's cool :)

If you want any help with them Cap, just let me know.

Shelly
Your type personality is: SAEK
Breakdown: Socializer 73.33%, Achiever 60.00%, Explorer 60.00%, Killer 6.67%

http://en.wikipedia.org/wiki/Bartle_Test

Return to “Modules”

Who is online

Users browsing this forum: No registered users and 1 guest