Menu

[r10367]: / legacy / etc / rc.d / proxy  Maximize  Restore  History

Download this file

35 lines (29 with data), 1.1 kB

#!/bin/sh
# Copyright (c) 2007-2009 Volker Theile (votdev@gmx.de)
# All rights reserved.
#
# Set proxy environment variables in shell settings file (/root/.cshrc).
#

# PROVIDE: proxy
# BEFORE: LOGIN

. /etc/rc.subr
. /etc/configxml.subr

# Defaults
cshrc_config=${cshrc_config:-"/root/.cshrc"}

# Remove proxy settings (HTTP_PROXY, HTTP_PROXY_AUTH, FTP_PROXY and FTP_PROXY_AUTH)
if [ -e ${cshrc_config} ]; then
	/usr/bin/sed -i "" '/^.*[HTTP|FTP]_PROXY[_AUTH]*.*$/d' ${cshrc_config}
fi

# Set proxy settings
/usr/local/bin/xml sel -t \
	-m "//system/proxy/http" \
		-i "count(enable) > 0" -n -v "concat('setenv HTTP_PROXY \"',address,':',port,'\"')" \
			-i "count(auth) > 0" -n -v "concat('setenv HTTP_PROXY_AUTH \"basic:*:',username,':',password,'\"')" -b \
		-b \
	-b \
	-m "//system/proxy/ftp" \
		-i "count(enable) > 0" -n -v "concat('setenv FTP_PROXY \"',address,':',port,'\"')" \
			-i "count(auth) > 0" -n -v "concat('setenv FTP_PROXY_AUTH \"basic:*:',username,':',password,'\"')" -b \
		-b \
	-b \
	${configxml_file} | /usr/local/bin/xml unesc >> ${cshrc_config}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.