42 lines
845 B
Bash
Executable File
42 lines
845 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
user=$(whoami)
|
|
|
|
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/
|
|
fi
|
|
|
|
echo "Reloading Systemd..."
|
|
$sudo systemctl daemon-reload
|
|
|
|
echo "Finished deployment. Exiting..."
|
|
exit 0
|