File webif-suse.diff of Package webif

Index: webif_0.3-8/usr/lib/webif/webif.sh
===================================================================
--- webif_0.3-8.orig/usr/lib/webif/webif.sh
+++ webif_0.3-8/usr/lib/webif/webif.sh
@@ -159,9 +159,9 @@ Pragma: no-cache
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 <head>
-<title>$_firmware_name @TR<<Administrative Console>></title>
+<title>$_firmware_name @TR<<Admin Console>></title>
 	<link rel="stylesheet" type="text/css" href="/themes/active/waitbox.css" media="screen" />
 	<link rel="stylesheet" type="text/css" href="/themes/active/webif.css" />
 	<link rel="alternate stylesheet" type="text/css" href="/themes/active/color_white.css" title="white" />
 	<link rel="alternate stylesheet" type="text/css" href="/themes/active/color_brown.css" title="brown" />
@@ -178,9 +178,9 @@ $header_inject_head</head>
 <body $4>$header_inject_body
 
 <div id="container">
 <div id="header">
-	<h1>@TR<<X-Wrt Administration Console>></h1>
+	<h1>@TR<<SUSE Linux Admin Console>></h1>
 	$short_status_frame
 </div>
 
 <div id="mainmenu">
@@ -282,10 +282,10 @@ cat <<EOF
 </fieldset>        
 $_endform
 <hr />
 <div id="footer">
-	<h3>X-Wrt</h3>
-	<em>@TR<<making_usable#End user extensions for OpenWrt>></em>
+	<h3>Admin Console based on X-Wrt</h3>
+	<em>@TR<<making_usable#Admin console for SUSE Linux>></em>
 </div>
 </div> <!-- End #container -->
 </body>
 </html>
Index: webif_0.3-8/usr/lib/webif/functions.sh
===================================================================
--- webif_0.3-8.orig/usr/lib/webif/functions.sh
+++ webif_0.3-8/usr/lib/webif/functions.sh
@@ -14,8 +14,39 @@
 #
 # Misc. functions
 #
 
+ipkg() {
+	case "$1" in
+		list_installed)
+			rpm -qa --queryformat "%{name} - %{version} - %{summary}\n"
+			;;
+		list)
+			zypper sl
+			;;
+		install)
+			zypper in $2
+			;;
+		info)
+			rpm -qi $2
+			;;
+		remove)
+			zypper rm $2
+			;;
+		update)
+			zypper lu
+			;;
+		*)
+			echo "ipkg $* not emulated"
+			;;
+	esac	
+}
+
+nvram()
+{
+	echo "nvram $*"
+}
+
 # workarounds for stupid busybox slowness on [ ]
 empty() {
 	case "$1" in
 		"") return 0 ;;
@@ -131,8 +162,9 @@ validate() {
 
 is_package_installed() {
 	# $1 = package name
 	# returns 0 if package is installed.
+	if false; then
 	for LOCATION in $(grep "^dest\>" /etc/ipkg.conf | cut -d ' ' -f 3); do
 
 		if [ "$LOCATION" = "/" ]; then
 		        paths="$paths /usr/lib/ipkg/status"
@@ -140,34 +172,51 @@ is_package_installed() {
 		        paths="$paths $LOCATION/usr/lib/ipkg/status"
 		fi
 	done
 	grep -q " $1\$" $paths >> /dev/null 2>&1
+	else
+	rpm -q $1 >/dev/null 2&>1
+	fi
 }
 
 install_package() {
 	# $1 = package name or URL
 	# returns 0 if success.
 	# if package is not found, and it isn't a URL, then it'll
 	# try an 'ipkg update' to see if it can locate it. Does
 	# emit output to std devices.
+	if false; then
 	! ipkg install "$1" -force-overwrite -force-defaults && {
 		echo "$1" | grep "://" >> /dev/null
 		! equal "$?" "0" && {
 			# wasn't a URL, so update
 			ipkg update
 			ipkg install "$1" -force-overwrite -force-defaults
 		}
 	}
+	else
+		echo "zypper in $1"
+		echo "Installation of packages not yet supported"
+	fi
 }
 
 remove_package() {
 	# $1 = package name
 	# returns 0 if success.
-	ipkg remove "$1"
+	if false; then
+		ipkg remove "$1"
+	else
+		echo "zypper rm $1"
+		echo "Removing packages not yet supported"
+	fi
 }
 
 update_package_list() {
-	ipkg update >> /dev/null
+	if false; then
+		ipkg update >> /dev/null
+	else
+		zypper sl
+	fi
 }
 
 has_pkgs() {
 	local pcnt=0
Index: webif_0.3-8/usr/lib/webif/apply.sh
===================================================================
--- webif_0.3-8.orig/usr/lib/webif/apply.sh
+++ webif_0.3-8/usr/lib/webif/apply.sh
@@ -407,13 +407,16 @@ switch_language() {
 		! equal "$CONFIG_general_lang" "en" && {
 			log_message "@TR<<apply_Installing_language_pack#Installing language pack>>"
 			# build URL for package
 			#  since the original webif may be installed to, have to make sure we get latest ver
-			webif_version=$(ipkg status webif | awk '/Version:/ { print $2 }')
-			xwrt_repo_url=$(cat /etc/ipkg.conf | grep -i "^src[[:space:]]*X-Wrt[[:space:]]*" | cut -d' ' -f3)
+			#webif_version=$(ipkg status webif | awk '/Version:/ { print $2 }')
+			webif_verion=$(rpm -q webif | sed 's/webif-//')
+			#xwrt_repo_url=$(cat /etc/ipkg.conf | grep -i "^src[[:space:]]*X-Wrt[[:space:]]*" | cut -d' ' -f3)
+			xwrt_repo_url=''
 			# always install language pack, since it may have been updated without package version change
-			ipkg install "${xwrt_repo_url}/webif-lang-${CONFIG_general_lang}_${webif_version}_mipsel.ipk" -force-reinstall -force-overwrite | uniq
-			if equal "$(ipkg status "webif-lang-${CONFIG_general_lang}" |grep "Status:" |grep " installed" )" ""; then
+			#ipkg install "${xwrt_repo_url}/webif-lang-${CONFIG_general_lang}_${webif_version}_mipsel.ipk" -force-reinstall -force-overwrite | uniq
+			#if equal "$(ipkg status "webif-lang-${CONFIG_general_lang}" |grep "Status:" |grep " installed" )" ""; then
+			if false; then
 				log_message "@TR<<apply_Error_installing_language#Error installing language pack>>!"
 				uci_set "webif" "general" "lang" "${CONFIG_orig_general_lang:-en}"
 				uci_commit "webif"
 			else
Index: webif_0.3-8/www/cgi-bin/webif/system-settings.sh
===================================================================
--- webif_0.3-8.orig/www/cgi-bin/webif/system-settings.sh
+++ webif_0.3-8/www/cgi-bin/webif/system-settings.sh
@@ -121,13 +121,13 @@ fi
 #####################################################################
 # initialize forms
 if empty "$FORM_submit"; then
 	# initialize all defaults
-	FORM_hostname="${wan_hostname:-$(nvram get wan_hostname)}"
+	FORM_hostname="${wan_hostname:-$(cat /proc/sys/kernel/hostname)}"
 	FORM_hostname="${FORM_hostname:-OpenWrt}"
-	time_zone_part="${time_zone_part:-$(nvram get time_zone)}"
-	time_zoneinfo_part="${time_zoneinfo_part:-$(nvram get time_zoneinfo)}"
-	FORM_ntp_server="${ntp_server:-$(nvram get ntp_server)}"
+	time_zone_part="${time_zone_part:-$(date +%Z)}"
+	time_zoneinfo_part="${time_zoneinfo_part:-$(grep ^TIMEZONE /etc/sysconfig/clock | sed 's/TIMEZONE="\([^"]*\)"/\1/')}"
+	FORM_ntp_server="${ntp_server:-$(grep server /etc/ntp.conf | grep -v 127 | grep -v '^#' | sed 's/server //' | head -n1)}"
 	time_zone_part="${time_zone_part:-"UTC+0"}"
 	time_zoneinfo_part="${time_zoneinfo_part:-"-"}"
 	FORM_system_timezone="${time_zoneinfo_part}@${time_zone_part}"
 
@@ -152,12 +152,12 @@ hostname|FORM_hostname|@TR<<Host Name>>|
 EOF
 	if equal "$?" 0 ; then
 		time_zone_part="${FORM_system_timezone#*@}"
 		time_zoneinfo_part="${FORM_system_timezone%@*}"
-		save_setting system wan_hostname "$FORM_hostname"
-		save_setting timezone time_zone "$time_zone_part"
-		save_setting timezone time_zoneinfo "$time_zoneinfo_part"
-		save_setting system ntp_server "$FORM_ntp_server"
+		#save_setting system wan_hostname "$FORM_hostname"
+		#save_setting timezone time_zone "$time_zone_part"
+		#save_setting timezone time_zoneinfo "$time_zoneinfo_part"
+		#save_setting system ntp_server "$FORM_ntp_server"
 
 		is_bcm947xx && {
 			case "$FORM_boot_wait" in
 				on|off) save_setting system boot_wait "$FORM_boot_wait";;
Index: webif_0.3-8/etc/config/webif
===================================================================
--- webif_0.3-8.orig/etc/config/webif
+++ webif_0.3-8/etc/config/webif
@@ -1,10 +1,10 @@
 config webif general
 	option lang "en"
-	option firmware_name ""
-	option firmware_version ""
-	option firmware_subtitle "With X-Wrt Extensions"
-	option device_name ""
+	option firmware_name "WebIF2 (X-Wrt) for SUSE"
+	option firmware_version "0.3.8"
+	option firmware_subtitle "Appliance Demo"
+	option device_name "Appliance Device"
 	option use_progressbar ""
 
 config webif syslog
 	option ipaddr ""
Index: webif_0.3-8/www/cgi-bin/webif/system-ipkg.sh
===================================================================
--- webif_0.3-8.orig/www/cgi-bin/webif/system-ipkg.sh
+++ webif_0.3-8/www/cgi-bin/webif/system-ipkg.sh
@@ -117,9 +117,10 @@ equal "$repo_update_needed" "1" && {
 	ipkg update
 	echo "</pre>"
 }
 
-repo_list=$(awk '/src/ { print "<tr class=\"repositories\"><td><a href=\"./system-ipkg.sh?remove_repo_name=" $2 "&amp;remove_repo_url=" $3 "\">@TR<<system_ipkg_removerepo#remove>></a>&nbsp;&nbsp;" $2 "</td><td colspan=\"2\">" $3 "</td></tr>"}' /etc/ipkg.conf)
+#repo_list=$(awk '/src/ { print "<tr class=\"repositories\"><td><a href=\"./system-ipkg.sh?remove_repo_name=" $2 "&amp;remove_repo_url=" $3 "\">@TR<<system_ipkg_removerepo#remove>></a>&nbsp;&nbsp;" $2 "</td><td colspan=\"2\">" $3 "</td></tr>"}' /etc/ipkg.conf)
+repo_list=$(zypper sl | sed -e 's/ *|/|/g' -e 's/| */|/g' -e 's/ *$//g' -e 's/ /\&nbsp/g' -e 's/|/ /g' | awk '{ print "<tr class=\"repositories\"><td><a href=\"./system-ipkg.sh?remove_repo_name=" $5 "&amp;remove_repo_url=" $6 "\">@TR<<system_ipkg_removerepo#remove>></a>&nbsp;&nbsp;" $5 "</td><td colspan=\"2\">" $1":"$5"@"$6" ("$4":"$2":"$3")</td></tr>"}')
 
 display_form <<EOF
 start_form|@TR<<system_ipkg_addrepo#Add Repository>>
 field|@TR<<system_ipkg_reponame#Repo. Name>>
Index: webif_0.3-8/www/cgi-bin/webif/status-basic.sh
===================================================================
--- webif_0.3-8.orig/www/cgi-bin/webif/status-basic.sh
+++ webif_0.3-8/www/cgi-bin/webif/status-basic.sh
@@ -5,24 +5,27 @@
 header "Status" "System" "@TR<<Device Status>>"
 
 echo "<meta http-equiv=\"refresh\" content=\"20\" />"
 
-MEMINFO=$(free | grep "Mem:")
+MEMINFO=$(free -m | grep "Mem:")
 nI="0"
 for CUR_VAR in $MEMINFO; do
 	case "$nI" in
 		1)	TOTAL_MEM=$CUR_VAR;;
-		3)	FREE_MEM=$CUR_VAR
+		3)	FREE_MEM=$CUR_VAR;;
+		5)	BUFF_MEM=$CUR_VAR;;
+		6)	CACHE_MEM=$CUR_VAR
 			break;;
 	esac
 	let "nI+=1"
 done
 
+FREE_MEM=$(expr $FREE_MEM + $BUFF_MEM + $CACHE_MEM)
 USED_MEM=$(expr $TOTAL_MEM - $FREE_MEM)
 MEM_PERCENT_FREE=$(expr $FREE_MEM "*" 100 / $TOTAL_MEM)
 MEM_PERCENT_USED=$(expr 100 - $MEM_PERCENT_FREE)
 
-SWAPINFO=$(free | grep "Swap:")
+SWAPINFO=$(free -m | grep "Swap:")
 nI="0"
 for CUR_VAR in $SWAPINFO; do
 	case "$nI" in
 		1)	TOTAL_SWAP=$CUR_VAR;;
@@ -36,10 +39,10 @@ done
 	USED_SWAP=$(expr $TOTAL_SWAP - $FREE_SWAP)
 	SWAP_PERCENT_FREE=$(expr $FREE_SWAP "*" 100 / $TOTAL_SWAP)
 	SWAP_PERCENT_USED=$(expr 100 - $SWAP_PERCENT_FREE)
 	swap_usage="
-string|<tr><td>@TR<<Swap>>: $TOTAL_SWAP @TR<<KiB>></td><td>
-progressbar|swapuse|@TR<<Used>>: $USED_SWAP @TR<<KiB>> ($SWAP_PERCENT_USED%)|200|$SWAP_PERCENT_USED|$SWAP_PERCENT_USED%||"
+string|<tr><td>@TR<<Swap>>: $TOTAL_SWAP @TR<<MiB>></td><td>
+progressbar|swapuse|@TR<<Used>>: $USED_SWAP @TR<<MiB>> ($SWAP_PERCENT_USED%)|200|$SWAP_PERCENT_USED|$SWAP_PERCENT_USED%||"
 	swap_usage_help="
 helpitem|Swap
 helptext|Helptext Swap#When a program requires more memory than is physically available in the computer, currently unused information can be written to a temporary buffer on the hard disk, called swap, thereby freeing memory."
 }
