Add scripts from k3s-main

This commit is contained in:
2024-12-28 06:30:02 +00:00
parent 3baa5a6306
commit eeb7102e1e
2 changed files with 50 additions and 0 deletions

31
update-ipv6-k3s.sh Executable file
View File

@@ -0,0 +1,31 @@
#! /bin/bash
PASSWORD=""
DOMAIN=nextia.cloud
addresses=$(/usr/sbin/ifconfig eth0 | grep 'inet6.*global>' | awk '{ print $2 }');
GREAT=0
add=""
for address in $addresses;
do
echo $address
secs=$(/usr/sbin/ip addr show dev eth0 | grep -A1 $address | grep -v $address | awk '{ print $2}')
if [ $GREAT -gt ${secs/sec/} ] || [ $GREAT == 0 ];
then
GREAT=${secs/sec/}
add=$address
fi
done
if [[ $add ]] && [[ -z $(grep $add /etc/haproxy/haproxy.cfg ) ]] || [[ $1 == "-f" ]] ; then
hadd=$(cat /etc/haproxy/haproxy.cfg | grep -m 1 'bind.*ssl' | awk '{ print $2 }');
sed -i s/${hadd::-4}/$add/ /etc/haproxy/haproxy.cfg
/root/.local/bin/ansible-playbook /root/ansible-notebooks/update-ip.yaml -i /root/ansible-notebooks/hosts.ini -e old_ip6="${hadd::-4}" -e new_ip6="$add"
date
echo curl --user "nextia365:$PASSWORD" -XPOST http://freedns.afraid.org/nic/update?hostname=$DOMAIN\&myip=$add
curl --user "nextia365:$PASSWORD" -XPOST http://freedns.afraid.org/nic/update?hostname=$DOMAIN\&myip=$add
systemctl restart haproxy
else
echo Unchanged
#curl --user "nextia365:$PASSWORD" -XPOST http://freedns.afraid.org/nic/update?hostname=$DOMAIN\&myip=$add
fi

19
upload_ziptars Executable file
View File

@@ -0,0 +1,19 @@
#! /bin/bash
s3cmd ls s3://k3s-main-backup/ziptars/ > /root/s3_uploads.txt
cd /home/ziptars/
for file in *;
do
if [[ -n $(grep "$file" /root/s3_uploads.txt) ]]; then
echo $file uploaded >> /root/uploads_success.txt
else
s3cmd put "$file" "s3://k3s-main-backup/ziptars/$file"
echo $file missing uploaded >> /root/uploads_success.txt
fi
done
cd