• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/hdparm-9.43/debian/

Lines Matching defs:*

0 #!/bin/sh
3 ### BEGIN INIT INFO
4 # Provides: hdparm
5 # Required-Start: mountdevsubfs
6 # Required-Stop:
7 # Should-Start: udev
8 # Default-Start: S
9 # Default-Stop:
10 # Short-Description: Tune IDE hard disks
11 ### END INIT INFO
13 set -e
15 . /lib/lsb/init-functions
17 # Defaults for configuration variables.
18 RAID_WORKAROUND=no
20 # Source the defaults file.
21 [ -e /etc/default/hdparm ] && . /etc/default/hdparm
23 raid_speed_limit_min=
24 raid_speed_limit_max=
26 case "$0" in
27 *hdparm)
28 FIRST=yes
31 FIRST=no
33 esac
35 case "$1" in
36 start|restart|reload|force-reload)
37 UDEV=no
39 hotplug)
40 UDEV=yes
41 [ "$DEVNAME" ] || exit 1
43 stop)
44 exit 0
47 log_failure_msg "Usage: $0 {stop|start|restart|reload|force-reload|hotplug}" >&2
48 exit 3
50 esac
52 if [ "$FORCE_RUN" != 'yes' ]; then
53 if [ -e /proc/cmdline ]; then #linux only - future proofing against BSD and Hurd :)
54 if grep -wq "nohdparm" /proc/cmdline ; then
55 log_warning_msg "Skipping setup of disc parameters."
56 exit 0
57 fi
58 fi
60 raidstat=OK
61 if [ -e /proc/mdstat ]; then
62 if egrep -iq "resync|repair|recover|check" /proc/mdstat; then
63 raidstat=RESYNC
64 fi
65 elif [ -e /proc/rd/status ]; then
66 raidstat=`cat /proc/rd/status`
67 fi
69 if ! [ "$raidstat" = 'OK' ] && [ "$RAID_WORKAROUND" != "yes" ]; then
70 log_failure_msg "RAID status not OK. Exiting."
71 exit 0
72 fi
73 fi
75 slow_down_raid_sync()
77 if [ -f /proc/sys/dev/raid/speed_limit_min ]; then
78 raid_speed_limit_min=`cat /proc/sys/dev/raid/speed_limit_min`
79 echo 0 >/proc/sys/dev/raid/speed_limit_min
80 fi
81 if [ -f /proc/sys/dev/raid/speed_limit_max ]; then
82 raid_speed_limit_max=`cat /proc/sys/dev/raid/speed_limit_max`
83 echo 0 >/proc/sys/dev/raid/speed_limit_max
84 fi
85 sleep 2
88 undo_slow_down_raid_sync()
90 if [ -f /proc/sys/dev/raid/speed_limit_min ] && [ "x$raid_speed_limit_min" != "x" ]; then
91 echo $raid_speed_limit_min >/proc/sys/dev/raid/speed_limit_min
92 fi
93 if [ -f /proc/sys/dev/raid/speed_limit_max ] && [ "x$raid_speed_limit_max" != "x" ]; then
94 echo $raid_speed_limit_max >/proc/sys/dev/raid/speed_limit_max
95 fi
98 set_option()
100 if test -n "$DISC"; then
101 NEW_OPT=
102 for i in $OPTIONS; do
103 if test x${i%${i#??}} != x${1%${1#??}}; then
104 NEW_OPT="$NEW_OPT $i"
105 else
106 NEW_OPT=${NEW_OPT%-q}
107 fi
108 done
109 OPTIONS="$NEW_OPT $OPT_QUIET $1"
110 else
111 NEW_DEF=
112 for i in $DEFAULT; do
113 if test x${i%${i#??}} != x${1%${1#??}}; then
114 NEW_DEF="$NEW_DEF $i"
115 else
116 NEW_DEF=${NEW_DEF%-q}
117 fi
118 done
119 DEFAULT="$NEW_DEF $DEF_QUIET $1"
120 fi
123 eval_value()
125 case $1 in
126 off|0)
127 set_option "$2"0
129 on|1)
130 set_option "$2"1
133 log_failure_msg "Unknown Value for $2: $1"
134 exit 1
136 esac
139 WAS_RUN=0
141 # Turn off RAID synchronisation if needed and asked for.
142 if [ "$raidstat" != 'OK' ] && [ "$RAID_WORKAROUND" = "yes" ]; then
143 slow_down_raid_sync
144 fi
146 # Get blocks as far as the drive's write cache.
147 /bin/sync
149 [ "$UDEV" = 'yes' ] || log_daemon_msg "Setting parameters of disc"
151 DISC=
152 DEFAULT=
153 OPTIONS=
154 DEF_QUIET=
155 OPT_QUIET=
157 egrep -v '^[[:space:]]*(#|$)' /etc/hdparm.conf |
159 while read KEY SEP VALUE; do
160 if [ "$NEXT_LINE" != 'go' ]; then
161 case $SEP in
163 case $KEY in
164 command_line)
165 NEXT_LINE=go
166 unset DISC
167 unset OPTIONS
168 unset OPT_QUIET
169 if [ "$UDEV" = 'yes' ]; then
170 IN_BLOCK=0
171 fi
174 DISC=$KEY
175 OPTIONS=$DEFAULT
176 OPT_QUIET=$DEF_QUIET
177 WAS_RUN=0
178 if [ "$UDEV" = 'yes' ]; then
179 if [ "$DISC" = "$DEVNAME" ]; then
180 IN_BLOCK=1
181 else
182 IN_BLOCK=0
183 fi
184 fi
186 esac
188 =)
189 case $KEY in
190 read_ahead_sect)
191 set_option -a$VALUE
193 lookahead)
194 eval_value $VALUE -A
196 bus)
197 eval_value $VALUE -b
199 apm)
200 set_option -B$VALUE
202 io32_support)
203 set_option -c$VALUE
205 dma)
206 eval_value $VALUE -d
208 defect_mana)
209 eval_value $VALUE -D
211 cd_speed)
212 set_option -E$VALUE
214 mult_sect_io)
215 set_option -m$VALUE
217 prefetch_sect)
218 set_option -P$VALUE
220 read_only)
221 eval_value $VALUE -r
223 spindown_time)
224 case "$VALUE" in
225 *[hms])
226 case "$VALUE" in
227 *h)
228 time=$((${VALUE%h} * 3600))
230 *m)
231 time=$((${VALUE%m} * 60))
233 *s)
234 time=${VALUE%s}
236 esac
237 if [ $time -lt 1260 ]; then # up to 21 minutes
238 new_VALUE=$(($time / 5))
239 if [ $new_VALUE -gt 240 ]; then
240 new_VALUE=240
241 fi
242 if [ $(($new_VALUE * 5)) -ne $time ]; then
243 log_warning_msg "$VALUE not possible, using $(($new_VALUE * 5)) seconds"
244 fi
245 VALUE=$new_VALUE
246 elif [ $time -lt 1800 ]; then
247 if [ $time -ne 1260 ]; then
248 log_warning_msg "$VALUE not possible, using 21 minutes"
249 fi
250 VALUE=252
251 else
252 new_time=$(($time / 1800))
253 if [ $new_time -gt 11 ]; then
254 new_time=11
255 fi
256 if [ $((new_time * 1800)) -ne $time ]; then
257 log_warning_msg "$VALUE not possible, using $(($new_time * 30)) minutes"
258 fi
259 VALUE=$((new_time + 240))
260 fi
262 esac
263 set_option -S$VALUE
265 poweron_standby)
266 eval_value $VALUE -s
268 interrupt_unmask)
269 eval_value $VALUE -u
271 write_cache)
272 eval_value $VALUE -W
274 transfer_mode)
275 set_option -X$VALUE
277 acoustic_management)
278 set_option -M$VALUE
280 keep_settings_over_reset)
281 eval_value $VALUE -k
283 keep_features_over_reset)
284 eval_value $VALUE -K
286 chipset_pio_mode)
287 set_option -p$VALUE
289 security_unlock)
290 set_option --security-unlock $VALUE
292 security_pass)
293 set_option --security-set-pass $VALUE
295 security_disable)
296 set_option --security-disable $VALUE
298 user-master)
299 set_option --user-master $VALUE
301 security_mode)
302 set_option --security-mode $VALUE
304 ROOTFS)
305 ROOTFS=$VALUE
308 log_failure_msg "Unknown option $KEY"
309 undo_slow_down_raid_sync
310 exit 1
312 esac
315 case $KEY in
317 if [ -z "$DISC" ] && [ "$WAS_RUN" != '1' ]; then
318 log_failure_msg "No disk enabled. Exiting"
319 undo_slow_down_raid_sync
320 exit 1
321 fi
322 if [ -n "$OPTIONS" ] && [ -b "$DISC" ]; then
323 if [ -n "$ROOTFS" ]; then
324 if [ "$FIRST" = 'yes' ] && [ "$DISC" != "$ROOTFS" ]; then
325 continue
326 fi
327 if [ "$FIRST" = 'no' ] && [ "$DISC" = "$ROOTFS" ]; then
328 continue
329 fi
330 fi
331 ret=0
332 if [ "$UDEV" = 'yes' ] && [ "$IN_BLOCK" = 1 ]; then
333 # Flush the drive's internal write cache to the disk.
334 /sbin/hdparm -q -f $DISC 2>/dev/null || ret=$?
335 /sbin/hdparm $OPTIONS $DISC 2>/dev/null || ret=$?
336 if [ "$VERBOSE" = 'yes' ]; then
337 log_progress_msg " $DISC"
338 log_end_msg $ret || true
339 fi
340 elif [ "$UDEV" = 'no' ]; then
341 /sbin/hdparm -q -f $DISC 2>/dev/null || ret=$?
342 /sbin/hdparm $OPTIONS $DISC 2>/dev/null || ret=$?
343 WAS_RUN=1
344 log_progress_msg " $DISC"
345 log_end_msg $ret || true
346 fi
347 fi
349 quiet)
350 if [ -n "$DISC" ]; then
351 OPT_QUIET=-q
352 else
353 DEF_QUIET=-q
354 fi
356 standby)
357 set_option -y
359 sleep)
360 set_option -Y
362 disable_seagate)
363 set_option -Z
365 security_freeze)
366 set_option --security-freeze
369 log_failure_msg "unknown option $KEY"
370 undo_slow_down_raid_sync
371 exit 1
373 esac
376 log_failure_msg "unknown separator $SEP"
377 undo_slow_down_raid_sync
378 exit 1
380 esac
381 else
382 $KEY $SEP $VALUE
383 NEXT_LINE=no-go
384 WAS_RUN=1
385 fi
386 done
388 if [ -n "$harddisks" ] && [ -n "$hdparm_opts" ] && [ "$UDEV" = 'no' ]; then
389 ret=0
390 for drive in $harddisks; do
391 WAS_RUN=1
392 /sbin/hdparm -q -f $drive 2>/dev/null|| ret=$?
393 /sbin/hdparm -q $hdparm_opts -q $drive 2>/dev/null|| ret=$?
394 log_progress_msg "$drive "
395 done
396 log_end_msg $ret || true
397 fi
399 if [ "$UDEV" = 'no' -a "$WAS_RUN" = 0 ]; then
400 log_progress_msg "(none)"
401 log_end_msg 0
402 fi
405 # Turn back on RAID synchronisation if we turned it off.
406 if [ "$raidstat" != 'OK' ] && [ "$RAID_WORKAROUND" = "yes" ]; then
407 undo_slow_down_raid_sync
408 fi
410 exit 0