diff --git a/cd.sh b/cd.sh index 72a7b1e..9f30d9b 100644 --- a/cd.sh +++ b/cd.sh @@ -3,14 +3,15 @@ CD_DNS_SERVERS=( '9.9.9.9' ) -CD_REPOSITORY='rwx.work/cd' +CD_REPOSITORY_NAME='cd' +CD_REPOSITORY_PATH='rwx.work' CD_DNS_FILE='/etc/resolv.conf' case "${CD_OS_NAME}" in 'debian') case "${CD_OS_VERSION}" in 'bookworm') - echo 'bookworm!' + echo 'TODO' ;; *) echo 'CD_OS_VERSION' @@ -23,6 +24,14 @@ case "${CD_OS_NAME}" in exit 1 ;; esac +[ "${CI_SERVER_URL}" ] && CD_REPOSITORY_URL="${CI_SERVER_URL}" +[ "${GITHUB_SERVER_URL}" ] && CD_REPOSITORY_URL="${GITHUB_SERVER_URL}" +if [ "${CD_REPOSITORY_URL}" ] ; then + CD_REPOSITORY_URL+="/${CD_REPOSITORY_PATH}/${CD_REPOSITORY_NAME}" +else + echo '_REPOSITORY_URL' + exit 3 +fi CD_STEP=0 function cd_step { @@ -172,6 +181,14 @@ function cd_clean_packages_cache { esac } +function cd_install { +local directory + cd_step "${FUNCNAME}" + directory="$(mktemp --directory)" || exit + git clone "${CD_REPOSITORY_URL}" "${directory}" || exit + # TODO copy +} + function cd_main { cd_set_dns_resolving cd_set_packages_repositories @@ -186,18 +203,10 @@ function cd_main { cd_install_git cd_install_python cd_clean_packages_cache + cd_install -DIRECTORY="$(mktemp --directory)" \ -|| exit -cd_step "clone Continuous Delivery" -git clone \ -"${GITHUB_SERVER_URL}/${CD_REPOSITORY}" \ -"${DIRECTORY}" \ -|| exit - -cd_step "bootstrap" -"${DIRECTORY}/bootstrap.sh" - + cd_step 'bootstrap' + "${DIRECTORY}/bootstrap.sh" } cd_main