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 automate hibernation for VectorLinux 5.9  (Read 7029 times)

M0E-lnx

  • Administrator
  • Vectorian
  • *****
  • Posts: 3258
How to automate hibernation for VectorLinux 5.9
« on: January 19, 2008, 05:07:11 pm »

I just wrote a simple howto based on my personal experience on getting hibernation to work on my Acer 3680 running VectorLinux-5.9 STD. This should work on most notebooks

http://vectorlinux.com/wiki/doku.php?id=howtos:hibernate

Enjoy! ;)
« Last Edit: January 19, 2008, 05:10:30 pm by M0E-lnx »
Logged

hata_ph

  • Packager
  • Vectorian
  • ****
  • Posts: 3261
  • -- Just being myself --
Re: How to automate hibernation for VectorLinux 5.9
« Reply #1 on: January 19, 2008, 07:45:36 pm »

it work for my Compaq M300........

but I did not set to auto hibernate when I close the lid....
I create a button at the task bar....so when I click it it will hibernate for me...below is the command if anyone want to do the same.....
Quote
/sbin/vsuper /usr/sbin/hibernate

btw, it will ask for the root password. How can I bypass the password? is there a way to add this option to the Quit button for Xfce? so that I have the option to hibernate when i click the Quit button. thanks...

PS: It even resume my wireless card connection after I resume from hibernation....nice.. :):)
Logged

easuter

  • Global Moderator
  • Vectorian
  • *****
  • Posts: 2160
Re: How to automate hibernation for VectorLinux 5.9
« Reply #2 on: January 20, 2008, 03:37:36 am »

I've managed to get my laptop to suspend to ram or suspend to disk when the lid closes without requesting passwords using the ACPID daemon. I can post the scripts I have later today.
Logged

hata_ph

  • Packager
  • Vectorian
  • ****
  • Posts: 3261
  • -- Just being myself --
Re: How to automate hibernation for VectorLinux 5.9
« Reply #3 on: January 20, 2008, 03:54:34 am »

Actually I don't have to auto hibernate when I close the lid. I just want to lock the screen when I close the lid. I have done that. I have create a hibernate button on the task bar just like what I can do on windows. But it will ask for root password and it will be a bonus if I can hibernate without key in the root password every time.

Btw, it would be nice to look at your script.......
« Last Edit: January 20, 2008, 03:58:27 am by hata_ph »
Logged

rbistolfi

  • Packager
  • Vectorian
  • ****
  • Posts: 2317
Re: How to automate hibernation for VectorLinux 5.9
« Reply #4 on: January 20, 2008, 04:52:11 am »

Hi hata,

What about adding "hibernate" to the sudoers? I can't try it now, I am not at my box, but perhaps adding "/usr/sbin/hibernate" to the "SHUTDOWN" line will do it. Be sure to put the full path because user has not /usr/sbin in the path. You can use visudo for safe editing.
Logged
"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!

hata_ph

  • Packager
  • Vectorian
  • ****
  • Posts: 3261
  • -- Just being myself --
Re: How to automate hibernation for VectorLinux 5.9
« Reply #5 on: January 20, 2008, 05:01:50 am »

do you mean add it to here?
Quote
Cmnd_Alias   SHUTDOWN=/sbin/shutdown,/sbin/halt,/sbin/fasthalt,/sbin/reboot,/sbin/fastboot,/usr/libexec/xfsm-shutdown-helper

