2 Commits
Author SHA1 Message Date
agboola 39ae143d33 Merge pull request 'added cloudflare DNS provider' (#5) from patch-1.3 into main
Reviewed-on: #5
2025-11-14 20:32:39 +00:00
agboola 19d6047b74 added cloudflare DNS provider
Cloudflare dns
2025-11-14 20:32:18 +00:00
+36 -16
View File
@@ -6,10 +6,10 @@
#revoked certificate names would be removed from existing list of issued certificates - done #revoked certificate names would be removed from existing list of issued certificates - done
#cron jobs would be created for renew function - done #cron jobs would be created for renew function - done
#add auto update for lego tool - (also to cron) - done, not using cron making manual from menu #add auto update for lego tool - (also to cron) - done, not using cron making manual from menu
#add install for webserver type either apache/nginx - done
#add install for webserver type either apache/nginx - pending #auto create default config file for created domains (man i really wish i can do this. lol) - pfff - I definitely will - pending
#RSYNC to different servers when renewed (either through sshkey or password think sshkey would be nicer) - pending
#auto create default config file for created domains (man i really wish i can do this. lol)
#Export to be based on user preference #Export to be based on user preference
#Enviromental Variables for certificate paths, this is to make sure certificates are always issued in same path #Enviromental Variables for certificate paths, this is to make sure certificates are always issued in same path
@@ -17,6 +17,7 @@
#Can be run without root - root only needed to install dependencies from apt/yum #Can be run without root - root only needed to install dependencies from apt/yum
#should be folder that doesn't need root permission #should be folder that doesn't need root permission
#Use case - namecheap (environment variable depends on dns provider) #Use case - namecheap (environment variable depends on dns provider)
#check out https://go-acme.github.io/lego/dns/index.html for dns provider variables #check out https://go-acme.github.io/lego/dns/index.html for dns provider variables
@@ -33,16 +34,23 @@ install_as_sudo() {
set_env_variables() { set_env_variables() {
#envs for lego #envs for lego
export CERT_PATH=/etc/acme export CERT_PATH=/etc/acme
export CONTACT_MAIL=xxxxxxxxxxxxxxxxxxxxxxxx export CONTACT_MAIL=info@theonasanyas.com
export DNS_PROVIDER=namecheap export DNS_PROVIDER=cloudflare
export NAMECHEAP_API_USER=xxxxxxxxxxxxxxxxxxxxxxxx
export NAMECHEAP_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxx
#envs for path #namecheap envs for lego
#export NAMECHEAP_API_USER=xxxxxxxxxxxxxxxxxxxxxxxx
#export NAMECHEAP_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxx
#cloudflare envs for lego
export CLOUDFLARE_EMAIL=xxxxxxxxxxxxxxxxxxxxxxxx@xxxx.xxx
export CLOUDFLARE_DNS_API_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxx
#envs for path - (i'm doing this to avoid lego being run without using this script)
export LEGO_PATH=$CERT_PATH export LEGO_PATH=$CERT_PATH
export GOPATH=$HOME/.go export GOPATH=$HOME/.go
export GO_HOME=/usr/local/go export GO_HOME=/usr/local/go
export PATH=$PATH:$GO_HOME/bin:$GOPATH/bin export PATH=$PATH:$GO_HOME/bin:$GOPATH/bin
} }
check_dependencies() { check_dependencies() {
@@ -176,7 +184,7 @@ install_web_server() {
exit 0 exit 0
;; ;;
"apache") "apache")
eval "echo $SUDO_PASS | sudo -S $install_cmd install apach2e* -y" eval "echo $SUDO_PASS | sudo -S $install_cmd install apache2* -y"
echo_message echo_message
exit 0 exit 0
;; ;;
@@ -195,11 +203,24 @@ echo_message(){
printf "\n\n\n" printf "\n\n\n"
echo "run below command as admin if SELINUX is enabled to allow network connections" echo "run below command as admin if SELINUX is enabled to allow network connections"
echo "setsebool httpd_can_network_connect 1" echo "setsebool httpd_can_network_connect 1"
echo "setsebool -P haproxy_connect_any=1"
echo "Install firewall (firewall-cmd or ufw) for additional security" echo "Install firewall (firewall-cmd or ufw) for additional security"
} }
update_lego() { update_lego() {
###to be used to store output from crontab renewals
LOG_PATH="$CERT_PATH/log"
DATE=$(date +%F-%H%M)
LOG_FILE="$LOG_PATH/lego-update-$DATE.log"
if [ ! -d $LOG_PATH ]; then
mkdir -p $LOG_PATH
fi
echo " "
eval " lego -v"
echo " "
export GO111MODULE=on export GO111MODULE=on
eval "go install github.com/go-acme/lego/v4/cmd/lego@latest" 2>&1 | tee -a $LOG_FILE eval "go install github.com/go-acme/lego/v4/cmd/lego@latest" 2>&1 | tee -a $LOG_FILE
} }
@@ -274,12 +295,11 @@ autorenew() {
###to be used to store output from crontab renewals ###to be used to store output from crontab renewals
LOG_PATH="$CERT_PATH/log" LOG_PATH="$CERT_PATH/log"
DATE=$(date +%F-%H%M) DATE=$(date +%F-%H%M)
LOG_FILE="$LOG_PATH/acme-$DATE" LOG_FILE="$LOG_PATH/acme-$DATE.log"
if [ ! -d $LOG_PATH ]; then if [ ! -d $LOG_PATH ]; then
mkdir -p $PATH mkdir -p $LOG_PATH
fi fi
for files in $(find $LEGO_PATH/certificates/*.json -type f); do for files in $(find $LEGO_PATH/certificates/*.json -type f); do
IFS=$'\n' IFS=$'\n'
for file in $files; do for file in $files; do
@@ -295,10 +315,10 @@ autorenew() {
functionlist() { functionlist() {
PS3="Select Option to enter option or and key to exit: " PS3="Select Option to enter option or and key to exit: "
options=("run" "revoke" "renew" "list" "update lego" "install webserver") options=("issue" "revoke" "renew" "list" "update lego" "install webserver")
select option in "${options[@]}"; do select option in "${options[@]}"; do
case $option in case $option in
"run") "issue")
run run
;; ;;
"revoke") "revoke")
@@ -327,7 +347,7 @@ functionlist() {
functionvar() { functionvar() {
case $1 in case $1 in
"run") "issue")
run run
;; ;;
"revoke") "revoke")
@@ -360,4 +380,4 @@ if [ -z "$1" ]; then
else else
functionvar $1 functionvar $1
exit 0 exit 0
fi f3