SiloCityLabs / lochnas

Docker configuration for all-in-one nas setup
https://lochnas.com
GNU General Public License v3.0
50 stars 3 forks source link

Bring domain add into golang #35

Closed ldrrp closed 2 years ago

ldrrp commented 2 years ago

Problem

Currently the old domain add script lives in bash:

# Check if nginx is running
DOCKER_STOPPED=false
if [ "$(docker ps -q -f name=nginx)" ]; then
    if [ "$(docker ps -aq -f status=running -f name=nginx)" ]; then
        #need to stop temp
        docker container stop nginx
        DOCKER_STOPPED=true
    fi
fi

if [ -z "$1" ]
  then
    echo "Please supply the domain name: 'add-domain.sh domain.com'"
    exit 1
fi

docker run --rm -i \
-v "/docker-nas/docker-data/letsencrypt:/etc/letsencrypt" \
-v "/docker-nas/docker-data/certbot:/var/www/certbot" \
-p 80:80 \
-p 443:443 \
certbot/certbot 'certonly' '--standalone' \
"-d $1" '--agree-tos' "-m $GLOBAL_EMAIL"

if [ $DOCKER_STOPPED = true ]; then
    docker container start nginx
fi

Solution

Allow the user to run command to add a domain name certificate. We want to eliminate calling scripts entirely.

We need to carry this into golang at the following location:

https://github.com/SiloCityLabs/docker-nas/blob/v3/server/models/domain.go#L49

Steps to Reproduce the Problem

  1. ./server.bin -domain add domain.com