Install PlantUML on Mac

Problem

You would like to create PlantUML diagrams on your Mac but don’t have the prerequisites or cli installed.

Solution

Steps

  1. Install java with brew install java
  2. Install PlantUML with brew install plantuml

Output for Java

  • Your output will look like the below if it is a new installation
┌─[user@laptop] – [~] – [Wed Feb 14, 15:13]
└─[$] <> brew install java
==> Downloading https://formulae.brew.sh/api/formula.jws.json
##O=- # #
==> Downloading https://formulae.brew.sh/api/cask.jws.json
############################################################################################################################################################################################################# 100.0%
Warning: Cask homebrew/cask/java was renamed to homebrew/core/java.
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/manifests/21.0.2
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/d437bb150fa297f0ee7f7f26594cb0a1e7aec55a45ec6570ed8660a033b7c3f9–openjdk-21.0.2.bottle_manifest.json
==> Fetching openjdk
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/blobs/sha256:9850be1875b9df8e9fa3510b6f2e947be2ff228d64a1c8e0daebc57a018ce2ef
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/ea1872f4761168acb4af2804e61d03cc5b31765cbc2ee364efcf7e10a67d2c8d–openjdk–21.0.2.arm64_sonoma.bottle.tar.gz
==> Pouring openjdk–21.0.2.arm64_sonoma.bottle.tar.gz
==> Caveats
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
openjdk is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides similar software and installing this software in
parallel can cause all kinds of trouble.
If you need to have openjdk first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"' >> ~/.zshrc
For compilers to find openjdk you may need to set:
export CPPFLAGS="-I/opt/homebrew/opt/openjdk/include"
==> Summary
🍺 /opt/homebrew/Cellar/openjdk/21.0.2: 600 files, 331.2MB
==> Running `brew cleanup openjdk`…
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
view raw output.sh hosted with ❤ by GitHub
  • Your output will look like the below if it is already installed
┌─[user@laptop] – [~] – [Wed Feb 14, 14:55]
└─[$] <> brew install java
==> Downloading https://formulae.brew.sh/api/formula.jws.json
############################################################################################################################################################################################################# 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
############################################################################################################################################################################################################# 100.0%
Warning: Cask homebrew/cask/java was renamed to homebrew/core/java.
Warning: openjdk 21.0.2 is already installed and up-to-date.
To reinstall 21.0.2, run:
brew reinstall openjdk
view raw output.sh hosted with ❤ by GitHub

Output for PlantUML

  • Your output will look like the below if it is a new installation
┌─[user@laptop] – [~] – [Wed Feb 14, 15:16]
└─[$] <> brew install plantuml
==> Downloading https://ghcr.io/v2/homebrew/core/plantuml/manifests/1.2024.1
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/34e1194efa92f43fc1d37f47254e076fc6defb4330b5500d36e5685aed26e3e6–plantuml-1.2024.1.bottle_manifest.json
==> Fetching plantuml
==> Downloading https://ghcr.io/v2/homebrew/core/plantuml/blobs/sha256:3f9404a546ff9e549e1b640e77515b3815819a4b36239fc9b17effe8135c65e3
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/2d560846774dbc633917be48445efd06524e670aaf0b7299d210b7cff5c91afa–plantuml–1.2024.1.all.bottle.tar.gz
==> Pouring plantuml–1.2024.1.all.bottle.tar.gz
🍺 /opt/homebrew/Cellar/plantuml/1.2024.1: 4 files, 11.3MB
==> Running `brew cleanup plantuml`…
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
view raw output.sh hosted with ❤ by GitHub
  • Your output will look like the below if it is already installed
┌─[user@laptop] – [~] – [Wed Feb 14, 15:19]
└─[$] <> brew install plantuml
Warning: plantuml 1.2024.1 is already installed and up-to-date.
To reinstall 1.2024.1, run:
brew reinstall plantuml
view raw output.sh hosted with ❤ by GitHub

References

  1. Install Homebrew
  2. Homebrew Java
  3. Homebrew PlantUML
  4. PlantUML homepage