btw, can anyone post the original /etc/sudoers file to me as I think just now I got modify it by using visudo.........
shit.......really not good using VI... :(:(
Logged

rbistolfi

  • Packager
  • Vectorian
  • ****
  • Posts: 2317
Re: How to automate hibernation for VectorLinux 5.9
« Reply #6 on: January 20, 2008, 05:10:01 am »

Code: [Select]
root:# cat /etc/sudoers
#
# Sample /etc/sudoers file.  (Assumes Linux paths)
#
# ~# chown root.root /etc/sudoers
# ~# chmod 440 /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for the details on how to write a sudoers file.
#

##
# User alias specification
##
#User_Alias     FULLTIMERS=millert,mikef,dowdy
#User_Alias     PARTTIMERS=bostley,jwfox,mccreary

##
# Cmnd alias specification
##
#Cmnd_Alias     DUMPS=/usr/etc/dump,/usr/etc/rdump,/usr/etc/restore,\
#                     /usr/etc/rrestore,/usr/bin/mt
#Cmnd_Alias     KILL=/bin/kill
#Cmnd_Alias     PRINTING=/usr/bin/lpc,/usr/bin/lprm
Cmnd_Alias      SHUTDOWN=/sbin/shutdown,/sbin/halt,/sbin/fasthalt,/sbin/reboot,/sbin/fastboot,/usr/libexec/xfsm-shutdown-helper
Cmnd_Alias      DIAL=/usr/bin/gkdial,/usr/X11R6/bin/xisp
Cmnd_Alias      SERVER=/opt/lampp/lampp
Cmnd_Alias      HW1=/usr/X11R6/bin/flphoto
Cmnd_Alias      HW2=/usr/X11R6/bin/qtparted
Cmnd_Alias      VASM=/sbin/vasm,/sbin/vlapt
Cmnd_Alias      MOUNT1=/lib/udev/vl-hot_mount,/lib/udev/vl-hot_umount,/bin/mount,/bin/umount,/usr/bin/disktype
Cmnd_Alias      PDMOUNT=/usr/X11/bin/mkpdmount,/usr/X11/bin/rmpdmount
Cmnd_Alias      SGMAP=/usr/bin/sg_map
Cmnd_Alias      WIFI=/sbin/iwconfig,/sbin/vwifi2,/sbin/modprobe,/usr/sbin/wifi-radar,/sbin/dhcpcd,/sbin/ifconfig
Cmnd_Alias      SMBMOUNT=/usr/bin/smbmount,/usr/bin/smbumount,/usr/bin/smbclient

#Cmnd_Alias     SHELLS=/bin/sh,/bin/csh,/bin/ksh,\
#                       /bin/tcsh,/bin/rsh,\
#                       /bin/zsh
#Cmnd_Alias     SU=/bin/su
#Cmnd_Alias     VIPW=/usr/bin/vipw,/bin/vipw,/usr/bin/passwd

##
# Host alias specification
##
#Host_Alias     SUN4=bruno,eclipse,moet,anchor
#Host_Alias     SUN3=brazil,columbine
#Host_Alias     DECSTATION=wilkinson,soma,dendrite,thang
#Host_Alias     DECALPHA=widget,thalamus,foobar
#Host_Alias     HPSNAKE=boa,nag,python
#Host_Alias     CSNETS=128.138.243.0,128.138.204.0,128.138.242.0
#Host_Alias     CUNETS=128.138.0.0/255.255.0.0

##
# User specification
##

# root and users in group wheel can run anything on any machine as any user
root            ALL=(ALL) ALL
#%wheel         ALL=(ALL) ALL

# melvin can run anything on any machine without a password
#melvin         ALL=NOPASSWD:ALL

# anyone in the group 'users' can run some programs without a password
%users          ALL=NOPASSWD:SHUTDOWN,DIAL,SERVER,HW1,MOUNT1,SGMAP,PDMOUNT,SMBMOUNT,WIFI

# anyone in the group 'users' can run some programs with a password
%users          ALL=VASM,HW2


# full time sysadmins can run anything on any machine without a password
#FULLTIMERS     ALL=NOPASSWD:ALL
# part time sysadmins may run anything except root shells or su
#PARTTIMERS     ALL=ALL,!SU,!SHELLS

# rodney may run anything except root shells or su on machines in CSNETS
#rodney         CSNETS=ALL,!SU,!SHELLS

# smartguy may run any command on any host in CUNETS (call B address)
#smartguy       CUNETS=ALL

# operator may run maintenance commands and anything in /usr/bin/
#operator       ALL=DUMPS,KILL,PRINTING,SHUTDOWN,HALT,REBOOT,/usr/bin/

# joe may su only to operator
#joe            /bin/su operator

# pete may change passwords for anyone but root
#pete           /bin/passwd [A-z]*,!/bin/passwd root

# bob may run anything except root shells or su on the sun3 and sun4 machines
#bob            SUN4=ALL,!SU,!SHELLS:\
#               SUN3=ALL,!SU,!SHELLS

# jim may run anything on machines in the biglab netgroup
#jim            +biglab=ALL

# users in the secretaries netgroup need to help manage the printers
#+secretaries   ALL=PRINTING

# fred can run /bin/ls as oracle by specifying -u oracle on command line;
# he can also run /bin/date as uid -2 without entering a password
#fred           ALL=(oracle) /bin/ls,(#-2) NOPASSWD:/bin/date

# somedude may su to anyone but root and must give su an argument
#somedude       ALL=/bin/su ?*, !/bin/su root

Here is mine, be careful, a bad sudoers file is the last thing you want.

do you mean add it to here?
Quote
Cmnd_Alias   SHUTDOWN=/sbin/shutdown,/sbin/halt,/sbin/fasthalt,/sbin/reboot,/sbin/fastboot,/usr/libexec/xfsm-shutdown-helper

Yep, so it will look

Cmnd_Alias   
Code: [Select]
SHUTDOWN=/sbin/shutdown,/sbin/halt,/sbin/fasthalt,/sbin/reboot,/sbin/fastboot,/usr/libexec/xfsm-shutdown-helper,/usr/sbin/hibernate
To test it run sudo /usr/sbin/hibernate
Logged
"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!

hata_ph

  • Packager
  • Vectorian
  • ****
  • Posts: 3261
  • -- Just being myself --
Re: How to automate hibernation for VectorLinux 5.9
« Reply #7 on: January 20, 2008, 05:17:39 am »

sudo /usr/sbin/hibernate work in my user account.......thanks..
btw, is VL using /sbin/vsuper instead of sudo?
and how to configure /sbin/vsuper to do the same as sudo?
« Last Edit: January 20, 2008, 05:45:36 am by hata_ph »
Logged

rbistolfi

  • Packager
  • Vectorian
  • ****
  • Posts: 2317
Re: How to automate hibernation for VectorLinux 5.9
« Reply #8 on: January 20, 2008, 05:35:36 am »

/sbin/vsuper shows you the prompt for the root password, it is a script which uses gksu.  I don't think is a sudo equivalent. You want to use it to launch password required apps from the desktop. Vsuper needs a command as argument, for ex. "vsuper gslapt" ask for the root password and gslapt as root is executed. Try vsuper in the console,  as an experiment :)
If you want to avoid the password prompt for every root app in the menu, you should add the app to the sudoers and replace vsuper with sudo in the proper .desktop. I dunno if there is a more easy way.
Logged
"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!

hata_ph

  • Packager
  • Vectorian
  • ****
  • Posts: 3261
  • -- Just being myself --
Re: How to automate hibernation for VectorLinux 5.9
« Reply #9 on: January 20, 2008, 05:45:00 am »

A further checking with the /sbin/vsuper script and found out that it is using kdesu (correct me if I am wrong) instead of sudo. And when I think of it it would be better that don't bypass the root password cause I don't want my VL keep on being hibernate if I accidentally click the hibernate button. I think I will stick with using /sbin/vsuper or remove the /usr/sbin/hibernate from /etc/sudoers.

btw, is there a way to modify the Quit button in xfce to add in the hibernate option?
Logged

rbistolfi

  • Packager
  • Vectorian
  • ****
  • Posts: 2317
Re: How to automate hibernation for VectorLinux 5.9
« Reply #10 on: January 20, 2008, 05:59:57 am »

Yep, to accidentally hibernate can be very annoying.
I checked the menu editor app from Xfce and looks like the "quit" button in the menu can't be edited. I couldn't find a .desktop or similar for it. But looks like you can add a new one to the menu and run the command for hibernation. I couldn't find a way to customize the pop up menu. Perhaps you could get more help from the Xfce guys on that one.

PS: This looks like irc :)
Logged
"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!

easuter

  • Global Moderator
  • Vectorian
  • *****
  • Posts: 2160
Re: How to automate hibernation for VectorLinux 5.9
« Reply #11 on: January 23, 2008, 02:34:44 am »

These are my scripts:

/etc/acpi/acpi_handler.sh:

Code: [Select]
#!/bin/sh
# Default acpi script that takes an entry for all actions

IFS=${IFS}/
set $@
LIDSTATE=$(/bin/sed -ne "/state:/{s/^state:[ ]*\([a-zA-Z]*\)$/\1/p;q}" \
/proc/acpi/button/lid/LID/state)

case "$1" in
  button)
    case "$2" in
