From: Rafal Krypa Date: Fri, 27 Jun 2014 09:46:14 +0000 (+0200) Subject: proxy_settings.sh: modify parsing kernel cmdline for proxy options X-Git-Tag: submit/tizen/20140918.012348~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=10b2d405ed088a9e0ab8f74f90feafd2104e7540;p=platform%2Fadaptation%2Femulator%2Fsystem-plugin-emulator.git proxy_settings.sh: modify parsing kernel cmdline for proxy options This changes script's behavior when a proxy option appears more than once in the kernel command line. Previously only the last occurrence was parsed. But this creates problem with how Tizen qemu passes these options. Proxy settings are appended to the kernel command line based on gconf settings in the hosts environment. When there is no global proxy set, qemu will always append empty "http_proxy=". If a user wants to set proxy only for qemu, but not for the entire system, he may try to manually add settings to cmdline. But Tizen emulator will append empty settings after user settings, overriding it. This patch changes parsing of proxy settings to get only the first occurrence, not the last. It enables a user to give his own proxy only for the emulator. Change-Id: I15834841b115ccb66fb5d67795333e5dc227998b Signed-off-by: Rafal Krypa --- diff --git a/filesystem/etc/profile.d/proxy_setting.sh b/filesystem/etc/profile.d/proxy_setting.sh index 05970da..762e9ee 100755 --- a/filesystem/etc/profile.d/proxy_setting.sh +++ b/filesystem/etc/profile.d/proxy_setting.sh @@ -1,34 +1,20 @@ #!/bin/sh -if grep -q "http_proxy=" /proc/cmdline ; then - __proxy=`sed 's/^.*http_proxy=\([^, ]*\).*$/\1/g' /proc/cmdline` - if [ "x${__proxy}" = "x" ]; then - export "http_proxy=" - else - export "http_proxy=http://${__proxy}/" - fi -fi -if grep -q "https_proxy=" /proc/cmdline ; then - __proxy=`sed 's/^.*https_proxy=\([^, ]*\).*$/\1/g' /proc/cmdline` - if [ "x${__proxy}" = "x" ]; then - export "https_proxy=" - else - export "https_proxy=https://${__proxy}/" - fi -fi -if grep -q "ftp_proxy=" /proc/cmdline ; then - __proxy=`sed 's/^.*ftp_proxy=\([^, ]*\).*$/\1/g' /proc/cmdline` - if [ "x${__proxy}" = "x" ]; then - export "ftp_proxy=" - else - export "ftp_proxy=ftp://${__proxy}/" - fi -fi -if grep -q "socks_proxy=" /proc/cmdline ; then - __proxy=`sed 's/^.*socks_proxy=\([^, ]*\).*$/\1/g' /proc/cmdline` - if [ "x${__proxy}" = "x" ]; then - export "socks_proxy=" - else - export "socks_proxy=socks://${__proxy}/" - fi -fi + +function cmd_get +{ + cat /proc/cmdline | tr -s [:space:] '\n' | grep -m1 "^$1=" | cut -d= -f2 +} + +__proxy=`cmd_get http_proxy` +[ -n "${__proxy}" ] && export "http_proxy=http://${__proxy}/" + +__proxy=`cmd_get https_proxy` +[ -n "${__proxy}" ] && export "https_proxy=https://${__proxy}/" + +__proxy=`cmd_get ftp_proxy` +[ -n "${__proxy}" ] && "ftp_proxy=ftp://${__proxy}/" + +__proxy=`cmd_get socks_proxy` +[ -n "${__proxy}" ] && "socks_proxy=socks://${__proxy}/" + export "no_proxy=localhost,127.0.0.1/8,10.0.0.0/16"