FireEye Agent Unattended Install

Problem

Need to install the FireEye Agent version 34.28.1 on Windows in a simple and unattended manner.

Solution

Assuming your msi and configuration file are both in C:\temp then you can run

msiexec C:\temp\xagtSetup_34.28.1_universal.msi /qn /quiet /norestart INSTALLSERVICE=1 CONFJSONDIR=C:\temp

References

  1. StackOverflow: Silent installation of a MSI package
  2. Silent Install Builder
  3. FireEye Endpoint Security Software

Installing Monit as a Service

Easy, proactive monitoring of processes, programs, files, directories,  filesystems and hosts | Monit

Problem

You need a service to keep your services running. However everything from hardware, network, software and security rules seem to be trying to take your services down. The challenge is to find a way to keep them up with minimal manual intervention.

Solution

Monit is a great tool to make this happen and is highly configurable. One important point is that monit needs to be running at all times especially after restarting the server. Fortunately it’s easy to install it as a service on Ubuntu.

!/bin/sh
sudo apt install monit && \
sudo systemctl enable monit

You can see from the script how straight forward it is to install and configure to run as a service so that if the server restarts it will start as well.

References

  1. TecMint: How to Install and Setup Monit (Linux Process and Services Monitoring) Program
  2. How To Install and Configure Monit

Monit for ElasticSearch

Easy, proactive monitoring of processes, programs, files, directories,  filesystems and hosts | Monit

Problem

The ElasticSearch service can be very important in many applications. If the service stops it can be equivalent to the server itself going down. If the cluster isn’t as redundant as it should be then losing a server could bring the cluster down. How can we prevent the service from stopping to avoid any of these scenarios?

Solution

The below commands will

  1. Install monit
  2. Enable monit as a service
  3. Create a configuration file for monit for ElasticSearch
    1. This will tell it how to ensure the process is running and what to do if it is not.
  4. Restart monit.service itself to use the new configuration file
  5. Finally print the status to ensure that it is running
#!/bin/sh
sudo apt install monit && \
sudo systemctl enable monit && \
echo '
check process elasticsearch with pidfile /var/run/elasticsearch/elasticsearch.pid
start program = "/bin/systemctl start elasticsearch.service"
stop program = "/bin/systemctl stop elasticsearch.service"' | sudo tee /etc/monit/conf.d/elasticsearch-monitrc && \
sudo systemctl stop monit.service && \
sudo systemctl start monit.service && \
sudo systemctl status monit.service && \
sudo systemctl status elasticsearch.service

In this example, I created a separate file to keep ElasticSearch configuration separate from other services monit is watching and restarting. I did this to make future updates simpler, easier and less risky. For many configuration management systems, it’s much easier to overwrite a file than it is to update a specific portion of a given file.

References

  1. DigitalOcean: TUTORIAL – How To Install and Configure Monit
  2. Monit Documentation
  3. Monit Systemd documentation
  4. TecMint: How to Install and Setup Monit (Linux Process and Services Monitoring) Program
  5. nixCraft: How to Install and Setup Monit (Linux Process and Services Monitoring) Program
  6. StackExchange: What command in monitrc can I use to start/stop systemd services?

Bitbucket Markdown

Problem

I wanted to create a Readme.md file for future engineers to use to get up and running in Bitbucket. One of the steps was to install chocolatey.

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

but it showed up like

Solution

Had to add \\ instead of \ to the powershell.exe path

`@"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"`

which corrected the preview to be like the below image

