Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / vfsck / bcheckrc-hp_ux110
1 #!/sbin/sh
2 # Copyright 2000, International Business Machines Corporation and others.
3 # All Rights Reserved.
4 #
5 # This software has been released under the terms of the IBM Public
6 # License. For details, see the LICENSE file in the top-level source
7 # directory or online at http://www.openafs.org/dl/license10.html
8
9 # @(#) $Revision$
10 #
11 ##################################################################
12 #
13 # Name :
14 # bcheckrc (afs) - /sbin/fs/afs/bcheckrc
15 #
16 # Description
17 # This file contains scripts/commands necessary to checks
18 # the afs file systems before mounting.
19 #
20 # It should be invoked by the generic bcheckrc script only.
21 #
22 # Input Parameters:
23 # None
24 #
25 # Expected results:
26 # see description.
27 #
28 # Side effects of this test:
29 # none
30 #
31 # Supporting files and Relationship:
32 # i) various "/sbin/fs/afs" commands are used by this script.
33 # ii) generic bcheckrc scrtipt located in the /sbin
34 # directory invokes this script.
35 #
36 #
37 ##################################################################
38 #
39 #
40 # Description - This function will check (fsck) all the afs file systems
41 # in the static file system table, /etc/fstab.
42 #
43 # Result values - status = 0 for success
44 # status = non-0 for failure
45 #
46 # Used (exclusively) by - /sbin/bcheckrc's fsck_afs portion
47 #
48
49
50 #
51 # ROOTSHELL - is the command that gives the user a shell in which
52 # to run fsck interactively. Someday fsck -y should
53 # be fixed to give the right answers to the questions,
54 # rather than always "yes", so this error-prone
55 # interactive fixing business can go away entirely.
56 #
57
58 ROOTSHELL='/sbin/sh'
59
60 # set stty (for manual mode)
61
62 /sbin/stty clocal icanon echo opost onlcr ixon icrnl ignpar erase "^h"
63
64 #
65 # In the remaining part of the function is devoted to the actual
66 # cleaning of the afs file systems.
67 #
68 # 1) run fsck -m and determine if any afs file systems
69 # need cleaning.
70 #
71 # 2) check exit status of fsck -m -
72 #
73 # 0 - indicates (and lists) that this afs file
74 # system was verified clean. Continues to
75 # boot.
76 #
77 # * - indicates and lists the file systems that
78 # were not properly shutdown. File systems
79 # that are corrupt should be fixed before
80 # continuing with the boot.
81 #
82 #
83 # 3) exit the function with the appropriate return status.
84 #
85 #
86 # When the file systems are corrupt the following steps are
87 # taken ...
88 #
89 # 1) fsck_afs(1M) command is invoked using the
90 # following command line - "/sbin/fsck -F afs -P -f"
91 # (refer to the fsck_afs(1M) man page)
92 #
93 # 2) The following actions are taken according to
94 # the appropriate return values ...
95 # 0 - the corrupt file system was fixed.
96 # Continue with boot'ing.
97 # * - could not automatically fix the
98 # corrupt file system, going into
99 # manual mode (shell).
100
101
102
103 afs_partitions_clean()
104 {
105 serverPartition=0 # number of AFS server partitions
106
107 for name in `/sbin/awk ' $0 ~ /^[ \t]*#/ { next }
108 $3 == "afs" { print $1 }' /etc/fstab`
109 do
110 /sbin/fs/hfs/fsck -m $name # check sanity
111 if [ $? -ne 0 ]
112 then
113 echo Cleaning AFS server partition $name
114 /sbin/fs/afs/fsck -P -f $name
115
116 case $? in
117 0)
118 echo AFS server partition $name is fixed
119 ;;
120 *)
121 echo "\007\n\n"
122 echo "UNEXPECTED ERROR DURING fsck -P, RUN fsck INTERACT
123 IVELY!"
124 echo "LOGGING IN AS root FOR MANUAL fsck, ENTER ^D WHEN
125 FILE SYSTEM FIXED"
126 PS1="(in bcheckrc)# "
127 export PS1
128 $ROOTSHELL
129 echo "CONTINUING bcheckrc"
130 ;;
131 esac
132
133
134 fi
135 serverPartition=1
136 done
137
138 if [ serverPartition -ne 1 ]
139 then
140 echo "NO AFS server partitions found"
141 fi
142
143 exit 0
144 }
145
146 afs_partitions_clean
147
148 #*********************************************************************
149 # End of bcheckrc (afs)
150 #*********************************************************************