debian: how to run script on logout but use runlevels?


Results 1 to 4 of 4

Thread: debian: how to run script on logout but use runlevels?

  1. #1
    Join Date
    Jan 2012
    Posts
    11

    debian: how to run script on logout but use runlevels?

    I have a script that shuts down all guest VMs when the host is shutdown.

    The LSB header for the script which Debian uses is:
    ### BEGIN INIT INFO
    # Provides: shutdown_vms
    # Required-Start:
    # Required-Stop: gdm vmware $local_fs $remote_fs $network
    # Default-Start:
    # Default-Stop: 0 2 3 4 5 6
    # Short-Description: Shutdown vms
    # Description: Shutdown vms
    ### END INIT INFO

    When I shutdown/reboot the host, the script successfully shuts down the guest VMs.

    However, how do I make it run so that when user logs out of their gnome-session, it will run the script as well?

    Currently, rc2.d directory shows the following:
    K01shutdown_vms

    but it is not running. Is it because runlevel1-5 is used for booting only while 0/6 are used for stopping services.

    I rather not use rc.local or gdm Postsession scripts.

  2. #2
    Join Date
    Sep 1999
    Location
    Cambridge, UK
    Posts
    509
    Runlevel scripts have nothing to do with user sessions. A gdm postsession script would in fact be a good place to do what you want.

  3. #3
    Join Date
    Jan 2012
    Posts
    11
    What about bringing it back from suspend/sleep? Would runlevel 2 be triggered?

  4. #4
    Join Date
    Sep 1999
    Location
    Cambridge, UK
    Posts
    509
    Nope. In normal operation runlevels are changed: at startup; again at shutdown; apart from that not at all.

    You could try using an acpid trigger for suspend/sleep stuff. Examples.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •