[ADD] Added info for the update_dns_cloudflare script and production md file
Signed-off-by: Alexandre Ferreira Benevides <alexandre.ferreira.benevides@gmail.com>
This commit is contained in:
parent
e96a83f036
commit
4e54ead47a
2 changed files with 43 additions and 10 deletions
|
|
@ -133,24 +133,40 @@ CAUTION, this will delete user's home, it's irrevocable.
|
||||||
|
|
||||||
# Update ip when public ip change with CloudFlare and crontab
|
# Update ip when public ip change with CloudFlare and crontab
|
||||||
|
|
||||||
|
First you need a valid python3 interpreter running with cloudflare module installed: (make sure your pip3 pointing the right python3)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip3 install cloudflare==2.20.0
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you need to create the cfg files with credentials for your cloudflare account.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir ~/.cloudflare
|
mkdir ~/.cloudflare
|
||||||
```
|
```
|
||||||
|
|
||||||
Edit ~/.cloudflare/cloudflare.cfg
|
Edit ~/.cloudflare/cloudflare.cfg
|
||||||
|
|
||||||
```
|
```
|
||||||
[PROFILE_NAME]
|
[PROFILE_NAME]
|
||||||
email=EMAIL
|
email=EMAIL
|
||||||
token=TOKEN
|
token=TOKEN (Use the global API key so that it works)
|
||||||
```
|
```
|
||||||
|
|
||||||
Add your cron
|
Add your cron and specify the python3 you want to use with it.
|
||||||
|
- USER is the local user with permissions to execute the script
|
||||||
|
- PATH is path to inside of ERPLibre/deployment/ folder
|
||||||
|
- PROFILE_NAME must match the PROFILE_NAME in cloudflare.cfg
|
||||||
|
- CLOUDFLARE_ZONE_NAME is the name of the website zone on cloudflare
|
||||||
|
- DNS_NAME is the name of one DNS A record name available on that zone
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
- Only one crontab is required because the script will automatically research all available zones with outdated ip and update them on all A records.
|
||||||
|
- For each crontab run, if public IP did not change compared to what is on cloudflare, the script will not do unnecessary changes and let everything as is.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
vim /etc/crontab
|
vim /etc/crontab
|
||||||
# Add
|
# Add
|
||||||
*/5 * * * * USER cd PATH && ./script/deployment/update_dns_cloudflare.py --profile PROFILE_NAME --zone_name CLOUDFLARE_ZONE_NAME --dns_name DNS_NAME --auto_sync
|
*/5 * * * * USER cd PATH && python3 script/deployment/update_dns_cloudflare.py --profile PROFILE_NAME --zone_name CLOUDFLARE_ZONE_NAME --dns_name DNS_NAME --auto_sync
|
||||||
```
|
```
|
||||||
|
|
||||||
Check log with
|
Check log with
|
||||||
|
|
@ -159,6 +175,21 @@ Check log with
|
||||||
sudo journalctl -feu cron
|
sudo journalctl -feu cron
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you want to log what is happening and when the script is run, like logging when ip changes, you can add a logging part to your cron
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vim /etc/crontab
|
||||||
|
# Add
|
||||||
|
*/5 * * * * USER cd PATH && python3 script/deployment/update_dns_cloudflare.py --profile PROFILE_NAME --zone_name CLOUDFLARE_ZONE_NAME --dns_name DNS_NAME --auto_sync > /home/USER/logs/update_dns_ZONE_NAME.log 2>&1
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
You can then read all logs with this command (Need to have ts installed: sudo apt install moreutils)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tail -f /home/USER/logs/update_dns_ZONE_NAME.log | ts
|
||||||
|
```
|
||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
|
|
||||||
## Update
|
## Update
|
||||||
|
|
|
||||||
|
|
@ -27,17 +27,19 @@ def get_config():
|
||||||
Can update all old_ip to new_ip.
|
Can update all old_ip to new_ip.
|
||||||
When auto_sync is enable:
|
When auto_sync is enable:
|
||||||
Check zone and name on cloudflare and compare with public ip, update all old ip with new ip if different.
|
Check zone and name on cloudflare and compare with public ip, update all old ip with new ip if different.
|
||||||
You need your profile in file ~/.cloudflare/cloudflare.cfg
|
1-you need a valid python3 interpreter running with cloudflare module installed:
|
||||||
|
pip3 install cloudflare==2.20.0
|
||||||
|
2-You need your profile in file ~/.cloudflare/cloudflare.cfg
|
||||||
Example:
|
Example:
|
||||||
[profil_name]
|
[profil_name]
|
||||||
email=email@email.com
|
email=email@email.com
|
||||||
token=TOKEN
|
token=TOKEN (Use the global API key so that it works)
|
||||||
|
|
||||||
Configure locally a crontab and adapt it, crontab -e, specify an existing DNS
|
Configure locally a crontab and adapt it, crontab -e, specify an existing DNS
|
||||||
Example each 5 minutes:
|
Example each 5 minutes:
|
||||||
*/5 * * * * USERNAME cd /home/USERNAME/ERPLibre && ./script/deployment/update_dns_cloudflare.py --profile profil_name --zone_name example.com --dns_name example.com --auto_sync
|
*/5 * * * * USERNAME cd /home/USERNAME/ERPLibre && python3 script/deployment/update_dns_cloudflare.py --profile profil_name --zone_name example.com --dns_name example.com --auto_sync
|
||||||
Example each minute:
|
Example each minute:
|
||||||
* * * * * USERNAME cd /home/USERNAME/ERPLibre && ./script/deployment/update_dns_cloudflare.py --profile profil_name --zone_name example.com --dns_name example.com --auto_sync
|
* * * * * USERNAME cd /home/USERNAME/ERPLibre && python3 script/deployment/update_dns_cloudflare.py --profile profil_name --zone_name example.com --dns_name example.com --auto_sync
|
||||||
""",
|
""",
|
||||||
epilog="""\
|
epilog="""\
|
||||||
""",
|
""",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue