Commit a6f9c565 authored by Nijsse, Bart's avatar Nijsse, Bart
Browse files

added argument on what to synchronize

parent c679841a
......@@ -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 iRODS
# KUBERNETES JOBS
#============================================================================
# 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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment