jitty-scripts/geuphoria.sh

177 lines
4.4 KiB
Bash
Executable File

#!/bin/bash
name="euphoria"
version="4.1.0"
state="beta2"
arch="x64"
fext="tar.gz"
extcmd="tar"
deps="curl"
target_dir="/usr/local"
url="http://nbtelecom.dl.sourceforge.net/project/rapideuphoria/Euphoria/${version}-${state}/${name}-${version}-Linux-${arch}-57179171dbed.${fext}"
tmpdir="/tmp"
check_deps(){
get_path=$(which curl)
if [ ! ${get_path} ];then
printf "Please install: ${deps}"
exit 0;
else
printf "Deps passed checks..moving on\n"
fi
}
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
}
remove_tmp(){
echo
printf "Do you want to remove ${tmpdir}/${name}-${version}-Linux-${arch} and ${tmpdir}/${name}-${version}.${fext}"
printf "[y/n]: "
read choice
if [ "${choice}" = "y" ];then
rm -v -r ${tmpdir}/${name}-${version}-Linux-${arch}
rm -v -r ${tmpdir}/${name}-${version}.${fext}
if [ ! -d ${tmpdir}/${name}-${version}-Linux-${arch} ] && [ ! -f ${tmpdir}/${name}-${version}.${fext} ];then
printf "${tmpdir} cleared\n"
else
printf "Failed to remove files\n"
fi
elif [ "${choice}" = "n" ];then
printf "Exiting...\n"
exit 0;
else
printf "Skipping and exiting...\n"
exit 0;
fi
}
case $1 in
install | i)
check_root
check_deps
check_install
download_pkgs
extract_files
install_build
post_install
;;
remove | r)
check_root
uninstall_pkg
;;
clean | c)
remove_tmp
;;
*)
printf """
[SYNOPSIS]
${0} <option>
[OPTIONS]
install | i Install ${name}-${version}
remove | r Uninstall ${name}-${version}
clean | c Clear out ${name} downloads in ${tmpdir}
"""
;;
esac