Compare commits

...

8 Commits

Author SHA1 Message Date
05d5edbaf2 updated envs to new vwesion 2025-03-05 17:39:41 +01:00
66890c5154 updated update script 2025-03-05 15:21:28 +01:00
189ca080b6 updated migration notification 2025-03-05 15:14:21 +01:00
f04aebb7f3 fixed typo 2025-03-05 15:10:56 +01:00
86e5e420ca fixed typos, added log 2025-03-05 15:04:56 +01:00
0857c434d0 fixed missing variable 2025-03-05 15:00:57 +01:00
33b231a37d fixed typo 2025-03-05 14:58:45 +01:00
4fa2055340 fixed typo 2025-03-05 14:58:04 +01:00
4 changed files with 14 additions and 136 deletions

View File

@ -14,7 +14,6 @@ dstDnsmasqConfigPath=$baseConfigPath/dnsmasq
# envs # envs
webport=10105 webport=10105
virtual_host=pihole_host
timezone=Europe/Rome timezone=Europe/Rome
if [ -f "$KAIDO_CONFIG_FOLDER/containers/$containerName/envs.sh" ]; then if [ -f "$KAIDO_CONFIG_FOLDER/containers/$containerName/envs.sh" ]; then
@ -42,9 +41,8 @@ echo "Creating new container"
podman create \ podman create \
--name $containerName \ --name $containerName \
--net=host \ --net=host \
-e WEB_PORT=$webport \ -e FTLCONF_webserver_port=$webport \
-e TZ="$timezone" \ -e TZ="$timezone" \
-e VIRTUAL_HOST="$virtual_host" \
-v $dstPiholeConfigPath:/etc/pihole \ -v $dstPiholeConfigPath:/etc/pihole \
-v $dstDnsmasqConfigPath:/etc/dnsmasq \ -v $dstDnsmasqConfigPath:/etc/dnsmasq \
$imageName $imageName

View File

@ -8,143 +8,21 @@ source /opt/kaido/src/libs/bash/lib.sh
root="/opt/kaido" root="/opt/kaido"
workdir="$HOME/.cache/kaido/update" workdir="$HOME/.cache/kaido/update"
confdir="$KAIDO_CONFIG_FOLDER" confdir="$KAIDO_CONFIG_FOLDER"
configureScript="$root/src/commands/configure.sh"
installScript="$root/src/commands/install.sh"
buildScript="$root/src/commands/build.sh"
updateConfig="$confdir/update.conf"
previusCommitFile="$workdir/previusCommit_kaido.txt"
previusCommitFile_config="$workdir/previousCommit_config.txt"
# ---------- # ----------
# create necessary folder and files
if [ ! -d "${confdir}" ]; then
echo "Creating folder at path: ${confdir}"
sudo mkdir -p $confdir
fi
skipContainerUpdate=0
if [ ! -f "${updateConfig}" ]; then
echo "WARNING: container updates will be skipped"
skipContainerUpdate=1
#sudo touch $updateConfig
fi
if [ ! -d "${workdir}" ]; then
echo "Creating folder at path: ${workdir}"
sudo mkdir -p $workdir
fi
# ----------------------
echo -e "Updating repository\n"
# config repository
cd "$confdir"
sudo git reset --hard
sudo git pull
echo ""
currentCommit_config=$(git rev-parse --verify HEAD)
previusCommit_config=origin/master
if [ -f "${previusCommitFile_config}" ]; then
previusCommit_config=$(head -n 1 ${previusCommitFile_config})
fi
git rev-parse --verify HEAD | sudo tee $previusCommitFile_config
# ---------------
# kaido repository # kaido repository
cd $root cd $root
sudo git reset --hard sudo git reset --hard
sudo git pull sudo git pull
echo "" #TODO: remove in the future
kaido upgrade
currentCommit=$(git rev-parse --verify HEAD)
previusCommit=origin/master
if [ -f "${previusCommitFile}" ]; then
previusCommit=$(head -n 1 ${previusCommitFile})
fi
git rev-parse --verify HEAD | sudo tee $previusCommitFile
# ------------
# read config files
installList=$(cat ${updateConfig} | grep -i install-)
configureList=$(cat ${updateConfig} | grep -i configure-)
buildList=$(cat ${updateConfig} | grep -i build-)
# -----------------------
echo -e "Starting installation and configs auto update\n"
echo "Kaido: "
echo "previus commit: ${previusCommit}"
echo "current commit: ${currentCommit}"
echo "Config:"
echo "previus commit: ${previusCommit_config}"
echo "current commit: ${currentCommit_config}"
echo ""
# TODO auto secret updates?
# auto update builds
# echo -e "Checking if custom images need to be built\n"
# for val in $buildList; do
# name=${val:5}
# if git diff --name-only $previusCommit $currentCommit build | grep -qi $name ; then
# echo -e "Building latest $name version\n"
# $buildScript $name
# fi
# done
# ---------------------------
# 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
if $(git -C "$root" diff --name-only $previusCommit $currentCommit src/commands/install | grep -qi $name) || \
( [ -f "$confdir/containers/$name/envs.sh" ] && $(git -C "$confdir" diff --name-only $previusCommit_config $currentCommit_config "$confdir/containers/$name/envs.sh" | grep -qi "envs\.sh" ) ) ;
then
echo -e "Updating ${name} installation\n"
$installScript $name
fi
done
echo -e "Installations updated\n"
# ( [ -d "$confdir/containers/$name/secrets" ] && [ ! $(git -C "$confdir" diff --name-only $previusCommit_config $currentCommit_config "$confdir/containers/$name/secrets") -z ] ) ;
# ---------------------------
# auto update configs
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
echo -e "Updating ${name} configuration\n"
$configureScript $name
fi
done
# ---------------------------
# TODO auto update sysconfig
echo -e "Configurations Updated\n"
echo "Update complete"
echo "WARNING: the update process is being split into two commands. echo "WARNING: the update process is being split into two commands.
kaido update: to download the latest container defitions and kaido versions kaido update: to download the latest container defitions and kaido versions
kaido upgrade: to donwload the lastest user configs and to actually upgrade your containers to the latest definitions" kaido upgrade: to donwload the lastest user configs and to actually upgrade your containers to the latest definitions
NOTE: when the transition is finished make sure that your kaido configs are in inside '$HOME/.config/kaido' instead of '/etc/kaido'"
echo "WARNING: if somethig fails, check your file permissions, make sure they belong to the correct user"
exit 0 exit 0

