~ps10gel/ubuntu/xenial/trafficserver/6.2.0

« back to all changes in this revision

Viewing changes to proxy/mgmt2/html2/configure/helper/floppy.cgi

  • Committer: Bazaar Package Importer
  • Author(s): Arno Toell
  • Date: 2011-01-13 11:49:18 UTC
  • Revision ID: james.westby@ubuntu.com-20110113114918-vu422h8dknrgkj15
Tags: upstream-2.1.5-unstable
ImportĀ upstreamĀ versionĀ 2.1.5-unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
#  Licensed to the Apache Software Foundation (ASF) under one
 
4
#  or more contributor license agreements.  See the NOTICE file
 
5
#  distributed with this work for additional information
 
6
#  regarding copyright ownership.  The ASF licenses this file
 
7
#  to you under the Apache License, Version 2.0 (the
 
8
#  "License"); you may not use this file except in compliance
 
9
#  with the License.  You may obtain a copy of the License at
 
10
#
 
11
#      http://www.apache.org/licenses/LICENSE-2.0
 
12
#
 
13
#  Unless required by applicable law or agreed to in writing, software
 
14
#  distributed under the License is distributed on an "AS IS" BASIS,
 
15
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
16
#  See the License for the specific language governing permissions and
 
17
#  limitations under the License.
 
18
FloppyDrive=`echo $QUERY_STRING | gawk 'BEGIN { FS = "&" } {for (i=1;i<=NF;i=i+1) print $i}' | awk -F'=' '/FloppyDrive/{print $2}' | sed "s/%2F/\//g"`
 
19
 
 
20
mounted_drives=0
 
21
media_count=0
 
22
permission_count=0
 
23
scanned_drives_count=0
 
24
 
 
25
echo "<tr>"
 
26
echo "<td nowrap class=\"bodyText\">"
 
27
for drive in `ls /dev/fd?`
 
28
do
 
29
  scanned_drives_count=`expr $scanned_drives_count + 1`
 
30
  escaped_drive=`exec echo $drive | sed 's&/&\\\/&g'`
 
31
  umount $drive &> /dev/null
 
32
  if mount | grep $drive &> /dev/null
 
33
  then
 
34
     echo "<tr>"
 
35
     echo "<td nowrap class=\"bodyText\">"
 
36
     mountDir=`mount | grep $drive | awk '{print $3}'`
 
37
     if [ "$mountDir" = "$FloppyDrive" ];
 
38
     then
 
39
       echo "  <input type=\"radio\" name=\"FloppyDrive\" value=\"$mountDir\" checked>  Floppy - $drive mounted on $mountDir"
 
40
     else
 
41
       echo "  <input type=\"radio\" name=\"FloppyDrive\" value=\"$mountDir\">  Floppy - $drive mounted on $mountDir"
 
42
     fi
 
43
     mounted_drives=`expr $mounted_drives + 1`
 
44
     echo "</td>"
 
45
     echo "</tr>"
 
46
  else
 
47
     drive_permissions=`exec awk "/$escaped_drive/{print $4}" /etc/fstab | awk '{print $4}' | gawk 'BEGIN { FS = "," } {for (i=1;i<=NF;i=i+1) print $i}' | grep -i "user"`
 
48
     if [ -z "$drive_permissions" ]
 
49
     then
 
50
       owner_drive_permissions=`exec awk "/$escaped_drive/{print $4}" /etc/fstab | awk '{print $4}' | gawk 'BEGIN { FS = "," } {for (i=1;i<=NF;i=i+1) print $i}' | grep -i "owner"`
 
51
       owner=`ls -l $drive | awk '{print $3}'`
 
52
       if [ "$owner_drive_permissions" -a $owner = "inktomi" ]
 
53
       then
 
54
          drive_permissions=$owner_drive_permissions
 
55
       else
 
56
          drive_permissions=""
 
57
       fi
 
58
     fi
 
59
     if [ "$drive_permissions" ]
 
60
     then
 
61
       umount $drive &> /dev/null
 
62
       mount $drive &> /dev/null
 
63
       if mount | grep $drive &> /dev/null
 
64
       then
 
65
         echo "<tr>"
 
66
         echo "<td nowrap class=\"bodyText\">"
 
67
         mountDir=`mount | grep $drive | awk '{print $3}'`
 
68
         #echo "  <input type=\"radio\" name=\"FloppyDrive\" value=\"$mountDir\">  Floppy - $drive mounted on $mountDir"
 
69
         if [ "$mountDir" = "$FloppyDrive" ];
 
70
         then
 
71
           echo "  <input type=\"radio\" name=\"FloppyDrive\" value=\"$mountDir\" checked>  Floppy - $drive mounted on $mountDir"
 
72
         else
 
73
           echo "  <input type=\"radio\" name=\"FloppyDrive\" value=\"$mountDir\">  Floppy - $drive mounted on $mountDir"
 
74
         fi
 
75
         mounted_drives=`expr $mounted_drives + 1`
 
76
         media_count=`expr $media_count + 1`
 
77
         echo "</td>"
 
78
         echo "</tr>"
 
79
       else
 
80
         media_count=`expr $media_count + 1`
 
81
       fi
 
82
     else
 
83
        #media_count=`expr $media_count - 1`
 
84
        permission_count=`expr $permission_count + 1` 
 
85
     fi
 
86
  fi
 
87
done;
 
88
 
 
89
if [ "$mounted_drives" -eq 0 -a "$media_count" -eq "$scanned_drives_count" ]
 
90
then
 
91
  echo "&nbsp;&nbsp;No floppy drives found or you don't have permission to mount the disk"
 
92
elif [ "$mounted_drives" -eq 0 -a "$media_count" -ne 0 ]; then
 
93
  echo "&nbsp;&nbsp;No media found in any of the scanned drives"
 
94
elif [ "$mounted_drives" -eq 0 -a "$permission_count" -eq "$scanned_drives_count" ]; then
 
95
  echo "&nbsp;&nbsp;Mount access denied. Please mount and unmount the floppy manually"
 
96
fi
 
97
echo "</td>"
 
98
echo "</tr>"