Installing mafia on Ubuntu

Again thanks for the additional help Spiny, I will experiment with it some more when I get the chance. Linux is about as easy as DOS or windows 3.1, I just feel like I traveled back in time to 1992 after installing Ubuntu, that is the source of my frustration. I don't mean to offend anyone who knows there way around this OS, I just thought that I would give it a try.
In the mean time I will try to find a way to get it to work as described above in headless unless there is an alternative to cron.

I have a few questions about headless mode:
How do I know if there is an instance of mafia already running?
Is there a task manager type thing in Linux where I can see my processes?
How do I shut it down without having to shut the computer down?
How do I restart it if mafia auto-aborts the script (Blame Jick Errors)?
(Some of the most tested scripts in these forums like wossname.ash suffer from Blame Jick Errors due to a server side issue that I don't understand)
If it is currently running headless, how can I access the cli on that instance since the command you posted above starts a new instance?

I agree that a good bot program should be able to handle many of these problems, but I have never seen a good bot program for mafia. They don't exist on these forums to learn anything from them. They require months of testing since clan activities do not change rapidly without a push. And they are not immune to mafia auto-aborts like the blame jick errors.

Mine probably breaks down two to three times a week and that is down from when I first started her. She is also my clan leader figurehead so she gets Kmail from time to time that needs to be checked and I need to do some manual clan management with her from time to time. I do all of this while the script is running. The script manages karma based clan ranks, auto-accepts applications, sends welcome packages, monitors the stash for looters, manages contests, auto advertises, and includes a chatbot with additional functionallity including cagebot. It also has to manage itself by auto adventuring (this often causes the hangups).


FYI
Cli command for the web browser is "relay"
 
Again thanks for the additional help Spiny, I will experiment with it some more when I get the chance. Linux is about as easy as DOS or windows 3.1, I just feel like I traveled back in time to 1992 after installing Ubuntu, that is the source of my frustration. I don't mean to offend anyone who knows there way around this OS, I just thought that I would give it a try.

Wait until people really start getting into Windows' PowerShell, then the new agonies of this will come back with a vengeance.

How do I know if there is an instance of mafia already running?
Is there a task manager type thing in Linux where I can see my processes?

Assuming bash for all of these, mainly because it is my preferred shell. I'm sure there are graphical clients, but from the command line:

Code:
ps ux | grep -i kolmafia | grep -v grep

... does a pretty good job of showing you the mafia process, if there is one.

In an if statement, you could do this:

Code:
if ps ux | grep -v grep | grep -i kolmafia >& /dev/null; then echo running;else echo not running;fi

How do I shut it down without having to shut the computer down?
How do I restart it if mafia auto-aborts the script (Blame Jick Errors)?

The shotgun approach?

Code:
ps ux | grep -i kolmafia | grep -v grep | cut -c 10-15 | xargs kill

Basically, take the list of proceses (ps ux), filter only the ones with kolmafia (grep -i kolmafia), filter out the grep used to filter out (grep -v grep), strip out the process id (cut -c 10-15 which is only use characters 10-15), then pump the results to kill (xargs kill).

To detect the abort, if you pipe the output of the headless script to a file, you can use grep to look for the "blame jick" line in the last X lines.

Code:
if tail -n 50 output.log | grep -i 'blame jick' >& /dev/null;then echo Jick is never to blame;fi

If it is currently running headless, how can I access the cli on that instance since the command you posted above starts a new instance?

This one would be a bit harder to do. You could do something with `screen` and some redirects, but probably not the easiest thing in the world to do.
 
Glad I could help! Oddly enough, this doesn't actually work on my machine! I think it has to do with the fact that I am running KDE4, and I'm not sure how Plasma workspaces are numbered. As for Ubuntu... have you visited the forums? The ubuntuforums are fantastic, and they go out of their way to help people with issues. What version of Ubuntu are you running by the way? Unlike with Windows, I would recommend upgrading versions every time a new version is released (every April and October), because they make leaps and bounds in stability and features every time. Have fun!
 
By the way, I finally had a chance to upload that .deb. Here it is! If you do install this .deb, the command to run KOLMafia from the command line is kol, and for cron it would be /usr/bin/kol . Hope it helps someone!
 
I just added a new target to the buildfile:

ant createdeb

will make a .deb file in the dist directory for you. I selected the properties based on the .deb file you uploaded, brennydoogles, with the exception that I do not include the version number in the jar file, and therefore /usr/bin/kol always gets /usr/lib/KoLmafia.jar

Feedback welcome; it would be nice to get this "right" before I add it to the stand list of "dist" targets, a la the .exe and .dmg files...
 
Hmmm... I am not familiar with ant createdeb. I have always built my .debs manually with dpkg -b, so I'm not sure what to tell you. Maybe we could chat in more detail about the files created by ant and their contents, to get a better understanding of whether it will create production ready .debs.

::EDIT::

After looking over build.xml on sourceforge, that seems pretty much right... but I wonder if the desktop entry shouldn't be created first since it gets packaged into the .deb before it is populated right now, and also the description field in the control file still says "Description Goes Here". Other than that it seems pretty good to me.
 
Last edited:
I wrote "ant createdeb" in the build.xml file. I found a public domain (well, apache licensed) ant task which would create a .deb file for you, imported it into our source tree (including the license, which is all the apache license requires), and configured it to create the .deb file we need. It DOES create the desktop entry first, since that is a prerequisite of the .deb file. It says "Description Goes Here" because that is the text I typed. It was intended to be a placeholder until I typed in the real description - which I neglected to do.

I'll fix the description.

Other than that, does the created .deb file work the way you expect it to? The advantage of my technique is that it is platform independent to create it; I created a .deb file on Mac OS-X, rather than having to boot up Ubuntu to do it.

P.S. A .deb file is a Unix "ar" archive. I took yours, used "ar" to extract the pieces, and looked at them. There is a "control" and a "data" .tar.gz file included in the "ar" archive. I used "gunzip" and "tar" to extract those and looked at the contents. I looked at the .desktop file and the control file.

The ant-deb task I found lets me configure every field in the .desktop and the control file and also include any desired file into the data .tar file. I configured them to create the same files your .deb provided - including the icon you included.

Basically, I think I am reproducing what you provided. I couldn't have done it without your example (and your icon file). At least, I couldn't have done it with only an hour and a half of my time without your example. For that, I thank you.

Thanks. :)
 
Last edited:
Yes, I noticed that you were using ant-deb-task upon inspection of the build.xml file, which is great for the convenience it affords. I did mine manually on Linux because.... well it's pretty easy that way when Ubuntu is your primary OS. As for whether or not the created .deb works the way you intend it to... I would assume so. A Debian installer is not a terribly complex thing (writing the actual program is infinitely more complicated), so I'm pretty sure it will work just fine. If you would like to send me a copy of it I would be more than willing to test it out for you. Next stop... setting up a PPA for apt-get availability! :p
 
Last edited:
Bump/Deb for ubuntu?

Sorry bout opening an old post but im wondering if theirs a deb file for ubuntu kolmafia and this is the only site ive gotten close to finding one any help would be appreciated
 
You shouldn't need a deb file. In all likelihood, you already have java on your system, so download the .jar. When you double click it, mafia should start.

Sometimes, however, you will need to change the default "opens with" setting...
 
Back
Top