You are not logged in.

#1 2012-11-06 15:14:48

Shark
Member
From: /dev/zero
Registered: 2011-02-28
Posts: 686

[SOLVED] ZSH - PATH problem when using script via udev rule

So, i have migrated to zsh and averything is fine except a little PATH problem. Now, i hava a power saving script that is executed when i unplug the power line (via udev rule). Till migration to zsh averything worked fine but when i changed #!/bin/bash to #!/bin/zsh in script, it doesn't work anymore. I found out that script is workable only if i write full paths in it, eg. /sbin/hdparm... instead of hdparm... When i am in terminal or console PATH variable is working fine. I also found out, for now, that the problem are commands in /sbin and /usr/sbin folder - commands in /usr/bin are working just fine.

My PATH:

/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/vendor_perl:/usr/bin/core_perl

I haven't messed up with /etc/zsh/zprofile neither.
My /etc/profile

# /etc/profile

#Set our umask
umask 022

# Set our default path

PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
export PATH

# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
        for profile in /etc/profile.d/*.sh; do
                test -r "$profile" && . "$profile"
        done
        unset profile
fi

# Source global bash config
if test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then
        . /etc/bash.bashrc
fi

# Termcap is outdated, old, and crusty, kill it.
unset TERMCAP

# Man is much better than us at figuring this out
unset MANPATH

My script:

#!/bin/zsh

case "$1" in
  true) # Enable power saving settings on battery
        # Device Runtime-PM
        #for dpcontrol in /sys/bus/{pci,spi,i2c}/devices/*/power/control; do echo auto > $dpcontrol; done
        # Disable nmi_watchdog
        echo 0 > /proc/sys/kernel/nmi_watchdog
        # kernel write mode
        echo 5 > /proc/sys/vm/laptop_mode
        echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
        # disk powersave
        hdparm -S 36 -B 128 /dev/sda &> /dev/null
        for i in /sys/class/scsi_host/host*/link_power_management_policy; do echo min_power > $i; done
        # sound card powersave
        echo 60 > /sys/module/snd_hda_intel/parameters/power_save
        echo Y > /sys/module/snd_hda_intel/parameters/power_save_controller
        # wlan0 powersave
        iwconfig wlan0 power on
        # backlight
        echo 2 > /sys/class/backlight/acpi_video0/brightness
        ;;
  false) # Return to default on AC power
        # Device Runtime-PM
        #for dpcontrol in /sys/bus/{pci,spi,i2c}/devices/*/power/control; do echo on > $dpcontrol; done
        # Enable nmi_watchdog
        echo 1 > /proc/sys/kernel/nmi_watchdog
        # kernel write mode
        echo 0 > /proc/sys/vm/laptop_mode
        echo 500 > /proc/sys/vm/dirty_writeback_centisecs
        # disk powersave
        hdparm -S 0 -B 254 /dev/sda &> /dev/null
        for i in /sys/class/scsi_host/host*/link_power_management_policy; do echo max_performance > $i; done
        # sound card powersave
        echo 300 > /sys/module/snd_hda_intel/parameters/power_save
        echo Y > /sys/module/snd_hda_intel/parameters/power_save_controller
        # wlan0 powersave
        iwconfig wlan0 power off
        #backlight
        echo 13 > /sys/class/backlight/acpi_video0/brightness
        ;;
esac
exit 0

Thanks for any tip!

Last edited by Shark (2012-11-08 09:06:05)


If you have built castles in the air, your work need not be lost; that is where they should be. Now put foundations under them.
Henry David Thoreau

Registered Linux User: #559057

Offline

#2 2012-11-08 09:05:43

Shark
Member
From: /dev/zero
Registered: 2011-02-28
Posts: 686

Re: [SOLVED] ZSH - PATH problem when using script via udev rule

I have solved the problem by creating file /etc/zsh/zshenv and write this down:

path=(/usr/local/bin /usr/bin /bin /usr/local/sbin /usr/sbin /sbin)

If you have built castles in the air, your work need not be lost; that is where they should be. Now put foundations under them.
Henry David Thoreau

Registered Linux User: #559057

Offline

Board footer

Powered by FluxBB