mirror of
https://github.com/jung-geun/DynamicDNS-SSL.git
synced 2025-12-19 20:44:40 +09:00
Refactor file paths and update cronjob for Cloudflare DDNS
This commit is contained in:
35
scripts/certbot.sh
Executable file
35
scripts/certbot.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Certbot 및 Cloudflare API 도구 설치
|
||||
sudo apt update
|
||||
sudo apt install -y certbot python3-certbot-dns-cloudflare jq
|
||||
|
||||
# 필요한 변수 설정
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
CONFIG_FILE="$DIR/../config/env.json"
|
||||
DOMAIN=$(jq -r '.CLOUDFLARE_DOMAIN' $CONFIG_FILE)
|
||||
CERTBOT_EMAIL=$(jq -r '.EMAIL' $CONFIG_FILE)
|
||||
CLOUDFLARE_API_TOKEN=$(jq -r '.CLOUDFLARE_API_KEY' $CONFIG_FILE)
|
||||
|
||||
# Cloudflare API 자격 증명 파일 생성
|
||||
CLOUDFLARE_CREDENTIALS_FILE="/etc/letsencrypt/cloudflare.ini"
|
||||
sudo mkdir -p /etc/letsencrypt
|
||||
sudo bash -c "echo 'dns_cloudflare_api_token = ${CLOUDFLARE_API_TOKEN}' > ${CLOUDFLARE_CREDENTIALS_FILE}"
|
||||
sudo chmod 600 ${CLOUDFLARE_CREDENTIALS_FILE}
|
||||
|
||||
# Certbot을 사용하여 인증서 발급 및 갱신
|
||||
sudo certbot certonly \
|
||||
--dns-cloudflare \
|
||||
--dns-cloudflare-credentials ${CLOUDFLARE_CREDENTIALS_FILE} \
|
||||
--email ${CERTBOT_EMAIL} \
|
||||
--agree-tos \
|
||||
--no-eff-email \
|
||||
-d "*.${DOMAIN}" \
|
||||
-d "${DOMAIN}"
|
||||
|
||||
# 크론탭을 사용하여 자동 갱신 설정 (매일 0시, 12시 실행)
|
||||
echo "0 0,12 * * * /usr/bin/certbot renew --dns-cloudflare --dns-cloudflare-credentials ${CLOUDFLARE_CREDENTIALS_FILE} --quiet" > $DIR/../cron/cronjob-certbot
|
||||
sudo cp $DIR/../cron/cronjob-certbot /etc/cron.d/certbot-renew
|
||||
|
||||
echo "Certbot and Cloudflare API tools installation completed."
|
||||
21
scripts/install.sh
Executable file
21
scripts/install.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
@echo off
|
||||
echo "Certbot and Cloudflare API tools installation"
|
||||
sudo apt update
|
||||
sudo apt install -y certbot python3-certbot-dns-cloudflare jq
|
||||
|
||||
sudo mkdir -p /app/cloudflare-ddns
|
||||
sudo cp -r $DIR/../* /app/cloudflare-ddns
|
||||
if [ -f /app/cloudflare-ddns/config/env.json ]; then
|
||||
echo "Environment configuration file already exists. Back up the existing file and create a new file."
|
||||
sudo mv /app/cloudflare-ddns/config/env.json /app/cloudflare-ddns/config/env.json.bak
|
||||
fi
|
||||
sudo mkdir -p /app/cloudflare-ddns/config
|
||||
sudo cp $DIR/../config/env_example.json /app/cloudflare-ddns/config/env.json
|
||||
sudo chmod 600 /app/cloudflare-ddns/config/env.json
|
||||
sudo cp $DIR/../cron/cronjob-ddns /etc/cron.d/cloudflare-ddns
|
||||
echo "Please modify the environment configuration file and save it in the /app/cloudflare-ddns/config/env.json path."
|
||||
|
||||
echo "Certbot and Cloudflare API tools installation completed."
|
||||
10
scripts/run_script.sh
Executable file
10
scripts/run_script.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
export CLOUDFLARE_API_KEY=$API_KEY
|
||||
export CLOUDFLARE_DOMAIN=$DOMAIN_NAME
|
||||
export CLOUDFLARE_ZONE_ID=$ZONE_ID
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# Run the script
|
||||
python3 $DIR/../src/update_dns.py $@
|
||||
10
scripts/start.sh
Executable file
10
scripts/start.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
if [ ! -f $DIR/../config/env.json ]; then
|
||||
cp $DIR/../config/default_env.json $DIR/../config/env.json
|
||||
fi
|
||||
|
||||
$DIR/run_script.sh
|
||||
|
||||
tail -f /var/log/cloudflare_ddns.log
|
||||
7
scripts/uninstall.sh
Normal file
7
scripts/uninstall.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
@echo "Uninstalling Cloudflare DDNS and Certbot..."
|
||||
@sudo rm -rf /app/cloudflare-ddns
|
||||
@sudo rm /etc/cron.d/cloudflare-ddns
|
||||
@sudo rm /var/log/cloudflare_ddns.log
|
||||
@sudo rm /var/log/cloudflare_ddns.log.*
|
||||
@echo "Done"
|
||||
Reference in New Issue
Block a user