Fix symlink problem - add missing files

This commit is contained in:
Robin Meier 2024-03-16 02:40:31 +01:00
parent 3264fd94de
commit 6f057ecd93
5 changed files with 84 additions and 5 deletions

View File

@ -1 +0,0 @@
/home/robin/.post_startup_env

3
.post_startup_env.EXAMPLE Executable file
View File

@ -0,0 +1,3 @@
DOCKER_HOME=/mnt/trident/docker
DOCKERS_TO_START=nextcloud,gitea,immich
DOCKERS_TO_RESTART=privatebin

View File

@ -1 +0,0 @@
.system_health_check_env

View File

@ -0,0 +1,3 @@
RAM_LIMIT=90
CPU_LIMIT=90
TEMP_LIMIT=85

View File

@ -1 +0,0 @@
.zfs_health_check_env

View File

@ -0,0 +1 @@
MONITORED_DATASETS="trident/media trident/private trident/qbli"

View File

@ -1 +0,0 @@
/home/robin/post_startup.sh

65
post_startup.sh Executable file
View File

@ -0,0 +1,65 @@
#!/bin/bash
set -o allexport
source .post_startup_env
set +o allexport
check_datasets_to_unlock () {
local num_datasets_to_unlock=0
for dataset in $(zfs list -H -p -o name,encryptionroot | awk -F "\t" '{if ($1 == $2) { print $1 }}')
do
if [ "$(zfs get -H -p -o value keylocation "$dataset")" = "prompt" ] && [ "$(zfs get -H -p -o value keystatus "$dataset")" = "unavailable" ]
then
local num_datasets_to_unlock=$((num_datasets_to_unlock+1))
fi
done
return $num_datasets_to_unlock
}
# /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// ///
echo "Checking for locked datasets..."
echo
while true; do
check_datasets_to_unlock
datasets_to_unlock=$?
sleep 1
if [[ "$datasets_to_unlock" -eq "0" ]]; then
echo "All datasets have been unlocked."
echo
break
else
echo "There are $datasets_to_unlock dataset(s) to unlock:"
echo
sudo /usr/bin/zfs mount -a -l
echo
fi
done
echo
echo "Starting relevant docker containers..."
echo
sleep 1
for docker_folder in ${DOCKERS_TO_START//,/ }
do
sudo --user=docker /usr/bin/docker compose --file $DOCKER_HOME/$docker_folder/docker-compose.yml up -d
echo
done
echo
echo "Restarting relevant docker containers..."
echo
sleep 1
for docker_folder in ${DOCKERS_TO_RESTART//,/ }
do
sudo --user=docker /usr/bin/docker compose --file $DOCKER_HOME/$docker_folder/docker-compose.yml restart
echo
done
echo
echo "Completed post startup script."

View File

@ -1 +0,0 @@
/etc/systemd/system/shutdown.target.wants/run-before-shutdown.service

View File

@ -0,0 +1,12 @@
[Unit]
Description=Run before shutdown service
DefaultDependencies=no
Before=shutdown.target
[Service]
Type=oneshot
ExecStart=/root/scripts/telegram_notification.sh "[SHUTDOWN] System going down"
TimeoutStartSec=0
[Install]
WantedBy=shutdown.target