Last active
January 1, 2024 08:41
-
-
Save jspw/532731d1c3fc54aba9aa71a2814bdbb7 to your computer and use it in GitHub Desktop.
Automate installing and configuration for Apache Message Queue using a bash script in Linux based machines. Just run `sudo ./install_apache_active_mq_5.17.1.sh`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # whoami -> MH Shifat | https://github.com/jspw | |
| # date -> Mon 30 May 2022 11:06:52 PM +06 | |
| GREETINGS="Welcome to the Active MQ installer\n\n\n" | |
| ACTIVE_MQ_DOWNLOAD_URL="http://archive.apache.org/dist/activemq/5.17.1/apache-activemq-5.17.1-bin.tar.gz" | |
| echo $GREETINGS | |
| printf "Downloading Active MQ...\n\n\n" | |
| wget $ACTIVE_MQ_DOWNLOAD_URL | |
| # split filename from url | |
| ACTIVE_MQ_DOWNLOAD_FILENAME=$(basename $ACTIVE_MQ_DOWNLOAD_URL) # apache-activemq-5.17.1-bin.tar.gz | |
| echo "Extracting $ACTIVE_MQ_DOWNLOAD_FILENAME" | |
| sudo tar -xvzf $ACTIVE_MQ_DOWNLOAD_FILENAME | |
| DIRECTORY_FOR_A_MQ="/opt/activemq" | |
| echo "Creating directory for ActiveMQ : "$DIRECTORY_FOR_A_MQ | |
| sudo mkdir $DIRECTORY_FOR_A_MQ | |
| # split file extract directory name | |
| ACTIVE_MQ_DIRECTORY_NAME=$(basename $ACTIVE_MQ_DOWNLOAD_FILENAME -bin.tar.gz) # apache-activemq-5.17.1 | |
| printf "Moving $ACTIVE_MQ_DIRECTORY_NAME to $DIRECTORY_FOR_A_MQ" | |
| FULL_DIR=$ACTIVE_MQ_DIRECTORY_NAME/* | |
| sudo mv $FULL_DIR $DIRECTORY_FOR_A_MQ | |
| printf "Create a group account activemq to run Apache ActiveMQ...\n\n\n" | |
| sudo addgroup --quiet --system | |
| printf "Create a user for the group...\n\n\n" | |
| sudo adduser --quiet --system --ingroup activemq --no-create-home --disabled-password activemq | |
| printf "Change the permissions of the /opt/activemq directory...\n\n\n" | |
| sudo chown -R activemq:activemq /opt/activemq | |
| CODE=" | |
| [Unit]\n | |
| Description=Apache ActiveMQ\n | |
| After=network.target\n | |
| [Service]\n | |
| Type=forking\n | |
| User=activemq\n | |
| Group=activemq\n | |
| ExecStart=/opt/activemq/bin/activemq start\n | |
| ExecStop=/opt/activemq/bin/activemq stop\n | |
| [Install]\n | |
| WantedBy=multi-user.target\n | |
| " | |
| printf "Creating a service file for Apache ActiveMQ...\n\n\n" | |
| sudo echo -e "$CODE" > /etc/systemd/system/activemq.service | |
| # replace `<property name="host" value="0.0.0.0"/>` with `<property name="host" value="127.0.0.1"/>` | |
| printf "Configuring Apache ActiveMQ on host '0.0.0.0' ...\n\n\n" | |
| sed -i 's+<property name="host" value="127.0.0.1"/>+<property name="host" value="0.0.0.0"/>+g' /opt/activemq/conf/jetty.xml | |
| printf "Starting Apache ActiveMQ...\n\n\n" | |
| sudo systemctl daemon-reload | |
| sudo systemctl start activemq | |
| sudo systemctl enable activemq | |
| sudo systemctl status activemq | |
| sudo systemctl restart activemq | |
| printf "ActiveMQ is installed successfully\n\n\n" | |
| printf "Goto http://localhost:8161/admin/ to check with username:admin & password:admin\n\n\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # whoami -> MH Shifat | https://github.com/jspw | |
| # date -> Mon 30 May 2022 11:06:52 PM +06 | |
| sudo systemctl daemon-reload | |
| sudo systemctl start activemq | |
| sudo systemctl enable activemq | |
| sudo systemctl status activemq | |
| sudo systemctl restart activemq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo rm -rf /opt/activemq | |
| sudo rm -rf /etc/systemd/system/activemq.service |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
actual commands:
wget http://archive.apache.org/dist/activemq/5.16.3/apache-activemq-5.16.3-bin.tar.gz