#!/bin/bash
#######################################################
# Rubyra Script 0.7 
# To install rubyra Script type: 
# curl -O https://rubyra.com/scripts/install && bash install
# longanhvn@gmail.com / from 6.6.2016 - 2026
# Reference servertut / centminmod / hocvps 
#######################################################

if [ $(id -u) != "0" ]; then
    printf "Please setup with root to run this command. Run \"sudo su\" to become root!\n"
    exit
fi

if [ -f /etc/rubyra/scripts.conf ]; then
	echo "========================================================================="
	echo "Exist rubyra Script"
	echo "Type: 'rubyra' (Ruby On Rails & PHP) to using"
	echo "========================================================================="
	read -r -p "You want re-intall ? [y/N] " response
	case $response in
	    [yY][eE][sS]|[yY]) 
	    	echo "Okay setup now ...." 
	        ;;
	    *)  
            
	        echo "Bye....!"
	        exit
	        ;;
	esac
	 
fi

rm -f install*
cd /root/
rm -f install*
check_os=$(awk 'NR==1{print $1}' /etc/*release) 
cat /etc/*release
echo $check_os

if [ "$check_os" = 'DISTRIB_ID=Ubuntu' ]; then
	check_detail=$(awk -F'=' '/DISTRIB_RELEASE/ {print $2}' /etc/*release)
	major_version=$(echo "$check_detail" | cut -d'.' -f1)
	if [ "$major_version" -ge 22 ]; then
		curl -O https://rubyra.com/scripts/ubuntu22/install && bash install
	else
		curl -O https://rubyra.com/scripts/ubuntu/install && bash install
	fi
fi

if [ "$check_os" = 'CentOS' ]; then
	echo 'Only support ubuntu OS!'
	exit 
fi

echo 'Check list done!'
exit 
