VectorLinux

Please login or register.

Login with username, password and session length
Advanced search  

News:

Visit our home page for VL info. For support and documentation, visit the Vector Linux Knowledge Center or search the Knowledge Center and this Forum using the search box above.

Author Topic: How to run a command before shutdown in Vector Linux Ligth 6? [Solved]  (Read 2962 times)

arthurg

  • Member
  • *
  • Posts: 6

is there a way to run a command before shutdown  the system?

I want to run the following command:
Quote
/opt/lampp/lampp stop

Thanks for the help.
« Last Edit: September 15, 2011, 02:43:34 pm by arthurg »
Logged

nightflier

  • Administrator
  • Vectorian
  • *****
  • Posts: 4085
Re: How to run a command before shutdown in Vector Linux Ligth 6?
« Reply #1 on: September 09, 2011, 01:37:02 pm »

Assuming VL6 Light with default IceWM:

In a text editor, open the file "~/.icewm/shutdown-dialog.sh"
- find this line:
      <action>"sudo /sbin/shutdown -h now"</action>
and add a line above it like this:
      <action>"/opt/lampp/lampp stop"</action>

You should do the same to the reboot line:
      <action>"sudo /sbin/shutdown -r now"</action>


Logged

arthurg

  • Member
  • *
  • Posts: 6
Re: How to run a command before shutdown in Vector Linux Ligth 6?
« Reply #2 on: September 09, 2011, 02:38:03 pm »

Thanks for your answer, but I forget to write that Im not using Xwindow with IceWM, Im using Vector Linux in console mode as a server (because is better and smaller than ubuntu server, for me).

So, it is possible to execute the command "/opt/lampp/lampp stop" before shutdown without a window system?

Logged

pierce.jason

  • Packager
  • Vectorite
  • ****
  • Posts: 250
Re: How to run a command before shutdown in Vector Linux Ligth 6?
« Reply #3 on: September 12, 2011, 02:53:34 pm »

How are you starting your lampp server? Manually or do you have a script in /etc/rc.d?

In VL7 I have a file /etc/init.d/sample/lampp. This seems to run /opt/lampp/lamppd. It has the normal Start Stop Status Restart and Reload like all our /etc/init.d scripts.

If you copy this file from /etc/init.d/sample into /etc/init.d/ I believe you should be all set. After that you can use VASM or VasmCC to add lampp to your runlevel. It will then startup automatically with your system and shutdown automatically with your system. If this init script is too outdated and won't work for you, you can copy the one from /opt/lampp/lampp into the same location.

If you don't want it to start automatically, but do want it to shutdown automatically... You could add a line near the top of /etc/rc.d/rc.K that runs '/etc/init.d/lampp stop'. Alternatively you could manually create a symlink in rc#.d (where # is your default runlevel). A symlink named such as K##lampp pointing to ../init.d/lampp is what you would want here (## here is a number that controls what order the symlink is ran, in relation to the other symlinks in that directory).
Logged
pierce.jason
Email: $(echo -e "moc\x2eliamg\x40nosaj.ecreip" | rev)

M0E-lnx

  • Administrator
  • Vectorian
  • *****
  • Posts: 3217
Re: How to run a command before shutdown in Vector Linux Ligth 6?
« Reply #4 on: September 13, 2011, 04:32:01 am »

you could just write a script that executes yhe commands and use that script to shit down
Code: [Select]
#!/bin/bash
/opt/lampp/lampp stop && halt
call this script instead of the shutdown command.

nightflier

  • Administrator
  • Vectorian
  • *****
  • Posts: 4085
Re: How to run a command before shutdown in Vector Linux Ligth 6?
« Reply #5 on: September 15, 2011, 09:05:42 am »

As pierce.jason suggests, I think the best way would be through a script in /etc/rc.d/init.d
If you want to really hack your system, edit /etc/rc.d/rc.K .. this will void your warranty, though. ;)
Logged

arthurg

  • Member
  • *
  • Posts: 6
Re: How to run a command before shutdown in Vector Linux Ligth 6?
« Reply #6 on: September 15, 2011, 02:43:16 pm »

Thanks guys, modifying the file /etc/rc.d/rc.K worked well
Logged