first commit

This commit is contained in:
Snogard 2023-07-06 14:17:44 +02:00
commit 32668f301f
6 changed files with 172 additions and 0 deletions

0
.gitignore vendored Normal file
View File

19
kaido.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
commandName=$1
rootFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
scriptPath=${rootFolder}/src/commands/${commandName}.sh
if test -f "$scriptPath"; then
if [[ ! -x "$scriptPath" ]]; then
sudo chmod +x $scriptPath
fi
#TODO: make parameters dynamic $@
echo "Executing: $scriptPath"
$scriptPath $2 $3 $4 $5 $6 $7 $8 $9
else
echo "Error file not found: ${scriptPath}"
fi

0
readme.md Normal file
View File

23
src/commands/setup.sh Executable file
View File

@ -0,0 +1,23 @@
#!/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
if test -f "$scriptPath"; then
if [[ ! -x "$scriptPath" ]]; then
sudo chmod +x $scriptPath
fi
echo "Executing: $scriptPath"
$scriptPath $2 $3 $4 $5
else
echo "Error file not found: ${scriptPath}"
fi

View File

@ -0,0 +1,15 @@
#!/bin/bash
newHostname=$1
previusHostname=$(cat /etc/hostname)
replace="s/${previusHostname}/${newHostname}/"
sudo sed -i $replace /etc/hostname
sudo sed -i $replace /etc/hosts
echo "Stamp:"
cat /etc/hostname
cat /etc/hosts
echo "You must reboot to apply this changes

115
src/commands/update.sh Executable file
View File

@ -0,0 +1,115 @@
#!/bin/bash
# variables
workdir=$HOME/.cache/kaido
confdir=/etc/kaido
configureScript=/opt/kaido/src/commands/configure.sh
installScript=/opt/kaido/src/commands/install.sh
buildScript=/opt/kaido/src/commands/build.sh
updateConfig=$confdir/update.conf
# ----------
# create necessary folder and files
if [ ! -d "${confdir}" ]; then
echo "Creating folder at path: ${confdir}"
sudo mkdir -p $confdir
fi
if [ ! -f "${updateConfig}" ]; then
echo "Creating empty update file"
sudo touch $updateConfig
fi
if [ ! -d "${workdir}" ]; then
echo "Creating folder at path: ${workdir}"
sudo mkdir -p $workdir
fi
# ----------------------
# read config files
installList=$(cat ${updateConfig} | grep -i install-)
configureList=$(cat ${updateConfig} | grep -i configure-)
buildList=$(cat ${updateConfig} | grep -i build-)
# -----------------------
echo -e "Updating repository\n"
cd /home-server
sudo git reset --hard
sudo git pull
echo ""
# executables
# echo -e "Configuring script permissions\n"
# sudo chmod +x -R /home-server/scripts
# sudo chmod +x -R /home-server/installation
# sudo chmod +x -R /home-server/configuration/container-units
# echo -e "Permissions added\n"
# protected
#sudo chmod 600 -R /home-server/reverse-proxy-server/dns-conf
# auto update of server and configs
previusCommitFile=$workdir/previusCommit.txt
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
echo -e "Starting installation and configs auto update\n"
echo -e "previus commit: ${previusCommit}"
echo "current commit: ${currentCommit}\n"
# 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
# auto update installations
echo -e "Checking if installations need to be updated\n"
for val in $installList; do
name=${val:8}
if git diff --name-only $previusCommit $currentCommit scripts/install | grep -qi $name ; then
echo -e "Updating ${name} installation\n"
$installScript $name
fi
done
echo -e "Installations updated\n"
# ---------------------------
# auto update configs
echo -e "Checking if configs need to be updated\n"
for val in $configureList; do
name=${val:10}
if git diff --name-only $previusCommit $currentCommit configuration | grep -qi $name ; then
echo -e "Updating ${name} configuration\n"
$configureScript $name
fi
done
# ---------------------------
echo -e "Configurations Updated\n"
echo "Update complete"
exit 0
# kaido update config
# install-reverse-proxy-server
# configure-reverse-proxy-server
# configure-container-units
# configure-home-foundry