summaryrefslogtreecommitdiffstats
path: root/urunlevel/my_linux/Trinux/chkfixed
blob: 4cbb45b29664ed12e6e483a5d0c310231d637659 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/sh
#
# chkfixed - look for legitimate parititions and build mount points
# and populate /etc/proc
#

rm /tmp/partitions 2> /dev/null


[ -d /etc/proc ] || mkdir /etc/proc

if [ -f /etc/tux/config/fstab ] 
then
	echo "fstab found, exiting..."
	exit 1
fi

for i in `grep -v nodev /proc/filesystems`
do
	echo "$i"
done > /etc/proc/availfs

echo "The following filesystems are supported:"
cat /etc/proc/availfs
echo

cdpart=`dmesg | grep D-ROM | grep hd | cut -d: -f1`

if [ "$cdpart" ] 
then
	echo "A CD-ROM was found at $cdpart"
	echo "$cdpart" > /tmp/partitions
fi

partitions=`dmesg | grep ' hd[abcdef]' | cut -d':' -f2`
scsiparts=`dmesg | grep "^ sd[abcdef][12345]"`

echo IDE Partitions: $partitions
echo SCSI Partitions: $scsiparts

for i in $partitions
do

	if  echo "$partitions"  | grep unknown > /dev/null
	then
		echo "Unkown partition"
	else
		echo $i >> /tmp/partitions 
	fi
done

for i in $partitions
do

	if  echo "$partitions"  | grep unknown > /dev/null
	then
		echo "Unkown partition"
	else
		echo $i >> /tmp/partitions 
	fi
done


for i in $scsiparts
do
	echo $i >> /tmp/partitions 
done

if [ ! -f /tmp/partitions ]
then
	echo "No fixed partitions found!"
	exit
fi

sort /tmp/partitions | uniq | grep "hd" > /etc/proc/partitions
sort /tmp/partitions | uniq | grep "sd" >> /etc/proc/partitions

echo "The following partitions were found: "
cat /etc/proc/partitions
echo

##echo "The following filesystems were found: "
for i in `cat /etc/proc/partitions`
do
	mkdir /$i 2> /dev/null

	for j in `cat /etc/proc/availfs`
	do
		echo -n Checking $i:
		if mount -o ro -t $j /dev/$i /$i  2> /dev/null > /dev/null
		then
			echo " found $j"
			echo "$i:$j" >> /etc/tux/config/fstab
			umount /dev/$i 2> /dev/null > /dev/null
		else
			echo
		fi
	done
done