tazpanel diff index.cgi @ rev 438

tazpanel: extended usage help; add restart command.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Tue Apr 07 03:50:06 2015 +0300 (2015-04-07)
parents 678dd43435a3
children 9aeb8fa5beaa
line diff
     1.1 --- a/index.cgi	Mon Apr 06 20:48:48 2015 +0200
     1.2 +++ b/index.cgi	Tue Apr 07 03:50:06 2015 +0300
     1.3 @@ -19,8 +19,7 @@
     1.4  
     1.5  # Check whether a configuration file has been modified after installation
     1.6  
     1.7 -file_is_modified()
     1.8 -{
     1.9 +file_is_modified() {
    1.10  	grep -l "  $1$" $INSTALLED/*/md5sum | while read file; do
    1.11  
    1.12  		# Found, but can we do diff?
    1.13 @@ -35,7 +34,7 @@
    1.14  				diff -abu $tmp$1 $1 | sed "s|$tmp||"
    1.15  				rm -rf $tmp;;
    1.16  			button)
    1.17 -				echo -n '<button name="action" value="diff" data-icon="diff">'$(gettext 'Differences')'</button>';;
    1.18 +				echo -n '<button name="action" value="diff" data-icon="diff">'$(_ 'Differences')'</button>';;
    1.19  		esac
    1.20  		break
    1.21  	done
    1.22 @@ -51,6 +50,20 @@
    1.23  
    1.24  
    1.25  
    1.26 +# Terminal prompt
    1.27 +
    1.28 +term_prompt() {
    1.29 +	if [ "$user" == 'root' ]; then
    1.30 +		local color1='color31' sign='#'
    1.31 +	else
    1.32 +		local color1='color32' sign='$'
    1.33 +	fi
    1.34 +	echo -n "<span class='$color1'>$user@$(hostname)</span>:<span class='color33'>"
    1.35 +	pwd | sed "s|^$HOME|~|" | tr -d '\n'; echo -n "</span>$sign "
    1.36 +}
    1.37 +
    1.38 +
    1.39 +
    1.40  #
    1.41  # Things to do before displaying the page
    1.42  #
    1.43 @@ -202,16 +215,14 @@
    1.44  	*\ terminal\ *|*\ cmd\ *)
    1.45  		# Cmdline terminal
    1.46  
    1.47 -		TITLE=$(gettext 'TazPanel - Terminal'); header; xhtml_header
    1.48 +		header; TITLE=$(gettext 'TazPanel - Terminal'); xhtml_header
    1.49  
    1.50 -		historyfile=/root/.ash_history
    1.51 -		#commands='cat cd date du fdisk help ls ping pwd who wget'
    1.52 +		user="$REMOTE_USER"
    1.53 +		HOME="$(awk -F: -vu=$user '$1==u{print $6}' /etc/passwd)"
    1.54 +		historyfile="$HOME/.ash_history"
    1.55 +
    1.56  		cmd=$(GET cmd)
    1.57 -
    1.58 -		path="$(GET path)"; path="${path:-/tmp}"; cd "${path/~//root}"
    1.59 -		[ "$path" == '/root' ] && path='~'
    1.60 -		user="$REMOTE_USER"
    1.61 -		[ -z "$HOME" ] && HOME=/root  # for apps that modified user settings
    1.62 +		path="$(GET path)"; path="${path:-/tmp}"; cd "$path"
    1.63  
    1.64  		font="${TERM_FONT:-monospace}"
    1.65  		palette=$(echo $TERM_PALETTE | tr A-Z a-z)
    1.66 @@ -265,7 +276,7 @@
    1.67  	<pre class="term $palette" style="font-family: '$font'" onclick="document.getElementById('typeField').focus()">
    1.68  EOT
    1.69  		if [ -n "$cmd" ]; then
    1.70 -			echo -n "<span class='color31'>$user@$(hostname)</span>:<span class='color33'>$path</span># "
    1.71 +			term_prompt
    1.72  			echo "$cmd" | htmlize
    1.73  		fi
    1.74  
    1.75 @@ -280,7 +291,8 @@
    1.76  			eval_gettext 'Downloading to: $dl'; echo
    1.77  			cd $dl; $cmd 2>&1 ;;
    1.78  		cd|cd\ *)
    1.79 -			path="${cmd#cd}"; path="${path:-/root}"; path="$(realpath $path)" ;;
    1.80 +			path="${cmd#cd}"; path="${path:-$HOME}";
    1.81 +			path="$(realpath $path)"; cd "$path" ;;
    1.82  		ls|ls\ *)
    1.83  			$cmd -w80 --color=always 2>&1 | filter_taztools_msgs ;;
    1.84  		cat)
    1.85 @@ -296,11 +308,10 @@
    1.86  			;;
    1.87  	esac
    1.88  
    1.89 -	[ "$path" == '/root' ] && path='~'
    1.90  	cat <<EOT
    1.91  <form id="term">
    1.92 -<div class="cmdline" id="cmdline"><span id="prompt"><span class="color31">$user@$(hostname)</span>:<span class="color33">$path</span># </span><span id="typeField"> </span></div>
    1.93 -<input type="hidden" name="path" value="$path"/>
    1.94 +<div class="cmdline" id="cmdline"><span id="prompt">$(term_prompt)</span><span id="typeField"> </span></div>
    1.95 +<input type="hidden" name="path" value="$(pwd)"/>
    1.96  <input type="hidden" name="cmd" id="cmd"/>
    1.97  </form>
    1.98  </pre>
    1.99 @@ -337,7 +348,9 @@
   1.100  
   1.101  	*\ rmhistory\ *)
   1.102  		# Manage shell commandline history
   1.103 -		historyfile=/root/.ash_history
   1.104 +		user="$REMOTE_USER"
   1.105 +		[ -z "$HOME" ] && HOME="$(awk -F: -vu=$user '$1==u{print $6}' /etc/passwd)"
   1.106 +		historyfile="$HOME/.ash_history"
   1.107  
   1.108  		# Return sed command for removing history lines ('8d12d' to remove 8 and 12 lines)
   1.109  		rms=$(echo $QUERY_STRING | awk 'BEGIN{RS="&";FS="="}{if($1=="rm")printf "%dd", $2}')
   1.110 @@ -609,14 +622,10 @@
   1.111  <p>$(gettext 'SliTaz administration and configuration Panel')<p>
   1.112  
   1.113  <form class="nogap"><!--
   1.114 -EOT
   1.115 -		[ "$REMOTE_USER" == "root" ] && cat <<EOT
   1.116  	--><button name="terminal" data-icon="terminal">$(gettext 'Terminal'        )</button><!--
   1.117 -	--><button name="report"   data-icon="report"  >$(gettext 'Create a report' )</button><!--
   1.118 -EOT
   1.119 -		cat <<EOT
   1.120 -	--><button name="top"      data-icon="proc"    >$(gettext 'Process activity')</button>
   1.121 -</form>
   1.122 +	--><button name="top"      data-icon="proc"    >$(gettext 'Process activity')</button><!--
   1.123 +	--><button name="report"   data-icon="report" data-root>$(gettext 'Create a report' )</button><!--
   1.124 +--></form>
   1.125  
   1.126  <section>
   1.127  	<header>$(gettext 'Summary')</header>