Squeeze のインストール(19)インストーラの再々修正

Debian

インストーラで 温度によるファン制御スクリプトをインストールするよう修正したのだが、 バグってた(藁

修正する。

yasunari@qube:/mnt/disk1/share/hackkit/current$ cp hackkit_squeeze_110109.sh hackkit_squeeze_110110.sh
yasunari@qube:/mnt/disk1/share/hackkit/current$ vi !$
vi hackkit_squeeze_110110.sh
	:
	:
yasunari@qube:/mnt/disk1/share/hackkit/current$ diff -u
yasunari@qube:/mnt/disk1/share/hackkit/current$ !cp:s/cp/diff -u/
diff -u hackkit_squeeze_110109.sh hackkit_squeeze_110110.sh
--- hackkit_squeeze_110109.sh 2011年01月09日 11:54:00.466927365 +0900
+++ hackkit_squeeze_110110.sh 2011年01月10日 11:51:51.081306734 +0900
@@ -264,7 +264,7 @@
 # # smartctl -A -d marvell /dev/sda
 # 194 Temperature_Celsius 0x0022 116 079 000 Old_age Always - 31
- CURTEMP=`smartctl -A -d marvell /dev/sda -s on | sed -n -e 's/^194 .* \([0-9]*\)$/1円/p'`
+ CURTEMP=\`smartctl -A -d marvell /dev/sda -s on | sed -n -e 's/^194 .* \([0-9]*\)$/1円/p'\`
 }
 set_fan_speed()
 {
yasunari@qube:/mnt/disk1/share/hackkit/current$
` (逆シングルクォート)だけだと、ファン制御スクリプト作成時に評価され smartctl が実行されてしまうので、 ファン制御スクリプト実行時に評価されるようにするためには \ で エスケープが必要

やれやれ

単体テスト

インストーラの ファン制御スクリプト作成の部分だけを取り出して念のため単体テスト。
テストには、ファイルサーバにしている lenny の LS-QL を使う。
qube:/tmp# sh make_fancontrol.sh
creating fancontrol ...
qube:/tmp# sh fancontrol
fancontrol: line 33: [: -gt: unary operator expected
fancontrol: line 37: [: -gt: unary operator expected
fancontrol: line 41: [: -gt: unary operator expected
qube:/tmp#
ふげぇ。。

デバッグ

何故、温度が採れていない?
smartctl を実行して確認する。
qube:/tmp# /usr/sbin/smartctl -A -d marvell /dev/sda -s on
smartctl version 5.38 [armv5tel-unknown-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.
=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
 1 Raw_Read_Error_Rate 0x000f 253 100 051 Pre-fail Always - 0
 3 Spin_Up_Time 0x0007 253 253 025 Pre-fail Always - 4416
 4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 171
 5 Reallocated_Sector_Ct 0x0033 100 100 010 Pre-fail Always - 1
 7 Seek_Error_Rate 0x000f 253 253 051 Pre-fail Always - 0
 8 Seek_Time_Performance 0x0025 253 253 015 Pre-fail Offline - 0
 9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 330
 10 Spin_Retry_Count 0x0033 253 253 051 Pre-fail Always - 0
 11 Calibration_Retry_Count 0x0012 253 253 000 Old_age Always - 0
 12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 163
 13 Read_Soft_Error_Rate 0x000e 100 100 000 Old_age Always - 12784
184 Unknown_Attribute 0x0033 253 253 099 Pre-fail Always - 0
187 Reported_Uncorrect 0x0032 253 253 000 Old_age Always - 0
188 Unknown_Attribute 0x0032 253 253 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0022 166 166 000 Old_age Always - 24 (Lifetime Min/Max 15/24)
194 Temperature_Celsius 0x0022 163 163 000 Old_age Always - 25 (Lifetime Min/Max 17/25)
195 Hardware_ECC_Recovered 0x001a 100 100 000 Old_age Always - 12784
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 1
197 Current_Pending_Sector 0x0012 253 253 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0030 253 253 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age Always - 1
200 Multi_Zone_Error_Rate 0x000a 253 253 000 Old_age Always - 0
201 Soft_Read_Error_Rate 0x000a 253 253 000 Old_age Always - 0
202 TA_Increase_Count 0x0032 253 253 000 Old_age Always - 0
qube:/tmp#
194 で始まる行が数字で終わっていないので、
 CURTEMP=`/usr/sbin/smartctl -A -d marvell /dev/sda -s on | sed -n -e 's/^194 .* \([0-9]*\)$/1円/p'`
と、\([0-9]*\)$ ではだめ。

ファンコントロールスクリプトを作ったときに確認した範囲では、 調べた全機種 194 で始まる行は数字で終わっていたのに、、、

対案

sed でパターンマッチできないこともないが、 10 フィールド目だと大変なので、 grep と めったに使わない awk を使う。負け感大(藁
qube:~# /usr/sbin/smartctl -A -d marvell /dev/sda -s on | grep '^194 '
194 Temperature_Celsius 0x0022 184 163 000 Old_age Always - 18 (Lifetime Min/Max 17/25)
qube:~# /usr/sbin/smartctl -A -d marvell /dev/sda -s on | grep '^194 ' | awk '{print 10ドル}'
18
qube:~#
念のため、squeeze の LS-VL でも試す。
root@vl:~# /usr/sbin/smartctl -A -d marvell /dev/sda -s on | grep '^194 ' | awk '{print 10ドル}'
8
root@vl:~#
OK。でも8°Cってどんだけ寒いんだ。

インストーラの再々々修正

qube:/mnt/disk1/share/hackkit/current# diff -u
hackkit_squeeze_110109.sh hackkit_squeeze_110110.sh
diff -u hackkit_squeeze_110109.sh hackkit_squeeze_110110.sh
--- hackkit_squeeze_110109.sh 2011年01月09日 11:54:00.466927365 +0900
+++ hackkit_squeeze_110110.sh 2011年01月10日 23:22:58.210876366 +0900
@@ -263,8 +263,9 @@
 {
 # # smartctl -A -d marvell /dev/sda
 # 194 Temperature_Celsius 0x0022 116 079 000 Old_age Always - 31
+ # 194 Temperature_Celsius 0x0022 181 163 000 Old_age Always - 19 (Lifetime Min/Max 17/25)
- CURTEMP=`smartctl -A -d marvell /dev/sda -s on | sed -n -e 's/^194 .* \([0-9]*\)$/1円/p'`
+ CURTEMP=\`smartctl -A -d marvell /dev/sda -s on | grep '^194 ' | awk '{print \10ドル}'\`
 }
 set_fan_speed()
 {
@@ -301,6 +302,7 @@
 set_fan_speed
 else # stop
 FANSPEED=stop
+ set_fan_speed
 fi
 EOF
qube:/mnt/disk1/share/hackkit/current#
LOW より低いときに、ファンを止められていないバグもつぶした(藁

再単体テスト

インストーラの ファン制御スクリプト作成の部分だけを取り出して再度実行。
qube:/mnt/disk1/share/hackkit/current# cp hackkit_squeeze_110110.sh /tmp
qube:/mnt/disk1/share/hackkit/current# pushd /tmp
/tmp /mnt/disk1/share/hackkit/current
qube:/tmp# mv hackkit_squeeze_110110.sh make_fancontrol.sh
qube:/tmp# vi make_fancontrol.sh
	:
	:
qube:/tmp# sh make_fancontrol.sh
creating fancontrol ...
qube:/tmp# sh fancontrol
19
fan_set_speed stop
qube:/tmp#
いけてそう。。。



Squeeze のインストール(18)LS-VL で再々確認
ハックの記録
LinkStation/玄箱 をハックしよう
Squeeze のインストール(20)LS-VL で再々々確認

Copyright (C) 2003-2011 Yasunari Yamashita. All Rights Reserved.
yasunari @ yamasita.jp 山下康成@京都府向日市

AltStyle によって変換されたページ (->オリジナル) /