FG42/install.sh

150 lines
3.5 KiB
Bash
Raw Normal View History

2011-07-22 14:48:30 +01:00
#! /bin/bash
2013-06-09 18:41:15 +01:00
# Kuso IDE installer script
# Its a very quick way to install Kuso IDE
# I now this code is not very nice but who cares it works
VERSION=1.0.0
2013-06-09 18:41:15 +01:00
remoteconffile="http://raw.github.com/Karajlug/KusoIDE/1.0/conf/dotkuso"
remoteexecutable="http://raw.github.com/Karajlug/KusoIDE/1.0/bin/kuso"
conffile=conf/dotkuso
2011-12-03 10:34:57 +00:00
mode="basic"
2013-07-18 13:32:30 +01:00
REQUIREMENTS=(emacs git)
2013-07-18 13:18:08 +01:00
2013-06-09 18:41:15 +01:00
# Coloring Functions
function info() {
echo -e "[\033[01;32mINFO\033[00m]: $1"
}
function error(){
echo -e "[\033[01;31mERR\033[00m]: $1"
}
function warn(){
echo -e "[\033[01;33mWARN\033[00m]: $1"
}
2013-07-18 13:32:30 +01:00
function requirements_check(){
2013-07-18 13:18:08 +01:00
for app in "${REQUIRMENTS[@]}"
do
info "Check for $app"
2013-07-18 13:28:00 +01:00
if hash $1 2>/dev/null; then
info "$app is present"
2013-07-18 13:28:00 +01:00
else
2013-07-18 13:32:30 +01:00
REQUIREMENTS_CHECK=false
error "Can not find $app"
2013-07-18 13:28:00 +01:00
fi
done
2013-07-18 13:18:08 +01:00
}
2013-07-22 13:24:34 +01:00
while getopts ":e" option
do
case "${option}"
in
e)mode="expert";;
esac
done
2011-12-03 10:34:57 +00:00
# Gathering informations
echo -e "\n\033[01;32mKuso IDE\033[00m $VERSION copyright 2010-2013 \033[01;34mSameer Rahmani <lxsameer@gnu.org>\033[00m\n\n"
2013-07-18 13:18:08 +01:00
# Requirments check to make sure everything is ok
echo -e "Requirment Check"
# if this variable changed to fasle , means we have something to install
2013-07-18 13:32:30 +01:00
REQUIREMENTS_CHECK=true
requirements_check $REQUIREMENTS
# exit if our requirement check
if [ $REQUIREMENTS_CHECK == false ]; then
2013-07-18 13:18:08 +01:00
error "Please install requirments first";
exit;
fi
echo -e "\n\n"
2011-12-03 10:34:57 +00:00
echo "Enter requested informations. You can change it later in top"
echo -e "your init file.\n\n"
2011-12-05 11:06:21 +00:00
condition="1"
while [ "$condition" == "1" ] ; do
read -p "Do you want to install Kuso IDE as an stand alone application ([y]/n)? " standalone
if [ "$standalone" == "" -o "$standalone" == "y" ]
then
2013-07-18 13:28:00 +01:00
standalone="y"
dotemacs=~/.kuso_dev
repo=~/.kuso.d_dev
condition="0"
executable=kuso
2011-12-05 11:06:21 +00:00
fi
if [ "$standalone" == "n" ]
then
2013-07-18 13:28:00 +01:00
dotemacs=~/.emacs
repo=~/.emacs.d
condition="0"
executable=kuso
2011-12-05 11:06:21 +00:00
fi
done
2011-12-03 10:34:57 +00:00
read -p "Enter your full name: " fullname
read -p "Enter your email address: " mail
read -p "Where is your workspace directory[~/src/]: " workspace
# Validating informations
if [ "$workspace" == "" ]
then
2011-12-03 11:18:19 +00:00
workspace="$HOME/src/"
2011-12-03 10:34:57 +00:00
fi
# Installing stage1
2013-06-09 18:41:15 +01:00
info "Creating configuration folder in $repo"
2011-12-05 11:06:21 +00:00
mkdir -p $repo
2013-06-09 18:41:15 +01:00
2011-12-05 11:06:21 +00:00
if [ -e $dotemacs ]; then
2013-06-09 18:41:15 +01:00
info "An init file already exists."
info "Backing up exists init file to $dotemacs.backup . . ."
#cp $dotemacs "$dotemacs.backup"
2011-07-22 14:48:30 +01:00
fi
2013-06-09 18:41:15 +01:00
if [ -e $conffile ]
then
info "Copying init files . . . "
cp $conffile $dotemacs
cp bin/$executable $repo/$executable
else
2013-06-09 18:41:15 +01:00
info "Downloading init file and executable . . ."
wget $remoteconffile -q -O $dotemacs
wget $remoteexecutable -q -O $repo/$executable
fi
2011-12-05 13:59:14 +00:00
if [ "$standalone" == "" -o "$standalone" == "y" ]
2011-12-05 13:59:14 +00:00
then
2013-06-09 18:41:15 +01:00
info "Creating a link in globe PATH . . ."
sudo ln -s $repo/$executable /usr/bin/$executable-dev
2013-07-17 23:01:03 +01:00
chmod +x $repo/$executable
2011-12-05 13:59:14 +00:00
fi
2011-12-03 10:34:57 +00:00
sed "s/--EMAIL--/$mail/mg" -i $dotemacs
sed "s/--FULLNAME--/$fullname/mg" -i $dotemacs
sed "s,--WORKSPACE--,$workspace,mg" -i $dotemacs
sed "s,--REPO--,$repo,mg" -i $dotemacs
2011-12-03 10:34:57 +00:00
#if [ $mode == "expert" ]
#then
# info "Installing base system . . ."
# echo "(setq KUSO-INSTALL-MODE \"expert\")" > /tmp/init_kuso_installer.el
# `which emacs` --batch -l /tmp/init_kuso_installer.el -l $dotemacs
#else
# info "Installing base system . . ."
# `which emacs` --batch -l $dotemacs
#fi
2013-06-09 18:41:15 +01:00
echo -e "\nNow run 'kuso' and have fun ;)"