bin: update walli & add synct

This commit is contained in:
xerus2000 2021-03-26 19:02:21 +01:00
parent 9d91fb90fa
commit 8fb5292834
2 changed files with 12 additions and 4 deletions

3
.local/bin/scripts/synct Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
apikey=$(grep apikey $XDG_CONFIG_HOME/syncthing/config.xml | cut -d '>' -f2 | cut -d '<' -f1)
curl -H 'Content-Type: application/json' -H "X-API-Key: $apikey" "http://localhost:8384/rest/$1" "${@:2}" | bat --style=numbers -l json

View File

@ -1,13 +1,18 @@
#!/bin/sh #!/bin/sh
# https://askubuntu.com/a/124512 and https://blog.sleeplessbeastie.eu/2018/06/21/how-to-create-iptables-firewall-using-custom-chains/ # https://askubuntu.com/a/124512 and https://blog.sleeplessbeastie.eu/2018/06/21/how-to-create-iptables-firewall-using-custom-chains/
sudo iptables --new-chain chain-times 2>/dev/null || sudo iptables --flush chain-times sudo iptables --new-chain chain-times 2>/dev/null || sudo iptables --flush chain-times
time9=$(date -u -d "$(date -d 09:00)" +%k)
# Always allow local connections - https://serverfault.com/a/550278 # Always allow local connections - https://serverfault.com/a/550278
sudo iptables -A chain-times -m owner --uid-owner janek -d 192.168.1.0/24 -j ACCEPT sudo iptables -A chain-times -m owner --uid-owner janek -d 192.168.1.0/24 -j ACCEPT
sudo iptables -A chain-times -m owner --uid-owner janek -d 127.0.0.0/8 -j ACCEPT sudo iptables -A chain-times -m owner --uid-owner janek -d 127.0.0.0/8 -j ACCEPT
sudo iptables -A chain-times -m owner --uid-owner janek -j DROP -m time --timestart $(date -u -d "$(date -d "${1:-15 min}")" +%k:%M) --timestop $time9:00
sudo iptables -A chain-times -m owner --uid-owner janek -j DROP -m time --weekdays 1-5 --timestart $time9:20 --timestop $(expr $time9 + 1):00 time9=$(date -u -d "$(date -d 09:00)" +%k)
sudo iptables -A chain-times -m owner --uid-owner janek -j DROP -m time --weekdays 1-5 --timestart $(expr $time9 + 1):20 --timestop $(expr $time9 + 2):00 sudo iptables -A chain-times -m owner --uid-owner janek -j DROP -m time \
--timestart $(date -u -d "$(date -d "${1:-15 min}")" +%k:%M) --timestop $time9:00
sudo iptables -A chain-times -m owner --uid-owner janek -j DROP -m time --weekdays 1-5 \
--timestart $time9:20 --timestop $(expr $time9 + 1):00
sudo iptables -A chain-times -m owner --uid-owner janek -j DROP -m time --weekdays 1-5 \
--timestart $(expr $time9 + 1):20 --timestop $(expr $time9 + 2):00
sudo iptables -L OUTPUT | grep -q "^chain-times" || sudo iptables -A OUTPUT -j chain-times sudo iptables -L OUTPUT | grep -q "^chain-times" || sudo iptables -A OUTPUT -j chain-times
if test "$2" = "--save"; then if test "$2" = "--save"; then
sudo iptables-save | sudo tee /etc/iptables/walli.rules sudo iptables-save | sudo tee /etc/iptables/walli.rules