Last active
November 2, 2020 08:32
-
-
Save mark-veenstra/a8d99db0c9e5709b32e69961b1b93129 to your computer and use it in GitHub Desktop.
Installing Mule 4 EE on Raspberry Pi
This file contains 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 | |
# See also: https://github.com/rajprins/mule-rpi/blob/master/install-mule4EE.sh | |
function bold { | |
tput bold | |
echo $1 | |
tput rmso | |
} | |
function introBanner { | |
clear | |
echo | |
echo "┌───────────────────────────────────────────────────────────────────────┐" | |
echo "│ (\_/) M U L E R U N T I M E I N S T A L L E R │" | |
echo "│ / \ Mule 4 EE runtime installer for Raspbian Stretch/Buster │" | |
echo "└───────────────────────────────────────────────────────────────────────┘" | |
} | |
function preInstallationOps { | |
echo | |
echo "This script will download, extract and install the Mule 4 EE runtime and" | |
echo "several other required packages. Some actions require root access using" | |
echo "the 'sudo' command. Your password might be asked." | |
sudo -v | |
} | |
function setPermissionToPiUser { | |
if [[ -d ${BASE_DIR} ]]; then | |
sudo chown -R pi:pi ${BASE_DIR} | |
fi | |
} | |
function installPackages { | |
echo;bold ">>> Installing required packages" | |
sudo apt-get update | |
sudo apt-get -y install openjdk-8-jdk-headless unzip | |
} | |
function createUser { | |
echo;bold ">>> Preparing user '${MULE_USER}'" | |
if ! [ `id -u ${MULE_USER} 2>/dev/null || echo -1` -ge 0 ]; then | |
echo "Creating user '${MULE_USER}'" | |
sudo useradd -s /bin/bash -d /home/${MULE_USER} -U -G sudo ${MULE_USER} | |
sudo mkdir /home/${MULE_USER} | |
sudo cp /home/pi/.bashrc /home/${MULE_USER}/ | |
sudo cp /home/pi/.profile /home/${MULE_USER}/ | |
sudo chown ${MULE_USER}:${MULE_USER} /home/${MULE_USER} | |
sudo passwd ${MULE_USER} <<EOF | |
${MULE_PASS} | |
${MULE_PASS} | |
EOF | |
echo "User created. Default password for user '${MULE_USER}' is '${MULE_PASS}'." | |
else | |
echo "User '${MULE_USER}' already exists. No action required." | |
fi | |
} | |
function createBaseDir { | |
echo;bold ">>> Creating installation directory" | |
if ! [[ -d ${BASE_DIR} ]] ; then | |
echo "Creating directory ${BASE_DIR}" | |
sudo mkdir ${BASE_DIR} | |
else | |
echo "Target directory ${BASE_DIR} already exists. No action required." | |
fi | |
cd ${BASE_DIR} | |
} | |
function downloadMule { | |
cd ${BASE_DIR} | |
echo;bold ">>> Downloading Mule EE runtime" | |
sudo wget https://s3.amazonaws.com/new-mule-artifacts/mule-ee-distribution-standalone-${MULE_VERSION}.zip | |
echo;bold ">>> Extracting Mule EE runtime. Please wait..." | |
sudo unzip -q ${BASE_DIR}/mule-ee-distribution-standalone-${MULE_VERSION}.zip | |
echo;bold ">>> Create/update symbolic link to current installed version" | |
ln -sf "$(basename ${MULE_HOME})" current | |
echo;bold ">>> Add Mule bin to PATH variable" | |
if ! sudo grep -q "${BASE_DIR}/bin" /home/${MULE_USER}/.bashrc 2> /dev/null; then | |
echo "" | sudo tee -a /home/${MULE_USER}/.bashrc | |
echo "# Add Mule bin to PATH" | sudo tee -a /home/${MULE_USER}/.bashrc | |
echo "PATH=\"\${PATH}:${BASE_DIR}/current/bin\"" | sudo tee -a /home/${MULE_USER}/.bashrc | |
fi | |
} | |
function downloadServiceWrapper { | |
cd ${BASE_DIR} | |
echo;bold ">>> Downloading Tanuki wrapper" | |
sudo wget https://download.tanukisoftware.com/wrapper/${WRAPPER_VERSION}/wrapper-linux-armhf-32-${WRAPPER_VERSION}.tar.gz | |
echo;echo ">>> Extracting Tanuki wrapper" | |
sudo tar zxf wrapper-linux-armhf-32-${WRAPPER_VERSION}.tar.gz | |
} | |
function patchMuleServiceWrapper { | |
echo;bold ">>> Patching Mule 4 runtime libraries" | |
sudo cp ${BASE_DIR}/wrapper-linux-armhf-32-${WRAPPER_VERSION}/lib/libwrapper.so ${MULE_HOME}/lib/boot/libwrapper-linux-armhf-32.so | |
sudo cp ${BASE_DIR}/wrapper-linux-armhf-32-${WRAPPER_VERSION}/lib/wrapper.jar ${MULE_HOME}/lib/boot/wrapper-${WRAPPER_VERSION}.jar | |
sudo cp ${BASE_DIR}/wrapper-linux-armhf-32-${WRAPPER_VERSION}/bin/wrapper ${MULE_HOME}/lib/boot/exec/wrapper-linux-armhf-32 | |
} | |
function setMuleConfiguration { | |
echo;bold ">>> Modifying wrapper.conf configuration file" | |
sudo sed -i 's/wrapper.java.initmemory=1024/wrapper.java.initmemory=256/g' ${MULE_HOME}/conf/wrapper.conf | |
sudo sed -i 's/wrapper.java.maxmemory=1024/wrapper.java.maxmemory=512/g' ${MULE_HOME}/conf/wrapper.conf | |
echo;bold ">>> Modifying mule launch script" | |
sudo sed -i 's/case "$PROC_ARCH" in/case "$DIST_ARCH" in\n 'armv7l')\n echo "Armhf architecture detected"\n DIST_ARCH="armhf"\n DIST_BITS="32"\n break;;/' ${MULE_HOME}/bin/mule | |
} | |
function setPermissions { | |
echo;bold ">>> Setting permissions for user '${MULE_USER}' on ${BASE_DIR}" | |
sudo chown -R ${MULE_USER}:${MULE_USER} ${BASE_DIR} | |
} | |
function postInstallationOps { | |
echo;bold ">>> Cleaning up" | |
cd ${BASE_DIR} | |
sudo rm -r wrapper-linux-armhf-32-${WRAPPER_VERSION}* | |
sudo rm mule-ee-distribution-standalone-${MULE_VERSION}.zip | |
echo | |
echo "All done. Log in as user '${MULE_USER}' and start Mule runtime using this command:" | |
bold "${MULE_HOME}/bin/mule start" | |
echo "Do not forget to install a license, otherwise this installation will behave as a 30-day trial version." | |
} | |
############################################################################## | |
# Main | |
############################################################################## | |
MULE_VERSION=4.3.0 | |
WRAPPER_VERSION=3.5.37 | |
BASE_DIR=/opt/mule | |
MULE_HOME=${BASE_DIR}/mule-enterprise-standalone-${MULE_VERSION} | |
MULE_USER=mule | |
MULE_PASS=mule | |
introBanner | |
preInstallationOps | |
installPackages | |
createUser | |
createBaseDir | |
downloadMule | |
downloadServiceWrapper | |
patchMuleServiceWrapper | |
setMuleConfiguration | |
setPermissions | |
postInstallationOps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install Raspian and exute the following command with the
pi
user: