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