Coder Social home page Coder Social logo

shammishailaj / godaddy-gitlab-certs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yashhere/godaddy-gitlab-certs

0.0 0.0 0.0 12 KB

A set of scripts to automatically update the https certificates of website hosted on GitLab with domain manager as GoDaddy

License: MIT License

Shell 37.12% Go 62.88%

godaddy-gitlab-certs's Introduction

GoDaddy-GitLab-Certs

A set of scripts to update the HTTPS certificates of my website https://yashagarwal.in using GoDaddy and GitLab APIs.

Build Status

Usage Instructions

First of all, set the four environmental variables EMAIL_ID, GODADDY_KEY, GODADDY_SECRET and GITLAB_TOKEN in your shell.

To generate API keys for GoDaddy, sign into your account and follow the instructions on this page.

To generate personal access token for GitLab API, follow the instructions given here.

To run these scripts, you will require Certbot and GoLang installed on your machine.

Once you have finished setting up your system, clone the repository and navigate to it.

In the file certbot.sh, edit the certbot command to include your domain names.

In the subsequent curl command in the same file, edit the URL part to include your repository address where your webiste's code sits. Follow the documentation of GitLab Pages Domain API here.

Now, in the auth_hook.sh file, towards the end, edit the if statement to compare the CERTBOT_DOMAIN variable to the the domain name, which is the last in the list that you defined in the certbot command above. For example -

certbot --manual \
--preferred-challenges dns \
--agree-tos \
--email "${EMAIL_ID}" \
--no-eff-email \
--expand \
--renew-by-default \
--manual-public-ip-logging-ok \
--noninteractive \
--redirect \
--config-dir ${DIR}/generated/config \
--work-dir ${DIR}/generated/work \
--logs-dir ${DIR}/generated/logs \
--manual-auth-hook ${DIR}/auth_hook.sh \
-d photos.yashagarwal.in \
-d yashagarwal.in \
-d readings.yashagarwal.in \ # THIS IS THE LAST DOMAIN DEFINED
certonly

So, in the auth_hook.sh file -

# Comparing with the last domain
if [ "${CERTBOT_DOMAIN}"  =  "readings.yashagarwal.in" ];  then
	for  (( i=0; i<5; i++ ));  do
		sleep 60s
	done
fi

Domain registrars require some time to publish the changes in the DNS records. Here I have assumed 15 minutes in case of GoDaddy, and it works fine for me. Change the time limit according to your experience.

Also update the key_dir vairable in the certbot.sh file to include your last domain name as explained above. So in the above case, key_dir variable will be -

key_dir="${DIR}/generated/config/live/readings.yashagarwal.in"

Now, while you are in the root of the directory, execute the following command -

bash certbot.sh

If everything works as expected, then you will see following message -

...
Congratulations! Your certificate and chain have been saved at:
...

The script will automatically update your https certificate on the GitLab pages also. Your website will reflect the changes in some time.

Authors

License

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

This script by Pallav Agarwal was the initial inspiration for this work. You can observe a lot of similarities in both the codes. Basically, I have just modified his code to work with GoDaddy API.

godaddy-gitlab-certs's People

Contributors

yashhere avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.