Compare commits
No commits in common. "4ed8c776d4323de6a5cac406dbec355b3010c7d8" and "ed646f6c719fa8d386839af9e82b17b7f85e3055" have entirely different histories.
4ed8c776d4
...
ed646f6c71
1 changed files with 57 additions and 50 deletions
107
cd.sh
107
cd.sh
|
@ -38,34 +38,52 @@ cd_set_environment () {
|
|||
"bookworm")
|
||||
echo "TODO"
|
||||
;;
|
||||
*) cd_error_os "CD_OS_VERSION=" ;;
|
||||
*)
|
||||
echo "CD_OS_VERSION"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*) cd_error_os "CD_OS_NAME=" ;;
|
||||
*)
|
||||
echo "CD_OS_NAME"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
# ci / github
|
||||
if [ "${GITHUB_ACTIONS}" ] ; then
|
||||
CD_SERVER_URL="${GITHUB_SERVER_URL}"
|
||||
CD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
|
||||
CD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
|
||||
CD_PROJECTS_GROUP="$(dirname "${GITHUB_REPOSITORY}")"
|
||||
# ci / gitlab
|
||||
elif [ "${GITLAB_CI}" ] ; then
|
||||
CD_SERVER_URL="${CI_SERVER_URL}"
|
||||
CD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
|
||||
CD_PROJECT_NAME="$(basename "${CI_PROJECT_PATH}")"
|
||||
CD_PROJECTS_GROUP="$(dirname "${CI_PROJECT_PATH}")"
|
||||
# ci / none
|
||||
else
|
||||
cd_error_ci "ø"
|
||||
# project / branch
|
||||
[ "${CI_COMMIT_BRANCH}" ] && CD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
|
||||
[ "${GITHUB_REF_NAME}" ] && CD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
|
||||
if [ ! "${CD_PROJECT_BRANCH}" ] ; then
|
||||
echo "CD_PROJECT_BRANCH"
|
||||
exit 3
|
||||
fi
|
||||
#
|
||||
[ "${CD_SERVER_URL}" ] || cd_error_ci "CD_SERVER_URL"
|
||||
[ "${CD_PROJECT_BRANCH}" ] || cd_error_ci "CD_PROJECT_BRANCH"
|
||||
[ "${CD_PROJECT_NAME}" ] || cd_error_ci "CD_PROJECT_NAME"
|
||||
[ "${CD_PROJECTS_GROUP}" ] || cd_error_ci "CD_PROJECTS_GROUP"
|
||||
#
|
||||
CD_PROJECTS_URL="${CD_SERVER_URL}/${CD_PROJECTS_GROUP}"
|
||||
# project / name
|
||||
[ "${CI_PROJECT_PATH}" ] \
|
||||
&& CD_PROJECT_NAME="$(basename "${CI_PROJECT_PATH}")"
|
||||
[ "${GITHUB_REPOSITORY}" ] \
|
||||
&& CD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
|
||||
if [ ! "${CD_PROJECT_NAME}" ] ; then
|
||||
echo "CD_PROJECT_NAME"
|
||||
exit 3
|
||||
fi
|
||||
# projects / group
|
||||
[ "${CI_PROJECT_PATH}" ] \
|
||||
&& CD_PROJECTS_GROUP="$(dirname "${CI_PROJECT_PATH}")"
|
||||
[ "${GITHUB_REPOSITORY}" ] \
|
||||
&& CD_PROJECTS_GROUP="$(dirname "${GITHUB_REPOSITORY}")"
|
||||
if [ ! "${CD_PROJECTS_GROUP}" ] ; then
|
||||
echo "CD_PROJECTS_GROUP"
|
||||
exit 3
|
||||
fi
|
||||
# projects / url
|
||||
[ "${CI_SERVER_URL}" ] && CD_PROJECTS_URL="${CI_SERVER_URL}"
|
||||
[ "${GITHUB_SERVER_URL}" ] && CD_PROJECTS_URL="${GITHUB_SERVER_URL}"
|
||||
if [ "${CD_PROJECTS_URL}" ] ; then
|
||||
CD_PROJECTS_URL="${CD_PROJECTS_URL}/${CD_PROJECTS_GROUP}"
|
||||
else
|
||||
echo "CD_PROJECTS_URL"
|
||||
exit 3
|
||||
fi
|
||||
# project / url
|
||||
CD_PROJECT_URL="${CD_PROJECTS_URL}/${CD_PROJECT_NAME}"
|
||||
#
|
||||
echo -n "\
|
||||
|
@ -77,13 +95,11 @@ CD_DNS_FILE=${CD_DNS_FILE}
|
|||
CD_PYTHON_COMMAND=${CD_PYTHON_COMMAND}
|
||||
CD_PYTHON_PACKAGES=${CD_PYTHON_PACKAGES}
|
||||
#
|
||||
CD_SERVER_URL=${CD_SERVER_URL}
|
||||
CD_PROJECT_BRANCH=${CD_PROJECT_BRANCH}
|
||||
CD_PROJECT_NAME=${CD_PROJECT_NAME}
|
||||
CD_PROJECTS_GROUP=${CD_PROJECTS_GROUP}
|
||||
#
|
||||
CD_PROJECTS_URL=${CD_PROJECTS_URL}
|
||||
CD_PROJECT_URL=${CD_PROJECT_URL}
|
||||
CD_PROJECTS_GROUP=${CD_PROJECTS_GROUP}
|
||||
CD_PROJECTS_URL=${CD_PROJECTS_URL}
|
||||
"
|
||||
}
|
||||
|
||||
|
@ -111,7 +127,7 @@ deb https://deb.debian.org/debian-security bookworm-security main
|
|||
"
|
||||
cd_cat "/etc/apt/sources.list"
|
||||
;;
|
||||
*) cd_error_os "cd_set_packages_repositories" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -129,7 +145,7 @@ Dir::Etc::SourceParts \"\";
|
|||
"
|
||||
cd_cat "/etc/apt/apt.conf.d/apt.conf"
|
||||
;;
|
||||
*) cd_error_os "cd_set_packages_configuration" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -142,7 +158,7 @@ Acquire::https::Verify-Peer False;
|
|||
"
|
||||
cd_cat "/etc/apt/apt.conf.d/https"
|
||||
;;
|
||||
*) cd_error_os "cd_set_https_verification_off" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -150,7 +166,7 @@ cd_update_packages_catalog () {
|
|||
cd_step "Update packages catalog"
|
||||
case "${CD_OS_NAME}" in
|
||||
"debian") apt-get update || exit ;;
|
||||
*) cd_error_os "cd_update_packages_catalog" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -158,7 +174,7 @@ cd_install_packages_tools () {
|
|||
cd_step "Install packages tools"
|
||||
case "${CD_OS_NAME}" in
|
||||
"debian") cd_install_package "apt-utils" ;;
|
||||
*) cd_error_os "cd_install_packages_tools" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -166,7 +182,7 @@ cd_install_ca () {
|
|||
cd_step "Install CA"
|
||||
case "${CD_OS_NAME}" in
|
||||
"debian") cd_install_package "ca-certificates" ;;
|
||||
*) cd_error_os "cd_install_ca" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -175,7 +191,7 @@ local target
|
|||
cd_step "Copy CA"
|
||||
case "${CD_OS_NAME}" in
|
||||
"debian") target="/usr/local/share/ca-certificates" ;;
|
||||
*) cd_error_os "cd_copy_ca" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
# TODO copy
|
||||
}
|
||||
|
@ -184,7 +200,7 @@ cd_update_ca () {
|
|||
cd_step "Update CA"
|
||||
case "${CD_OS_NAME}" in
|
||||
"debian") update-ca-certificates || exit ;;
|
||||
*) cd_error_os "cd_update_ca" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -192,7 +208,7 @@ cd_set_https_verification_on () {
|
|||
cd_step "Set HTTPS verification on"
|
||||
case "${CD_OS_NAME}" in
|
||||
"debian") cd_rm "/etc/apt/apt.conf.d/https" ;;
|
||||
*) cd_error_os "cd_set_https_verification_on" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -200,7 +216,7 @@ cd_upgrade_packages () {
|
|||
cd_step "Upgrade packages"
|
||||
case "${CD_OS_NAME}" in
|
||||
"debian") apt-get upgrade --yes || exit ;;
|
||||
*) cd_error_os "cd_upgrade_packages" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -208,7 +224,7 @@ cd_install_git () {
|
|||
cd_step "Install Git"
|
||||
case "${CD_OS_NAME}" in
|
||||
"debian") cd_install_package "git" ;;
|
||||
*) cd_error_os "cd_install_git" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -216,7 +232,7 @@ cd_install_python () {
|
|||
cd_step "Install Python"
|
||||
case "${CD_OS_NAME}" in
|
||||
"debian") cd_install_package "python3" ;;
|
||||
*) cd_error_os "cd_install_python" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -224,7 +240,7 @@ cd_clean_packages_cache () {
|
|||
cd_step "Clean packages cache"
|
||||
case "${CD_OS_NAME}" in
|
||||
"debian") apt-get clean || exit ;;
|
||||
*) cd_error_os "cd_clean_packages_cache" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -279,15 +295,6 @@ cd_cat () {
|
|||
fi
|
||||
}
|
||||
|
||||
cd_error_ci () {
|
||||
echo "× CI: ${1}"
|
||||
exit 1
|
||||
}
|
||||
cd_error_os () {
|
||||
echo "× OS: ${1}"
|
||||
exit 2
|
||||
}
|
||||
|
||||
cd_install_package () {
|
||||
if [ "${1}" ] ; then
|
||||
case "${CD_OS_NAME}" in
|
||||
|
|
Loading…
Reference in a new issue