ssfs rev 26
Add small server CGI SHell web interface
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Jun 12 05:33:35 2011 +0200 (2011-06-12) |
parents | 7837967d8513 |
children | d19dc31bdfc5 |
files | README web/ssfs.cgi web/style.css |
line diff
1.1 --- a/README Sun Jun 12 05:27:00 2011 +0200 1.2 +++ b/README Sun Jun 12 05:33:35 2011 +0200 1.3 @@ -83,8 +83,7 @@ 1.4 plan for a users files web interface since security if more important, actually 1.5 user home have 0700 mode as so standard web server running user www can't see 1.6 the files. We may implemnt a HTTP Public dir wich coul handle xHTML pages, a 1.7 -wiki, etc. Actually they is some work on a Ssfs server web interface with the 1.8 -goal to provide service status an information. 1.9 +wiki, etc. 1.10 1.11 1.12 Get configs on boot 1.13 @@ -159,6 +158,13 @@ 1.14 login name. 1.15 1.16 1.17 +Server web interface 1.18 +-------------------- 1.19 +Ssfs package provide a small CGI SHell web interface to the server. The goal 1.20 +to provide service status an information. It use the server configuration to 1.21 +know Ssfs virtual disk path and display statistics about the filesystem. 1.22 + 1.23 + 1.24 Development and Bugs 1.25 -------------------- 1.26 If you want to install the latest code to test and help in development you can
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/web/ssfs.cgi Sun Jun 12 05:33:35 2011 +0200 2.3 @@ -0,0 +1,99 @@ 2.4 +#!/bin/sh 2.5 +# 2.6 +echo "Content-Type: text/html" 2.7 +echo "" 2.8 + 2.9 +. /etc/ssfs/ssfs-server.conf 2.10 + 2.11 +notes=/var/cache/ssfs-server.notes 2.12 +root=$SSFS_CHROOT 2.13 +vdisk=$(basename $SSFS_VDISK) 2.14 +vsize=$(du -sh $SSFS_VDISK | awk '{print $1}') 2.15 +vused=$(du -sh $root | awk '{print $1}') 2.16 +users=$(ls $root/home | wc -l) 2.17 +pct=$(df $root | fgrep $root | awk '{print $5}') 2.18 +tz=$(cat /etc/TZ) 2.19 +date=$(date "+%Y-%m-%d %H:%M") 2.20 + 2.21 +# XHTML footer function. 2.22 +xhtml_footer() { 2.23 + cat << EOT 2.24 +</div> 2.25 + 2.26 +<div id="footer"> 2.27 + Ssfs Open Source - <a href="$SCRIPT_NAME?doc">Documentation</a> 2.28 + - <a href="http://scn.slitaz.org/groups/ssfs/">Community</a> 2.29 +</div> 2.30 + 2.31 +</body> 2.32 +</html> 2.33 +EOT 2.34 +} 2.35 + 2.36 +# xHTML 5 header. 2.37 +cat << EOT 2.38 +<!DOCTYPE html> 2.39 +<html xmlns="http://www.w3.org/1999/xhtml"> 2.40 +<head> 2.41 + <title>Ssfs Server</title> 2.42 + <meta charset="utf-8" /> 2.43 + <link rel="shortcut icon" href="favicon.ico" /> 2.44 + <link rel="stylesheet" type="text/css" href="style.css" /> 2.45 +</head> 2.46 +<body> 2.47 + 2.48 +EOT 2.49 + 2.50 +case ${QUERY_STRING} in 2.51 + doc) 2.52 + # Open a dic for content but keep small margins. 2.53 + echo '<div>' 2.54 + echo '<h1>Ssfs Documentation</h1>' 2.55 + echo '<pre>' 2.56 + cat /usr/share/doc/ssfs/README | sed \ 2.57 + -e s"#^[\#|\$]\([^']*\)#<span style='color: brown;'>\0</span>#"g \ 2.58 + -e s"#http://\([^']*\).*#<a href='\0'>\0</a>#"g 2.59 + echo '</pre>' 2.60 + xhtml_footer && exit 0 ;; 2.61 +esac 2.62 + 2.63 +# Content 2.64 +cat << EOT 2.65 +<h1>Ssfs Server</h1> 2.66 + 2.67 +<div id="content"> 2.68 + 2.69 +<h2>Hostname $(hostname)</h2> 2.70 +<pre> 2.71 +Server time : $date 2.72 +Time zone : $tz 2.73 +</pre> 2.74 + 2.75 +<h2>Virtual disk stats</h2> 2.76 +<pre> 2.77 +Virtual disk : $vdisk 2.78 +Ssfs root : $root 2.79 +Vdisk size : $vsize 2.80 +Vdisk usage : $vused 2.81 +Vdisk users : $users 2.82 +</pre> 2.83 + 2.84 +<div class="box" style="padding: 0;"> 2.85 + <div style="background: #d66018; width: $pct;">$pct</div> 2.86 +</div> 2.87 +<p> 2.88 + Filesystem usage provided by 'df' include ext3 reserved space. 2.89 +</p> 2.90 + 2.91 +EOT 2.92 + 2.93 +# Server admin notes for users. 2.94 +if [ -f "$notes" ]; then 2.95 + echo '<h2>Server side notes</h2>' 2.96 + echo '<pre>' 2.97 + cat $notes | sed s"#http://\([^']*\).*#<a href='\0'>\0</a>#"g 2.98 + echo '</pre>' 2.99 +fi 2.100 + 2.101 +xhtml_footer 2.102 +exit 0
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/web/style.css Sun Jun 12 05:33:35 2011 +0200 3.3 @@ -0,0 +1,14 @@ 3.4 +/* CSS style fro Ssfs */ 3.5 + 3.6 +html { height: 102%; } 3.7 +body { font-size: 96%; margin: 0 40px; } 3.8 +h1 { color: #351a0a; border-bottom: 1px dotted #ddd; } 3.9 +h2 { color: #444; font-size: 130%; } 3.10 +pre { font-size: 110%; } 3.11 +pre, .box { 3.12 + padding: 10px; background: #f1f1f1; 3.13 + border: 1px solid #ddd; border-radius: 4px; 3.14 +} 3.15 +#content { margin: 0 10%; } 3.16 +#footer { color: #888; text-align: center; padding: 40px; } 3.17 +#footer a { color: #888; }