Pagina 1 di 1

[Workaround] Spegnere Ubuntu 10.04 server con pulsante

Inviato: mercoledì 5 maggio 2010, 9:48
da Wingman
Ciao a tutti! Sono ancora qui :)

Sul mio server personale quando avevo Hardy 8.04 bastava installare il pacchetto "acpid" per abilitare lo spegnimento del server premendo semplicemente il pulsante di accensione. Ora con lucid invece (installato da zero) non basta più, ma non riesco a capire dove stia il problema.

Se può aiutare ecco il file /etc/acpi/events/powerbtn

Codice: Seleziona tutto

# /etc/acpi/events/powerbtn
# This is called when the user presses the power button and calls
# /etc/acpi/powerbtn.sh for further processing.

# Optionally you can specify the placeholder %e. It will pass
# through the whole kernel event message to the program you've
# specified.

# We need to react on "button power.*" and "button/power.*" because
# of kernel changes.

event=button[ /]power
action=/etc/acpi/powerbtn.sh
Ed ecco il file /etc/acpi/powerbtn.sh

Codice: Seleziona tutto

#!/bin/sh
# /etc/acpi/powerbtn.sh
# Initiates a shutdown when the power putton has been
# pressed.

. /usr/share/acpi-support/power-funcs

# getXuser gets the X user belonging to the display in $displaynum.
# If you want the foreground X user, use getXconsole!
getXuser() {
        user=`pinky -fw | awk '{ if ($2 == ":'$displaynum'" || $(NF) == ":'$displaynum'" ) { print $1; exit; } }'`
        if [ x"$user" = x"" ]; then
                startx=`pgrep -n startx`
                if [ x"$startx" != x"" ]; then
                        user=`ps -o user --no-headers $startx`
                fi
        fi
        if [ x"$user" != x"" ]; then
                userhome=`getent passwd $user | cut -d: -f6`
                export XAUTHORITY=$userhome/.Xauthority
        else
                export XAUTHORITY=""
        fi
        export XUSER=$user
}

# Skip if we just in the middle of resuming.
test -f /var/lock/acpisleep && exit 0

# If the current X console user is running a power management daemon that
# handles suspend/resume requests, let them handle policy This is effectively
# the same as 'acpi-support's '/usr/share/acpi-support/policy-funcs' file.

getXconsole
PMS="gnome-power-manager kpowersave xfce4-power-manager"
PMS="$PMS guidance-power-manager.py dalston-power-applet"

if pidof x $PMS > /dev/null ||
        ( test "$XUSER" != "" && pidof dcopserver > /dev/null && test -x /usr/bin/dcop && /usr/bin/dcop --user $XUSER kded kded loadedModules | grep -q klaptopdaemon) ||
        ( test "$XUSER" != "" && test -x /usr/bin/qdbus && test -r /proc/$(pidof kded4)/environ && su - $XUSER -c "eval $(echo -n 'export '; cat /proc/$(pidof kded4)/environ |t$
    exit
fi

# If all else failed, just initiate a plain shutdown.
/sbin/shutdown -h now "Power button pressed"
Qualche idea? :-\

Re: Spegnere Ubuntu 10.04 server con pulsante

Inviato: mercoledì 5 maggio 2010, 10:33
da Wingman
Dopo qualche indagine ho scoperto che la causa sta nel fatto che il secondo script (powerbtn.sh) si blocca all'altezza di

Codice: Seleziona tutto

#!/bin/sh
# /etc/acpi/powerbtn.sh
# Initiates a shutdown when the power putton has been
# pressed.

. /usr/share/acpi-support/power-funcs
...
perchè non riesce a trovare la cartella "/usr/share/acpi-support/power-funcs", che infatti non esiste. Come workaround è bastato escludere questa sezione dello script (che tra l'altro non ho neanche capito cosa faccia) aggiungendoci un cancelletto davanti

Codice: Seleziona tutto

#!/bin/sh
# /etc/acpi/powerbtn.sh
# Initiates a shutdown when the power putton has been
# pressed.

#. /usr/share/acpi-support/power-funcs
...
Ora tutto fila liscio, ma qualcuno sa perchè quella cartella non esiste? e cosa dovrebbe contenere?  :)