I am trying to make a bash script to let the user to configure the proxy for the Konsole using the KDE proxy configarator gui to be able to use wget and apt-get. I did the following:
Code:
---------------- start -------------------------
#!/bin/bash
## 1st will open KDE proxy configarator
kcmshell proxy
## 2nd will copy the settings to /etc/apt/apt.conf
CONF_DIR=~/.kde/share/config
ftp_Prox=`grep "^ftpProxy=" "${CONF_DIR}/kioslaverc" | sed -e 's/.*=\(.*\)/\1/'`
htp_Prox=`grep "^httpProxy=" "${CONF_DIR}/kioslaverc" | sed -e 's/.*=\(.*\)/\1/'`
htps_Prox=`grep "^httpsProxy=" "${CONF_DIR}/kioslaverc" | sed -e 's/.*=\(.*\)/\1/'`
echo "APT::Cache-Limit 20000000;" > /etc/apt/apt.conf
echo "Apt::Get::Purge;" >> /etc/apt/apt.conf
echo "Acquire{" >> /etc/apt/apt.conf
echo 'FTP::proxy' '"'$ftp_Prox'"'';' >> /etc/apt/apt.conf
echo 'HTTP::proxy' '"'$htp_Prox'"'';' >> /etc/apt/apt.conf
echo 'HTTPS::proxy' '"'$htps_Prox'"'';' >> /etc/apt/apt.conf
echo "}" >> /etc/apt/apt.conf
------------------- End ---------------------------
But the problem, the file I am trying to write the setting in (/etc/apt/apt.conf) requires root prevlige. Is there a way to aquire such prevlige using Xdialoge or kdialoge? I know how to do it from command line as follows:
Code:
if [ $(id -u) != 0 ]; then
echo You have to be root to run this script.
exec su -c "$0" || echo authorization failed. && exit 1
fi
but I do not want the user to see the command line.