#!/bin/bash name="euphoria" version="4.1.0" state="beta2" arch="x64" fext="tar.gz" extcmd="tar" target_dir="/usr/local" url="http://nbtelecom.dl.sourceforge.net/project/rapideuphoria/Euphoria/${version}-${state}/${name}-${version}-Linux-${arch}-57179171dbed.${fext}" tmpdir="/tmp" check_root(){ if [[ $EUID -ne 0 ]]; then printf "${LRED}This script must be run as root${NC}\n" 1>&2 exit 1 fi } check_install(){ if [ ! -d ${target_dir}/${name}-${version}-Linux-${arch} ];then printf "Install check passed...moving on...\n" else printf "${0}: ${name}-${version} is already installed\n" exit 0; fi } download_pkgs(){ if [ ! -f ${tmpdir}/${name}-${version}.${fext} ];then curl -o ${tmpdir}/${name}-${version}.${fext} ${url} else printf "The archive already exists..moving to extraction phase\n" fi } extract_files(){ cd ${tmpdir} if [ ! -f ${name}-${version}.${fext} ];then printf "${0}: ${tmpdir}/${name}-${version}.${fext}: no such file\n" else ${extcmd} xvzf ${name}-${version}.${fext} fi } install_build(){ cd ${tmpdir} if [ ! -d ${name}-${version}-Linux-${arch} ];then printf "${0}: ${name}-${version}-Linux-${arch}: No such firectory\n" else cp -r ${tmpdir}/${name}-${version}-Linux-${arch} ${target_dir}/ fi } post_install(){ ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eui /usr/bin ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/euc /usr/bin ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eutest /usr/bin ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eudist /usr/bin ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eudoc /usr/bin ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eushroud /usr/bin ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/euloc /usr/bin ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eudis /usr/bin ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eubind /usr/bin ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eub /usr/bin ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/echoversion /usr/bin ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/creole /usr/bin ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eucoverage /usr/bin } uninstall_pkg(){ if [ ! -d ${target_dir}/${name}-${version}-Linux-${arch} ];then printf "${name}-${version} is not installed\n" else rm -v -r ${target_dir}/${name}-${version}-Linux-${arch} rm -v /usr/bin/eui rm -v /usr/bin/euc rm -v /usr/bin/eutest rm -v /usr/bin/eudist rm -v /usr/bin/eudoc rm -v /usr/bin/eushroud rm -v /usr/bin/euloc rm -v /usr/bin/eudis rm -v /usr/bin/eubind rm -v /usr/bin/eub rm -v /usr/bin/echoversion rm -v /usr/bin/creole rm -v /usr/bin/eucoverage if [ ! -d ${target_dir}/${name}-${version}-Linux-${arch} ];then echo printf "${name}-${version} is uninstalled\n" else printf "${name}-${version} still exists on the system\n" printf "Location: ${target_dir}/${name}-${version}-Linux-${arch}\n" fi fi } case $1 in install) check_root check_install download_pkgs extract_files install_build post_install ;; uninstall) check_root uninstall_pkg ;; *) printf """ [SYNOPSIS] ${0}