@@ -57,13 +60,13 @@ USED_CONNECTIONS_PERCENT=$(expr 100 - $F
 #	_uptime="${_uptime#*up }"
 #}
 
 mounts_form=$(
-df | uniq | awk 'BEGIN { mcount=0 };
+df -P --block-size=1048576 | uniq | awk 'BEGIN { mcount=0 };
 	/\// {
 		filled_caption=$5;
-		print "string|<tr><td><strong>"$6"</strong><br /><em>"$1"</em></td><td>"
-		print "progressbar|mount_" mcount "|" $3 "@TR<<KiB>> @TR<<mount_of#of>> " $2 "@TR<<KiB>>|200|" $5 "|" filled_caption "|"; mcount+=1
+		print "string|<tr><td><strong>"$6" "$7"</strong><br /><em>"$1"</em></td><td>"
+		print "progressbar|mount_" mcount "|" $3 "@TR<<MiB>> @TR<<mount_of#of>> " $2 "@TR<<MiB>>|200|" $5 "|" filled_caption "|"; mcount+=1
 		print "</td></tr>"
 	}'
 )
 swap_form=$(cat /proc/swaps | awk 'BEGIN { mcount=0 };
@@ -77,9 +80,9 @@ swap_form=$(cat /proc/swaps | awk 'BEGIN
 			swap_type="@TR<<status_basic_swap_partition#swap partition>>"
 		else
 			swap_type="@TR<<status_basic_swap_file#swap file>>"
 		print "string|<tr><td><strong>"swap_type" "$5"</strong><br /><em>"$1"</em></td><td>"
-		print "progressbar|swap_" mcount "|" $4 "@TR<<KiB>> @TR<<mount_of#of>> " $3 "@TR<<KiB>>|200|" $4 "|" filled_caption "%|"; mcount+=1
+		print "progressbar|swap_" mcount "|" int($4/1024+0.5) "@TR<<MiB>> @TR<<mount_of#of>> " int($3/1024+0.5) "@TR<<MiB>>|200|" $4 "|" filled_caption "%|"; mcount+=1
 		print "</td></tr>"
 	}'
 )
 
