-
-
Save alienzj/968f99a2875415e31c3eab39e188b28a to your computer and use it in GitHub Desktop.
MATLAB silent install script
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
# 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