Created
July 7, 2020 04:14
-
-
Save ticchen/efc97e132adb843dd44bdc5bf7842233 to your computer and use it in GitHub Desktop.
Makefile to help install flex server
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
INSTALL_DIR=/usr/local/flexlm/licenses | |
#get hostname from license file | |
licensed_hostname=$(shell cat license.dat | grep ^SERVER | awk '{print $$2}') | |
licensed_macaddr=$(shell cat license.dat | grep ^SERVER | awk '{print $$3}' | sed -e 's/../\0:/g' -e 's/:$$//' ) | |
help: | |
# Usage: | |
# make install # install license server | |
# make uninstall # uninstall license server | |
# make start|stop|restart|status # operate server | |
# make flex_info # show flex info (for debug) | |
# make flex_status # show flex status | |
# make flex_process # show flex process | |
####################### | |
# install/uninstall | |
####################### | |
install: | |
# check license file | |
@if [ ! -f license.dat ]; then echo "Error: no license.dat";exit 1; fi | |
# download flex (source: https://developer.arm.com/tools-and-software/software-development-tools/license-management/downloads) | |
wget -nc https://armkeil.blob.core.windows.net/developer/Files/downloads/licensing/Latest%20Version/BX002-PT-00007-r11p16-06rel0.tgz | |
# install flex | |
sudo mkdir -p $(INSTALL_DIR)/ | |
sudo tar zxf BX002-PT-00007-r11p16-06rel0.tgz -C $(INSTALL_DIR)/ --strip-components=1 --no-same-owner | |
# install license file | |
sudo cp license.dat $(INSTALL_DIR)/ | |
# create flex log folder | |
sudo mkdir -p /usr/tmp/.flexlm/ | |
# fix flex missing library ld-lsb-x86-64.so.3 | |
sudo ln -svf `ls /lib64/ld-linux-x86-64.so* | head -n 1` /lib64/ld-lsb-x86-64.so.3 | |
# change hostname to licensed hostname | |
sudo hostnamectl set-hostname '$(licensed_hostname)' | |
make install_service | |
uninstall: | |
make uninstall_service | |
sudo rm -rf $(INSTALL_DIR) | |
####################### | |
# service | |
####################### | |
install_service: | |
# create service script | |
echo "$$arm_license_server_service" | sudo tee /lib/systemd/system/arm_license_server.service > /dev/null | |
# restart service and enable it | |
sudo systemctl daemon-reload | |
sudo systemctl restart arm_license_server | |
sudo systemctl enable arm_license_server | |
uninstall_service: | |
sudo systemctl disable arm_license_server | |
sudo systemctl stop arm_license_server | |
sudo rm -f /lib/systemd/system/arm_license_server.service | |
sudo systemctl daemon-reload | |
start stop restart status: | |
sudo systemctl $@ arm_license_server | |
####################### | |
# flex | |
####################### | |
flex_info: | |
$(INSTALL_DIR)/lmutil lmhostid -hostname | |
$(INSTALL_DIR)/lmutil lmhostid | |
flex_status: | |
$(INSTALL_DIR)/lmutil lmstat | |
flex_process: | |
pgrep -a lm | |
############################# | |
# here document | |
############################# | |
#============================ | |
# /lib/systemd/system/arm_license_server.service | |
define arm_license_server_service | |
[Unit] | |
Description=ARM License Server | |
[Service] | |
User=root | |
Type=forking | |
Environment=TCP_NODELAY=1 | |
ExecStartPre=-/usr/bin/sudo ip link add bond0 type dummy | |
ExecStartPre=-/usr/bin/sudo ip link set dev bond0 address $(licensed_macaddr) up | |
ExecStart=$(INSTALL_DIR)/lmgrd -c $(INSTALL_DIR)/license.dat -reuseaddr | |
ExecStop=$(INSTALL_DIR)/lmutil lmdown -q -all | |
[Install] | |
WantedBy=multi-user.target | |
endef | |
#============================ | |
export arm_license_server_service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment