Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
server-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NoCloud
server-utils
Commits
875e65eb
Commit
875e65eb
authored
11 months ago
by
Elian Loraux
Browse files
Options
Downloads
Patches
Plain Diff
switch all comments in English
parent
a42dbfc5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
auto-start-reverseSSHproxy.sh
+17
-12
17 additions, 12 deletions
auto-start-reverseSSHproxy.sh
net-switch.sh
+27
-5
27 additions, 5 deletions
net-switch.sh
with
44 additions
and
17 deletions
auto-start-reverseSSHproxy.sh
+
17
−
12
View file @
875e65eb
#!/usr/bin/env bash
#!/usr/bin/env bash
# ==============================================
# Si tetrix joingnable
#
# This is second part of switch network between WAN and 4G
# This script is Aquila part
#
# ==============================================
# if tetrix reachable
# Si etatCourant != Normal
# Si etatCourant != Normal
#
etatCourrant
= Normal
#
currentStatre
= Normal
#
S
toppe
rServiceSurAquila
#
s
toppe
dAquilaService
# Sinon
# Sinon
# Si
etatCourant
!= Backup
# Si
currentStatre
!= Backup
#
etatCourant
= Backup
#
currentStatre
= Backup
#
DemarrerServiceSurAquila
#
startAquilaService
# ==============================================
IPPubliqueTetrixChez
OVH
=
"109.190.180.230"
tetrixPublicIPOn
OVH
=
"109.190.180.230"
URL
=
"https://
$
IPPubliqueTetrixChez
OVH
"
URL
=
"https://
$
tetrixPublicIPOn
OVH
"
stateFile
=
"/opt/net-state"
stateFile
=
"/opt/net-state"
reverseSSHproxyPath
=
"/home/dockerweb/reverse-ssh-proxy"
reverseSSHproxyPath
=
"/home/dockerweb/reverse-ssh-proxy"
#
Faire une requête HTTP et vérifier le code de statut de la répons
e
#
Send HTTP request on tetrix to get status cod
e
HTTP_STATUS
=
$(
curl
-o
/dev/null
-w
"%{http_code}
\n
"
-s
-k
$URL
)
HTTP_STATUS
=
$(
curl
-o
/dev/null
-w
"%{http_code}
\n
"
-s
-k
$URL
)
if
[[
-f
"
$stateFile
"
]]
;
then
if
[[
-f
"
$stateFile
"
]]
;
then
$state
=
`
cat
$stateFile
`
$state
=
`
cat
$stateFile
`
#
Vérifier si le service est accessible (code de statut
200)
#
check if tetrix is reachable (status code
200)
if
[
$HTTP_STATUS
-eq
200
]
;
then
if
[
$HTTP_STATUS
-eq
200
]
;
then
if
[[
$state
!=
"normal"
]]
;
then
if
[[
$state
!=
"normal"
]]
;
then
# Switch on normal mode
# Switch on normal mode
...
...
This diff is collapsed.
Click to expand it.
net-switch.sh
+
27
−
5
View file @
875e65eb
#!/usr/bin/env bash
#!/usr/bin/env bash
IPPubliqueTetrixChezOVH
=
"109.190.180.230"
# ==============================================
IPPubliqueAquilaChezOVH
=
"5.135.140.89"
#
# This is first part of switch network between WAN and 4G
# This script is Tetrix part
#
# ==============================================
# if myPublicIP == tetrixPublicIPOnOVH
# if currentStatre != Normal
# currentStatre = Normal
# stoppedSSHTunnel
# changeTetrixAndWithGandiAPI to tetrixPublicIPOnOVH
# sandMainAtRoot
# Else
# if currentStatre != Backup
# currentStatre = Backup
# startSSHTunnel
# changeTetrixAndWithGandiAPI vers aquilaPublicIPOnOVH
# sandMainAtRoot
# ==============================================
tetrixPublicIPOnOVH
=
"109.190.180.230"
aquilaPublicIPOnOVH
=
"5.135.140.89"
# Gandi personal Token
APIKEY
=
"PUT YOUT PERSONAL TOKEN"
# Jeton sur passbotl
APIKEY
=
"PUT YOUT PERSONAL TOKEN"
# Jeton sur passbotl
stateFile
=
"/opt/net-state"
stateFile
=
"/opt/net-state"
...
@@ -17,19 +39,19 @@ if [[ -f "$stateFile" ]]; then
...
@@ -17,19 +39,19 @@ if [[ -f "$stateFile" ]]; then
$state
=
`
cat
$stateFile
`
$state
=
`
cat
$stateFile
`
# Check if current ip is different of normal ip
# Check if current ip is different of normal ip
if
[[
$
IPPubliqueTetrixChez
OVH
==
$currentIP
]]
;
then
if
[[
$
tetrixPublicIPOn
OVH
==
$currentIP
]]
;
then
if
[[
$state
!=
"normal"
]]
;
then
if
[[
$state
!=
"normal"
]]
;
then
# Switch on normal mode
# Switch on normal mode
pid
=
`
ps aux |
grep
test.sh |
grep
-v
grep
|
awk
'{print $2}'
`
pid
=
`
ps aux |
grep
test.sh |
grep
-v
grep
|
awk
'{print $2}'
`
kill
$pid
kill
$pid
change_dns
$APIKEY
$
IPPubliqueTetrixChez
OVH
change_dns
$APIKEY
$
tetrixPublicIPOn
OVH
echo
"normal"
>
"
$stateFile
"
echo
"normal"
>
"
$stateFile
"
fi
fi
else
else
if
[[
$state
=
"normal"
]]
;
then
if
[[
$state
=
"normal"
]]
;
then
# Switch on back up mode
# Switch on back up mode
bash
$reverseSSHProxyPath
&
bash
$reverseSSHProxyPath
&
change_dns
$APIKEY
$
IPPubliqueAquilaChez
OVH
change_dns
$APIKEY
$
aquilaPublicIPOn
OVH
echo
"backup"
>
"
$stateFile
"
echo
"backup"
>
"
$stateFile
"
fi
fi
fi
fi
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment