Installing mafia on Ubuntu

masterZ

New member
Can someone help me install mafia onto my Ubuntu Jaunty OS? I want to start using Windows less and less, and especially because there are many things for Kol that must be done every day, I do not want to boot up windows every day just for KoL.



Thank you,
masterZ
 

Spiny

Member
Download mafia to the folder you want it to be. Open up a shell from that directory do, for example, "java -jar KoLmafia-7502.jar". Replace the file name as appropriate. Your data will be stored in a hidden directory in your user file under .kolmafia. Within there you'll find /data and /scripts etc.

Hope that helps,
Spiny
 

mredge73

Member
I asked this on another thread but I want to ask again here...

How do you auto-start mafia in Ubuntu?

I want to autostart mafia after rollover every day, I got it to work great on my windows machine but I want to move my clan bot to my Ubuntu machine and am missing this little ingredient.
 
For future reference, and for easy menu integration, I have created a .deb of kolMafia. I am going to find a good place to host it, and then link to it here... unless a kolMafia.us admin can add .deb to the list of allowed extensions...

LINK!
 
Last edited:

mredge73

Member
I have still not been able to figure out how to use cron, any help will be appreciated. Keep in mind that I am a windows user who installed linux for the first time a few weeks ago on an older computer. A quick step by step method would be awesome!
 
Last edited:

Spiny

Member
I have still not been able to figure out how to use cron, any help will be appreciated. Keep in mind that I am a windows user who installed linux for the first time a few weeks ago on an older computer. A quick step by step method would be awesome!

I personally haven't dealt with anything in cron and I'm no longer running on Ubuntu (though I wish I was - my laptop died a while back :( ). I'm running on Puppy Linux, but I do everything tunneled into my account on a networked Gentoo system.

This may help get you started, but I haven't looked at it too closely. https://help.ubuntu.com/community/CronHowto

-Spiny
 

Spiny

Member
A goood link is THIS : it will show you how to add any program to system startup in Gnome (the default Desktop Environment for Ubuntu).

The link you quoted is good for having a program run upon startup, but not at a scheduled time. Startup for me is when I wake up (or reboot my system for whatever reason), not when KoL rolls over as mredge73 is interested in. ;) Also the link you quoted has an additional http:// that isn't needed.

Here's a link about Gnome-schedule which is a GUI interface that handles cron tasks.

Hope it helps,
-Spiny
 

mredge73

Member
on the command window, how do I set up the command to make mafia run?

In the terminal I use this to run the .jar:
Code:
java -jar KoLmafia.jar
But when I set it up in cron using the gnome-schedule it never pops up, to test I set it up to occur in a few minutes and the time comes and nothing happens.

Brennydoogles:
I cannot get launchpad to work, I registered but it keeps kicking me off as an invalid user. What is a .deb?
Can you rename it kolMaifa.deb.txt and post it in the forums? Then I can remove the extension when I get it.
 
Last edited:
Brennydoogles:
I cannot get launchpad to work, I registered but it keeps kicking me off as an invalid user. What is a .deb?
Can you rename it kolMaifa.deb.txt and post it in the forums? Then I can remove the extension when I get it.

A .deb is the Debian/Ubuntu version of a windows installer package. If you install my version, open a terminal and type kol, followed by tab-tab. I can't remember if I named the script which calls kolMafia kol or kolmafia, but either way, the resulting command will be what you would put in gnome-scheduler, and it should work fine. I am uploading (hopefully) kolmafia.deb.txt... feel free to give it a try!

::EDIT:: I still can't upload the file... I even tried zipping it. I will keep trying.
 

Spiny

Member
on the command window, how do I set up the command to make mafia run?

In the terminal I use this to run the .jar:
Code:
java -jar KoLmafia.jar
But when I set it up in cron using the gnome-schedule it never pops up, to test I set it up to occur in a few minutes and the time comes and nothing happens.

Ok, this is probably a combination of issues. One, cron needs access to the file as far as permissions so it needs to run the file as "you" rather than as root or whatever. It also needs to know where to find the file in general. You can try to further instruct the gnome-schedule by giving it a more complete path to find your file... example:

if it's in /home/username/...

then you want to try java -jar /home/username/KoLmafia.jar

This MAY work, but if cron doesn't have permission into your home folder, then you may need to copy/move KoLmafia.jar into a folder that cron has permission to access.

One of the hardest things I've had to deal with transitioning from Windows to Linux/Mac is permissions. *grumble mumble*

-Spiny
 

mredge73

Member
I really am starting to hate linux :(
I have worked on this all night and giving up. :confused:

I am trying to use the gnome cron scheduler to do it but no luck.
Commands that I have tried:

java -jar KoLmafia.jar

java -jar /home/mredge73/KoLmafia.jar

/usr/lib/jvm/java-6-openjdk/jre/bin/java -jar /home/mredge73/KoLmafia.jar

all work with the terminal! but not with cron :mad:


I tried a work around by building a bash/shell script with the java call in it. I made it executable and called it from terminal and it worked. But it does not work from cron! :mad:


Attached the bash script(s)...
I had to change the extension to .txt to be able to upload the file.

Thanks for your help in advance.
 

Attachments

  • mafia.txt
    159 bytes · Views: 54
  • mafia1.txt
    93 bytes · Views: 51

Spiny

Member
Ok, the problem is that kolmafia needs to run headless when run from cron.

Set up a shell script called mafia_start.sh containing:
Code:
/usr/lib/jvm/java-6-openjdk/jre/bin/java -jar /home/mredge73/KoLmafia.jar --CLI < mafia_login.txt >> mafia_log.txt

The --CLI is what makes this headless.

Set up a 2nd script called (as per the example) mafia_login.txt. In this you want:
Code:
<insert login profile name to use, also the password if mafia doesn't already have this stored>
<insert bot script, breakfast script or whatever you want to run>
quit

Mafia_log.txt is a dump file that cron will append to so that you know it's running and doing its thing. It's not necessary to have it, but it's nice to know what's happening.

To call this in cron, call the mafia_start.sh script. I tested this in Gentoo and it worked, so it should work for you as well.

-Spiny
 

mredge73

Member
Well
Looks like I am giving up on Linux, I was told it was the easiest most configurable operating system and user friendly OS. That is obviously wrong.

Your method appeared to work but I have no interaction with it.
This would be fine if I was just running a short breakfest script and then shutting down but I am using this to run a complex clan bot. I can not even shut it down. If the script hiccups then I cannot recover. I just wanted mafia to autostart on its own like it does on my windows xp system. It autostarts after rollover and my clan bot script runs until 5 min before rollover and it issues a quit command to mafia and then XP starts it back up after rollover. The script could encounter problems during the day (Blame Jick problems) that need servicing and I like to also go on and manualy do some things while the script is running like browse the message boards. I also need the abilty to turn it off at any time without having to issue the command through chat from another character.

Thanks for your help Spiny, I guess I wasted enough time on this project if it is limited to "headless mode"
 
There has to be a way to autostart kolmafia graphically. Let me look into it a little bit further, and let you know. I still suspect permissions issues.
 

Spiny

Member
Well
Looks like I am giving up on Linux, I was told it was the easiest most configurable operating system and user friendly OS. That is obviously wrong.

Your method appeared to work but I have no interaction with it.
This would be fine if I was just running a short breakfest script and then shutting down but I am using this to run a complex clan bot. I can not even shut it down. If the script hiccups then I cannot recover. I just wanted mafia to autostart on its own like it does on my windows xp system. It autostarts after rollover and my clan bot script runs until 5 min before rollover and it issues a quit command to mafia and then XP starts it back up after rollover. The script could encounter problems during the day (Blame Jick problems) that need servicing and I like to also go on and manualy do some things while the script is running like browse the message boards. I also need the abilty to turn it off at any time without having to issue the command through chat from another character.

Thanks for your help Spiny, I guess I wasted enough time on this project if it is limited to "headless mode"

Sorry you're having difficulties getting what you want accomplished and I'm really upset that you're blaming Linux, as a whole, for the problems you're having. Cron is archaic and complex. Linux is fairly easy, especially Ubuntu. I tried to help you, by getting my RL friends to help me help you. You said you wanted to run a bot, that to me means set it and forget it, and a good bot program should be able to handle issues it may encounter. You said you wanted it to boot up at rollover, cron with good timing approximation would allow that to happen. Now you say you want to be hands on and do what all you might do, in addition to bot functions, like read message boards etc as though you were manually logged in. I suppose you could script that in, but it sounds like you just want mafia to autorun WITH its interface to do what you want to do. I suppose you could still do this if there's a CLI command to load in browser, then you'd start the script with:

/usr/lib/jvm/java-6-openjdk/jre/bin/java -jar /home/mredge73/KoLmafia.jar --CLI

and NOT feed it any scripts to login with. You'd enter your username and pw and be faced with a CLI prompt. If there IS a load in web browser CLI command, I'm not sure what that might be atm as I'm not logged in to look.

My clan has started experimenting with running a bot using PyKol, but even that is running on it's own with no user interaction other than writing the script and watching it do it's thing in shell.

Anyhow, if anyone else can help you, great. Good luck.

-Spiny
 
From help.ubuntu.com:
It is possible to run gui applications via cronjobs. This can be done by telling cron which display to use.

00 06 * * * env DISPLAY=:0 gui_appname

The env DISPLAY=:0 portion will tell cron to use the current display (desktop) for the program "gui_appname".

Maybe this will help?
 
Top