Author Topic: Linux boot script question?  (Read 2020 times)

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Linux boot script question?
« Reply #30 on: March 13, 2011, 05:37:22 am »


               And apparently getting a post in while they try to maintain site is a bad idea, it makes them triplicate.
               
               

               


                     Modifié par Calvinthesneak, 13 mars 2011 - 10:07 .
                     
                  


            

Legacy_Skildron

  • Sr. Member
  • ****
  • Posts: 421
  • Karma: +0/-0
Linux boot script question?
« Reply #31 on: March 13, 2011, 10:23:08 am »


               Hey there, Calvin!

I'm not sure what you are trying to do. Since I don't use nwnx2, I don't no how to start it, but AFAIKS there is no place in the startup process to offer a player password. After nwserver started, you can provide one with

./nwservctl.sh playerpassword password

But this will not log you into the server as player, but set the password you need to log into the server with the graphical multiplayer client.

Perhaps, you could explain a little more what you are trying to do, then I may be able to help.

Greetings
Skildron
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Linux boot script question?
« Reply #32 on: March 13, 2011, 10:40:17 am »


               Running standalone server from linux box.   What I'm trying to do is when it starts up via the script is let the server start and remove the password after about 5 minutes or so.

with or without nwnx the process for the bash script doesn't change much, empty expect simply looks for text to appear, either it waits for "module loaded" string or if you're running in nwnx, it just lists the memory loc for the nwnx INIT function which is that fixed string of "0x08203e79"

Either way they are both strings which signal that it should provide a response.  That response it provides immediately on recieving the keyphrase.  Right now I set it to reply with PASS_RESPONSE="playerpassword\\n".

So basically this just sends the playerpassword command to the nwserver and clears the password.   I spose what I really will have to do is make the sleep between the server load and the password removal longer, or just leave it the way I had it running.
               
               

               
            

Legacy_Skildron

  • Sr. Member
  • ****
  • Posts: 421
  • Karma: +0/-0
Linux boot script question?
« Reply #33 on: March 13, 2011, 03:19:21 pm »


               You will probably not have any grace time - as soon as empty finds the pass phrase in the out.fifo, it sends the pass response to the in.fifo. The -t switch only tells empty the amount of time to wait for the pass phrase before giving up with a time out - otherwise, empty would wait forever if the server program does not send the expected pass phrase.

But, anyhow, what you want to do should work the way you try. I suspect the \\n closing you playerpassword statement to be superfluous. There is no instance of echo or printf involved that would be able to evaluate the newline command.

If that does not work in any way, you could modify the script around line 100 in the following way:

$WAIT_LOADED
if [ "$(pidof nwserver)" ]
       then
           echo "nwserver is running now"
       sleep 300
       echo "playerpassword" | empty -s -o ./in.fifo
   else
       echo "nwserver loading failed.."
           EXCODE=1
fi


That would, of course, add 5 to the time the script stays active after the success message.

HTH
Greetings
Skildron
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Linux boot script question?
« Reply #34 on: March 13, 2011, 11:10:09 pm »


               Hmmm I did it a little different Skil.

Changed the WAIT_LOADED command to:

Quote
WAIT_LOADED="empty -s -o in.fifo $PASS_RESPONSE"


then I went and changed the text in the same area as you, but a bit differently.

Quote

shift
NWSERVER_START="$NWSERVER_START $*"
$NWSERVER_START
echo "Starting nwserver please wait.."
sleep 5


if [ "$(pidof nwserver)" ]
then
echo "nwserver is running now"
else
echo "nwserver loading failed.."
EXCODE=1
fi
echo "waiting 3 mins for password before removing"
sleep 180
echo "removing password"
$WAIT_LOADED
;;
stop|restart)
               
               

               


                     Modifié par Calvinthesneak, 13 mars 2011 - 11:11 .
                     
                  


            

Legacy_Skildron

  • Sr. Member
  • ****
  • Posts: 421
  • Karma: +0/-0
Linux boot script question?
« Reply #35 on: March 13, 2011, 11:31:38 pm »


               Just out of curiosity: Why would you want to remove the player password for your server? And if you absolutely don't need a password, why don't you remove it in the nwnplayer.ini file?

Greetings
Skildron
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Linux boot script question?
« Reply #36 on: March 14, 2011, 02:31:58 am »


               You want to start it up so players can't log in while it's loading.  Then wish players to freely log in once it's loaded and had a chance to run initialization routines and such in the module.
               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
Linux boot script question?
« Reply #37 on: March 16, 2011, 08:34:23 pm »


               Hey guys ...did you notice. The script works great for just reloading nwserver program unless the computer itself reboots .I have to manually delete the in.fifo and out.fifo files from my directory after the computer reboots for the script to work again.I was wondering should I somehow have these files deleted on system start up?
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Linux boot script question?
« Reply #38 on: March 17, 2011, 12:05:14 am »


               You shouldn't ever need to create or delete the fifo files.  I made that mistake the very first time.  It should run all on it's own, soon as the script terminates the files should self delete.  Even if they didn't delete, the fifos should be empty, and just resume feeding buffer commands.
               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
Linux boot script question?
« Reply #39 on: April 07, 2011, 04:27:39 pm »


               empty -f will not work with precreated fifo files so nwserver never starts. I could not test with nwnx2 because I don't have it, but with plain nwserver, everything works and you can communicate with nwserver via the nwservctl.sh script. Bear in mind, though, that lots of server commands are set up in a way so that they don't give output on the console. I don't know wether nwserver would create output on those commands, but the script only catches output for status, help and listbans. All other commands stay silent, even if they normally would give output.



Yes script works great until PC crashes leaving the in.fifo and out.fifo in the directory since nwserver didnt shut down via the nwservctl.sh which deletes these.What are my choices ?delete these files sytem startup?
               
               

               
            

Legacy_Skildron

  • Sr. Member
  • ****
  • Posts: 421
  • Karma: +0/-0
Linux boot script question?
« Reply #40 on: April 07, 2011, 10:39:32 pm »


               Deleting the files on startup if they exist would be a good choice - I personally would add some commands at the very beginning of nwservctl.sh to that effect, e.g.

test -f ./in.fifo && rm -f in.fifo
test -f ./out.fifo && rm -f out.fifo


That should take care of your problems. Another question is why your server crashes. My own linux server only reboots if I update the kernel - but I don't run nwserver on this machine, so I don't know if it would crash the system. Linux usually  is quite stable, except if your hardware is faulty/unstable. That's a condition Linux abhors.

Greetings
Skildron
               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
Linux boot script question?
« Reply #41 on: April 07, 2011, 11:34:09 pm »


               My other linux server rarely crashed ,this one is a virtual machine.Only crashes when Im not around to delete the fifo files lol.Hows this look ,I added this to my cron tab.....

@reboot   /home/dan/test -f ./in.fifo && rm -f in.fifo
@reboot   /home/dan/test -f ./out.fifo && rm -f out.fifo
               
               

               
            

Legacy_Skildron

  • Sr. Member
  • ****
  • Posts: 421
  • Karma: +0/-0
Linux boot script question?
« Reply #42 on: April 08, 2011, 11:51:33 am »


               This probably won't work, unless you really have a test program in /home/dan. I think you meant to do something like this:

@reboot /usr/bin/test -f /home/dan/in.fifo && rm -f home/dan/in.fifo


Replace /home/dan with the path to your nwserver installation.

Greetings
Skildron
               
               

               
            

Legacy_Calvinthesneak

  • Hero Member
  • *****
  • Posts: 1159
  • Karma: +0/-0
Linux boot script question?
« Reply #43 on: April 10, 2011, 10:13:00 pm »


               I'm still somewhat confused here.

I can run any nwserver console command via the ./nwservctl.sh (nwserver command).

ie ./nwservctl.sh information

I don't know about changing directories.... but I tend to start a new terminal window if I need to do something else.  I'll test a bit later on......
               
               

               
            

Legacy_Skildron

  • Sr. Member
  • ****
  • Posts: 421
  • Karma: +0/-0
Linux boot script question?
« Reply #44 on: April 11, 2011, 08:08:06 am »


               Yes, of course, if you are already in your nwserver directory, then you can do what you need to do with ./nwservctl.sh, but knight_shield wants crond to remove stale fifo files on reboot. As crond does not know about your nwn dirs and usually not even about system paths if they are not given in the crontab, you have to enter the command with full pathnames to work properly.

Greetings
Skildron