add rsync scripts and wg config
This commit is contained in:
17
rsync_cron/christopher.kolb
Normal file
17
rsync_cron/christopher.kolb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
folders=(
|
||||||
|
#00_Temp
|
||||||
|
01_Projects
|
||||||
|
02_Lernen
|
||||||
|
03_Dateien
|
||||||
|
04_Medien
|
||||||
|
#05_Programme
|
||||||
|
#06_Downloads
|
||||||
|
#07_Programme
|
||||||
|
Backup
|
||||||
|
Documents
|
||||||
|
Kamera-Uploads
|
||||||
|
Keepass
|
||||||
|
Notes
|
||||||
|
Screenshot_2015-05-18-21-08-01.png
|
||||||
|
syncdate.txt
|
||||||
|
)
|
||||||
44
rsync_cron/cron-rsync-clear-remote.sh
Executable file
44
rsync_cron/cron-rsync-clear-remote.sh
Executable file
@@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
BWLIMIT=2500
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--bwlimit)
|
||||||
|
BWLIMIT="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
./reresolve-dns.sh
|
||||||
|
systemctl stop wg-quick@wg0
|
||||||
|
systemctl start wg-quick@wg0
|
||||||
|
|
||||||
|
#WENN wg show einen lange zurückliegenden handshake zeigt, muss der keepalive auf Serverseite verlängert werden
|
||||||
|
|
||||||
|
cd /home/ck/
|
||||||
|
|
||||||
|
echo syncing `pwd` `date`
|
||||||
|
|
||||||
|
source sync-accounts
|
||||||
|
|
||||||
|
for account in ${accounts[@]}; do
|
||||||
|
echo $account
|
||||||
|
source $account
|
||||||
|
|
||||||
|
echo $(date "+%FT%T") >> /media/data/ncdata/data/$account/files/syncdate.txt
|
||||||
|
echo "$(tail -20 /media/data/ncdata/data/$account/files/syncdate.txt)" > /media/data/ncdata/data/$account/files/syncdate.txt
|
||||||
|
|
||||||
|
for folder in ${folders[@]}; do
|
||||||
|
echo $folder
|
||||||
|
#!! in rsync --delete deletes all fles that are available remotely but not locally
|
||||||
|
## -n für "trockenlauf"
|
||||||
|
rsync -auszv --bwlimit=$BWLIMIT --password-file=rsyncpw --delete /media/data/ncdata/data/$account/files/$folder Christopher@server-haus-12b.home::Christopher/$account/files/
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
#echo $(date "+%FT%T") >> $logfile
|
||||||
41
rsync_cron/cron-rsync-reverse.sh
Executable file
41
rsync_cron/cron-rsync-reverse.sh
Executable file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
BWLIMIT=2500
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--bwlimit)
|
||||||
|
BWLIMIT="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
./reresolve-dns.sh
|
||||||
|
systemctl stop wg-quick@wg0
|
||||||
|
systemctl start wg-quick@wg0
|
||||||
|
|
||||||
|
#WENN wg show einen lange zurückliegenden handshake zeigt, muss der keepalive auf Serverseite verlängert werden
|
||||||
|
|
||||||
|
cd /home/ck/
|
||||||
|
|
||||||
|
echo syncing `pwd` `date`
|
||||||
|
|
||||||
|
source sync-accounts
|
||||||
|
|
||||||
|
for account in ${accounts[@]}; do
|
||||||
|
echo $account
|
||||||
|
source $account
|
||||||
|
|
||||||
|
# echo $(date "+%FT%T") >> /media/data/ncdata/data/$account/files/syncdate.txt
|
||||||
|
|
||||||
|
for folder in ${folders[@]}; do
|
||||||
|
echo $folder
|
||||||
|
rsync -auszv --progress --bwlimit=$BWLIMIT --password-file=rsyncpw --exclude-from="exclude-file" Christopher@server-haus-12b.home::Christopher/$account/files/$folder /media/data/ncdata/data/$account/files/
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
#echo $(date "+%FT%T") >> $logfile
|
||||||
46
rsync_cron/cron-rsync.sh
Executable file
46
rsync_cron/cron-rsync.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
BWLIMIT=2500
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--bwlimit)
|
||||||
|
BWLIMIT="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
./reresolve-dns.sh
|
||||||
|
systemctl stop wg-quick@wg0
|
||||||
|
systemctl start wg-quick@wg0
|
||||||
|
|
||||||
|
#WENN wg show einen lange zurückliegenden handshake zeigt, muss der keepalive auf Serverseite verlängert werden
|
||||||
|
|
||||||
|
cd /home/ck/
|
||||||
|
|
||||||
|
echo syncing `pwd` `date`
|
||||||
|
|
||||||
|
source sync-accounts
|
||||||
|
|
||||||
|
for account in ${accounts[@]}; do
|
||||||
|
echo $account
|
||||||
|
source $account
|
||||||
|
|
||||||
|
echo $(date "+%FT%T") >> /media/data/ncdata/data/$account/files/syncdate.txt
|
||||||
|
echo "$(tail -20 /media/data/ncdata/data/$account/files/syncdate.txt)" > /media/data/ncdata/data/$account/files/syncdate.txt
|
||||||
|
|
||||||
|
for folder in ${folders[@]}; do
|
||||||
|
echo $folder
|
||||||
|
EXTRA_FLAGS=""
|
||||||
|
if [ "$folder" == "Backup" ]; then
|
||||||
|
EXTRA_FLAGS="--delete"
|
||||||
|
fi
|
||||||
|
rsync -auszv $EXTRA_FLAGS --bwlimit=$BWLIMIT --password-file=rsyncpw /media/data/ncdata/data/$account/files/$folder Christopher@server-haus-12b.home::Christopher/$account/files/
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
#echo $(date "+%FT%T") >> $logfile
|
||||||
2
rsync_cron/exclude-file
Normal file
2
rsync_cron/exclude-file
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
@*
|
||||||
|
.designerthumb
|
||||||
1
rsync_cron/family
Normal file
1
rsync_cron/family
Normal file
@@ -0,0 +1 @@
|
|||||||
|
folders=()
|
||||||
768223
rsync_cron/log
Normal file
768223
rsync_cron/log
Normal file
File diff suppressed because one or more lines are too long
1
rsync_cron/marina.schens
Normal file
1
rsync_cron/marina.schens
Normal file
@@ -0,0 +1 @@
|
|||||||
|
folders=()
|
||||||
46
rsync_cron/reresolve-dns.sh
Executable file
46
rsync_cron/reresolve-dns.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
#
|
||||||
|
# Copyright (C) 2015-2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
||||||
|
|
||||||
|
echo reresolve `date`
|
||||||
|
|
||||||
|
set -e
|
||||||
|
shopt -s nocasematch
|
||||||
|
shopt -s extglob
|
||||||
|
export LC_ALL=C
|
||||||
|
|
||||||
|
CONFIG_FILE="$1"
|
||||||
|
[[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,15}$ ]] && CONFIG_FILE="/etc/wireguard/$CONFIG_FILE.conf"
|
||||||
|
[[ $CONFIG_FILE =~ /?([a-zA-Z0-9_=+.-]{1,15})\.conf$ ]]
|
||||||
|
INTERFACE="${BASH_REMATCH[1]}"
|
||||||
|
|
||||||
|
process_peer() {
|
||||||
|
[[ $PEER_SECTION -ne 1 || -z $PUBLIC_KEY || -z $ENDPOINT ]] && return 0
|
||||||
|
[[ $(wg show "$INTERFACE" latest-handshakes) =~ ${PUBLIC_KEY//+/\\+}\ ([0-9]+) ]] || return 0
|
||||||
|
(( ($EPOCHSECONDS - ${BASH_REMATCH[1]}) > 135 )) || return 0
|
||||||
|
wg set "$INTERFACE" peer "$PUBLIC_KEY" endpoint "$ENDPOINT"
|
||||||
|
reset_peer_section
|
||||||
|
}
|
||||||
|
|
||||||
|
reset_peer_section() {
|
||||||
|
PEER_SECTION=0
|
||||||
|
PUBLIC_KEY=""
|
||||||
|
ENDPOINT=""
|
||||||
|
}
|
||||||
|
|
||||||
|
reset_peer_section
|
||||||
|
while read -r line || [[ -n $line ]]; do
|
||||||
|
stripped="${line%%\#*}"
|
||||||
|
key="${stripped%%=*}"; key="${key##*([[:space:]])}"; key="${key%%*([[:space:]])}"
|
||||||
|
value="${stripped#*=}"; value="${value##*([[:space:]])}"; value="${value%%*([[:space:]])}"
|
||||||
|
[[ $key == "["* ]] && { process_peer; reset_peer_section; }
|
||||||
|
[[ $key == "[Peer]" ]] && PEER_SECTION=1
|
||||||
|
if [[ $PEER_SECTION -eq 1 ]]; then
|
||||||
|
case "$key" in
|
||||||
|
PublicKey) PUBLIC_KEY="$value"; continue ;;
|
||||||
|
Endpoint) ENDPOINT="$value"; continue ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
done < "$CONFIG_FILE"
|
||||||
|
process_peer
|
||||||
1
rsync_cron/sync-accounts
Normal file
1
rsync_cron/sync-accounts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
accounts=(christopher.kolb marina.schens family)
|
||||||
11
wg/wg0.conf
Normal file
11
wg/wg0.conf
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[Interface]
|
||||||
|
PrivateKey = yJ4YHfJuUV6vvfMaObt5YYEtWesAcHt/uACuJNtqXk4=
|
||||||
|
Address = 10.200.200.2/24
|
||||||
|
#DNS = 192.168.2.1
|
||||||
|
|
||||||
|
[Peer]
|
||||||
|
PublicKey = dWtALjJh6avKZfb9uFMxFv7LlBJPf2fwn5l8IgaLX1A=
|
||||||
|
PresharedKey = 8FOMGLaholfh7DqF99qjQ2GVsDhLRiUl2KXEWuuuZTI=
|
||||||
|
AllowedIPs = 192.168.2.0/24
|
||||||
|
Endpoint = haus12b.ddns.net:53280
|
||||||
|
PersistentKeepalive = 21
|
||||||
Reference in New Issue
Block a user