fixed this
[jprojects-scripts.git] / fix-project-remotes.sh
index cd51a97..f4bd38b 100755 (executable)
@@ -31,7 +31,8 @@ for project in ${LIST}; do
        GIT_URL3="${MEDIA_BASE}/${USER}/${MEDIA_NAME2}/${MEDIA_PATH}/${project}.git"
        GIT_URL4="file:///E:/Java%20Project/${project}.git"
        GIT_URL5="E:/Java Project/${project}.git"
-       echo "$0: GIT_URL1='${GIT_URL1}',GIT_URL2='${GIT_URL2}',GIT_URL3='${GIT_URL3}',GIT_URL4='${GIT_URL4}',GIT_URL5='${GIT_URL5}'"
+       GIT_URL6="${MEDIA_BASE}/${USER}/${MEDIA_NAME1}/${MEDIA_PATH}/${project}.git"
+       echo "$0: GIT_URL1='${GIT_URL1}',GIT_URL2='${GIT_URL2}',GIT_URL3='${GIT_URL3}',GIT_URL4='${GIT_URL4}',GIT_URL5='${GIT_URL5}',GIT_URL6='${GIT_URL6}'"
 
        cd "${JPROJECTS_HOME}/${project}" || exit 255
 
@@ -45,7 +46,20 @@ for project in ${LIST}; do
        REMOTES=`git remote | wc -l`
        echo "$0: REMOTES='${REMOTES}'"
 
-       if [ "${REMOTES}" = "1" ]
+       if [ "${REMOTES}" = "0" ]
+       then
+               if [ -n "${SHELL}" -a -f "/proc/version" ]
+               then
+                       echo "$0: Found no repositories in '${project}'. Creating all (Linux) ..."
+                       git remote add "${GIT_ORIGIN}" "${GIT_URL6}" --track "${GIT_BRANCH}"
+                       git remote add "${WANTED_NAME1}" "${GIT_URL1}"
+                       git remote add "${WANTED_NAME2}" "${GIT_URL2}"
+                       git remote add "${WANTED_NAME3}" "${GIT_URL3}"
+               else
+                       echo "$0: Don't know how to create repositories, maybe unsupported."
+                       exit 1
+               fi
+       elif [ "${REMOTES}" = "1" ]
        then
                echo "$0: Only one remote found for '${project}'"
 
@@ -69,9 +83,10 @@ for project in ${LIST}; do
                else
                        echo "$0: Not a media remote."
                        MXCHANGE_REMOTE=`echo "${REMOTE_PUSH}" | grep "${GIT_URL1}"`
+                       LINUX_MEDIA_PATH_REMOTE=`echo "${REMOTE_PUSH}" | grep "${GIT_URL3}"`
                        WINDOWS_FILE_REMOTE=`echo "${REMOTE_PUSH}" | grep "${GIT_URL4}"`
                        WINDOWS_PATH_REMOTE=`echo "${REMOTE_PUSH}" | grep "${GIT_URL5}"`
-                       echo "$0: MXCHANGE_REMOTE='${MXCHANGE_REMOTE}',WINDOWS_FILE_REMOTE='${WINDOWS_FILE_REMOTE}',WINDOWS_PATH_REMOTE='${WINDOWS_PATH_REMOTE}'"
+                       echo "$0: MXCHANGE_REMOTE='${MXCHANGE_REMOTE}',WINDOWS_FILE_REMOTE='${WINDOWS_FILE_REMOTE}',WINDOWS_PATH_REMOTE='${WINDOWS_PATH_REMOTE}',LINUX_MEDIA_PATH_REMOTE='${LINUX_MEDIA_PATH_REMOTE}'"
 
                        if [ -n "${MXCHANGE_REMOTE}" ]
                        then
@@ -101,6 +116,21 @@ for project in ${LIST}; do
 
                                echo "$0: Adding '${GIT_ORIGIN}' to '${project}' ..."
                                git remote add "${GIT_ORIGIN}" "${GIT_URL1}" --track "${GIT_BRANCH}" || exit 255
+                       elif [ -n "${LINUX_MEDIA_PATH_REMOTE}" ]
+                       then
+                               echo "$0: Found a Linux (USB stick) remote."
+
+                               if [ -n "${GIT_ORIGIN}" -a "${REMOTE}" = "${GIT_ORIGIN}" ]
+                               then
+                                       echo "$0: Need to fix remote repositories ..."
+                                       git remote rename origin transport || exit 255
+                                       git remote add "${GIT_ORIGIN}" "${GIT_URL6}" --track "${GIT_BRANCH}" || exit 255
+                                       git remote add "${WANTED_NAME1}" "${GIT_URL1}" --track "${GIT_BRANCH}" || exit 255
+                                       git remote add "${WANTED_NAME2}" "${GIT_URL2}" --track "${GIT_BRANCH}" || exit 255
+                               else
+                                       echo "$0: Don't know how to fix '${REMOTE}' (${REMOTE_PUSH})."
+                                       exit 1
+                               fi
                        else
                                echo "$0: Unknown remote '${REMOTE_PUSH}' found. Exiting ..."
                                exit 1