Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Noschvie/ac2d5ec2a93ce070f2d4d46f0b4fe8db to your computer and use it in GitHub Desktop.

Select an option

Save Noschvie/ac2d5ec2a93ce070f2d4d46f0b4fe8db to your computer and use it in GitHub Desktop.

Revisions

  1. Noschvie revised this gist May 3, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions create_docker_compose_basic_auth_string_for_traefik.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #!/usr/bin/env bash
    #!/bin/bash

    command -v docker >/dev/null 2>&1 || { echo >&2 "I require Docker but it's not installed. Aborting."; exit 1; }

    @@ -11,7 +11,7 @@ docker pull httpd:alpine >/dev/null 2>&1
    # Generate strings
    echo "------- Your string for configuration file (YAML/TOML) --------"
    string=$(docker run --rm -i -t httpd:alpine htpasswd -nbB $USER $PW)
    echo $string
    echo "$string"
    echo "------- Your string for docker-compose.yml --------"
    # Escape string
    echo "$string" | sed -e 's/\$/\$\$/g'
  2. @movd movd revised this gist Dec 16, 2019. 1 changed file with 6 additions and 8 deletions.
    14 changes: 6 additions & 8 deletions create_docker_compose_basic_auth_string_for_traefik.sh
    100644 → 100755
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,16 @@
    #!/bin/bash
    #!/usr/bin/env bash

    SUDO=''
    if (( $EUID != 0 )); then SUDO='sudo'; fi
    command -v docker >/dev/null 2>&1 || { echo >&2 "I require Docker but it's not installed. Aborting."; exit 1; }

    echo "Basic auth for traefik >= v1.7"
    read -p "User: " USER
    read -p "Password: " PW

    # Checks if htpasswd is available or install it otherwise
    which htpasswd >/dev/null || ($SUDO apt-get update && $SUDO apt-get install apache2-utils)
    # Pull httpd:alpine image (small and includes httpasswd)
    docker pull httpd:alpine >/dev/null 2>&1

    # Generate strings
    echo "------- Your string for .env --------"
    string=$(htpasswd -nbB $USER $PW)
    echo "------- Your string for configuration file (YAML/TOML) --------"
    string=$(docker run --rm -i -t httpd:alpine htpasswd -nbB $USER $PW)
    echo $string
    echo "------- Your string for docker-compose.yml --------"
    # Escape string
  3. @TechupBusiness TechupBusiness revised this gist Apr 9, 2019. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions create_docker_compose_basic_auth_string_for_traefik.sh
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,14 @@
    #!/bin/bash

    SUDO=''
    if (( $EUID != 0 )); then
    SUDO='sudo'
    fi
    if (( $EUID != 0 )); then SUDO='sudo'; fi

    echo "Basic auth for traefik >= v1.7"
    read -p "User: " USER
    read -p "Password: " PW

    # Checks if htpasswd is available or install it otherwise
    which htpasswd >/dev/null || ($sudo apt-get update && $sudo apt-get install apache2-utils)
    which htpasswd >/dev/null || ($SUDO apt-get update && $SUDO apt-get install apache2-utils)

    # Generate strings
    echo "------- Your string for .env --------"
  4. @TechupBusiness TechupBusiness created this gist Apr 9, 2019.
    21 changes: 21 additions & 0 deletions create_docker_compose_basic_auth_string_for_traefik.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/bin/bash

    SUDO=''
    if (( $EUID != 0 )); then
    SUDO='sudo'
    fi

    echo "Basic auth for traefik >= v1.7"
    read -p "User: " USER
    read -p "Password: " PW

    # Checks if htpasswd is available or install it otherwise
    which htpasswd >/dev/null || ($sudo apt-get update && $sudo apt-get install apache2-utils)

    # Generate strings
    echo "------- Your string for .env --------"
    string=$(htpasswd -nbB $USER $PW)
    echo $string
    echo "------- Your string for docker-compose.yml --------"
    # Escape string
    echo "$string" | sed -e 's/\$/\$\$/g'