"Fossies" - the Fresh Open Source Software Archive

Member "hdparm-9.65/contrib/ultrabayd" (12 Oct 2016, 864 Bytes) of package /linux/misc/hdparm-9.65.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 VERSION="0.1.000"
    4 
    5 TPCTL="/usr/bin/tpctl"
    6 IDECTL="/sbin/idectl"
    7 
    8 INTERVAL=5
    9 
   10 case "$1" in
   11 -V )
   12     echo "$0: Version $VERSION"
   13     exit 0
   14 ;;
   15 
   16 -daemon )
   17     o_d_type=""
   18     o_d_id=""
   19 
   20     while true; do
   21         d_type=""
   22         d_type_n=""
   23         d_id=""
   24         d_id_n=""
   25 
   26         while read w1 w2 w3 wn; do
   27             case "$w1" in
   28             device )
   29                 case "$w2" in
   30                 type: ) d_type=$w3; d_type_n="$wn";;
   31                 ID: )   d_id=$w3; d_id_n="$wn";;
   32                 esac
   33             ;;
   34             esac
   35 
   36             if [ "$d_type" ] && [ "$d_id" ]; then
   37                 break;
   38             fi
   39         done <<- END
   40             `eval $TPCTL -iU`
   41         END
   42 
   43         if [ "$d_type" != "$o_d_type" ] || [ "$d_id" != "$o_d_id" ]; then
   44             echo -n "\07" > /dev/tty1
   45 
   46             o_d_type="$d_type"
   47             o_d_id="$d_id"
   48 
   49             case "$d_type" in
   50             0x10 )
   51                 eval "$IDECTL 1 rescan"
   52             ;;
   53 
   54             * )
   55                 eval "$IDECTL 1 off"
   56             ;;
   57             esac
   58         fi
   59 
   60         sleep $INTERVAL
   61     done
   62 ;;
   63 
   64 * )
   65     exec nohup $0 -daemon 2>&1 > /dev/null &
   66 ;;
   67 esac
   68