Initial commit, with README and deploy script
This commit is contained in:
commit
3937672576
22
README.md
Normal file
22
README.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# App server configuration
|
||||||
|
|
||||||
|
This repository contains the running configuration files for App server's services (containers).
|
||||||
|
|
||||||
|
## Use
|
||||||
|
* all modifications to services' configurations should be done in this repository and then deployed
|
||||||
|
(see [below](#deployment))
|
||||||
|
* then, after it's been tested and validated, a change can be commit and pushed
|
||||||
|
* this way, it is easy to revert to last working state
|
||||||
|
|
||||||
|
### Deployment
|
||||||
|
Script `deploy.sh` copies configuration files for selected or all of below services, and then reloads Systemd and
|
||||||
|
restarts said services.
|
||||||
|
|
||||||
|
## Services
|
||||||
|
|
||||||
|
### Nspawn containers
|
||||||
|
We use Systemd Nspawn containers to host our applications. They reside in standard directory `/var/lib/machines`,
|
||||||
|
each mounted from a BTRFS subvolume (see [this repository](https://gitea.kto.black/adminconf/containers) for more
|
||||||
|
details). These containers' configuration thus reside in 2 places:
|
||||||
|
* `fstab` lists the subvolumes to mount
|
||||||
|
* `/etc/systemd/nspawn/` contains each container's configuration file
|
40
deploy.sh
Executable file
40
deploy.sh
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ "$1" = "" ]; then
|
||||||
|
echo "Please specify one of nspawn or all. Exiting."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
nspawn=0
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [[ $arg = "nspawn" || $arg = "all" ]]; then
|
||||||
|
nspawn=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $nspawn -eq 0 ]]; then
|
||||||
|
echo "Please specify one of nspawn or all. Exiting."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
run_directory=$(dirname $(readlink -f "$0"))
|
||||||
|
|
||||||
|
if [[ $user != 'root' ]]; then
|
||||||
|
sudo="sudo"
|
||||||
|
else
|
||||||
|
sudo=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $nspawn -eq 1 ]]; then
|
||||||
|
echo "Deploying nspawn containers configuration..."
|
||||||
|
echo "WARNING: Mind that containers will not be stopped or started, neither will subvolumes be mounted or unmounted."
|
||||||
|
$sudo rm /etc/systemd/nspawn/*
|
||||||
|
$sudo cp $run_directory/nspawn/*.nspawn /etc/systemd/nspawn/
|
||||||
|
$sudo cp $run_directory/nspawn/fstab /etc/fstab
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Reloading Systemd..."
|
||||||
|
$sudo systemctl daemon-reload
|
||||||
|
|
||||||
|
echo "Finished deployment. Exiting..."
|
||||||
|
exit 0
|
Loading…
Reference in New Issue
Block a user