added select_system_proxy module
This commit is contained in:
33
modules/select_system_proxy.sh
Normal file
33
modules/select_system_proxy.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# Set system wide proxy if on the good network
|
||||
# This file is part of the init.sh project
|
||||
# Copyright (c) 2019-2021 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
|
||||
# ------------------------------------------------------------------------------
|
||||
# This file is distributed under 3-clause BSD license.
|
||||
# The complete license agreement can be obtained at:
|
||||
# https://opensource.org/licenses/BSD-3-Clause
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_select_system_proxy="0.0.1"
|
||||
export DEP_select_system_proxy="upgrade_dist"
|
||||
|
||||
select_system_proxy()
|
||||
{
|
||||
if [[ -e /etc/apt/apt.conf.d/00proxy ]]; then
|
||||
prnt I "Configuration proxy trouvé, on ajoute le switch."
|
||||
backupdist /etc/rc.local
|
||||
appendfile proxy.rc.local /etc/rc.local
|
||||
else
|
||||
prnt I "Pas de configurtion proxy, rien à faire."
|
||||
fi
|
||||
}
|
||||
|
||||
precheck_select_system_proxy()
|
||||
{
|
||||
:
|
||||
}
|
||||
|
||||
export -f select_system_proxy
|
||||
export -f precheck_select_system_proxy
|
||||
|
||||
# EOF
|
||||
16
repo/common/proxy.rc.local
Normal file
16
repo/common/proxy.rc.local
Normal file
@@ -0,0 +1,16 @@
|
||||
apt_proxy=/etc/apt/apt.conf.d/00proxy
|
||||
proxy_line=$(cat $apt_proxy | awk '{print $2}')
|
||||
proxy_srv=$(echo $proxy_line | cut -d'/' -f 3 | cut -d':' -f 1)
|
||||
|
||||
echo "Le serveur proxy est : $proxy_srv"
|
||||
ping -c1 $proxy_srv &>/dev/null
|
||||
errout=$?
|
||||
if [[ $errout -eq 0 ]]; then
|
||||
echo "Proxy fonctionnel ($errout)"
|
||||
sed -i -e "s/^#Acquire:/Acquire:/" $apt_proxy
|
||||
export http_proxy=$proxy_line
|
||||
export https_proxy=$proxy_line
|
||||
else
|
||||
echo "Pas de proxy ($errout)"
|
||||
sed -i -e "s/^Acquire:/#Acquire:/" $apt_proxy
|
||||
fi
|
||||
Reference in New Issue
Block a user