mirror of
https://gitlab.com/Snogard/kaido.git
synced 2025-06-25 02:13:00 +02:00
now the user can execute custom scripts in its config folder
This commit is contained in:
parent
24ef940378
commit
dd30f0f55d
16
readme.md
16
readme.md
@ -14,7 +14,13 @@ every configuration must be under /etc/kaido.
|
||||
(to implement): if "/etc/kaido/" is a git repository, the update function will also take that into account when deciding what container to recreate
|
||||
### Folder structure
|
||||
- /etc/kaido
|
||||
- commands (not implemented)
|
||||
- commands
|
||||
- install
|
||||
- install-transmission.sh
|
||||
- install-pihole.sh
|
||||
- ecc...
|
||||
- config
|
||||
- ecc...
|
||||
- containers
|
||||
- container1
|
||||
- config
|
||||
@ -63,4 +69,10 @@ kaido install gitlab-runner register "insert_token_here"
|
||||
other times:
|
||||
```
|
||||
kaido install gitlab-runner
|
||||
```
|
||||
```
|
||||
|
||||
# Container Build
|
||||
|
||||
### foundry
|
||||
- first setup a private repository properly tagged for each foundry version you intend to build
|
||||
- set the link to your repository inside your config
|
@ -5,10 +5,10 @@ prefix=build
|
||||
|
||||
rootFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
scriptFolder=${rootFolder}/${prefix}
|
||||
|
||||
|
||||
scriptName=$1
|
||||
scriptPath=${scriptFolder}/${prefix}-${scriptName}.sh
|
||||
|
||||
scriptPath=""
|
||||
set_script_path $prefix $scriptName
|
||||
|
||||
buildPath="$BUILDS_FOLDER/$scriptName"
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
#!/bin/bash
|
||||
source /opt/kaido/src/libs/bash/lib.sh
|
||||
|
||||
prefix=config
|
||||
|
||||
rootFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
scriptFolder=${rootFolder}/${prefix}
|
||||
|
||||
|
||||
scriptName=$1
|
||||
scriptPath=${scriptFolder}/${prefix}-${scriptName}.sh
|
||||
|
||||
scriptPath=""
|
||||
set_script_path $prefix $scriptName
|
||||
|
||||
if test -f "$scriptPath"; then
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
#!/bin/bash
|
||||
source /opt/kaido/src/libs/bash/lib.sh
|
||||
|
||||
prefix=install
|
||||
|
||||
rootFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
scriptFolder=${rootFolder}/${prefix}
|
||||
|
||||
|
||||
scriptName=$1
|
||||
scriptPath=${scriptFolder}/${prefix}-${scriptName}.sh
|
||||
|
||||
scriptPath=""
|
||||
set_script_path $prefix $scriptName
|
||||
|
||||
if test -f "$scriptPath"; then
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
prefix=setup
|
||||
|
||||
rootFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
scriptFolder=${rootFolder}/${prefix}
|
||||
|
||||
#sudo chmod +x -R $scriptFolder
|
||||
|
||||
scriptName=$1
|
||||
scriptPath=${scriptFolder}/${prefix}-${scriptName}.sh
|
||||
|
||||
scriptPath=""
|
||||
set_script_path $prefix $scriptName
|
||||
|
||||
if test -f "$scriptPath"; then
|
||||
|
||||
|
@ -3,4 +3,4 @@
|
||||
sudo apt install -y zram-tools
|
||||
echo "PERCENT=5" | sudo tee -a /etc/default/zramswap
|
||||
echo "PRIORITY=100" | sudo tee -a /etc/default/zramswap
|
||||
systemctl enable --now zramswap
|
||||
sudo systemctl enable --now zramswap
|
||||
|
@ -1,12 +1,14 @@
|
||||
#!/bin/bash
|
||||
source /opt/kaido/src/libs/bash/lib.sh
|
||||
|
||||
prefix=sysconfig
|
||||
|
||||
rootFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
scriptFolder=${rootFolder}/${prefix}
|
||||
|
||||
|
||||
scriptName=$1
|
||||
scriptPath=${scriptFolder}/${prefix}-${scriptName}.sh
|
||||
|
||||
scriptPath=""
|
||||
set_script_path $prefix $scriptName
|
||||
|
||||
if test -f "$scriptPath"; then
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
#TODO check repository persmissions for both kaido and config
|
||||
#TODO replace confdir with KAIDO_CONFIG_FOLDER
|
||||
source /opt/kaido/src/libs/bash/lib.sh
|
||||
|
||||
# variables
|
||||
root="/opt/kaido"
|
||||
workdir="$HOME/.cache/kaido"
|
||||
confdir="/etc/kaido"
|
||||
workdir="$HOME/.cache/kaido/update"
|
||||
confdir="$KAIDO_CONFIG_FOLDER"
|
||||
configureScript="$root/src/commands/configure.sh"
|
||||
installScript="$root/src/commands/install.sh"
|
||||
buildScript="$root/src/commands/build.sh"
|
||||
@ -21,9 +24,11 @@ if [ ! -d "${confdir}" ]; then
|
||||
sudo mkdir -p $confdir
|
||||
fi
|
||||
|
||||
skipContainerUpdate=0
|
||||
if [ ! -f "${updateConfig}" ]; then
|
||||
echo "Creating empty update file"
|
||||
sudo touch $updateConfig
|
||||
echo "WARNING: container updates will be skipped"
|
||||
skipContainerUpdate=1
|
||||
#sudo touch $updateConfig
|
||||
fi
|
||||
|
||||
if [ ! -d "${workdir}" ]; then
|
||||
@ -99,8 +104,14 @@ echo ""
|
||||
# done
|
||||
# ---------------------------
|
||||
|
||||
# auto update installations
|
||||
echo -e "Checking if installations need to be updated\n"
|
||||
|
||||
# quit early
|
||||
if [[ $skipContainerUpdate -eq 1 ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# auto update containers
|
||||
echo -e "Checking if containers need to be updated\n"
|
||||
for val in $installList; do
|
||||
name=${val:8}
|
||||
# TODO support parameters
|
||||
@ -116,7 +127,7 @@ echo -e "Installations updated\n"
|
||||
# ---------------------------
|
||||
|
||||
# auto update configs
|
||||
echo -e "Checking if configs need to be updated\n"
|
||||
echo -e "Checking if container configs need to be updated\n"
|
||||
for val in $configureList; do
|
||||
name=${val:6}
|
||||
if $(git -C "$root" diff --name-only $previusCommit_config $currentCommit_config "$confdir/containers/$name/config" | grep -qi $name) ; then
|
||||
|
15
src/libs/bash/functions-commands.sh
Normal file
15
src/libs/bash/functions-commands.sh
Normal file
@ -0,0 +1,15 @@
|
||||
function set_script_path()
|
||||
{
|
||||
local prefix=$1
|
||||
local scriptName=$2
|
||||
|
||||
local userScriptPath="$KAIDO_CONFIG_FOLDER/commands/${prefix}/${prefix}-${scriptName}.sh"
|
||||
local kaidoScriptPath="${scriptFolder}/${prefix}-${scriptName}.sh"
|
||||
|
||||
if [ -f "$userScriptPath" ]; then
|
||||
scriptPath=$userScriptPath
|
||||
else
|
||||
scriptPath=$kaidoScriptPath
|
||||
fi
|
||||
}
|
||||
|
44
src/libs/bash/functions-common.sh
Normal file
44
src/libs/bash/functions-common.sh
Normal file
@ -0,0 +1,44 @@
|
||||
function create_folder()
|
||||
{
|
||||
local path=$1
|
||||
|
||||
if [ ! -d "${path}" ]; then
|
||||
echo "Creating folder path at ${path}"
|
||||
mkdir -p "$path"
|
||||
chmod 777 "$path"
|
||||
fi
|
||||
}
|
||||
|
||||
function symlink_folder()
|
||||
{
|
||||
local src=$1
|
||||
local dst=$2
|
||||
|
||||
if [ ! -L "${dst}" ]; then
|
||||
echo "Creating symlink from ${src} to ${dst}"
|
||||
ln -s $src $dst
|
||||
fi
|
||||
}
|
||||
|
||||
function ensure_file()
|
||||
{
|
||||
local src=$1
|
||||
local dst=$2
|
||||
|
||||
if [ ! -f "${dst}" ]; then
|
||||
if [ -f "${src}"]; then
|
||||
echo "Copy ${src} to ${dst}"
|
||||
cp "${src}" "${dst}"
|
||||
else
|
||||
echo "Creating empty file at ${dst}"
|
||||
touch "${dst}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function open_port()
|
||||
{
|
||||
local port=$1
|
||||
#TODO: check if port is already open
|
||||
sudo ufw allow $port
|
||||
}
|
@ -42,51 +42,6 @@ function create_systemd_services()
|
||||
--name $name
|
||||
}
|
||||
|
||||
function create_folder()
|
||||
{
|
||||
local path=$1
|
||||
|
||||
if [ ! -d "${path}" ]; then
|
||||
echo "Creating folder path at ${path}"
|
||||
mkdir -p "$path"
|
||||
chmod 777 "$path"
|
||||
fi
|
||||
}
|
||||
|
||||
function symlink_folder()
|
||||
{
|
||||
local src=$1
|
||||
local dst=$2
|
||||
|
||||
if [ ! -L "${dst}" ]; then
|
||||
echo "Creating symlink from ${src} to ${dst}"
|
||||
ln -s $src $dst
|
||||
fi
|
||||
}
|
||||
|
||||
function ensure_file()
|
||||
{
|
||||
local src=$1
|
||||
local dst=$2
|
||||
|
||||
if [ ! -f "${dst}" ]; then
|
||||
if [ -f "${src}"]; then
|
||||
echo "Copy ${src} to ${dst}"
|
||||
cp "${src}" "${dst}"
|
||||
else
|
||||
echo "Creating empty file at ${dst}"
|
||||
touch "${dst}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function open_port()
|
||||
{
|
||||
local port=$1
|
||||
#TODO: check if port is already open
|
||||
sudo ufw allow $port
|
||||
}
|
||||
|
||||
function secret_check()
|
||||
{
|
||||
local secret_name=$1
|
@ -1,2 +1,4 @@
|
||||
source /opt/kaido/src/libs/bash/envs.sh
|
||||
source /opt/kaido/src/libs/bash/functions.sh
|
||||
source /opt/kaido/src/libs/bash/functions-common.sh
|
||||
source /opt/kaido/src/libs/bash/functions-commands.sh
|
||||
source /opt/kaido/src/libs/bash/functions-containers.sh
|
Loading…
x
Reference in New Issue
Block a user