View File

@ -9,7 +9,7 @@ workDir=$HOME/.cache/kaido/update
updateConfig="$configDir/update.conf" updateConfig="$configDir/update.conf"
previousCommitFile_kaido="$workDir/previousCommit_kaido.txt" previousCommitFile_kaido="$workDir/previousCommit_kaido.txt"
previousCommitFIle_config="$workDir/previousCOmmit_config.txt" previousCommitFIle_config="$workDir/previousCommit_config.txt"
skipContainerUpdate=0 skipContainerUpdate=0
@ -28,6 +28,7 @@ fi
# get commit hashes # get commit hashes
echo "Getting kaido info"
cd "$root" cd "$root"
currentCommit_kaido=$(git rev-parse --verify HEAD) currentCommit_kaido=$(git rev-parse --verify HEAD)
@ -37,16 +38,17 @@ if [ -f "${previousCommitFile_kaido}" ]; then
fi fi
echo "Getting config info"
cd "$configDir" cd "$configDir"
git reset --hard git reset --hard
git pull git pull
currentCommit_config=$(git rev-parse --verify HEAD) currentCommit_config=$(git rev-parse --verify HEAD)
previusCommit_config=origin/master previousCommit_config=origin/master
if [ -f "${previousCommitFIle_config}" ]; then if [ -f "${previousCommitFIle_config}" ]; then
previusCommit_config=$(head -n 1 ${previousCommitFIle_config}) previousCommit_config=$(head -n 1 ${previousCommitFIle_config})
fi fi
# ------------ # ------------
@ -126,7 +128,7 @@ updateSuccess=1
# end # end
if [[ $updateSuccess -eq 1 ]]; then if [[ $updateSuccess -eq 1 ]]; then
echo $previousCommit_kaido | tee "${previousCommitFile_kaido}" echo $previousCommit_kaido | tee "${previousCommitFile_kaido}"
echo $previousCOmmit_config | tee "${previousCommitFIle_config}" echo $previousCommit_config | tee "${previousCommitFIle_config}"
fi fi

View File

@ -24,7 +24,7 @@ function symlink_folder()
function ensure_folder(){ function ensure_folder(){
local dst=$1 local dst=$1
if [ ! -d "${}" ]; then if [ ! -d "${dst}" ]; then
echo "Creating folder at path $(dst)" echo "Creating folder at path $(dst)"
mkdir -p "${dst}" mkdir -p "${dst}"
if [ ! $? -eq 0 ]; then if [ ! $? -eq 0 ]; then