Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
UNLOCK
sync
Commits
a6f9c565
Commit
a6f9c565
authored
May 19, 2021
by
Nijsse, Bart
Browse files
added argument on what to synchronize
parent
c679841a
Changes
1
Hide whitespace changes
Inline
Side-by-side
sync.sh
View file @
a6f9c565
...
...
@@ -8,31 +8,83 @@
#============================================================================
DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
"
usage
()
{
echo
"Usage:
$0
[-c|--cwl] [-r|--references] [-i|--infrastructure] [-a|--all]"
1>&2
;
exit
1
;
}
vars
=
$(
getopt
-o
c:r:i:a:
--long
cwl:,references:,infrastructure:,all:
)
#============================================================================
#
Pull from iROD
S
#
KUBERNETES JOB
S
#============================================================================
# irsync -r i:/tempZone/Infrastructure /unlock/
# Clean up finished sync pods
kubectl get pods
--namespace
=
'unlock'
|
grep
munlock-sync |
grep
Completed |
awk
'{print "kubectl -n unlock delete pod "$1}'
| sh
# Get all possible nodes
kubectl get nodes
-l
node-role.kubernetes.io/worker
=
true
|
grep
-v
"SchedulingDisabled"
|
awk
'{print $1}'
|
grep
-v
NAME
>
$DIR
/nodes.txt
# For each node perform the sync
while
read
node
;
do
echo
"
$node
"
sed
"s/HOSTNAME/
$node
/g"
$DIR
/template_sync_cwl.yaml
>
$DIR
/
$node
\_
cwl.yaml
sed
"s/HOSTNAME/
$node
/g"
$DIR
/template_sync_infrastructure.yaml
>
$DIR
/
$node
\_
infrastructure.yaml
sed
"s/HOSTNAME/
$node
/g"
$DIR
/template_sync_references.yaml
>
$DIR
/
$node
\_
references.yaml
kubectl apply
-f
$DIR
/
$node
\_
cwl.yaml
kubectl apply
-f
$DIR
/
$node
\_
infrastructure.yaml
kubectl apply
-f
$DIR
/
$node
\_
references.yaml
# Cleanup
rm
$DIR
/
$node
\_
cwl.yaml
$DIR
/
$node
\_
infrastructure.yaml
$DIR
/
$node
\_
references.yaml
done
<
$DIR
/nodes.txt
runall
=
false
if
[
"
$1
"
==
""
]
;
then
runall
=
true
fi
for
opt
;
do
if
[[
$opt
==
"-a"
||
$opt
==
"--all"
]]
;
then
runall
=
true
fi
done
if
$runall
;
then
while
read
node
;
do
sed
"s/HOSTNAME/
$node
/g"
$DIR
/template_sync_cwl.yaml
>
$DIR
/
$node
\_
cwl.yaml
sed
"s/HOSTNAME/
$node
/g"
$DIR
/template_sync_infrastructure.yaml
>
$DIR
/
$node
\_
infrastructure.yaml
sed
"s/HOSTNAME/
$node
/g"
$DIR
/template_sync_references.yaml
>
$DIR
/
$node
\_
references.yaml
kubectl apply
-f
$DIR
/
$node
\_
cwl.yaml
kubectl apply
-f
$DIR
/
$node
\_
infrastructure.yaml
kubectl apply
-f
$DIR
/
$node
\_
references.yaml
# Cleanup
rm
$DIR
/
$node
\_
cwl.yaml
$DIR
/
$node
\_
infrastructure.yaml
$DIR
/
$node
\_
references.yaml
done
<
$DIR
/nodes.txt
exit
1
fi
# If not all sent job any given option
for
opt
;
do
case
"
$opt
"
in
-c
|
--cwl
)
while
read
node
;
do
sed
"s/HOSTNAME/
$node
/g"
$DIR
/template_sync_cwl.yaml
>
$DIR
/
$node
\_
cwl.yaml
kubectl apply
-f
$DIR
/
$node
\_
cwl.yaml
# Cleanup
rm
$DIR
/
$node
\_
cwl.yaml
done
<
$DIR
/nodes.txt
;;
-r
|
--references
)
while
read
node
;
do
sed
"s/HOSTNAME/
$node
/g"
$DIR
/template_sync_references.yaml
>
$DIR
/
$node
\_
references.yaml
kubectl apply
-f
$DIR
/
$node
\_
references.yaml
# Cleanup
rm
$DIR
/
$node
\_
references.yaml
done
<
$DIR
/nodes.txt
;;
-i
|
--infrastructure
)
while
read
node
;
do
sed
"s/HOSTNAME/
$node
/g"
$DIR
/template_sync_infrastructure.yaml
>
$DIR
/
$node
\_
infrastructure.yaml
kubectl apply
-f
$DIR
/
$node
\_
infrastructure.yaml
# Cleanup
rm
$DIR
/
$node
\_
references.yaml
done
<
$DIR
/nodes.txt
;;
*
)
usage
esac
done
\ No newline at end of file
Write
Preview
Supports
Markdown
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