KermMartian wrote:
Excellent, it can indeed go straight from the command line. Now, how would I configure load options to do that? [Answer to self: JFGI]


"wine blockland <args to blockland here>" Rolling Eyes
what about settings the base dir?!
Oh wait, I see how this works. It's not like the VirtualPC type programs that create a virtual drive. The programs coexist with the Linux filesystem. Got it now. Smile
KermMartian wrote:
what about settings the base dir?!
Oh wait, I see how this works. It's not like the VirtualPC type programs that create a virtual drive. The programs coexist with the Linux filesystem. Got it now. Smile


well, sorta

wine creates a "c" program folder for windows (~/.wine/drive_c). This is where the fake windows folder and such go. Wine also allows programs access to the "z" drive, which is the / file system. This is how they can both access the fake windows folder easily (c:\windows) but also have access to the directory it is being launched from via some branch off of z:\

wine is not an emulator, it is a wrapper. What this means is that it doesn't try to recreate a windows environment, but rather translate windows calls into linux ones (for example, if a program wanted to copy a file, rather than calling windows_file_copy(src, dest), it would translated that to linux_file_copy(src, dest) - obviously those are fake functions, but you get the idea)
I wondered what it did. I need to play around with it once is a while
FTPing Blockland onto Cemetech0 now. Then I'll try starting up a serv and see what happens. How about making it work on boot?
KermMartian wrote:
FTPing Blockland onto Cemetech0 now. Then I'll try starting up a serv and see what happens. How about making it work on boot?


create an rc-init file like such:

file: /etc/init.d/blockland

Code:
start() {
   ebegin "Starting blockland server"
   ${blockland_launcher} start
   eend $?
}

stop() {
   ebegin "Stoping blockland server"
   ${blockland_launcher} stop
   eend $?
}


${blockland_launcher} needs to be some sort of script that launches the blockland server and can kill it. The easiest way that I can think of would be a python script that launches it, dumps the PID to a file in /tmp and then returns. Then if the arg is stop rather than start, it reads the dumped file in /tmp and kills the PID

Or, since you have to manually restart the computer anyway, you can just do it yourself Wink (How often do you plan on restarting the server anyway? Linux has great uptime, so you shouldn't have to restart too often...)
Where the server is right now, it gets shut off ever night from like 8pm to 8 am. Eventually I'll move it, but right now I need something to start it up. What not just have /etc/init.d/blockland contain wine blockland args
KermMartian wrote:
Where the server is right now, it gets shut off ever night from like 8pm to 8 am. Eventually I'll move it, but right now I need something to start it up. What not just have /etc/init.d/blockland contain wine blockland args


How is it going to get shutdown again when /etc/init.d/blockland stop gets executed? you can have wine blockland args in the start(), but you have to have a stop() function too. You would then have to have a function go through /proc and locate the running blockland process, which both stop AND start would need, as start would have to check if it is running, and stop would need its PID to kill...

this is where a python script that simply logs the PID is much easier Wink


Code:
import sys, os
import signal

def start():
   pid = os.spawnlp(os.P_NOWAIT, 'wine', 'wine', '/path/to/blockland/blockland.exe', ...)
   #replacing '...' with the rest of the args seperated by commas ;)
   f = open("/tmp/blockland", 'w')
   f.write(str(pid))
   f.close()

def stop():
   f = open("/tmp/blockland", "r")
   pid = int(f.read())
   f.close()
   os.kill(pid, signal.SIGQUIT)

if (len(sys.argv) <> 2):
   sys.exit(0)
if (sys.argv[1] == 'start'):
   start()
elif (sys.argv[1] == 'stop'):
   stop()
else:
   print "Unknown command: \'%s\'" % sys.argv[1]
   sys.exit(0)
sys.exit(1)


Notice that there is little to no error checking. It assumes that this launcher is only run from the init script, meaning stop can never be run if start hasn't already been run (init checks for this) This can be abused very easily if ran manually (for example, if start is repeatedly run it will happily keep spawning blockland servers - again, init checks this)
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 6 of 6
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement