# Install prerequisites pkg update pkg install python311 py311-certbot py311-certbot-dns-cloudflare git # There have some different name in my truenas core 13, update this command. # Use pkg search certbot you can check the latest version.
# Install the deploy script git clone https://github.com/danb35/deploy-freenas.git /opt/deploy-freenas cp /opt/deploy-freenas/deploy_config.example /opt/deploy-freenas/deploy_config # Now configure the deploy script by editing /opt/deploy-freenas/deploy_config # Add some detail. pkg install vim # Edit it. vim /opt/deploy-freenas/deploy_config # 这里面的 私钥 和 fullchain 证书的位置, 与脚本提供的默认位置已经不同了,需要在配置文件里面指定一下。 # 如果还没生成证书可以暂时不配置, certbot 命令运行完成后回来填。 # Please note that you need to replace all [...] with your values. # Line-Number CONFIG field 7 api_key = [YOUR TRUENAS CORE API KEY create at step 2] 14 cert_fqdn = [YOUR TRUENAS CORE FQDN FOR CERT CSR] 28 privkey_path = [/usr/local/etc/letsencrypt/live/[FQDN]/privkey.pem] 33 fullchain_path = [/usr/local/etc/letsencrypt/live/[FQDN]/fullchain.pem]
# Run certbot to get the certificates for the first time (fill in the domain and email address) # 在运行这个命令结束之后, 会提供正确的保存位置, 将这个路径填到 /opt/deploy-freenas/deploy_config 这个配置文件中。 certbot certonly -d ["*.example.com"] -m ["your.email@example.com"] --dns-cloudflare --dns-cloudflare-credentials /usr/local/etc/certbot_cloudflare.conf --preferred-challenges dns-01
# Ensure the deploy script can successfully deploy the certificate to TrueNAS Core # 在这里需要指定一下写好的配置文件, 理论上应该是直接运行命令可以识别到, 为了保险和后续的稳定执行, 在命令行加参数指定。 /opt/deploy-freenas/deploy_freenas.py -c /opt/deploy-freenas/deploy_config