kchristensen / udm-le

Let's Encrypt support for Ubiquiti UniFi OS
MIT License
594 stars 79 forks source link

Error running initial command #24

Closed hanss50 closed 3 years ago

hanss50 commented 3 years ago

Running the command gives:

/mnt/data/udm-le/udm-le.sh initial

: not founddm-le/udm-le.sh: /mnt/data/udm-le/udm-le.env: line 4:

First 4 lines of udm-le.sh :

!/bin/sh

set -e

Load environment variables

. /mnt/data/udm-le/udm-le.env

ls -l of /mnt/data/udm-le/ -rw-r--r-- 1 root root 5225 Jan 6 01:50 CODE_OF_CONDUCT.md -rw-r--r-- 1 root root 1073 Jan 6 01:50 LICENSE -rw-r--r-- 1 root root 2966 Jan 6 01:50 README.md drwxr-xr-x 2 root root 4096 Jan 6 01:53 on_boot.d -rw-r--r-- 1 root root 1298 Jan 6 01:57 udm-le.env -rwxr-xr-x 1 root root 3299 Jan 6 01:50 udm-le.sh

Any suggestions?

kchristensen commented 3 years ago

That looks fine to me, what kind of hardware and unifi-os version are you running?

hanss50 commented 3 years ago

That looks fine to me, what kind of hardware and unifi-os version are you running?

info output: Model: UniFi Dream Machine PRO Version: 1.8.5.2964

kchristensen commented 3 years ago

I'd say check the format of your udm-le.env file to make sure you don't have any syntax errors in there, that's all I can think of that would be causing it to error possibly.

hanss50 commented 3 years ago

Here is my config (with mydomain, user, CloudFlare token in place of what I put). Unless the CloudFlare token needs single quotes around it (I don't think I took those out), I don't see any syntax issues.

Required configuration

Email for LetsEncrypt certificate issuance

CERT_EMAIL='user@mydomain.net'

The FQDN of your UDMP (comma separated fqdns are supported)

CERT_HOSTS='unifi.mydomain.net'

Enable updating Captive Portal certificate as well as device certificate

ENABLE_CAPTIVE='no'

CloudFlare settings, see the README.md for information about other providers

Note: Quoting your CLOUDFLARE_DNS_API_TOKEN below seems to cause issues

CLOUDFLARE_DNS_API_TOKEN=my cloudflare token DNS_PROVIDER='cloudflare'

GCP CloudDNS settings, see the README.md for information about other providers.

Note: The default path for the service account file is /root/.gcloud

GCE_SERVICE_ACCOUNT_FILE=/root/.gcloud/sa.json

DNS_PROVIDER='gcloud'

GCE_PROPAGATION_TIMEOUT=3600

Change stuff below at your own risk

DNS_RESOLVERS supports a host:port if you need to override system DNS

DNS_RESOLVERS=''

Changing below requires changing line 6 of udm-le.sh

UDM_LE_PATH='/mnt/data/udm-le'

These should only change if Unifi-OS core changes require it

CERT_IMPORT_CMD='java -jar /usr/lib/unifi/lib/ace.jar import_key_cert' UBIOS_CERT_PATH='/mnt/data/unifi-os/unifi-core/config' UNIFIOS_CERT_PATH='/data/unifi-core/config'

hanss50 commented 3 years ago

I noticed a space between the . and the / in the udm-le.sh script (on line 4 that it's compaining about). Should that space be there?

kchristensen commented 3 years ago

Yeah the space is intentional, . is a shell equivalent to source.

tackynugget commented 3 years ago

Hi, I'm just getting my feet wet with these kinds of mods and found this thread and wanted to try to help out if I could.

I intentionally sabotaged line 4 of my /mnt/data/udm-le-master/udm-le.sh shell script (inserted a stray letter in the file path to get it to fail; unrelated, I chose to keep the folder name the same as the extracted zip archive of this repo) and it returned this error: /mnt/data/udm-le-master/udm-le.sh: .: line 6: can't open '/qmnt/data/udm-le-master/udm-le.env': No such file or directory

I also noticed that line 4 of my shell script is an empty space--I had spaces surrounding the set -e #!/bin/sh ` set -e # Load environment variables . /mnt/data/udm-le-master/udm-le.env`

Whereas @hanss50 initial post didn't seem to have spaces there. Also, the reported error message appeared to have a typo: : not founddm-le/udm-le.sh: /mnt/data/udm-le/udm-le.env: line 4:

I'm not sure if that might help identify the source of the problem. In my adventures here, I've also come to prefer editing these sorts of files via the vi text editor, as I have found that copying/pasting some characters (like the single quotes from line 4 of the udm-le.env file) can cause issues.

I hope this helps. Thanks @kchristensen for developing this!

kchristensen commented 3 years ago

Good idea, I hadn't considered people were copy and pasting this vs curling it off of github, downloading a zip, or cloning it.