slitaz-arm rev 138

cgi-adm: move time setiing to core and misc fixes
author Christophe Lincoln <pankso@slitaz.org>
date Sat Apr 26 12:06:42 2014 +0200 (2014-04-26)
parents 8d2fe01fe16f
children fae61a8c31e0
files cgi-adm/data/style.css cgi-adm/plugins/upload/upload.cgi cgi-adm/tools.cgi rpi/cgi-adm/plugins/rpi_cam/rpi_cam.cgi rpi/cgi-adm/plugins/rpi_config/rpi_config.cgi
line diff
     1.1 --- a/cgi-adm/data/style.css	Sat Apr 26 11:11:16 2014 +0200
     1.2 +++ b/cgi-adm/data/style.css	Sat Apr 26 12:06:42 2014 +0200
     1.3 @@ -43,6 +43,7 @@
     1.4  
     1.5  #content { margin: 4%; text-align: justify; }
     1.6  #notify { padding: 10px; background-color: #ddd; border: 1px solid #00A500; }
     1.7 +#error { padding: 10px; background-color: #ddd; border: 1px solid red; }
     1.8  .button { margin: 25px 0; } .button a { text-decoration: none; }
     1.9  .center { text-align: center; }
    1.10  
    1.11 @@ -76,7 +77,7 @@
    1.12  }
    1.13  
    1.14  pre, input[type="submit"], input[type="text"], textarea, .button a,
    1.15 -#notify, img {
    1.16 +#notify, #error, img {
    1.17  	border-radius: 4px;
    1.18  }
    1.19  
     2.1 --- a/cgi-adm/plugins/upload/upload.cgi	Sat Apr 26 11:11:16 2014 +0200
     2.2 +++ b/cgi-adm/plugins/upload/upload.cgi	Sat Apr 26 12:06:42 2014 +0200
     2.3 @@ -6,7 +6,6 @@
     2.4  case " $(POST) " in
     2.5  	*\ upload\ *)
     2.6  		[ "$updir" ] || updir="/var/cache/uploads"
     2.7 -		[ -d "$updir" ] || mkdir -p ${updir}
     2.8  		upload="true"
     2.9  		name=$(FILE file name)
    2.10  		tmpname=$(FILE file tmpname)
    2.11 @@ -20,6 +19,7 @@
    2.12  
    2.13  if [ "$(GET upload)" ] || [ "$upload" ]; then
    2.14  	[ "$updir" ] || updir="/var/cache/uploads"
    2.15 +	[ -d "$updir" ] || mkdir -p ${updir}
    2.16  	html_header "File Upload"
    2.17  	echo "<h1>File Upload</h1>"
    2.18  	cat << EOT
     3.1 --- a/cgi-adm/tools.cgi	Sat Apr 26 11:11:16 2014 +0200
     3.2 +++ b/cgi-adm/tools.cgi	Sat Apr 26 12:06:42 2014 +0200
     3.3 @@ -70,6 +70,8 @@
     3.4  	mem_used_pct=$(( ( ${mem_used} * 100) / ${mem_total} ))
     3.5  	cat << EOT
     3.6  <pre>
     3.7 +System time  : $(date)
     3.8 +Time zone    : $(cat /etc/TZ)
     3.9  Kernel       : $(uname -snrm)
    3.10  Uptime       : $(uptime | awk '{print $3}' | sed s"/:/h /" | sed s"/,/min/")
    3.11  Network IP   : $(echo $ip | awk '{print $1}')
    3.12 @@ -83,6 +85,7 @@
    3.13  	<form method="get" action="$script">
    3.14  		<input type="submit" name="reboot" value="Reboot system" />
    3.15  		<input type="submit" name="halt" value="Halt system" />
    3.16 +		<input type="submit" name="rdate" value="Set system time" />
    3.17  	</form>
    3.18  </div>
    3.19  EOT
    3.20 @@ -104,11 +107,23 @@
    3.21  case " $(GET) " in
    3.22  	*\ reboot\ *) reboot ;;
    3.23  	*\ halt\ *) halt ;;
    3.24 +	
    3.25  	*\ plugins\ *)
    3.26  		html_header "Plugins"
    3.27  		echo "<h1>Plugins list</h1>"
    3.28  		list_plugins
    3.29  		html_footer ;;
    3.30 +	
    3.31 +	*\ rdate\ *)
    3.32 +		html_header "System time"
    3.33 +		echo "<h1>System time</h1>"
    3.34 +		echo "<pre>"
    3.35 +		echo -n "Old date: "; date
    3.36 +		rdate -s tick.greyware.com
    3.37 +		echo -n "New date: "; date 
    3.38 +		echo "</pre>" 
    3.39 +		html_footer && exit 0 ;;
    3.40 +	
    3.41  	*)
    3.42  		html_header "Admin"
    3.43  		echo "<h1>System admin</h1>"
     4.1 --- a/rpi/cgi-adm/plugins/rpi_cam/rpi_cam.cgi	Sat Apr 26 11:11:16 2014 +0200
     4.2 +++ b/rpi/cgi-adm/plugins/rpi_cam/rpi_cam.cgi	Sat Apr 26 12:06:42 2014 +0200
     4.3 @@ -18,18 +18,20 @@
     4.4  	img { margin: 10px 0; }
     4.5  </style>
     4.6  EOT
     4.7 -		# Wen need VC Tools
     4.8 -		if [ ! -x "/opt/vc/bin/raspivid" ]; then
     4.9 -			echo "<p>VideoCore tools are missing. Please use tazberry \
    4.10 -				to setup the PiCam/NoIR</p>" && exit 0
    4.11 +		# We need VC Tools
    4.12 +		if [ ! -x "/opt/vc/bin/raspistill" ]; then
    4.13 +			echo "<div id='error'>VideoCore tools are missing. \
    4.14 +				Please use tazberry to setup your PiCam/NoIR</div>" 
    4.15 +				html_footer && exit 0
    4.16  		fi
    4.17  		
    4.18  		# raspivid + raspistill
    4.19  		case " $(GET rpi_cam) " in
    4.20  			*\ shot\ *)
    4.21 -				notify "Executing raspistill..."
    4.22 -				echo "$(GET options)" > ${camdir}/shot.opts
    4.23 -				raspistill $(GET options) -o ${camdir}/shot.jpg 
    4.24 +				opts="$(GET options)"
    4.25 +				notify "Executing: raspistill $opts"
    4.26 +				echo "$opts" > ${camdir}/shot.opts
    4.27 +				raspistill ${opts} -o ${camdir}/shot.jpg 
    4.28  				notify hide ;;
    4.29  			*\ rm_shot\ *)
    4.30  				rm -f ${camdir}/shot.jpg ;;
     5.1 --- a/rpi/cgi-adm/plugins/rpi_config/rpi_config.cgi	Sat Apr 26 11:11:16 2014 +0200
     5.2 +++ b/rpi/cgi-adm/plugins/rpi_config/rpi_config.cgi	Sat Apr 26 12:06:42 2014 +0200
     5.3 @@ -5,7 +5,7 @@
     5.4  
     5.5  case " $(GET) " in
     5.6  	*\ audio\ *)
     5.7 -		html_header "Audio Mixer"
     5.8 +		html_header "Audio Control"
     5.9  		case " $(GET audio) " in
    5.10  			*\ auto\ *|*\ analog\ *|*\ hdmi\ *) 
    5.11  				amixer -q cset numid=3  $(GET cset) ;;
    5.12 @@ -60,9 +60,9 @@
    5.13  		html_header "Leds"
    5.14  		case " $(GET leds) " in
    5.15  			*\ act_test\ *)
    5.16 -				notify "ACT Led should be on..."
    5.17 +				notify "ACT Led turned on for 5 sec..."
    5.18  				echo "1" > ${brightness}
    5.19 -				sleep 4
    5.20 +				sleep 5
    5.21  				echo "0" > ${brightness} 
    5.22  				notify hide ;;
    5.23  			*\ act_on\ *)
    5.24 @@ -78,23 +78,13 @@
    5.25  Brightness : $(cat $brightness)
    5.26  </pre>
    5.27  <div class="button">
    5.28 -	<a href="$script?leds=act_test">ACT Test</a>
    5.29 -	<a href="$script?leds=act_on">ACT On</a>
    5.30 -	<a href="$script?leds=act_off">ACT Off</a>
    5.31 +	<a href="$script?leds=act_test">ACT Led test</a>
    5.32 +	<a href="$script?leds=act_on">ACT Led on</a>
    5.33 +	<a href="$script?leds=act_off">ACT Led off</a>
    5.34  </div>
    5.35  EOT
    5.36  		html_footer && exit 0 ;;
    5.37  	
    5.38 -	*\ rdate\ *)
    5.39 -		html_header "System time"
    5.40 -		echo "<h1>System time</h1>"
    5.41 -		echo "<pre>"
    5.42 -		echo -n "Old date: "; date
    5.43 -		rdate -s tick.greyware.com
    5.44 -		echo -n "New date: "; date 
    5.45 -		echo "</pre>" 
    5.46 -		html_footer && exit 0 ;;
    5.47 -	
    5.48  	*\ oclock\ *)
    5.49  		html_header "Overclocking"
    5.50  		cat << EOT
    5.51 @@ -127,8 +117,7 @@
    5.52  
    5.53  <div id="actions">
    5.54  	<form method="get" action="$script">
    5.55 -		<input type="submit" name="rdate" value="Set system time" />
    5.56 -		<input type="submit" name="audio" value="Audio mixer" />
    5.57 +		<input type="submit" name="audio" value="Audio control" />
    5.58  		<input type="submit" name="oclock" value="Overclocking" />
    5.59  		<input type="submit" name="leds" value="Leds" />
    5.60  	</form>