@@ -90,10 +93,10 @@ swap_form=$(cat /proc/swaps | awk 'BEGIN
 #end_form|
 
 display_form <<EOF
 start_form|@TR<<RAM Usage>>
-string|<tr><td>@TR<<Total>>: $TOTAL_MEM @TR<<KiB>></td><td>
-progressbar|ramuse|@TR<<Used>>: $USED_MEM @TR<<KiB>> ($MEM_PERCENT_USED%)|200|$MEM_PERCENT_USED|$MEM_PERCENT_USED%||
+string|<tr><td>@TR<<Total>>: $TOTAL_MEM @TR<<MiB>></td><td>
+progressbar|ramuse|@TR<<Used>>: $USED_MEM @TR<<MiB>> ($MEM_PERCENT_USED%)|200|$MEM_PERCENT_USED|$MEM_PERCENT_USED%||
 $swap_usage
 helpitem|RAM Usage
 helptext|Helptext RAM Usage#This is the current RAM usage. The amount free represents how much applications have available.
 $swap_usage_help
Index: webif_0.3-8/www/cgi-bin/webif/status-processes.sh
===================================================================
--- webif_0.3-8.orig/www/cgi-bin/webif/status-processes.sh
+++ webif_0.3-8/www/cgi-bin/webif/status-processes.sh
@@ -127,9 +127,9 @@ echo "</form>"
 <table>
 <tbody>
 <?
 
-proclist=$(echo -n "";ps)
+proclist=$(echo -n ""; ps -eo pid,uname,rss:6,stat,comm)
 echo "$proclist" | grep -v "[p]s " | sed 's/\(.\{5\}\)[[:space:]]\(.\{8\}\)[[:space:]]\(.\{6\}\)[[:space:]]\(.\{4\}\)/\1|\2|\3|\4|/' |
 	awk -F "|" -v interval="$FORM_interval" -v siglist="$signal_list" '
 BEGIN {
 	odd=1
Index: webif_0.3-8/www/cgi-bin/webif/system-editor.sh
===================================================================
--- webif_0.3-8.orig/www/cgi-bin/webif/system-editor.sh
+++ webif_0.3-8/www/cgi-bin/webif/system-editor.sh
@@ -169,10 +169,10 @@ saved_filename="/tmp/.webif/edited-files
 
 empty "$FORM_cancel" || FORM_edit=""
 
 if empty "$FORM_edit"; then
-	(ls -alLe "$FORM_path" 2>/dev/null | sed '/^[^d]/d';
-		ls -alLe "$FORM_path" 2>/dev/null | sed '/^[d]/d') 2>/dev/null | awk \
+	(ls -alL "$FORM_path" 2>/dev/null | sed '/^[^d]/d';
+		ls -alL "$FORM_path" 2>/dev/null | sed '/^[d]/d') 2>/dev/null | awk \
 		-v url="$SCRIPT_NAME" \
 		-v path="$FORM_path" \
 		-f $libdir/common.awk \
 		-f $libdir/browser.awk
Index: webif_0.3-8/usr/lib/webif/browser.awk
===================================================================
--- webif_0.3-8.orig/usr/lib/webif/browser.awk
+++ webif_0.3-8/usr/lib/webif/browser.awk
@@ -12,18 +12,18 @@ BEGIN {
 	print "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>"
 	print "</tr>"
 	odd=0
 	# do not let the user to make wrong things (hm, at least some of them)
-	xdirectory="^(/bin$|/bin/$|/dev$|/dev/.*$|/etc$|/jffs$|/lib$|/lib/modules$|/lib/modules/.*$|/mnt$|/proc$|/proc/.*$|/rom$|/rom/.*$|/sbin$|/sys$|/sys/.*$|/usr$|/usr/bin$|/usr/lib$|/usr/lib/webif$|/usr/sbin$|/usr/share$|/www$|/www/.*$|/www/themes/.*$|/www/cgi-bin/webif$)"
+	xdirectory="^(/bin$|/bin/$|/dev$|/dev/.*$|/etc$|/jffs$|/lib$|/lib64$|/lib/modules$|/lib/modules/.*$|/mnt$|/proc$|/proc/.*$|/rom$|/rom/.*$|/sbin$|/sys$|/sys/.*$|/usr$|/usr/bin$|/usr/lib$|/usr/lib64$|/usr/lib/webif$|/usr/sbin$|/usr/share$|/www$|/www/.*$|/www/themes/.*$|/www/cgi-bin/webif$)"
 	xdownload="^(/dev$|/dev/.*$|/proc$|/proc/.*$|/sys$|/sys/.*$)"
-	xedit="^(/dev$|/dev/.*$|/lib$|/lib/modules/.*$|/proc$|/proc/.*$|/rom$|/rom/.*$|/sys$|/sys/.*$)"
-	xdelete="^(/dev$|/dev/.*$|/lib$|/lib/modules/.*$|/proc$|/proc/.*$|/rom$|/rom/.*$|/sys$|/sys/.*$)"
+	xedit="^(/dev$|/dev/.*$|/lib$|/lib64$|/usr/lib$|/usr/lib64$|/lib/modules/.*$|/proc$|/proc/.*$|/rom$|/rom/.*$|/sys$|/sys/.*$)"
+	xdelete="^(/dev$|/dev/.*$|/lib$|/lib64$|/usr/lib$|/usr/lib64$|/lib/modules/.*$|/proc$|/proc/.*$|/rom$|/rom/.*$|/sys$|/sys/.*$)"
 }
 
 {
 	type = substr($1, 1, 1);
-	fname = $11
-	for (i = 12; i <= NF; i++)
+	fname = $9
+	for (i = 10; i <= NF; i++)
 		fname = fname " " $i
 	line = ""
 	fullpath = path "/" fname
 	gsub(/^\/\//, "/", fullpath)
@@ -37,9 +37,9 @@ BEGIN {
 		print "<tr class=\"odd\">"
 		odd++
 	}
 	finfo = "@TR<<browser_Permissions#Permissions>>: " substr($1,2) "<br />@TR<<browser_Owner#Owner>>: " $3 "<br />@TR<<browser_Group#Group>>: " $4 "<br />@TR<<browser_Time#Time>>: " $6
-	for (i=7; i<=10; i++) finfo = finfo " " $i
+	for (i=7; i<=8; i++) finfo = finfo " " $i
 }
 
 type == "d" {
 	if (fname == "..") {
Index: webif_0.3-8/www/themes/xwrt/webif.css
===================================================================
--- webif_0.3-8.orig/www/themes/xwrt/webif.css
+++ webif_0.3-8/www/themes/xwrt/webif.css
@@ -60,9 +60,9 @@ hr,
 	color: #ccc;
 	background-color: #51779e;
 }
 
-#header h1 { display: none; }
+/* #header h1 { display: none; } */
 
 /* ---  Short-status  --- */
 #header #short-status {
 	position: absolute;
openSUSE Build Service is sponsored by