chore: add current provisioning state before migration
This commit is contained in:
parent
a9703b4748
commit
50745b0f22
660 changed files with 88126 additions and 0 deletions
10
taskservs/oci-reg/default/env-oci-reg.j2
Normal file
10
taskservs/oci-reg/default/env-oci-reg.j2
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{%- if taskserv.name == "oci-reg" %}
|
||||
VERSION="{{taskserv.version}}"
|
||||
OCI_DATA="{{taskserv.oci_data}}"
|
||||
OCI_ETC="{{taskserv.oci_etc}}"
|
||||
OCI_LOG="{{taskserv.oci_log}}"
|
||||
OCI_USER="{{taskserv.oci_user}}"
|
||||
OCI_USER_GROUP="{{taskserv.oci_user_group}}"
|
||||
OCI_CMDS="{{taskserv.oci_cmds}}"
|
||||
OCI_BIN_PATH="{{taskserv.oci_bin_path}}"
|
||||
{%- endif %}
|
||||
100
taskservs/oci-reg/default/install-oci-reg.sh
Executable file
100
taskservs/oci-reg/default/install-oci-reg.sh
Executable file
|
|
@ -0,0 +1,100 @@
|
|||
#!/bin/bash
|
||||
# Info: Script to install oras
|
||||
# Author: JesusPerezLorenzo
|
||||
# Release: 1.0
|
||||
# Date: 11-01-2024
|
||||
|
||||
USAGE="install-oci-reg.sh "
|
||||
[ "$1" == "-h" ] && echo "$USAGE" && exit 1
|
||||
|
||||
ORG=$(dirname "$0")
|
||||
|
||||
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')"
|
||||
OS="$(uname | tr '[:upper:]' '[:lower:]')"
|
||||
|
||||
_get_version() {
|
||||
local curr_version
|
||||
#JQ=$(type -P jq)
|
||||
#[ -z "$JQ" ] && echo "jq not installed " && exit 1
|
||||
local cmd=$1
|
||||
local out
|
||||
out="/tmp/oci.$$"
|
||||
$cmd -v &>"$out"
|
||||
#curr_version=$($JQ < "$out" '.commit' | sed 's/v//g' | sed 's/"//g')
|
||||
cur_version=$(cat $out | cut -f3 -d"," | cut -f2 -d":" | sed 's/"//g')
|
||||
rm -r "$out"
|
||||
echo "$curr_version"
|
||||
}
|
||||
|
||||
_install_oci-reg() {
|
||||
[ -z "$VERSION" ] && echo "VERSION not found" && exit 1
|
||||
local has_cmd
|
||||
local curr_vers
|
||||
for cmd in $OCI_CMDS
|
||||
do
|
||||
has_cmd=$(type "$cmd" 2>/dev/null)
|
||||
if [ -n "$has_cmd" ] ; then
|
||||
curr_vers=$(_get_version "$cmd")
|
||||
else
|
||||
curr_vers=""
|
||||
fi
|
||||
if [ -n "$curr_vers" ] && [[ "$curr_vers" =~ $VERSION ]] ; then
|
||||
continue
|
||||
else
|
||||
if ! curl -fsSLO "https://github.com/project-zot/zot/releases/download/v${VERSION}/${cmd}-${OS}-${ARCH}"; then
|
||||
echo "Error download v${VERSION}/${cmd}-${OS}-${ARCH} "
|
||||
exit 1
|
||||
fi
|
||||
sudo mv "${cmd}-${OS}-${ARCH}" /usr/local/bin/"${cmd}"
|
||||
sudo chmod +x /usr/local/bin/"${cmd}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
_config_oci-reg() {
|
||||
local has_user
|
||||
[ -z "$OCI_USER" ] && echo "OCI_USER not found" && exit 1
|
||||
has_user=$(sudo grep "$OCI_USER" /etc/passwd)
|
||||
if [ -z "$has_user" ] ; then
|
||||
sudo adduser --no-create-home --disabled-password --gecos --disabled-login "$OCI_USER"
|
||||
fi
|
||||
if [ ! -d "$OCI_DATA" ] ; then
|
||||
sudo mkdir -p "$OCI_DATA"
|
||||
sudo chown -R "${OCI_USER}:${OCI_USER_GROUP}" "$OCI_DATA"
|
||||
fi
|
||||
if [ ! -d "$OCI_LOG" ] ; then
|
||||
sudo mkdir -p "$OCI_LOG"
|
||||
sudo chown -R "${OCI_USER}:${OCI_USER_GROUP}" "$OCI_LOG"
|
||||
fi
|
||||
[ ! -d "$OCI_ETC" ] && sudo mkdir "$OCI_ETC"
|
||||
if [ -r "$ORG/config.json" ] ; then
|
||||
sudo cp "$ORG/config.json" "$OCI_ETC"
|
||||
fi
|
||||
if [ -r "$ORG/htpasswd" ] ; then
|
||||
sudo mv "$ORG/htpasswd" "$OCI_ETC"
|
||||
sudo chown "$OCI_USER" "$OCI_ETC"/htpasswd
|
||||
sudo chmod 400 "$OCI_ETC"/htpasswd
|
||||
fi
|
||||
[ -d "$OCI_ETC/ssl" ] && sudo rm -rf "$OCI_ETC/ssl"
|
||||
if [ -r "$ORG/ssl" ] ; then
|
||||
sudo mv "$ORG/ssl" "$OCI_ETC"
|
||||
sudo chown -R "$OCI_USER" "$OCI_ETC"/ssl
|
||||
sudo chmod 400 "$OCI_ETC"/ssl/privkey.pem
|
||||
fi
|
||||
if [ -r "$ORG/zot.service" ] ; then
|
||||
sudo cp zot.service /lib/systemd/system
|
||||
[ ! -L "/etc/systemd/system/zot.service" ] && sudo ln -s /lib/systemd/system/zot.service /etc/systemd/system
|
||||
sudo timeout -k 10 20 systemctl daemon-reload
|
||||
sudo timeout -k 10 20 systemctl enable zot 2>/dev/null
|
||||
fi
|
||||
sudo timeout -k 10 20 systemctl restart zot
|
||||
if [ -r "$ORG/zli-cfg" ] ; then
|
||||
cp "$ORG/zli-cfg" "$HOME/.zot"
|
||||
fi
|
||||
}
|
||||
|
||||
[ -r "./env-oci-reg" ] && . ./env-oci-reg
|
||||
|
||||
# Update and add packages to installation
|
||||
[ -z "$1" ] || [ "$1" == "install" ] && _install_oci-reg
|
||||
[ -z "$1" ] || [ "$1" == "config" ] && _config_oci-reg
|
||||
20
taskservs/oci-reg/default/prepare
Executable file
20
taskservs/oci-reg/default/prepare
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env nu
|
||||
# Info: Prepare for oci-reg installation
|
||||
# Author: JesusPerezLorenzo
|
||||
# Release: 1.0.2
|
||||
# Date: 24-12-2023
|
||||
|
||||
use lib_provisioning/cmd/env.nu *
|
||||
use lib_provisioning/cmd/lib.nu *
|
||||
|
||||
use lib_provisioning/utils/ui.nu *
|
||||
|
||||
print $"(_ansi green_bold)OCI-reg(_ansi reset) with ($env.PROVISIONING_VARS)"
|
||||
|
||||
let defs = load_defs
|
||||
if not ($env.PROVISIONING_WK_ENV_PATH | path exists) {
|
||||
print $"(_ansi red_bold)PROVISIONING_WK_ENV_PATH(_ansi reset) ($env.PROVISIONING_WK_ENV_PATH) not found"
|
||||
exit 1
|
||||
}
|
||||
$defs.taskserv.config | save -f ($env.PROVISIONING_WK_ENV_PATH | path join "config.json")
|
||||
print "config.json generated !"
|
||||
2
taskservs/oci-reg/default/provisioning.toml
Normal file
2
taskservs/oci-reg/default/provisioning.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
info = "zot"
|
||||
release = "1.0"
|
||||
16
taskservs/oci-reg/default/zot.service.j2
Normal file
16
taskservs/oci-reg/default/zot.service.j2
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[Unit]
|
||||
Description=OCI Distribution Registry
|
||||
Documentation=https://zotregistry.io/
|
||||
After=network.target auditd.service local-fs.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart={{taskserv.oci_bin_path}}/zot serve {{taskserv.oci_etc}}/config.json
|
||||
Restart=on-failure
|
||||
User={{taskserv.oci_user}}
|
||||
Group={{taskserv.oci_user_group}}
|
||||
LimitNOFILE=500000
|
||||
MemoryHigh={{taskserv.oci_memory_high}}G
|
||||
MemoryMax={{taskserv.oci_memory_max}}G
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Loading…
Add table
Add a link
Reference in a new issue