Skip to content

Commit

Permalink
install script docker and mosq update
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiny380 committed Jul 8, 2022
1 parent 51401bd commit 5d6d50f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
4 changes: 4 additions & 0 deletions install-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ if ! hash docker > /dev/null; then
usermod -aG docker $USER
usermod -aG docker $(who am i | awk '{print $1}')
set -e
echo ""
echo "-- Reboot required after docker installation! --"
echo "Then re-run this script to continue installation"
exit 0
fi
# Install requirements
apt install -y docker-compose git python3-pip jq
Expand Down
30 changes: 17 additions & 13 deletions update-mosquitto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,24 @@ function addDocker() {
echo "Creating config backup to $BACKUP_FILE"
cp $CONFIG_FILE $BACKUP_FILE

echo "Adding Docker listener to Mosquitto config"
LISTENER="listener 1883 $DOCKER_IP"
if [[ $(grep "$LISTENER" $CONFIG_FILE) ]]; then
sed -i 's/^#.*'"$LISTENER"'/'"$LISTENER"'/' $CONFIG_FILE
else
sed -i '/^listener.*/a '"$LISTENER"'' $CONFIG_FILE
fi

echo "Modifying service file to wait for Docker"
if [ -z "$(grep -E "After=.*docker.service" $SERVICE_FILE)" ]; then
sed -i 's/After=.*/& docker.service/' $SERVICE_FILE
systemctl daemon-reload
if [[ ! $(grep -E "^listener 1883$" $CONFIG_FILE) ]]; then
echo "Adding Docker listener to Mosquitto config"
LISTENER="listener 1883 $DOCKER_IP"
if [[ $(grep "$LISTENER" $CONFIG_FILE) ]]; then
sed -i 's/^#.*'"$LISTENER"'/'"$LISTENER"'/' $CONFIG_FILE
else
sed -i '/^listener.*/a '"$LISTENER"'' $CONFIG_FILE
fi

echo "Modifying service file to wait for Docker"
if [ -z "$(grep -E "After=.*docker.service" $SERVICE_FILE)" ]; then
sed -i 's/After=.*/& docker.service/' $SERVICE_FILE
systemctl daemon-reload
else
echo "No service file modification needed."
fi
else
echo "No modification needed."
echo "Mosquitto config already contains a global listener. No edits were made to config or service file."
fi

if command -v ufw &> /dev/null; then
Expand Down

0 comments on commit 5d6d50f

Please sign in to comment.