Skip to content

Instantly share code, notes, and snippets.

@adminph-de
Last active November 17, 2020 17:30
Show Gist options
  • Save adminph-de/ee95a839ac43dfc9aba5c9c1f6a2cedb to your computer and use it in GitHub Desktop.
Save adminph-de/ee95a839ac43dfc9aba5c9c1f6a2cedb to your computer and use it in GitHub Desktop.
Deploy ANSYS License Server (CentOS 7.x)
#!/bin/bash
gituser="$1"
gitpw="$2"
azurl="$3"
unset probe
unset flexuser
unset flexgrp
echo "Handover Variables:"
echo "Git Username : ${gituser}"
echo "Git Password : ${gitpw}"
echo "AZCOPY URL : ${azurl}"
echo "Updating OS and install necessary (yum) packages......"
sudo yum update -y
sudo yum install -y tree screen git wget epel-release iftop yum-utils p7zip p7zip-plugins xorg-x11-server-Xorg xorg-x11-xauth xorg-x11-apps firefox libpng12 compat-libtiff3 redhat-lsb
sudo yum install -y mesa-dri-drivers.x86_64 mesa-libGL.x86_64 dbus-x11
echo "Installing DockerCE......"
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce docker-ce-cli containerd.io
sudo usermod -aG docker $USER
sudo systemctl enable docker
sudo systemctl start docker
if [ ! -d ~/docker-apache2-http-probe ]; then
echo "Docker build for http-probe (new)......"
cd ~/
git clone https://github.com/adminph-de/docker-apache2-http-probe.git
cd ~/docker-apache2-http-probe
sudo docker build -t http-probe:latest .
sudo docker container run --name http-probe -d --restart always -p 8080:80 http-probe:latest
else
echo "Docker build for http-probe (refresh)......"
probe=`docker container ls | grep http-probe:latest | awk '{ print $1 }'`
cd ~/docker-apache2-http-probe
git pull
docker build -t http-probe:latest .
if [ ! -z ${probe+x} ]; then
echo "Removing running http-probe container: '$probe'";
docker container rm -f $probe
fi
echo "Starting Docker container (http-probe:latest)....."
docker container run --name http-probe -d --restart always -p 8080:80 http-probe:latest
fi
if [ ! -f ~/.Xauthority ]; then
echo "Generating .Xauthority file....."
touch ~/.Xauthority
sudo ln -s ~/.Xauthority /root/.Xauthority
fi
if [ ! -d ~/lic-fls-ansys ]; then
echo "cloning lic-fls-ansys repository......"
cd ~/
git clone https://${gituser}:${gitpw}@flsmidth.visualstudio.com/ANSYS%20License%20Service/_git/lic-fls-ansys
fi
if [ ! -f /usr/bin/azcopy ]; then
echo "Installing AZCOPY into /usr/bin......"
wget https://azcopyvnext.azureedge.net/release20201106/azcopy_linux_amd64_10.7.0.tar.gz -P ~/
sudo tar -xzf ~/azcopy_linux_amd64_10.7.0.tar.gz -C /usr/bin --transform='s/.*\///'
sudo chmod +x /usr/bin/azcopy
fi
if [ ! -f ~/ANSYSLICMAN_2020R2_LINX64.tar ]; then
echo "Download and Unpacking ANSYS License Server binaries......"
azcopy copy ${azurl} ~/
if [ ! -f ~/2020R2/INSTALL ]; then
mkdir ~/2020R2
tar -xf ~/ANSYSLICMAN_2020R2_LINX64.tar -C ~/2020R2
fi
fi
if [ ! -d /ansys_inc ]; then
echo "Installing ANSYS License Server......"
sudo ~/2020R2/INSTALL -silent -LM
fi
flexgrp=`grep -c '^lmadmin:' /etc/group`
if [ $flexgrp -eq 0 ]; then
echo "Creating group lmadmin......"
sudo groupadd -r lmadmin
fi
flexuser=`grep -c '^lmadmin:' /etc/passwd`
if [ $flexuser -eq 0 ]; then
echo "Creating user lmadmin......"
sudo useradd -r -g lmadmin -d /home/lmadmin -s /sbin/nologin -c "FlexLM License Server" lmadmin
sudo usermod -aG wheel lmadmin
fi
if [ ! -d /ansys_inc ]; then
echo "Customizing ANSYS Tomcat server for remote access......"
sudo chown -R lmadmin:lmadmin /ansys_inc
sudo sed -i "s|127.0.0.1|0.0.0.0|g" /ansys_inc/shared_files/licensing/tools/tomcat/conf/server.xml
echo "Adding Tomcat server to autostart......"
sudo cp /ansys_inc/shared_files/licensing/init_ansyslm_tomcat /etc/init.d
sudo chmod 555 /etc/init.d/init_ansyslm_tomcat
sudo chkconfig --add init_ansyslm_tomcat
sudo chkconfig init_ansyslm_tomcat on
sudo kill -9 `ps -aux | grep tomcat | awk '/root/ {print $2}'`
sudo /etc/init.d/init_ansyslm_tomcat start
echo "Adding ANSYS License Server to autostart......"
sudo cp ~/lic-fls-ansys/config/ansysli.service /etc/systemd/system/
sudo chmod 755 /etc/systemd/system/ansysli.service
sudo chmod 755 /ansys_inc/shared_files/licensing/linx64/ansysli_server
sudo systemctl daemon-reload
sudo systemctl enable ansysli.service
sudo systemctl start ansysli.service
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment