#!/bin/sh

if [ "$EUID" -ne 0 ]
  then echo -e "\e[31mPlease run as root!:\e[0m"
  exit
fi
clear
mkdir -p /etc/astra

if [ -f "/etc/astra/license.txt" ];
then 
echo "\e[32mFound license:\e[0m"; cat /etc/astra/license.txt;
read -p "Replace your license? y/N " -n 1 -r
echo #
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
    echo -e "\e[31mExit\e[0m";
    exit 1;
fi
fi

echo  "\e[31mAttention!:\e[0m" 
echo 
echo 
echo "==============================================="
echo  "After you purchase a license or request a demo version,\na file containing the license serial number will be sent to your e-mail address"
echo  "Example contents file license.txt:\n\e[31m{"l":"zrbc9c555e6e7tdrdrcyce2tdo15rbya","e":"belousov@cesbo.com"}\e[0m"
echo  "Note - this is only an example of the contents of the file!\nAll characters in this file are part of the license number.\nPlease copy \e[31mALL\e[0m contents from the received file."
echo "==============================================="
echo 
echo

read -p "Enter your license number: " SN
echo "$SN" >/etc/astra/license.txt
echo "\e[32mInstalled  license:\e[0m"
cat /etc/astra/license.txt;
