Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vagrantsetup
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
devbox
vagrantsetup
Commits
a09728ca
Commit
a09728ca
authored
Mar 16, 2021
by
Reimar Stier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add restart vpn/squid script
parent
cd62d558
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
restart_squid.bat
files/restart_squid.bat
+6
-0
start-vpn.ps1
files/start-vpn.ps1
+52
-0
No files found.
files/restart_squid.bat
0 → 100644
View file @
a09728ca
Powershell.exe -executionpolicy remotesigned -File C:\documents\scripts\start-vpn.ps1
:: net stop squidsrv
:: net start squidsrv
pause
timeout 10
files/start-vpn.ps1
0 → 100644
View file @
a09728ca
# Start VPN connection if necesary
$vpnName
=
"Daimler Emergency VPN EMEA01"
;
$vpn
=
Get-VpnConnection
-Name
$vpnName
;
if
(
$vpn
.ConnectionStatus -eq
"Disconnected"
){
Write-Host
-ForegroundColor Yellow
"Starting VPN"
rasdial
$vpnName
;
Start-Sleep
-s 2
}
else
{
Write-Host
-ForegroundColor Green
"VPN running"
}
# Wait for VPN connection to connect
$vpn
=
Get-VpnConnection
-Name
$vpnName
;
if
(
$vpn
.ConnectionStatus -ne
"Connected"
){
Write-Host
-ForegroundColor Yellow
"Waiting another three seconds"
Start-Sleep
-s 3
}
Write-Host
-ForegroundColor Yellow
"Ping proxy server"
$name
=
"s415078c.detss.corpintra.net"
;
for
(
$num
=
1 ;
$num
-le 5 ;
$num
++
){
if
(
Test-Connection
-ComputerName
$name
-Count 1 -ErrorAction SilentlyContinue
){
Write-Host
"
$name
,up"
break
}
else
{
Write-Host
"
$name
,down"
}
}
# Restart squid
Write-Host
-ForegroundColor Green
"Restarting squid ..."
try
{
stop-service
squidsrv -ErrorAction Stop
start-service
squidsrv -ErrorAction Stop
}
catch
{
Write-Error
"Failed to restart squid.
`r`n
$(
$_
.Exception.Message
)
"
}
# Check internet connection via proxy
Write-Host
-ForegroundColor Green
"Check request proxy ..."
for
(
$num
=
1 ;
$num
-le 5 ;
$num
++
){
try
{
Invoke-WebRequest
-Proxy
"http://127.0.0.1:3128"
https://ifconfig.me
Write-Host
-ForegroundColor Green
"Proxy responded. Everything fine."
break
}
catch
{
Write-Error
"No proxy connection established.
`r`n
$(
$_
.Exception.Message
)
"
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment