acmesh-official / acme.sh

A pure Unix shell script implementing ACME client protocol
https://acme.sh
GNU General Public License v3.0
39.4k stars 4.98k forks source link

script for Mosquitto server with certificate #5253

Open spendist opened 2 months ago

spendist commented 2 months ago

dir: deploy/mosquitto.sh content

#!/usr/bin/bash

#Here is a script to deploy cert to mosquitto server.

#returns 0 means success, otherwise error.

########  Public functions #####################
export MQTT_HOST="192.168.0.73"      # Change to your server IP or hostname
export MQTT_DIR="/etc/mosquitto/certs/"

#domain keyfile certfile cafile fullchain
mosquitto_deploy() {
  _cdomain="$1"
  _ckey="$2"
  _ccert="$3"
  _cca="$4"
  _cfullchain="$5"

  _debug _cdomain "$_cdomain"
  _debug _ckey "$_ckey"
  _debug _ccert "$_ccert"
  _debug _cca "$_cca"
  _debug _cfullchain "$_cfullchain"

  _info "== Begin deploy certificate to mosquitto server: [$MQTT_HOST:$MQTT_DIR]"
  [ -d ${MQTT_DIR} ] || mkdir $MQTT_DIR
  scp $_cfullchain $MQTT_HOST:$MQTT_DIR  
  scp $_ckey       $MQTT_HOST:$MQTT_DIR
  scp $_ccert      $MQTT_HOST:$MQTT_DIR
  scp $_cca        $MQTT_HOST:$MQTT_DIR
  ssh $MQTT_HOST "chown -R mosquitto:mosquitto $MQTT_DIR"
  ssh $MQTT_HOST  "systemctl restart mosquitto"
  _info " == End deploy certificate to mosquitto server: [$MQTT_HOST:$MQTT_DIR]"
  return 0
}

================================================

github-actions[bot] commented 2 months ago

Please upgrade to the latest code and try again first. Maybe it's already fixed. acme.sh --upgrade If it's still not working, please provide the log with --debug 2, otherwise, nobody can help you.