power)
if [ "$LIDSTATE" == "open" ]; then
/usr/sbin/presusp
    hibernate -F /etc/hibernate/ram.conf
elif [ "$LIDSTATE" == "closed" ]; then
hibernate -F /etc/hibernate/ususpend-ram.conf
fi
         ;;
lid)
if [ "$LIDSTATE" == "closed" ]; then
/usr/sbin/presusp
hibernate -F /etc/hibernate/ram.conf
elif [ "$LIDSTATE" == "open" ]; then
hibernate -F /etc/hibernate/ususpend-ram.conf
fi
;;
*) logger "ACPI action $2 is not defined"
         ;;
    esac
    ;;
  *)
    logger "ACPI group $1 / action $2 is not defined"
    ;;
esac

acpi_handler.sh will suspend to ram if the lid is closed or if the power button is pushed.

/usr/sbin/presusp is simply a script that has commands in that should be used before suspending, such as unmounting all external storage devices, killing wpa_supplicant and dhcpcd, removing modules:

Code: [Select]
#!/bin/bash

execute_commands() {

killall dhcpcd
killall wpa_supplicant
vlh-umount
umount /mnt/shared
/sbin/ifconfig eth1 down
/sbin/ifconfig eth0 down
/sbin/ifconfig wlan0 down
/sbin/rmmod zd1211rw
/sbin/rmmod ndiswrapper
/sbin/rmmod 8139too

}

