#!/bin/bash

# Magic Set Editor 2 beta.
# This script and this program are licensed under the GNU General Public License Version 2
# The full text of this license is in the file COPYING

# This script installs Magic Set Editor onto your system.
# If executed as root (including via sudo), it is installed to /usr/local/share/magicseteditor. (with an executable symlink in /usr/local/bin)
# If executed as any other user, it will install to ~/.magicseteditor with a symlink in ~/bin.

case $UID in
    0)
        INSTALL_DIR='/usr/local/share/magicseteditor/';
        EXEC_SYMLINK='/usr/local/bin/magicseteditor';;
    *)
        INSTALL_DIR='$HOME/.magicseteditor/';
        EXEC_SYMLINK='$HOME/bin/magicseteditor';
esac;

echo "Magic Set Editor version $VERSION Installer Script.

Magic Set Editor will be installed to $INSTALL_DIR.
A symbolic link to the executable will be put at $EXEC_SYMLINK.

Is this correct [y/N]? ";

read -n 1 CONFIRM;

case $CONFIRM in
    [yY])
        :;;
    *)
        exit;;
esac;

echo "Installing...";

mkdir "$INSTALL_DIR";
cp -r program/* "$INSTALL_DIR";

ln -s "$INSTALL_DIR/magicseteditor" "$EXEC_SYMLINK"
