debian recipe
This commit is contained in:
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
CONF="/etc/conf.d/jenkins-slave"
|
||||
if [ -e "/etc/jenkins-slave.conf" ]; then
|
||||
CONF="/etc/jenkins-slave.conf"
|
||||
fi
|
||||
|
||||
TOTAL_MEMORY=$(cat /proc/meminfo | grep MemTotal | awk '{ printf "%sg", int($2/1024/1024)+1 }')
|
||||
sed -i "s|^JENKINS_SLAVE_NAME=.*$|JENKINS_SLAVE_NAME='slave-$ETH0_IP'|" "${CONF}"
|
||||
sed -i "s|^JENKINS_SLAVE_USERNAME=.*$|JENKINS_SLAVE_USERNAME='$JENKINS_SLAVE_USERNAME'|" "${CONF}"
|
||||
sed -i "s|^JENKINS_SLAVE_PASSWORD=.*$|JENKINS_SLAVE_PASSWORD='$JENKINS_SLAVE_PASSWORD'|" "${CONF}"
|
||||
sed -i "s|^JENKINS_MASTER_URL=.*$|JENKINS_MASTER_URL='$JENKINS_MASTER_URL'|" "${CONF}"
|
||||
sed -i "s|^JENKINS_SLAVE_LABELS=.*$|JENKINS_SLAVE_LABELS='docker docker-compose mem-$TOTAL_MEMORY $JENKINS_SLAVE_LABELS'|" "${CONF}"
|
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
ENV_FILE=${ENV_FILE:-/var/run/one-context/one_env}
|
||||
|
||||
# $TOKENTXT is available only through the env. file
|
||||
# shellcheck disable=SC1090
|
||||
if [ -f "${ENV_FILE}" ]; then
|
||||
. "${ENV_FILE}"
|
||||
fi
|
||||
|
||||
###
|
||||
|
||||
if [ -n "${GITLAB_URL}" ]; then
|
||||
if command -v gitlab-runner; then
|
||||
if [ -n "${GITLAB_SHELL}" ]; then
|
||||
opts="--shell=${GITLAB_SHELL}"
|
||||
fi
|
||||
# shellcheck disable=SC2086
|
||||
gitlab-runner register \
|
||||
--non-interactive \
|
||||
--url="${GITLAB_URL}" \
|
||||
--registration-token="${GITLAB_TOKEN}" \
|
||||
--executor="${GITLAB_EXECUTOR}" \
|
||||
--description="${GITLAB_RUNNER_NAME}" \
|
||||
--tag-list="${GITLAB_TAG_LIST}" \
|
||||
--locked=false \
|
||||
--access-level=not_protected \
|
||||
--run-untagged=false \
|
||||
"${opts}"
|
||||
fi
|
||||
fi
|
@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Generate all the configuration files
|
||||
# Get all the values from the VLS_DIR
|
||||
# Process each template from the TPL_DIR with this values
|
||||
#
|
||||
|
||||
ENV_FILE=${ENV_FILE:-/var/run/one-context/one_env}
|
||||
TPL_DIR="/usr/share/builder/templates"
|
||||
VLS_DIR="/usr/share/builder/values"
|
||||
CONFIG=""
|
||||
|
||||
. ${ENV_FILE}
|
||||
|
||||
BTR="$(command -v btr)"
|
||||
if [ "${?}" -ne 0 ]; then
|
||||
echo "Warning: Nothing to do the templater is not installed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -e "${TPL_DIR}" ]; then
|
||||
echo "Error: The template dir is missing (${TPL_DIR})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e "${VLS_DIR}" ]; then
|
||||
echo "Error: The template dir is missing (${VLS_DIR})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
jsonQuery() {
|
||||
local data="${1}"
|
||||
local query="${2}"
|
||||
echo "${data}" | jq -cr "${query}"
|
||||
}
|
||||
|
||||
# NAME: @jsonMerge
|
||||
# AIM: Merge two json structures
|
||||
# NOTES:
|
||||
# The last one has de last word
|
||||
# if you have the same key in A and B
|
||||
# this keeps the value of the B structure.
|
||||
# PARAMS:
|
||||
# $1: original JSON Structure
|
||||
# $2: updated JSON Structure
|
||||
jsonMerge() {
|
||||
local data="${1}"
|
||||
local data2="${2}"
|
||||
|
||||
echo "${data} ${data2}" | jq -cr -s ".[0] * .[1]"
|
||||
}
|
||||
|
||||
getValues() {
|
||||
|
||||
local values=""
|
||||
|
||||
for file in $(find ${VLS_DIR} -name "*.json"); do
|
||||
values="${values}$(cat ${file})"
|
||||
done
|
||||
|
||||
if [ -n "${RAW_CONFIG}" ]; then
|
||||
values="$(jsonMerge ${values} ${RAW_CONFIG})"
|
||||
fi
|
||||
|
||||
for key in $(echo ${values} | jq -cr '.|keys[]'); do
|
||||
ukey=${key^^}
|
||||
if [ -n "${!ukey}" ]; then
|
||||
values="$(jsonMerge "${values}" "{\"${key}\":\"${!ukey}\"}")"
|
||||
fi
|
||||
done
|
||||
echo ${values}
|
||||
}
|
||||
|
||||
processTemplates() {
|
||||
${BTR} -t ${TPL_DIR} -c "${1}"
|
||||
}
|
||||
VALUES=$(getValues)
|
||||
echo ${VALUES}
|
||||
processTemplates "${VALUES}"
|
21
recipes/debian/provisionning/conf/one-context/net-97-k3s
Normal file
21
recipes/debian/provisionning/conf/one-context/net-97-k3s
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
ENV_FILE=${ENV_FILE:-/var/run/one-context/one_env}
|
||||
|
||||
# $TOKENTXT is available only through the env. file
|
||||
# shellcheck disable=SC1090
|
||||
if [ -f "${ENV_FILE}" ]; then
|
||||
. "${ENV_FILE}"
|
||||
fi
|
||||
|
||||
###
|
||||
|
||||
if [ -n "${K3S_ROLE}" ]; then
|
||||
if [ "${K3S_ROLE}" = "server" ]; then
|
||||
rc-update add dnsmasq default
|
||||
service dnsmasq start
|
||||
|
||||
rc-update add k3s default
|
||||
service k3s start
|
||||
fi
|
||||
fi
|
Reference in New Issue
Block a user