Skip to content

Instantly share code, notes, and snippets.

@CzechJiri
CzechJiri / run.sh
Created July 16, 2020 19:53
openVPN server Let's Encrypt renewal via single command line
certbot certonly --standalone \
--non-interactive \
--preferred-challenges tls-sni \
--agree-tos \
--email hostmaster@mydomain.com \
--domains vpn.mydomain.com \
--pre-hook '/usr/local/openvpn_as/scripts/sacli stop' \
--post-hook '/usr/local/openvpn_as/scripts/sacli --key "cs.priv_key" --value_file "/etc/letsencrypt/live/office.deep-labs.com/privkey.pem" ConfigPut && /usr/local/openvpn_as/scripts/sacli --key "cs.cert" --value_file "/etc/letsencrypt/live/office.deep-labs.com/cert.pem" ConfigPut && /usr/local/openvpn_as/scripts/sacli --key "cs.ca_bundle" --value_file "/etc/letsencrypt/live/office.deep-labs.com/fullchain.pem" ConfigPut && /usr/local/openvpn_as/scripts/sacli start'

Keybase proof

I hereby claim:

  • I am czechjiri on github.
  • I am czechjiri (https://keybase.io/czechjiri) on keybase.
  • I have a public key ASACq5_vCcvs6OfAcIuzbClI4oKCmHFERAMW6Ml2pNGdlgo

To claim this, I am signing this object:

@CzechJiri
CzechJiri / datetime.py
Created May 25, 2017 16:23
my ideal date format for python logging with no spaces, commas or missing timezone
from datetime import datetime, timezone
print( datetime.now(timezone.utc).isoformat() )
@CzechJiri
CzechJiri / wait-for-it postgres style
Last active June 24, 2016 20:55
running application and DB using docker-compose.yml is tricky, because app will not wait for DB to be fully up and read to accept connections (docker-compose.yml only deals with dependencies). This function can be part of application entrypoint script, it waits up to 30 seconds for postgres to start. It uses pg_isready (works even without passwo…
function pg_ready()
{
waitTime=30 # keep trying for x seconds
n=0
until [ $n -ge $waitTime ]; do
# please note pg_isready does not care about username/dbname
# you can add correct values if you want to avoid errors in PG log
pg_isready --host=$DB_HOST --port=$DB_PORT && break