RabbitMQ: Install Guide

    1. Set the environment variable RABBITMQ_BASE= to the desired directory. By default it goes to C:\Users\{user}\AppData\Roaming\RabbitMQ for the user that installed it not the current user.
    2. Set_RabbitMQ_Base_2018-08-27_13-14-40
    3. Log out and log back in.
      1. This makes sure the environment variable above is set
    4. Check it by running set | find "RABBITMQ_BASE" in the command prompt
    5. RabbitMQ_Set_Base_Dir_2018-08-09_14-31-09
    6. Download the latest RabbitMQ binary. You can use any version as long as it is within the same feature version as the rest of the cluster/nodes.
    7. Install the downloaded version
    8. You may have to install Erlang as part of the process. Make sure that you install the correct version for your RabbitMQ version.
    9. Follow the prompts if necessary
    10. Click Start
    11. Type cmd
    12. Select the RabbitMQ Command Prompt
    13. Type rabbitmqctl environment
    14. Click Enter
    15. This will show you all the config files, log files and other RabbitMQ files reside within the base directory above

References

  1. https://www.rabbitmq.com/install-windows-manual.html
  2. https://stackoverflow.com/a/5327531/299327
  3. https://groups.google.com/forum/#!topic/rabbitmq-users/vDRdzJn6sLg
  4. https://github.com/rabbitmq/rabbitmq-server/issues/626#issuecomment-359933219

NSIS Select Install Directory and Backup

After quite a few times of having to update my software manually(and really one time is too many), I decided to embark on the difficult road of creating an updater where one had not existed. I turned to my trusted NSIS, which had worked well for me in the past(your mileage may vary).

My only complaint would be that not that many people use it(I know not a lot of people make windows installers anymore, but I needed to for this project.), which leads to confusing documentation, Q&A and resources kind of scattered around online. I had some difficulty finding out elementary basic examples of how to do the following with NSIS.

  • Prompt the user to choose the installation directory
  • Backup the existing directory with a datetime stamp
  • Mark the backup as readonly

These are pretty standard, and I assume pretty common requirements for an install or update. Below is my solution which is performs these simple tasks.

!include FileFunc.nsh
!insertmacro GetTime

SetCompressor /SOLID /FINAL lzma

# name the installer
OutFile "Installer.exe"

InstallDir $%HOMEDRIVE%

Page directory
Page instfiles

Section Backup
    Var /GLOBAL backupFolder
    Var /GLOBAL command

    # define the output path for this file
    setOutPath $INSTDIR

    DetailPrint "The user has chose the directory: $INSTDIR for the install."

    ${GetTime} "" "L" $0 $1 $2 $3 $4 $5 $6

    StrCpy $backupFolder "$INSTDIR.backup.$1-$0-$2.$4_$5_$6"

    StrCpy $command 'xcopy "$INSTDIR" "$backupFolder" /S /E /V /Y /I'
    DetailPrint $command
    ExecWait $command
SectionEnd 

Update!
The following code should be used with caution. I had to remove it, due to the permission implications of setting file/folder attributes. Many configurations will not allow user’s to set these attributes, especially on network drives. So you have been warned.

    ExecWait 'attrib +r "$backupFolder\*.*" /S /D'

Ask for an Install

I have been asked for the status of various projects, and I have asked other people about the status of their work. Sometimes there were discrepancies between the reported status and the actual progress.

To be clear, the inconsistency represents miscommunication and/or misunderstanding rather than dishonesty. I consider all the discussions about what “DONE” means.

This motivated me to search for a better way. How will I know if my team or myself are on schedule? Or even early? Consider how the success of the project will be measured, the customer will use it and decide for themselves. Here’s some of the subconscious questions being answered:

  1. Did it run?
  2. Does it look good?
  3. Does it do what I want?(Note the question is not “Does it do what we agreed it should do?”)
  4. Was it easy to do what I wanted?

Other possibilities exist, but you get the idea. One notably absent question is “What’s the status of this?”. The customer asks the software these questions rather than its creator.

Consider the last time you test drove a car.

Old Carriage

Did you ask the engineer, designer or mechanic how the car handled? Of course not, you knew exactly how it handled, because you drove it. How can a user “drive” software?

The user must install and use the software(yes, the install counts). The next time someone requests status, give them a build or install the latest build on a clean environment for them.

The next time you want to know the status, ask for a build. Yes, this takes more time than asking “Is it done yet?” or “Where are we on X?”, but it saves time and embarrassment with the final product.