Skip to content

Instantly share code, notes, and snippets.

@faruktoptas
Created January 30, 2019 15:13
Show Gist options
  • Save faruktoptas/373216be4e282a92c80654f9a6964ee6 to your computer and use it in GitHub Desktop.
Save faruktoptas/373216be4e282a92c80654f9a6964ee6 to your computer and use it in GitHub Desktop.
Script to renew letsencrypt certificate
echo "1/7 Stopping nginx"
sudo service nginx stop
echo "2/7 Removing mongod.lock"
rm /var/lib/mongodb/mongod.lock
echo "3/7 Stopping mongod"
sudo service mongod stop
echo "4/7 Renewing letsencrypt"
/opt/letsencrypt/letsencrypt-auto renew
echo "5/7 Copying new certificate"
sudo cat /etc/letsencrypt/archive/[SITE_NAME]/{fullchain$1.pem,privkey$1.pem} | sudo tee /etc/ssl/mongo.pem
echo "6/7 Restarting mongod"
sudo service mongod start
echo "7/7 Restarting nginx"
sudo service nginx start
echo "Renewing finished."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment