source: trunk/make/mod/files/root/usr/lib/cgi-bin/mod/mounted.cgi

Letzte Änderung dieser Datei war 11038, erstellt von cuma, vor 4 Jahren

status page:

  • use megabyte values for memory
  • use correct decimal separator
  • for partitions too
  • Eigenschaft svn:executable auf * gesetzt
Dateigröße: 3.6 KB
Zeile 
1#!/bin/sh
2ERRORFILE=/tmp/mounted.err
3
4eval "$(modcgi cmd:path mounted)"
5
6do_remount() {
7    mount -o remount "$@" 2> "$ERRORFILE"
8}
9
10do_unmount() {
11    sec_begin '$(lang de:"Unmount-Meldungen" en:"Unmount messages")'
12    echo "<pre class='plain'>"
13    /etc/hotplug/storage unplug "$MOUNTED_PATH" 2> "$ERRORFILE" | html
14    echo "</pre>"
15    sec_end
16}
17
18errpath=""
19if [ "$sec_level" -eq 0 -a -n "$MOUNTED_CMD" ]; then
20    case $MOUNTED_CMD in
21        R)       do_remount -r "$MOUNTED_PATH" ;;
22        W)       do_remount -w "$MOUNTED_PATH" ;;
23        unmount) do_unmount "$MOUNTED_PATH" ;;
24    esac
25    if [ -r "$ERRORFILE" ]; then
26        errpath=$MOUNTED_PATH
27    fi
28fi
29
30# actions=true if action buttons are to be displayed
31if [ "$sec_level" -eq 0 ]; then
32    actions=true
33else
34    actions=false
35fi
36# The status page is called both as /cgi-bin/status.cgi and /cgi-bin/index.cgi
37if [ "$SCRIPT_NAME" != /cgi-bin/pkgstatus.cgi ]; then
38    [ "$MOD_MOUNTED_UMOUNT" != "yes" ] && actions=false
39fi
40formact=$(html "$SCRIPT_NAME${QUERY_STRING:+?$QUERY_STRING}")
41
42sec_begin '$(lang de:"Eingeh&auml;ngte Partitionen" en:"Mounted partitions")'
43
44decim="$(lang de:"," en:".")"
45format_size() {
46    echo "$1B" | sed -e "s/[KMGT]\?B/ &/;s/KB$/kB/;s/\./$decim/g"
47}
48format_path() {
49    echo "$1" | sed -e 's#/#/\&shy;#g'
50}
51
52print_mountpoints() {
53    while read -r fstyp mountopts device path; do
54        echo "$DFOUT" | sed -ne "\#$path# { s/\(% [^ ]*\) /\1\n/g; p; q}" |
55        while read -r device total used free percent path; do
56            print_mp
57        done
58    done
59}
60
61print_mp() {
62    case "$fstyp=$device" in
63        fuse=http*) fstyp="davfs" ;;
64        fuseblk=*)  fstyp="$(blkid $device | sed -nr 's!.*TYPE="([^"]*).*!\1!p')" ;;
65    esac
66    total=$(format_size "$total")
67    used=$(format_size "$used")
68    free=$(format_size "$free")
69    percent=${percent%\%}
70    case $mountopts in
71        ro*) actstatus=o ;;
72        rw*) actstatus=w ;;
73    esac
74    showpath=$(format_path "$path")
75    showdev=$(format_path "$device")
76    rdisabled=$disabledbtn
77    wdisabled=$disabledbtn
78    if [ "$actstatus" = "w" ]; then
79        barstyle="rw"
80        newstatus="r"
81        $actions && rdisabled=''
82    else
83        barstyle="ro"
84        newstatus="w"
85        $actions && wdisabled=''
86    fi
87    echo "<tbody class='$barstyle'>"
88    echo -n "<tr>"
89    echo -n "<td class='path'>$showpath</td><td class='device'>$showdev</td>"
90    echo -n "<td class='fstype'>$fstyp</td>"
91    echo -n '<td class='actions'>'
92    $actions && echo -n '<small>$(lang de:"Mountoptionen" en:"Mount options"):</small>'
93    echo '</td></tr>'
94    echo -n "<tr><td colspan='3' class='free'>${used} $(lang de:"von" en:"of") ${total} $(lang de:"belegt" en:"used"), ${free} $(lang de:"frei" en:"free")</td>"
95    echo '<td colspan="1" class="actions">'
96    echo "<form class='btn' action='$formact' method='post'>"
97    echo "<input type='hidden' name='path' value='$(html "$path")'>"
98    echo "<input class='button' type='submit' name='cmd' value='R' $rdisabled>"
99    echo "<input class='button' type='submit' name='cmd' value='W' $wdisabled>"
100    if $actions; then
101        echo "<input type='submit' name='cmd' value='unmount'>"
102    fi
103    echo '</form>'
104    echo '</td></tr>'
105    if [ "$errpath" = "$path" -a -r "$ERRORFILE" ]; then
106        echo "<tr><td colspan='4'>"
107        echo "<pre class='plain error'>"
108        html < "$ERRORFILE"
109        echo "</pre>"
110        echo "</td></tr>"
111    fi
112    echo "<tr><td colspan='4'>"
113    stat_bar $barstyle $percent
114    echo "</td></tr>"
115    echo "</tbody>"
116}
117
118disabledbtn="disabled='disabled' "
119DFOUT=$(df -hP)
120mfilt=$(mount |
121    sed -rn '
122        \#^/dev/(sd|mapper/)|^https?://|^.* on .* type (jffs|fuse|cifs|yaffs)|^.*:/.* on .* type nfs# {
123            s/^([^ ]+) on (.*) type ([^ ]*) \(([^)]*)\)$/\3 \4 \1 \2/; p
124        }
125    '
126)
127if [ -z "$mfilt" ]; then
128    echo "<p>$(lang de:"Keine gefunden" en:"none found")</p>"
129else
130    echo '<table class="mounted">'
131    echo "$mfilt" | print_mountpoints
132    echo "</table>"
133fi
134sec_end
135
136rm -f "$ERRORFILE"
137# vim: set ts=4:
Hinweis: Hilfe zum Repository-Browser finden Sie in TracBrowser.