MQTT script error on Hassbian 1.1 - mosquitto_sub: command not found

Have run the script to install Mosquitto,

sudo ./hassbian-scripts/install_mosquitto.sh

I then get the following, which concludes with Installation done! but it appears not to be the case…

Mosquitto Installer for Hassbian
Modified by Landrash for use with Hassbian.
Copyright© 2016 Dale Higgs https://gitter.im/dale3h

Adding mosquitto user
The system user `mosquitto’ already exists. Exiting.
Creating pid file
Creating data directory
Installing repository key
./hassbian-scripts/install_mosquitto.sh: line 26: cd: /srv/homeassistant/src: No such file or directory
–2017-02-24 14:14:04-- http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
Resolving repo.mosquitto.org (repo.mosquitto.org)… 85.119.83.194, 2001:ba8:1f1:f271::2
Connecting to repo.mosquitto.org (repo.mosquitto.org)|85.119.83.194|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 3137 (3.1K) [application/octet-stream]
Saving to: ‘mosquitto-repo.gpg.key’

mosquitto-repo.gpg.ke 100%[==========================>] 3.06K --.-KB/s in 0s

2017-02-24 14:14:04 (122 MB/s) - ‘mosquitto-repo.gpg.key’ saved [3137/3137]

OK
Adding repository
–2017-02-24 14:14:05-- http://repo.mosquitto.org/debian/mosquitto-jessie.list
Resolving repo.mosquitto.org (repo.mosquitto.org)… 85.119.83.194, 2001:ba8:1f1:f271::2
Connecting to repo.mosquitto.org (repo.mosquitto.org)|85.119.83.194|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 49 [application/octet-stream]
Saving to: ‘mosquitto-jessie.list.1’

mosquitto-jessie.list 100%[==========================>] 49 --.-KB/s in 0s

2017-02-24 14:14:05 (3.63 MB/s) - ‘mosquitto-jessie.list.1’ saved [49/49]

Installing mosquitto
Hit http://repo.mosquitto.org jessie InRelease
Hit http://archive.raspberrypi.org jessie InRelease
Get:1 http://repo.mosquitto.org jessie/main armhf Packages [2,187 B]
Ign http://repo.mosquitto.org jessie/main Translation-en_GB
Ign http://repo.mosquitto.org jessie/main Translation-en
Hit http://archive.raspberrypi.org jessie/main armhf Packages
Hit http://archive.raspberrypi.org jessie/ui armhf Packages
Ign http://archive.raspberrypi.org jessie/main Translation-en_GB
Ign http://archive.raspberrypi.org jessie/main Translation-en
Ign http://archive.raspberrypi.org jessie/ui Translation-en_GB
Ign http://archive.raspberrypi.org jessie/ui Translation-en
Err http://mirrordirector.raspbian.org jessie InRelease

Err http://mirrordirector.raspbian.org jessie Release.gpg
Cannot initiate the connection to mirrordirector.raspbian.org:80 (2a00:1098:0:80:1000:75:0:3). - connect (101: Network is unreachable) [IP: 2a00:1098:0:80:1000:75:0:3 80]
Reading package lists… Done
N: Ignoring file ‘mosquitto-jessie.list.1’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension
N: Ignoring file ‘pwfile’ in directory ‘/etc/apt/sources.list.d/’ as it has no filename extension
W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/jessie/InRelease

W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/jessie/Release.gpg Cannot initiate the connection to mirrordirector.raspbian.org:80 (2a00:1098:0:80:1000:75:0:3). - connect (101: Network is unreachable) [IP: 2a00:1098:0:80:1000:75:0:3 80]

W: Some index files failed to download. They have been ignored, or old ones used instead.
libmosquittopp-dev - MQTT version 3.1 client C++ library, development files
mosquitto - MQTT version 3.1/3.1.1 compatible message broker
mosquitto-dbg - debugging symbols for mosquitto binaries
python-mosquitto - MQTT version 3.1 Python client library
python3-mosquitto - MQTT version 3.1 Python 3 client library
libmosquitto-dev - MQTT version 3.1/3.1.1 client library, development files
libmosquitto1 - MQTT version 3.1/3.1.1 client library
libmosquitto1-dbg - debugging symbols for libmosquitto binaries
libmosquittopp1 - MQTT version 3.1/3.1.1 client C++ library
libmosquittopp1-dbg - debugging symbols for libmosquittopp binaries
mosquitto-clients - Mosquitto command line MQTT clients
N: Ignoring file ‘mosquitto-jessie.list.1’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension
N: Ignoring file ‘pwfile’ in directory ‘/etc/apt/sources.list.d/’ as it has no filename extension
N: Ignoring file ‘mosquitto-jessie.list.1’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension
N: Ignoring file ‘pwfile’ in directory ‘/etc/apt/sources.list.d/’ as it has no filename extension
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
libc-ares2 libmosquitto1 libwebsockets3
Suggested packages:
apparmor
The following NEW packages will be installed:
libc-ares2 libmosquitto1 libwebsockets3 mosquitto mosquitto-clients
0 upgraded, 5 newly installed, 0 to remove and 6 not upgraded.
Need to get 325 kB of archives.
After this operation, 801 kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
libwebsockets3 libc-ares2
N: Ignoring file ‘mosquitto-jessie.list.1’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension
N: Ignoring file ‘pwfile’ in directory ‘/etc/apt/sources.list.d/’ as it has no filename extension
N: Ignoring file ‘mosquitto-jessie.list.1’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension
N: Ignoring file ‘pwfile’ in directory ‘/etc/apt/sources.list.d/’ as it has no filename extension
E: There are problems and -y was used without --force-yes
Writing default configuration
./hassbian-scripts/install_mosquitto.sh: line 41: cd: /etc/mosquitto: No such file or directory
mv: cannot stat ‘mosquitto.conf’: No such file or directory
cp: cannot create regular file ‘/etc/mosquitto/mosquitto.conf’: No such file or directory
chown: cannot access ‘mosquitto.conf’: No such file or directory
Initializing password file

Please take a moment to setup your first MQTT user

Username: Robin
Password:
Creating password entry for user Robin
./hassbian-scripts/install_mosquitto.sh: line 69: mosquitto_passwd: command not found
Restarting Mosquitto service
Failed to restart mosquitto.service: Unit mosquitto.service failed to load: No such file or directory.

Installation done!

Your MQTT broker is running at 192.168.0.15
192.168.0.13:1883

If you have issues with this script, please contact @Landrash on gitter.im
Original script by @dale3h on gitter.im

pi@hassbian:~ $ mosquitto_sub -d -u Robin -P xxxxxx -t dev/test
-bash: mosquitto_sub: command not found

Ok this is strange… My install above was via SSH. I repeated the install on my pi directly (i.e. via monitor and mouse) and it has now worked

SSH should have worked but if you look at your log the server it was trying to install from was down or unreachable for your pi.

I think this is part of the problem. I know this morning I was also trying to install mosquitto for the first time and it kept hanging trying to connect to mirrordirector. This afternoon I retried and I was able to get it installed. I’m wondering if you only got a partial install and may need to remove everything mosquitto related and start again. Now sure exactly the best way to do that – maybe someone else can chime in with that part.

1 Like