source: titan/oealliance/sbin/fsck.info @ 42356

Last change on this file since 42356 was 40393, checked in by obi, 7 years ago

add oealliance start scripts

  • Property svn:executable set to *
File size: 4.5 KB
Line 
1#!/bin/sh
2model=`cat /etc/model`
3
4echo "[fsck.info] ---- start ----"
5echo "[fsck.info] $*"
6
7BEGINTIME=`date +%s`
8STARTTIME=`date +"%Y.%m.%d %H.%M.%S"`
9echo "[fsck.info] STARTTIME: $STARTTIME"
10               
11set20() {
12        while [ $count -lt 20 ]; do
13                count=$(($count + 1))
14                maxcount=$(($maxcount + 1))
15                killall -4 infobox > /dev/null 2>&1
16                if [ ! "$model" = "ipbox910" ] && [ ! "$model" = "ipbox900" ] && [ ! "$model" = "ipbox91" ] && [ ! "$model" = "ipbox9000" ]; then
17                        if [ "$model" = "atemio520" ] || [ "$model" = "atemio530" ]; then
18                                echo "C"$maxcount > /dev/vfd
19                        else
20                                echo "FSCK $type: $maxcount %" > /dev/vfd
21                        fi
22                fi     
23        done
24}
25
26echo "$0" | grep "fsck.ext2.gui" > /dev/null
27if [ $? -eq 0 ]; then type=ext2; fi
28echo "$0" | grep "fsck.ext3.gui" > /dev/null
29if [ $? -eq 0 ]; then type=ext3; fi
30echo "$0" | grep "fsck.ext4.gui" > /dev/null
31if [ $? -eq 0 ]; then type=ext4; fi
32echo "$0" | grep "fsck.jfs.gui" > /dev/null
33if [ $? -eq 0 ]; then type=jfs; fi
34echo "$0" | grep "fsck.fat.gui" > /dev/null
35if [ $? -eq 0 ]; then type=vfat; fi
36
37if [ -z "$type" ]; then
38        echo "[fsck.info] only ext2 ; ext3 ; ext4 ; vfat ; jfs supported"
39        exit 1
40fi
41
42dev=`echo $* | tr " " "\n" | tail -n1`
43
44tmpfile=/tmp/fsck.tmp
45logfile=/tmp/fsck.log
46errfile=/tmp/fsck.err
47count=0
48inode=0
49run=0
50oldrun=0
51maxcount=0
52
53(echo 3 > /proc/sys/vm/drop_caches) >/dev/null 2>&1
54sync
55stfbcontrol a 255
56
57killall infobox > /dev/null 2>&1
58rm -f "$tmpfile"
59rm -f "$logfile"
60rm -f "$errfile"
61
62if [ "$type" = "jfs" ] ; then
63        infobox 1000 "FILESYSTEM CHECK - Bitte warten" "     Filesystem Check ($type) auf $dev   " > /dev/null 2>&1 &
64        ln -s /sbin/jfs_fsck /tmp/fsck.$type
65        /tmp/fsck.$type -p -f $* || echo $? > "$errfile"
66elif [ "$type" = "vfat" ] ; then
67        infobox 1000 "FILESYSTEM CHECK - Bitte warten" "     Filesystem Check ($type) auf $dev   " > /dev/null 2>&1 &
68        ln -s /sbin/fsck.vfat /tmp/fsck.$type
69        /tmp/fsck.$type -a -v $* || echo $? > "$errfile"
70else   
71        touch "$tmpfile"
72        (
73                sleep 2
74                ln -s /sbin/e2fsck /tmp/fsck.$type
75                /tmp/fsck.$type -C 1 $* || echo $? > "$errfile"
76                cp "$tmpfile" "$logfile"
77                rm -f "$tmpfile"
78        ) > "$tmpfile" &
79        echo "[fsck.info] Look at your TV screen for progress information..."
80        killall infobox > /dev/null 2>&1
81        infobox 15001 "FILESYSTEM CHECK" "     Filesystem Check ($type) auf $dev   " > /dev/null 2>&1 &
82        if [ "$model" = "atemio520" ] || [ "$model" = "atemio530" ]; then
83                echo "oooo" > /dev/vfd
84        else
85                echo "Check" > /dev/vfd
86        fi
87        sleep 2
88        while [ -e "$tmpfile" ]; do
89                stat=`cat "$tmpfile" | tail -n1`
90                run=`echo $stat | cut -d " " -f1`
91                inode=`echo $stat | cut -d " " -f2`
92                if [ "$run" != 1 ] && [ "$run" != 2 ] && [ "$run" != 3 ] && [ "$run" != 4 ] && [ "$run" != 5 ]; then
93                        continue
94                fi
95       
96                if [ $run -ne $oldrun ]; then
97                        while [ $oldrun -lt $run ] && [ $oldrun -ne 0 ]; do
98                                set20
99                                oldrun=$(($oldrun +1))
100                                count=0
101                        done
102                        max=`echo $stat | cut -d " " -f3`
103                        if [ $max -le 0 ]; then max=1; fi
104                                oldrun=$run
105                                count=0
106                        fi
107
108                if [ ! -z "$max" ]; then
109                        prozent=$((($inode * 20) / $max))
110                        while [ $count -lt $prozent ]; do
111                                count=$(($count + 1))
112                                maxcount=$(($maxcount + 1))
113                                killall -4 infobox > /dev/null 2>&1
114                        if [ ! "$model" = "ipbox910" ] && [ ! "$model" = "ipbox900" ] && [ ! "$model" = "ipbox91" ] && [ ! "$model" = "ipbox9000" ]; then
115                                if [ "$model" = "atemio520" ] || [ "$model" = "atemio530" ]; then
116                                        echo "C"$maxcount > /dev/vfd
117                                else
118                                        echo "FSCK $type: $maxcount %" > /dev/vfd
119                                fi
120                        fi
121                        done
122                fi
123
124    #   sleep 1
125        done
126        if [ $oldrun -eq 0 ]; then oldrun=1; fi
127        while [ $oldrun -le 5 ]; do
128                set20
129                count=0
130                oldrun=$(($oldrun + 1))
131        done
132fi
133
134cat "$logfile"
135echo
136rm -f "$logfile"
137
138killall infobox > /dev/null 2>&1
139
140errcode=0
141if [ -e "$errfile" ]; then errcode=`cat "$errfile"`; fi
142
143if [ $errcode -eq 0 ]; then
144        infobox 5 "FILESYSTEM CHECK" "Filesystem Check: abgeschlossen !!" >/dev/null 2>&1 &
145        if [ "$model" = "atemio520" ] || [ "$model" = "atemio530" ]; then
146                echo "Ende" > /dev/vfd
147        else
148                echo "FSCK: Fertig !" > /dev/vfd
149        fi
150        ret=0
151else
152        infobox 5 "FILESYSTEM CHECK" "Filesystem Check: Fehler (errorcode=$errcode) !!" >/dev/null 2>&1 &
153        if [ "$model" = "atemio520" ] || [ "$model" = "atemio530" ]; then
154                echo "Err" > /dev/vfd
155        else
156                echo "FSCK: Fehler !" > /dev/vfd
157        fi
158        ret=1
159fi
160
161(echo 0 > /proc/sys/vm/drop_caches) >/dev/null 2>&1
162rm -f /tmp/fsck.$type
163
164DONETIME=`date +%s`
165TIME=`expr $DONETIME - $BEGINTIME`
166ENDTIME=`date +"%Y.%m.%d %H.%M.%S"`
167echo "[fsck.info] ENDTIME: $ENDTIME"
168echo "[fsck.info] build time all: ($TIME s) done"
169               
170echo "[fsck.info] ---- ende ----"
171exit $ret
Note: See TracBrowser for help on using the repository browser.