vault backup: 2024-01-12 13:01:20

This commit is contained in:
2024-01-12 13:01:20 +08:00
parent 1860ca6c42
commit a34c8270a3
12 changed files with 301 additions and 39 deletions

View File

@@ -0,0 +1,18 @@
{
"nodes":[
{"id":"e94c9e71b9aeaa89","type":"group","x":440,"y":-360,"width":400,"height":900,"label":"設定"},
{"id":"d624199752cf24de","type":"text","text":"![[更新與安裝工具]]","x":460,"y":-340,"width":360,"height":120},
{"id":"a63a5baed201beda","type":"text","text":"![[設定日誌大小]]","x":460,"y":160,"width":360,"height":180},
{"id":"f210470376a4829d","type":"text","text":"![[設定Cloudflare DDNS]]","x":460,"y":370,"width":360,"height":150},
{"id":"6e59f6b9f36b24e2","type":"text","text":"![[安裝]]","x":-80,"y":-37,"width":383,"height":177},
{"id":"bc030994aafc5a3b","type":"text","text":"![[bashrc]]","x":460,"y":-37,"width":360,"height":177},
{"id":"6875474760fafe7c","type":"text","text":"![[raspi-config]]","x":460,"y":-200,"width":360,"height":140}
],
"edges":[
{"id":"9683c15c63c167c0","fromNode":"6e59f6b9f36b24e2","fromSide":"right","toNode":"e94c9e71b9aeaa89","toSide":"left"},
{"id":"af36558e6c250c94","fromNode":"d624199752cf24de","fromSide":"bottom","toNode":"6875474760fafe7c","toSide":"top"},
{"id":"feff628bc758f1e4","fromNode":"6875474760fafe7c","fromSide":"bottom","toNode":"bc030994aafc5a3b","toSide":"top"},
{"id":"f1a7af20d2d64873","fromNode":"bc030994aafc5a3b","fromSide":"bottom","toNode":"a63a5baed201beda","toSide":"top"},
{"id":"64bd8b56a86d56af","fromNode":"a63a5baed201beda","fromSide":"bottom","toNode":"f210470376a4829d","toSide":"top"}
]
}

View File

@@ -0,0 +1,5 @@
## `~/.bashrc`
```bash
alias ll='ls -al'
alias pwoff='sudo shutdown -h now'
```

View File

@@ -0,0 +1,40 @@
## `/home/awin/script/ddns.sh`
```bash
#!/bin/bash
CF_ACCESS_TOKEN=033xQP4_ZpTq3sSkeftz5J6BWw_R9eoDNTba7zfH
CF_ZONE_ID=1d6a623d1780c31544fc86f718dac16e
URLS=('awin.one'
'blog.awin.one'
'ftp.awin.one'
'git.awin.one',
'storj.awin.one')
CF_RECORD_IDS=('d67b2a1b3d7cd520b8e8dad2cb522460'
'69dcc0bd619b1a3d4a71458faff2aa50'
'bd397d9779d42c0b92c9c9c47b765769'
'4eccb48e85f2daa8fefeb92c8cb4b4ee'
'216d631bc860c6a11b62e3a1003f3e3e')
INTERNET_IP=`curl -s http://ipv4.icanhazip.com`
INTERFACE_IP=`ip address show ppp0 | grep ppp0 | grep global | awk '{print$2}'`
DNS_RECORD_IP=`dig +short "${URLS[0]}" | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | awk 'NR==1{print}'`
NOW_TIME=`date`
if [ "$INTERNET_IP" != "$DNS_RECORD_IP" ]
then
echo "Renew IP: ${DNS_RECORD_IP} to ${INTERNET_IP}"
echo "${NOW_TIME}: Renew IP: ${DNS_RECORD_IP} to ${INTERNET_IP}" > /home/awin/log/ddns.log
for ((i = 0; i < ${#URLS[@]}; i++)); do
curl -X PUT "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/dns_records/${CF_RECORD_IDS[$i]}" \
-H "Authorization: Bearer ${CF_ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
--data '{"type":"A","name":"'${URLS[$i]}'","content":"'${INTERNET_IP}'","ttl":120,"proxied":false}'
done
else
echo "No change: ${INTERNET_IP}"
echo "${NOW_TIME}: No change: ${INTERNET_IP}" > /home/awin/log/ddns.log
fi
```
### 參考
- [5 分鐘整合 Cloudflare API 實做 Cloudflare DDNS 動態 IP 對應網址](https://blog.toright.com/posts/7333/cloudflare-ddns)
- [自架 DDNS 教學:用 Cloudflare API 達成多域名同步更新! | by Rex | Medium](https://blog.rexyuan.com/%E7%94%A8-cloudflare-dns-api-%E4%BE%86%E9%81%94%E6%88%90-ddns-adaee3c5a84d)

View File

@@ -0,0 +1,3 @@
## `raspi-config`
1. 打開ssh與vnc
2. 開機進入console

View File

@@ -0,0 +1,5 @@
1. 到[官網](https://www.raspberrypi.com/software/)下載`imager`
2. 記得在`imager`裡面設定
1. ssh public key
2. WIFI
3. account/password

View File

@@ -0,0 +1,3 @@
1. `sudo apt update`
2. `sudo apt upgrade -y`
3. `sudo apt install dnsutils`

View File

@@ -0,0 +1,3 @@
用[[crontab]]設定[[ddns.sh]]
1. `crontab -e`
2. 加入 `*/15 * * * * /home/awin/script/ddns.sh`

View File

@@ -0,0 +1,5 @@
打開`/etc/systemd/journald.conf`
- `SystemMaxUse=1G`
- `RuntimeMaxUse=100M`
[[journalctl]]