Since the acpid daemon runs this as root, there is no need to use sudo. But to let user suspend, I did the following:

1 - Create a new group called hibernate.
Open /etc/group and create a new group called "hibernate" and then add the usernames you want to be part of that group. Here is an example:

Code: [Select]
hibernate::44:easuter
2 - Create entries in /etc/sudoers to allow users belonging to that group to use the scripts without passwords (make a backup of /etc/sudoers before doing this!):

Code: [Select]
visudo
Now enter this text:

Code: [Select]
#Let users that belong to the "hibernate" group use suspend/hibernate commands
#without entering the root password:

Cmnd_Alias HIBERNATE=/usr/sbin/hibernate
Cmnd_Alias PRESUSP=/usr/sbin/presusp
%hibernate ALL=NOPASSWD:HIBERNATE,PRESUSP

Save the file and that should be it!

To run the hibernate script for a suspend to disk, do:

Code: [Select]
sudo /usr/sbin/hibernate
If you want to suspend to ram, then do:

Code: [Select]
sudo /usr/sbin/hibernate -F /etc/hibernate/ram.conf
You can also run the pre-suspend script before any of these commands of course.
Hope this is useful ;)

« Last Edit: January 23, 2008, 03:58:18 am by easuter »
Logged

RJARRRPCGP

  • Member
  • *
  • Posts: 14
Re: How to automate hibernation for VectorLinux 5.9
« Reply #12 on: December 07, 2008, 12:21:27 pm »

I just wrote a simple howto based on my personal experience on getting hibernation to work on my Acer 3680 running VectorLinux-5.9 STD. This should work on most notebooks

http://vectorlinux.com/wiki/doku.php?id=howtos:hibernate

Enjoy! ;)

That page don't exist now.
Logged