# Synchronizing Git Submodules Modifying URLs

Sometimes it is not possible to access submodules as they were registered. Solution is here:

```{.bash}
#!/bin/bash

NUMARGS=$#
SCRIPT=`basename ${BASH_SOURCE[0]}`
GREEN='\033[1;32m'
NC='\033[0m'

function HELP {
  echo -e "${GREEN}Usage${NC}: ${SCRIPT} server-name ip-address timeout-sec"
  exit 1
}

if [ $NUMARGS -ne 3 ]; then
  HELP
fi

name=$1
address=$2
timeout=$3

rc=1
while [ $rc -ne 0 ]; do
  find ./ -type f \( -name .gitmodules \) -print0 | xargs -0 sed -i "s/$name/$address/g"
  git submodule sync --recursive
  timeout $timeout git submodule update --init --recursive
  rc=$?
done

echo -e "${GREEN}All done.${NC}"
```