This commit is contained in:
Christoph J. Scherr 2024-04-22 12:22:41 +02:00
commit 81df6aaa8f
5 changed files with 61 additions and 4 deletions

View File

@ -4,7 +4,7 @@
export BORG_REPO=/srv/data/backup/borg/homeserver export BORG_REPO=/srv/data/backup/borg/homeserver
# See the section "Passphrase notes" for more infos. # See the section "Passphrase notes" for more infos.
export BORG_PASSPHRASE="$(cat /root/secret/borg-homeserver.key)" export BORG_PASSPHRASE="$(cat /root/secret/borg/borg-homeserver.key)"
# some helpers and error handling: # some helpers and error handling:
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; } info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }

View File

@ -19,7 +19,8 @@ borg check -v data/backup/borg/snowboard
status_check=$? status_check=$?
echo "finished checking the downloaded repo. Status: $status_check" echo "finished checking the downloaded repo. Status: $status_check"
if [ "$status_check" -eq "0" ]; then if [ "$status_check" -eq "0" ]; then
chown fileserver:fileserver $REPO_DIR/$backupdir cd $REPO_ROOT
chown fileserver:fileserver $backupdir
rm -r old rm -r old
else else
echo "the new repo was not checked successfully, keeping old repo." echo "the new repo was not checked successfully, keeping old repo."

30
mail-script Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env python3
from email.message import EmailMessage
import sys
if sys.argv[1] == "--help" or sys.argv[1] == "-h" or sys.argv[1] == "":
print("""
This is just a hacked together python script from stackoverflow that can be used to add a proper
MIME header for file attachments to a mail. Pipe the outpit to sendmail -oi -t to send.
usage:
mail-script "from@email.com" "to@email.com" "subject" /file/to/append < /body/of/mail | sendmail -oi -t
""")
exit(0)
msg = EmailMessage()
msg['From'] = sys.argv[1]
msg['To'] = sys.argv[2]
msg['Subject'] = sys.argv[3]
# Don't mess with the preamble, the documentation is wrong to suggest you do
msg.set_content(''.join([line for line in sys.stdin]))
with open(sys.argv[4], 'r') as attachment:
#msg.add_attachment(attachment.read(), maintype='text', subtype='plain')
asStr = attachment.read()
asBytes = asStr.encode('utf-8')
msg.add_attachment(asBytes, maintype='application', subtype='octet-stream', filename="appendix.txt")
print(msg.as_string())

25
mount-docker-sockets.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
TARGET=/var/run/docker-snowboard.socket
MAX_FAILS=10
SLEEP_TIME=2
echo "removing $TARGET"
rm /var/run/docker-snowboard.sock -rf
echo "relaying snowboards socket with ssh"
ssh -nNT -L /var/run/docker-snowboard.sock:/var/run/docker.sock root@cscherr.de &
# check if the target is a socket, and adjust it.
for ((i=0; i<=MAX_FAILS; i++)); do
if [[ $(file -b /var/run/docker-snowboard.sock) = 'socket' ]]; then
set -e
echo "$TARGET is a socket, adjusting permissions"
chmod 660 /var/run/docker-snowboard.sock
chgrp docker /var/run/docker-snowboard.sock
exit 0 # good end
else
echo "$i: $TARGET is not a socket"
fi
sleep $SLEEP_TIME
done
echo "$TARGET is not a socket even after waiting"
exit 1 # bad end

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
tailscale up \ tailscale up \
--timeout 30s \ --login-server https://vpn.cscherr.de \
--login-server https://vpn.cscherr.de \ --advertise-exit-node \
--accept-risk=lose-ssh