mirror of
https://gitlab.com/Snogard/kaido.git
synced 2025-08-20 10:50:06 +02:00
added reverse-proxy install, added reverse-proxy config, now update.sh should account for user configurations too when installing
This commit is contained in:
parent
a9389226ec
commit
ec03aa451e
@ -7,13 +7,13 @@ chmod 777 /opt/kaido
|
||||
```
|
||||
Then in your .zshrc or .bashrc
|
||||
```
|
||||
alias kaido="/opt/kaido/kaido.sh
|
||||
alias kaido="/opt/kaido/kaido.sh"
|
||||
```
|
||||
|
||||
# Configuration
|
||||
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
|
||||
### Folder structure
|
||||
- /etc/kaido
|
||||
- commands (not implemented)
|
||||
- containers
|
||||
@ -43,11 +43,11 @@ regardless of the order in the file, the execution is in this order:
|
||||
1. install
|
||||
2. configure
|
||||
|
||||
###
|
||||
warning: No parameters are supported yet
|
||||
|
||||
# Container Installation:
|
||||
|
||||
## gitlab-runner
|
||||
### gitlab-runner
|
||||
|
||||
first time:
|
||||
```
|
||||
|
19
src/commands/config/config-reverse-proxy.sh
Normal file
19
src/commands/config/config-reverse-proxy.sh
Normal file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
containerName=reverse-proxy
|
||||
srcConfigPath=/etc/kaido/containers/$containerName/config
|
||||
dstConfigPath=/mnt/storage/containers/$containerName/config
|
||||
|
||||
if [ -d $srcConfigPath ]; then
|
||||
echo "Failed config: reverse-proxy"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
systemctl stop --user $containerName
|
||||
|
||||
# TODO make chown id configurable
|
||||
echo "Copy ${srcConfigPath} contents to ${dstConfigPath}"
|
||||
sudo cp -r $srcConfigPath/. $dstConfigPath/
|
||||
sudo chown -R 100999:100999 $dstConfigPath
|
||||
|
||||
systemctl start --user $containerName
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
source /opt/kaido/src/libs/bash/lib.sh
|
||||
# docs https://github.com/nextcloud/docker
|
||||
source /opt/kaido/src/libs/bash/lib.sh
|
||||
|
||||
echo "This is still experimental"
|
||||
exit 1
|
||||
|
52
src/commands/install/install-reverse-proxy.sh
Normal file
52
src/commands/install/install-reverse-proxy.sh
Normal file
@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
source /opt/kaido/src/libs/bash/lib.sh
|
||||
# docs = https://github.com/linuxserver/docker-swag
|
||||
|
||||
# setup
|
||||
imageName=docker.io/linuxserver/swag:2.6.0-ls207
|
||||
containerName=reverse-proxy
|
||||
|
||||
dstConfigPath=/mnt/storage/containers/$containerName/config
|
||||
|
||||
# envs
|
||||
timezone="Europe/Rome"
|
||||
domain="example.com"
|
||||
subdomains=""
|
||||
email="example@example.com"
|
||||
|
||||
source /ect/kaido/containers/$containerName/envs.sh
|
||||
|
||||
# pre install
|
||||
create_folder $dstConfigPath
|
||||
stop_and_remove_container $containerName
|
||||
|
||||
# firewall
|
||||
echo "Checking firewall rules"
|
||||
|
||||
echo "Allowing https"
|
||||
sudo ufw allow 443/tcp
|
||||
|
||||
echo "Allowing http"
|
||||
sudo ufw allow 80/tcp
|
||||
|
||||
|
||||
# install
|
||||
echo "Creating new container"
|
||||
podman create \
|
||||
--name $containerName \
|
||||
--cap-add=NET_ADMIN \
|
||||
--net=host \
|
||||
-e PUID=1000 \
|
||||
-e PGID=1000 \
|
||||
-e TZ=$timezone \
|
||||
-e URL=$domain \
|
||||
-e SUBDOMAINS=$subdomains \
|
||||
-e VALIDATION=http \
|
||||
-e EMAIL=$email \
|
||||
-v $dstConfigPath:/config \
|
||||
$imageName
|
||||
|
||||
|
||||
# systemd
|
||||
create_systemd_services $containerName
|
||||
systemctl --user enable --now $containerName
|
@ -2,13 +2,16 @@
|
||||
source /opt/kaido/src/libs/bash/lib.sh
|
||||
|
||||
# variables
|
||||
root=/opt/kaido
|
||||
workdir=$HOME/.cache/kaido
|
||||
confdir=/etc/kaido
|
||||
configureScript=$root/src/commands/configure.sh
|
||||
installScript=$root/src/commands/install.sh
|
||||
buildScript=$root/src/commands/build.sh
|
||||
updateConfig=$confdir/update.conf
|
||||
root="/opt/kaido"
|
||||
workdir="$HOME/.cache/kaido"
|
||||
confdir="/etc/kaido"
|
||||
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"
|
||||
# ----------
|
||||
|
||||
|
||||
@ -30,10 +33,7 @@ fi
|
||||
# ----------------------
|
||||
|
||||
|
||||
if [ -d "$MASTER_CONFIG_FOLDER" ]; then
|
||||
cd "$MASTER_CONFIG_FOLDER"
|
||||
git pull
|
||||
fi
|
||||
|
||||
|
||||
# read config files
|
||||
installList=$(cat ${updateConfig} | grep -i install-)
|
||||
@ -42,28 +42,32 @@ buildList=$(cat ${updateConfig} | grep -i build-)
|
||||
# -----------------------
|
||||
|
||||
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
|
||||
cd $root
|
||||
sudo git reset --hard
|
||||
sudo git pull
|
||||
|
||||
echo ""
|
||||
|
||||
# executables
|
||||
# echo -e "Configuring script permissions\n"
|
||||
# sudo chmod +x -R $root/scripts
|
||||
# sudo chmod +x -R $root/installation
|
||||
# sudo chmod +x -R $root/configuration/container-units
|
||||
# echo -e "Permissions added\n"
|
||||
|
||||
|
||||
# protected
|
||||
#sudo chmod 600 -R $root/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
|
||||
@ -71,12 +75,19 @@ if [ -f "${previusCommitFile}" ]; then
|
||||
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}"
|
||||
echo ""
|
||||
echo "Kaido: "
|
||||
echo "previus commit: ${previusCommit}"
|
||||
echo "current commit: ${currentCommit}"
|
||||
echo "Config:"
|
||||
echo "previus commit: ${previusCommit_config}"
|
||||
echo "current commit: ${currentCommit_config}"
|
||||
|
||||
|
||||
|
||||
|
||||
# auto update builds
|
||||
|
||||
@ -93,7 +104,10 @@ echo ""
|
||||
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 src/commands/install | grep -qi $name ; then
|
||||
# TODO support parameters
|
||||
if $(git diff --name-only $previusCommit $currentCommit src/commands/install | grep -qi $name) || \
|
||||
( [ -f "$confdir/containers/$name/envs.sh" ] && $(git diff --name-only $previusCommit_config $currentCommit_config "$confdir/containers/$name/envs.sh" | grep -qi "envs\.sh" ) ) || \
|
||||
[ ! $(git diff --name-only $previusCommit_config $currentCommit_config $confdir/containers/$name/secrets) -z ] ; then
|
||||
echo -e "Updating ${name} installation\n"
|
||||
$installScript $name
|
||||
fi
|
||||
@ -102,23 +116,17 @@ 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 "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
|
||||
exit 0
|
Loading…
x
Reference in New Issue
Block a user