Skip to content

Instantly share code, notes, and snippets.

@kahlos
Last active June 23, 2020 14:50
Show Gist options
  • Save kahlos/97c9371f7a5476678ef11c836c97a14f to your computer and use it in GitHub Desktop.
Save kahlos/97c9371f7a5476678ef11c836c97a14f to your computer and use it in GitHub Desktop.
MATLAB silent install script
# Script to silently install MATLAB components, run as root if installing to /opt
# Requires: `license.lic`, `packages` list and `file-install-key` files
# Download license.lic and create file-install-key file from [MATLAB license centre](https://uk.mathworks.com/licensecenter/licenses)
# Download and extract latest [MATLAB installer](https://uk.mathworks.com/downloads/)
# Download packages `archive` files by running installer graphically first
# Make a package list, uncommenting lines from installer_input, `tail -87 installer_input.txt > packages`
# Check destination directories are correct below
# Destination, MATLAB installer and config files directory
dest=/opt/matlab
install=$dest/install
config=$install/cfg
# Create directories if they don't already exist
mkdir -p $dest $install $config
# Check if required files exist in current directory
error="license.lic, packages list and/or file-install-key files missing in current directory"
[ -f license.lic ] && [ -f packages ] && [ -f file-install-key ] || { echo $error; exit 1; }
# Remove blank and commented lines from packages file
packages=$(grep -v '^$\|^#' packages)
# Check if there are any packages to install, exit if not
[ "$packages" ] || { echo "No packages to install"; exit 1; }
# MATLAB install configuration
installcfg="
destinationFolder=$dest
outputFile=$config/install.log
fileInstallationKey=$(cat file-install-key)
agreeToLicense=yes
mode=silent
activationPropertiesFile=$config/activate.cfg
"
# Combine install config with package list and output to config directory
{ echo "$installcfg" ; echo "$packages" ; } > $config/install.cfg
# MATLAB activation configuration
activatecfg="
isSilent=true
licenseFile=$config/license.lic
activateCommand=activateOffline
"
# Create activation config file and output to config directory
echo "$activatecfg" > $config/activate.cfg
# Copy license file to install config directory
cp -u license.lic $config 2> /dev/null
# Run the installer, displaying only error messages
echo "Installing the following packages:
$packages"
$install/install -inputFile $config/install.cfg > /dev/null
# Check and force the MATLAB executable to be linked properly
ln -sf $dest/bin/matlab /usr/local/bin/
echo "Installation complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment