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