Gentoo Laptop
2. Packages ¶
emerge acpi acpid acpitool cpufreqd cpufrequtils laptop-mode-tools hibernate-script
emerge xfce4-battery xfce4-cpu-freq xfce4-cpugraph xfce4-netload xfce4-sensors xfce4-systemload xfce4-wavelan 3. init.d ¶rc-update add acpid default rc-update add cpufreqd default rc-update add cpufrequtils default rc-update add lm_sensors default rc-update add laptop_mode default 4. ACPI ¶
# /etc/acpi/default.sh # Default acpi script that takes an entry for all actions set $* #echo $* >> /acpilog.txt group=${1%%/*} action=${1#*/} device=$2 id=$3 value=$4
event=ac_adapter action=/etc/acpi/actions/lm_ac_adapter.sh %e
event=battery.* action=/etc/acpi/actions/lm_battery.sh %e
event=button[ /]lid action=/etc/acpi/actions/lm_lid.sh %e
event=button[ /]power action=/etc/acpi/actions/lm_power.sh %e
event=button[ /]sleep action=/etc/acpi/actions/lm_sleep.sh %e
/usr/local/bin/net.sh hibernate-ram /usr/local/bin/netstart.sh
case "$*" in *[13579bdf]) echo 1 > /proc/acpi/video/EGFX/LCD0/brightness ;; *[02468ace]) echo 7 > /proc/acpi/video/EGFX/LCD0/brightness ;; esac 5. cpufreq ¶
6. net.sh ¶
killall -TERM dhcpcd # for bridge start killall -TERM parprouted killall -TERM bcrelay brctl delif br0 eth0 brctl delif br0 wlan0 brctl delif br0 wmaster0 brctl delif br0 tap0 brctl delif br0 tap1 # for bridge end ifconfig eth0 0.0.0.0 ifconfig eth0 down ifconfig wlan0 0.0.0.0 ifconfig wlan0 down # for bridge start ifconfig tap0 0.0.0.0 ifconfig tap1 0.0.0.0 ifconfig br0 down brctl delbr br0 # for bridge end rmmod iwlagn iwlcore # 4965 wireless ¾È¾µ¶§ ¸ðµâÁ¶Â÷ ³»·Á¹ö¸®¸é Àü¿ø¿¡ µµ¿ò Á» µÉ°Í°°´Ù. ±Ù°Å´Â ¾øÀ½. /etc/init.d/iptables stop # for bridge case "$1" in eth0) ifconfig eth0 up # for bridge start brctl addbr br0 brctl addif br0 eth0 dhcpcd br0 -A brctl addif br0 tap0 brctl addif br0 tap1 # for bridge end # not bridge : dhcpcd eth0 -A ;; wlan0) modprobe iwlagn # Àڽſ¡°Ô ¸Â´Â wireless ¸ðµâ ifconfig wlan0 up ESSIDS=`iwlist wlan0 scanning | grep ESSID | sed -e 's/\s*ESSID://g' -e 's/"//g'` KNOWNS="myessid companyessid iptime" # ¿©±â¿¡ ÀÚ½ÅÀÌ »ç¿ëÇÏ´Â essid ¸¦ Àû´Â´Ù. for ESS in $KNOWNS; do ESSID=`echo "$ESSIDS" | grep $ESS` if [[ "$ESSID" != "" ]]; then break fi done if [[ "$ESSID" == "" ]]; then ESSID=`echo "$ESSIDS" | head -n 1` fi iwconfig wlan0 essid $ESSID if [[ "$ESSID" == "companyessid" ]]; then # ¾ÏÈ£°¡ ÇÊ¿äÇϸé ÀÌ·¸°Ô ÇÏ¸é µÈ´Ù. iwconfig wlan0 key s:BF43425FC5B123 iwconfig wlan0 essid companyessid fi echo $ESSID dhcpcd wlan0 -A # for bridge start WLANIP=`ifconfig wlan0 | grep 'inet addr' | awk '{ print $2 }' | awk -F : '{ print $2 }' | awk -F . '{ print $1"."$2"."$3 }'` ifconfig tap0 $WLANIP.222 netmask 255.255.255.0 ifconfig tap1 $WLANIP.223 netmask 255.255.255.0 route del -net 192.168.0.0 netmask 255.255.255.0 tap0 route del -net 192.168.0.0 netmask 255.255.255.0 tap1 /etc/init.d/iptables start parprouted wlan0 tap0 parprouted wlan0 tap1 route add -net 192.168.0.0 netmask 255.255.255.0 tap0 route add -net 192.168.0.0 netmask 255.255.255.0 tap1 bcrelay -i tap0 -o wlan0 -d bcrelay -i tap1 -o wlan0 -d # for bridge end ;; esac
/etc/init.d/iptables start iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE /etc/init.d/iptables save /etc/init.d/iptables stop 7. netstart.sh ¶
NET=/usr/local/bin/net.sh ethstart () { STATE=`ethtool eth0 | grep Duplex | awk -F : '{ print $2 }'` if [[ "$STATE" == " Full" ]]; then $NET eth0 STATE=`ifconfig br0 | grep 'inet addr' | awk '{ print $2 }' | awk -F : '{ print $2 }' | awk -F . '{ print $1"."$2 }'` # bridge ¾È¾²¸é br0 ´ë½Å eth0 if [[ "$STATE" == "169.254" ]]; then wlanstart fi exit fi } wlanstart () { $NET wlan0 STATE=`ifconfig wlan0 | grep 'inet addr' | awk '{ print $2 }' | awk -F : '{ print $2 }' | awk -F . '{ print $1"."$2 }'` if [[ "$STATE" == "169.254" ]]; then $NET exit fi } ethstart wlanstart |
The wise shepherd never trusts his flock to a smiling wolf. |