Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script for Mosquitto server with certificate #5253

Open
spendist opened this issue Aug 20, 2024 · 1 comment
Open

script for Mosquitto server with certificate #5253

spendist opened this issue Aug 20, 2024 · 1 comment

Comments

@spendist
Copy link

spendist commented Aug 20, 2024

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
}

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

Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant