#!/bin/bash

# Make temp dir
mkdir ~/autokey/

# Download archive
wget -P ~/autokey/ http://packages.macroscop.com/misc/autokey.tar.gz

# Extract archive
tar -xf ~/autokey/autokey.tar.gz

# Move libs
sudo mv ~/autokey/libs/haspvlib* /var/hasplm/
sudo cp ~/autokey/libs/libstdc++.so.6 /opt/
sudo mv ~/autokey/libs/libstdc++.so.6 /lib64/

# Change mode
#sudo chmod 777 /opt/libstdc++.so.6

# Add execute bit
#chmod +x ~/autokey/hasp_update_x86_64

# Install highway auto key 
~/autokey/hasp_update_x86_64 u ~/autokey/demo/SDK_4lo_60d_WORLD.v2c

# Remove temp dir
rm -rf ~/autokey/

# Allow web
sudo echo "ACCremote = 1" | sudo tee /etc/hasplm/hasplm.ini > /dev/null