#!/bin/bash
# kotmi-14 serverio setup script, installs to /usr/local/bin

# server and config working directories
cp -rn /opt/KOTMI/ServerIO/configurations .
cp -rf /opt/KOTMI/ServerIO/protocols2 .

# RdxServer.ini (and maybe other ini) - do not overwrite (-n)
cp -n /opt/KOTMI/ServerIO/astra-linux.inst/*.ini .

# rdxrun file
echo '#!/bin/bash' > rdxrun
echo 'LD_LIBRARY_PATH=/opt/KOTMI/ServerIO/Bin /opt/KOTMI/ServerIO/Bin/$1 $2 $3' >> rdxrun
chmod +x rdxrun

# desktop shortcuts (icons already copied by postinst)
cp /opt/KOTMI/ServerIO/astra-linux.inst/*.desktop .
chmod 0777 *.desktop

# Exec and Path in *.desktop
echo Path=$(pwd) >> kotmi_server.desktop
echo Exec=$(pwd)/rdxrun RdxServer >> kotmi_server.desktop

echo Path=$(pwd) >> kotmi_config.desktop
echo Exec=$(pwd)/rdxrun RdxConfig >> kotmi_config.desktop

echo Path=$(pwd) >> kotmi_monitor.desktop
echo Exec=$(pwd)/rdxrun QtMonitor >> kotmi_monitor.desktop

if [ -d ~/Desktop ]; then
cp *.desktop ~/Desktop
fi
