ssfs view web/ssfs.cgi @ rev 109

Remove ashism ==
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Feb 26 12:27:01 2019 +0100 (2019-02-26)
parents aa620b69c929
children
line source
1 #!/bin/sh
2 #
3 echo "Content-Type: text/html"
4 echo ""
6 . /etc/ssfs/ssfs-server.conf
7 export TZ=$(cat /etc/TZ)
9 notes=/var/lib/ssfs/notes
10 root=$SSFS_CHROOT
11 vdisk=$(basename $SSFS_VDISK)
12 vsize=$(du -sh $SSFS_VDISK | awk '{print $1}')
13 vused=$(du -sh $root | awk '{print $1}')
14 users=$(ls $root/home | wc -l)
15 pct=$(df $root | fgrep $root | awk '{print $5}')
16 date=$(date "+%Y-%m-%d %H:%M")
18 # XHTML footer function.
19 xhtml_footer() {
20 cat << EOT
21 </div>
23 <div id="footer">
24 Ssfs Open Source - <a href="$SCRIPT_NAME?doc">Documentation</a>
25 - <a href="http://scn.slitaz.org/groups/ssfs/">Community</a>
26 </div>
28 </body>
29 </html>
30 EOT
31 }
33 # xHTML 5 header.
34 cat << EOT
35 <!DOCTYPE html>
36 <html xmlns="http://www.w3.org/1999/xhtml">
37 <head>
38 <title>Ssfs Server</title>
39 <meta charset="utf-8" />
40 <link rel="shortcut icon" href="favicon.ico" />
41 <link rel="stylesheet" type="text/css" href="style.css" />
42 </head>
43 <body>
45 EOT
47 case ${QUERY_STRING} in
48 doc)
49 # Open a doc for content but keep small margins.
50 echo '<div>'
51 #echo '<h1>Ssfs Documentation</h1>'
52 echo '<pre>'
53 cat /usr/share/doc/ssfs/README | sed \
54 -e s"#^[\#|\$]\([^']*\)#<span style='color: brown;'>\0</span>#"g \
55 -e s"#http://\([^']*\).*#<a href='\0'>\0</a>#"g
56 echo '</pre>'
57 xhtml_footer && exit 0 ;;
58 esac
60 # Content
61 cat << EOT
62 <!-- <h1>Ssfs Server</h1> -->
64 <div id="content">
66 <h2>Ssfs server $(hostname)</h2>
67 <pre>
68 Server time : $date
69 Time zone : $TZ
70 </pre>
72 <h2>Virtual disk stats</h2>
73 <pre>
74 Virtual disk : $vdisk
75 Ssfs root : $root
76 Vdisk size : $vsize
77 Vdisk usage : $vused
78 Vdisk users : $users
79 </pre>
81 <div class="box" style="padding: 0;">
82 <div style="background: #d66018; width: $pct;">$pct</div>
83 </div>
84 <p>
85 Filesystem usage provided by 'df' includes ext3 reserved space.
86 </p>
88 EOT
90 # Server admin notes for users.
91 if [ -f "$notes" ]; then
92 echo '<h2>Server side notes</h2>'
93 echo '<pre>'
94 cat $notes | sed s"#http://\([^']*\).*#<a href='\0'>\0</a>#"g
95 echo '</pre>'
96 fi
98 xhtml_footer
99 exit 0