aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2022-06-16 17:16:08 -0300
committerSilvio Rhatto <rhatto@riseup.net>2022-06-16 17:16:08 -0300
commit9aacc6683853c6544cb439b6cbb317d3a96bc614 (patch)
treea6c121593f9966c99260a1a6ed1250c5327590e6
parentd07c917010714db82e8c038acb71c34d607a00c5 (diff)
downloadtrashman-9aacc6683853c6544cb439b6cbb317d3a96bc614.tar.gz
trashman-9aacc6683853c6544cb439b6cbb317d3a96bc614.tar.bz2
Feat: trashman: adds gitlab-runner
-rw-r--r--share/trashman/gitlab-runner/info1
-rwxr-xr-xshare/trashman/gitlab-runner/unix/linux/debian/files/script.deb.sh221
-rwxr-xr-xshare/trashman/gitlab-runner/unix/linux/debian/install20
3 files changed, 242 insertions, 0 deletions
diff --git a/share/trashman/gitlab-runner/info b/share/trashman/gitlab-runner/info
new file mode 100644
index 0000000..ff34506
--- /dev/null
+++ b/share/trashman/gitlab-runner/info
@@ -0,0 +1 @@
+runs continuous integration (CI) jobs
diff --git a/share/trashman/gitlab-runner/unix/linux/debian/files/script.deb.sh b/share/trashman/gitlab-runner/unix/linux/debian/files/script.deb.sh
new file mode 100755
index 0000000..298cb9e
--- /dev/null
+++ b/share/trashman/gitlab-runner/unix/linux/debian/files/script.deb.sh
@@ -0,0 +1,221 @@
+#!/bin/bash
+
+unknown_os ()
+{
+ echo "Unfortunately, your operating system distribution and version are not supported by this script."
+ echo
+ echo "You can override the OS detection by setting os= and dist= prior to running this script."
+ echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
+ echo
+ echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
+ echo
+ echo "Please email support@packagecloud.io and let us know if you run into any issues."
+ exit 1
+}
+
+gpg_check ()
+{
+ echo "Checking for gpg..."
+ if command -v gpg > /dev/null; then
+ echo "Detected gpg..."
+ else
+ echo "Installing gnupg for GPG verification..."
+ apt-get install -y gnupg
+ if [ "$?" -ne "0" ]; then
+ echo "Unable to install GPG! Your base system has a problem; please check your default OS's package repositories because GPG should work."
+ echo "Repository installation aborted."
+ exit 1
+ fi
+ fi
+}
+
+curl_check ()
+{
+ echo "Checking for curl..."
+ if command -v curl > /dev/null; then
+ echo "Detected curl..."
+ else
+ echo "Installing curl..."
+ apt-get install -q -y curl
+ if [ "$?" -ne "0" ]; then
+ echo "Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work."
+ echo "Repository installation aborted."
+ exit 1
+ fi
+ fi
+}
+
+install_debian_keyring ()
+{
+ if [ "${os,,}" = "debian" ]; then
+ echo "Installing debian-archive-keyring which is needed for installing "
+ echo "apt-transport-https on many Debian systems."
+ apt-get install -y debian-archive-keyring &> /dev/null
+ fi
+}
+
+
+detect_os ()
+{
+ if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then
+ # some systems dont have lsb-release yet have the lsb_release binary and
+ # vice-versa
+ if [ -e /etc/lsb-release ]; then
+ . /etc/lsb-release
+
+ if [ "${ID}" = "raspbian" ]; then
+ os=${ID}
+ dist=`cut --delimiter='.' -f1 /etc/debian_version`
+ else
+ os=${DISTRIB_ID}
+ dist=${DISTRIB_CODENAME}
+
+ if [ -z "$dist" ]; then
+ dist=${DISTRIB_RELEASE}
+ fi
+ fi
+
+ elif [ `which lsb_release 2>/dev/null` ]; then
+ dist=`lsb_release -c | cut -f2`
+ os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'`
+
+ elif [ -e /etc/debian_version ]; then
+ # some Debians have jessie/sid in their /etc/debian_version
+ # while others have '6.0.7'
+ os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'`
+ if grep -q '/' /etc/debian_version; then
+ dist=`cut --delimiter='/' -f1 /etc/debian_version`
+ else
+ dist=`cut --delimiter='.' -f1 /etc/debian_version`
+ fi
+
+ else
+ unknown_os
+ fi
+ fi
+
+ if [ -z "$dist" ]; then
+ unknown_os
+ fi
+
+ # remove whitespace from OS and dist name
+ os="${os// /}"
+ dist="${dist// /}"
+
+ echo "Detected operating system as $os/$dist."
+}
+
+detect_version_id () {
+ # detect version_id and round down float to integer
+ if [ -f /etc/os-release ]; then
+ . /etc/os-release
+ version_id=${VERSION_ID%%.*}
+ elif [ -f /usr/lib/os-release ]; then
+ . /usr/lib/os-release
+ version_id=${VERSION_ID%%.*}
+ else
+ version_id="1"
+ fi
+}
+
+main ()
+{
+ detect_os
+ curl_check
+ gpg_check
+ detect_version_id
+
+ # Need to first run apt-get update so that apt-transport-https can be
+ # installed
+ echo -n "Running apt-get update... "
+ apt-get update &> /dev/null
+ echo "done."
+
+ # Install the debian-archive-keyring package on debian systems so that
+ # apt-transport-https can be installed next
+ install_debian_keyring
+
+ echo -n "Installing apt-transport-https... "
+ apt-get install -y apt-transport-https &> /dev/null
+ echo "done."
+
+
+ gpg_key_url="https://packages.gitlab.com/runner/gitlab-runner/gpgkey"
+ apt_config_url="https://packages.gitlab.com/install/repositories/runner/gitlab-runner/config_file.list?os=${os}&dist=${dist}&source=script"
+
+ apt_source_path="/etc/apt/sources.list.d/runner_gitlab-runner.list"
+ gpg_keyring_path="/usr/share/keyrings/runner_gitlab-runner-archive-keyring.gpg"
+
+ echo -n "Installing $apt_source_path..."
+
+ # create an apt config file for this repository
+ curl -sSf "${apt_config_url}" > $apt_source_path
+ curl_exit_code=$?
+
+ if [ "$curl_exit_code" = "22" ]; then
+ echo
+ echo
+ echo -n "Unable to download repo config from: "
+ echo "${apt_config_url}"
+ echo
+ echo "This usually happens if your operating system is not supported by "
+ echo "packagecloud.io, or this script's OS detection failed."
+ echo
+ echo "You can override the OS detection by setting os= and dist= prior to running this script."
+ echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
+ echo
+ echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
+ echo
+ echo "If you are running a supported OS, please email support@packagecloud.io and report this."
+ [ -e $apt_source_path ] && rm $apt_source_path
+ exit 1
+ elif [ "$curl_exit_code" = "35" -o "$curl_exit_code" = "60" ]; then
+ echo "curl is unable to connect to packagecloud.io over TLS when running: "
+ echo " curl ${apt_config_url}"
+ echo "This is usually due to one of two things:"
+ echo
+ echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)"
+ echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version"
+ echo
+ echo "Contact support@packagecloud.io with information about your system for help."
+ [ -e $apt_source_path ] && rm $apt_source_path
+ exit 1
+ elif [ "$curl_exit_code" -gt "0" ]; then
+ echo
+ echo "Unable to run: "
+ echo " curl ${apt_config_url}"
+ echo
+ echo "Double check your curl installation and try again."
+ [ -e $apt_source_path ] && rm $apt_source_path
+ exit 1
+ else
+ echo "done."
+ fi
+
+ echo -n "Importing packagecloud gpg key... "
+ # import the gpg key
+ curl -fsSL "${gpg_key_url}" | gpg --dearmor > ${gpg_keyring_path}
+ # check for os/dist based on pre debian stretch
+ if
+ { [ "${os,,}" = "debian" ] && [ "${version_id}" -lt 9 ]; } ||
+ { [ "${os,,}" = "ubuntu" ] && [ "${version_id}" -lt 16 ]; } ||
+ { [ "${os,,}" = "linuxmint" ] && [ "${version_id}" -lt 19 ]; } ||
+ { [ "${os,,}" = "raspbian" ] && [ "${version_id}" -lt 9 ]; } ||
+ { { [ "${os,,}" = "elementaryos" ] || [ "${os,,}" = "elementary" ]; } && [ "${version_id}" -lt 5 ]; }
+ then
+ # move to trusted.gpg.d
+ mv ${gpg_keyring_path} /etc/apt/trusted.gpg.d/runner_gitlab-runner.gpg
+ fi
+ echo "done."
+
+ echo -n "Running apt-get update... "
+ # update apt on this system
+ apt-get update &> /dev/null
+ echo "done."
+
+ echo
+ echo "The repository is setup! You can now install packages."
+}
+
+main
+
diff --git a/share/trashman/gitlab-runner/unix/linux/debian/install b/share/trashman/gitlab-runner/unix/linux/debian/install
new file mode 100755
index 0000000..0878d84
--- /dev/null
+++ b/share/trashman/gitlab-runner/unix/linux/debian/install
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+# Installs GitLab Runner.
+#
+
+# Parameters
+DIRNAME="`dirname $0`"
+SHARE="$1"
+LIB="$2"
+
+# Include basic functions
+. $LIB/trashman/functions || exit 1
+. $LIB/trashman/debian || exit 1
+
+# Setup GitLab Debian repositories
+# See https://docs.gitlab.com/runner/install/linux-repository.html
+$SUDO $DIRNAME/files/script.deb.sh
+
+# Install GitLab Runner
+trashman_apt_install gitlab-runner