diff --git a/.gitignore b/.gitignore index 0344ad1a..0bf30100 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ node_modules/ ideas *_err.log *.swp +package-lock.json diff --git a/.travis.yml b/.travis.yml index 09e0123f..46660f47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,22 @@ language: node_js +node_js: + - "8" sudo: required before_install: - - 'if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi' - wget "http://static.druid.io/artifacts/releases/druid-0.8.3-bin.tar.gz" - tar -zxvf druid-0.8.3-bin.tar.gz - wget "https://archive.apache.org/dist/kafka/0.8.2.0/kafka_2.10-0.8.2.0.tgz" - tar -zxvf kafka_2.10-0.8.2.0.tgz install: - - npm -s install - - mvn -q clean install -f ./infinispan_example_app/pom.xml + - npm install + - mvn clean install -f ./infinispan_example_app/pom.xml script: + - node --version - ./infispector.sh help - ./infispector.sh prepare - - ./infispector.sh nodes + - ./infispector.sh nodes 1 + - ./infispector.sh nodes 1 + - ./infispector.sh nodes 1 + - ./infispector.sh nodes 1 - ./testFunctionality.sh - npm --harmony test diff --git a/gruntFile.js b/gruntFile.js index 5f470b1e..c673b9d6 100644 --- a/gruntFile.js +++ b/gruntFile.js @@ -195,7 +195,7 @@ serverFile: 'app.js', shell: { nodemon: { - command: 'nodemon <%= serverFile %>', + command: '${infispector_location}/node_modules/nodemon/bin/nodemon.js <%= serverFile %>', options: { stdout: true, stderr: true, @@ -218,4 +218,4 @@ }); -}; \ No newline at end of file +}; diff --git a/infinispan_example_app/pom.xml b/infinispan_example_app/pom.xml index 3e0a3d63..3dbf3233 100644 --- a/infinispan_example_app/pom.xml +++ b/infinispan_example_app/pom.xml @@ -8,8 +8,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 7.4.Final diff --git a/infispector.sh b/infispector.sh index 6ed5380d..95de7019 100755 --- a/infispector.sh +++ b/infispector.sh @@ -5,25 +5,19 @@ cleanUp() { pkill -f kafka -e pkill -f zookeeper -e pkill -f grunt -e + pkill -f nodemon -e } -#colors -NC='\033[0m' -WHITE='\033[1;37m' -GREEN='\033[0;32m' -RED='\033[0;31m' - -if [ "$#" -eq "0" ] || [ $1 == "help" ] -then +printHelp() { printf " - _____ __ _ _ - |_ _| / _|(_) | | - | | _ __ | |_ _ ___ _ __ ___ ___ | |_ ___ _ __ + _____ __ _ _ + |_ _| / _|(_) | | + | | _ __ | |_ _ ___ _ __ ___ ___ | |_ ___ _ __ | | | '_ \ | _|| |/ __|| '_ \ / _ \ / __|| __| / _ \ | '__| - _| |_ | | | || | | |\__ \| |_) || __/| (__ | |_ | (_) || | - |_____||_| |_||_| |_||___/| .__/ \___| \___| \__| \___/ |_| - | | - |_| + _| |_ | | | || | | |\__ \| |_) || __/| (__ | |_ | (_) || | + |_____||_| |_||_| |_||___/| .__/ \___| \___| \__| \___/ |_| + | | + |_| commands: @@ -32,60 +26,67 @@ ${GREEN}infispector prepare${NC} - starts dependecies (zookeeper, kafka, druid) ${GREEN}infispector start${NC} - starts application ${GREEN}infispector stop${NC} - stops infispector ${GREEN}infispector nodes${NC} - starts 4 instances +${GREEN}infispector uninstall${NC} - uninstalls infispector ${GREEN}infispector nodes ${RED}NUMBER${NC} - starts specified ${RED}NUMBER${NC} of instances " - exit 0 -fi - -#paths -DRUID_LOCATION=`find /home -type d -name druid-0.8.3 2> /dev/null` -KAFKA_LOCATION=`find /home -type d -name kafka_2.10-0.8.2.0 2> /dev/null` -INFISPECTOR_LOCATION=`find /home -type d -iname infispector 2> /dev/null | awk '{ print length, $0 }' | sort -n -s | head -n1 | cut -f 2 -d ' '` - -DEFAULT="4" -NUMBER_CHECK='^[0-9]+$' -cnt="0" -TIMEOUT="0" - -if [ -z $DRUID_LOCATION ] -then - printf "Druid not found. Druid must be in /home/* directory\n" >&2 - exit 1 -fi - -if [ -z $KAFKA_LOCATION ] -then - printf "Kafka not found. Kafka must be in /home/* directory\n" >&2 - exit 1 -fi +} -if [ -z $INFISPECTOR_LOCATION ] -then - printf "Infispector not found. Infispector must be in /home/* directory\n" >&2 - exit 1 -fi +getInfispectorLocation() { + result="" + if [[ -z "$infispector_location" ]] + then + result=`find /home -type d -name infispector 2> /dev/null | awk '{ print length, $0 }' | sort -n -s | head -n1 | cut -f 2 -d ' '` + else + result="$infispector_location" + fi + if [[ -z "$result" ]] + then + printf "Infispector not found. Infispector must be in /home/* directory\n" >&2 + exit 1 + fi + echo "$result" +} -if [ $EUID -eq 0 ] -then - printf "Please, run this as a ${WHITE}normal${NC} user, not root.\n" >$2 - exit 1 -fi +getDruidLocation() { + result=`find /home -type d -name druid-0.8.3 2> /dev/null` + if [[ -z "$result" ]] + then + printf "Druid not found. Druid must be in /home/* directory\n" >&2 + exit 1 + fi + echo "$result" +} -if [ "$#" -gt "2" ] || { [ "$#" -eq "2" ] && [ "$1" != "nodes" ]; } -#if [ \( "$#" -gt "2" \) -o \( "$g" "$#" -eq "2" -a "$1" -ne "nodes" \) ] -then - printf "Invalid number of arguments!\n" >$2 - exit 1 -fi +getKafkaLocation() { + result=`find /home -type d -name kafka_2.10-0.8.2.0 2> /dev/null` + if [[ -z "$result" ]] + then + printf "Kafka not found. Kafka must be in /home/* directory\n" >&2 + exit 1 + fi + echo "$result" +} +checkUserAndParams() { + if [[ $EUID -eq 0 ]] + then + printf "Please, run this as a ${WHITE}normal${NC} user, not root.\n" >&2 + exit 1 + fi + + if [[ "$#" -gt "2" ]] || { [[ "$#" -eq "2" ]] && [[ "$1" != "nodes" ]]; } + then + printf "Invalid number of arguments!\n" >&2 + exit 1 + fi +} -if [ $1 == "prepare" ] -then - cd $KAFKA_LOCATION +startKafka() { + cd ${KAFKA_LOCATION} printf "Starting zookeeper ...." bin/zookeeper-server-start.sh config/zookeeper.properties > /dev/null & sleep 1 - if [ $? -ne 0 ] + if [[ $? -ne 0 ]] then printf " ${RED}FAIL${NC}\n" cleanUp @@ -96,7 +97,7 @@ then printf "Starting kafka ...." bin/kafka-server-start.sh config/server.properties > /dev/null & sleep 1 - if [ $? -ne 0 ] + if [[ $? -ne 0 ]] then printf " ${RED}FAIL${NC}\n" cleanUp @@ -104,11 +105,14 @@ then else printf " ${GREEN}OK${NC}\n" fi +} - cd $DRUID_LOCATION +startDruid() { + TIMEOUT="0" + cd ${DRUID_LOCATION} printf "Starting druid ...." - java -Xmx512m -Duser.timezone=UTC -Dfile.encoding=UTF-8 -Ddruid.realtime.specFile=$INFISPECTOR_LOCATION/kafka_druid_infrastructure/infispectorDruid.spec -classpath "config/_common:config/realtime:lib/*" io.druid.cli.Main server realtime > log.txt 2> log_err.txt & - if echo $INFISPECTOR_LOCATION | grep travis > /dev/null + java -Xmx512m -Duser.timezone=UTC -Dfile.encoding=UTF-8 -Ddruid.realtime.specFile=${INFISPECTOR_LOCATION}/kafka_druid_infrastructure/infispectorDruid.spec -classpath "config/_common:config/realtime:lib/*" io.druid.cli.Main server realtime > log.txt 2> log_err.txt & + if echo ${INFISPECTOR_LOCATION} | grep travis > /dev/null then sleep 10 fi @@ -119,62 +123,77 @@ then then break fi - if [ $TIMEOUT -eq "20" ] + if [[ "$TIMEOUT" -eq 20 ]] then printf " ${RED}FAIL${NC}\n" cleanUp exit 1 fi TIMEOUT=$[$TIMEOUT + 1] - sleep 1 + sleep 1 done - printf " ${GREEN}OK${NC}\n" - printf "Infispector is ready to be started!\n" - exit 0 -fi +} -if [ $1 == "start" ] -then - cd $INFISPECTOR_LOCATION - grunt - exit 0 -fi +prepare() { + startKafka + startDruid + printf " ${GREEN}OK${NC}\n" + printf "Infispector is ready to be started!\n" +} -if [ $1 == "stop" ] -then - cleanUp - exit 0 -fi +start() { + cd ${INFISPECTOR_LOCATION} + grunt | tee output.out & + while true + do + if cat output.out | grep "Server is listening on port 8080" > /dev/null + then + break + fi + done + rm output.out +} +uninstall() { + ${INFISPECTOR_LOCATION}/uninstall.sh +} -if [ $1 == "nodes" ] -then - cd $INFISPECTOR_LOCATION/infinispan_example_app - if ! [[ -z "$2" ]] +setNumberOfNodes() { + result="4" + NUMBER_CHECK='^[0-9]+$' + if ! [[ -z "$1" ]] then - if ! [[ $2 =~ $NUMBER_CHECK ]] + if ! [[ $1 =~ $NUMBER_CHECK ]] then printf "Second argument must be a number\n" >&2 exit 1 fi - DEFAULT=$2 - if [ $DEFAULT -ge "10" ] + result=$1 + if [[ "$result" -ge "10" ]] then while true; do - read -p "Are you sure you want to start ${DEFAULT} instances? [y/n] " yn + read -p "Are you sure you want to start ${result} instances? [y/n] " yn case $yn in [Yy]* ) break;; [Nn]* ) exit 0;; - *) echo "Please answer y or n.";; + *) echo "Please answer y or n." >&2;; esac done fi fi + echo "$result" +} + +nodes() { + DEFAULT="$(setNumberOfNodes "$1")" + cnt="0" + cd ${INFISPECTOR_LOCATION}/infinispan_example_app + printf "Starting $DEFAULT nodes ...." - while [ $cnt -ne $DEFAULT ] + while [[ "$cnt" -ne "$DEFAULT" ]] do - if [ $cnt -eq $[$DEFAULT - 1] ] + if [[ ${cnt} -eq $((DEFAULT - 1)) ]] then mvn exec:exec > /dev/null else @@ -182,7 +201,7 @@ then fi cnt=$[$cnt + 1] done - if [ $? -eq 0 ] + if [[ $? -eq 0 ]] then printf " ${GREEN}OK${NC}\n" exit 0 @@ -190,7 +209,33 @@ then printf " ${RED}FAIL${NC}\n" exit 1 fi +} + +#paths +DRUID_LOCATION=$(getDruidLocation) +KAFKA_LOCATION=$(getKafkaLocation) +INFISPECTOR_LOCATION=$(getInfispectorLocation) + +#colors +NC='\033[0m' +WHITE='\033[1;37m' +GREEN='\033[0;32m' +RED='\033[0;31m' + +checkUserAndParams +if [[ $# -eq 0 ]] +then + printHelp + exit 0 fi -printf "Invalid argument!\n" >&2 -exit 1 +case $1 in +("prepare") prepare ;; +("start") start; xdg-open http://localhost:8080 ;; +("stop") cleanUp ;; +("nodes") nodes $2;; +("uninstall") uninstall ;; +("help") printHelp ;; +(*) echo "invalid argument"; echo "usage: " ; printHelp ;; +esac +exit 0 diff --git a/infispectorAutocomplete b/infispectorAutocomplete index ad007942..57a84775 100644 --- a/infispectorAutocomplete +++ b/infispectorAutocomplete @@ -2,7 +2,7 @@ _infispector_complete() { local words cur cur="${COMP_WORDS[COMP_CWORD]}" COMPREPLY=() - words="prepare start nodes help stop" + words="prepare start nodes help stop uninstall" if [ ${COMP_CWORD} -eq 1 ] then COMPREPLY=( $(compgen -W "${words}" -- $cur) ) diff --git a/install.sh b/install.sh index 78609c90..563d5730 100755 --- a/install.sh +++ b/install.sh @@ -1,8 +1,160 @@ #!/bin/bash +checkRequirements() { + if [[ $EUID -eq 0 ]] + then + printf "Please, run this script as a ${WHITE}superuser${NC}, not root.\n" >&2 + exit 1 + fi + + wget -q --spider http://google.com + + if [[ $? -ne 0 ]] + then + printf "Internet connection is necessary in order to run this script\n" >&2 + exit 1 + fi + java -version > /dev/null + if [[ $? -ne 0 ]] + then + printf "Please install java and run this script again\n" >&2 + exit 1 + fi +} + +downloadDruid() { + printf "Looking for a druid-0.8.3 folder in device ...." + druid_location=`find /home -type d -name druid-0.8.3 2> /dev/null` + if echo ${druid_location} | grep "Trash" > /dev/null + then + rm -rf ${druid_location} + druid_location="" + fi + + if [[ -z "$druid_location" ]] + then + printf " ${RED}NOT FOUND${NC}.\n" + wget ${_PROGRESS_OPT} ${URL_DRUID} + if [[ $? -eq 0 ]] + then + tar -xvzf druid-0.8.3-bin.tar.gz -C $HOME > /dev/null + /bin/rm -rf druid-0.8.3-bin.tar.gz > /dev/null + else + printf "Druid download failed\n" >&2 + exit 1 + fi + else + printf " ${GREEN}FOUND${NC}.\nDownload will be skipped.\n" + fi +} + +downloadKafka() { + printf "Looking for a kafka_2.10-0.8.2.0 folder in device ...." + kafka_location=`find /home -type d -name kafka_2.10-0.8.2.0 2> /dev/null` + + if echo ${kafka_location} | grep "Trash" > /dev/null + then + rm -rf ${kafka_location} + kafka_location="" + fi + + if [[ -z "$kafka_location" ]] + then + printf " ${RED}NOT FOUND${NC}.\n" + wget ${_PROGRESS_OPT} ${URL_KAFKA} + if [[ $? -eq 0 ]] + then + tar -xvzf kafka_2.10-0.8.2.0.tgz -C $HOME > /dev/null + /bin/rm -rf kafka_2.10-0.8.2.0.tgz > /dev/null + chmod +x $HOME/kafka_2.10-0.8.2.0/bin/*.sh + else + printf "Kafka download failed\n" >&2 + fi + else + printf " ${GREEN}FOUND${NC}.\nDownload will be skipped.\n" + fi +} + +modifyBashrc() { + if [[ -z "$infispector_location" ]] + then + printf "${RED}Unable to find infispector directory. It cannot be renamed for this script to work${NC}\n" >&2 + exit 1 + fi + + if ! grep "#infispector" < ~/.bashrc > /dev/null + then + printf "Modifying .bashrc file ...." + printf "\n\n#infispector\n" >> ~/.bashrc + fi + + if ! grep "alias infispector='${infispector_location}/infispector.sh'" < ~/.bashrc > /dev/null + then + printf "alias infispector='${infispector_location}/infispector.sh'\n" >> ~/.bashrc + printf "infispector_location='${infispector_location}'\n" >> ~/.bashrc + printf "export infispector_location\n" >> ~/.bashrc + fi +} + +autocompletion() { + if ! grep "source /etc/bash_completion.d/infispectorAutocomplete" < ~/.bashrc > /dev/null + then + printf "source /etc/bash_completion.d/infispectorAutocomplete\n" >> ~/.bashrc + printf " ${GREEN}OK${NC}\n" + fi + if ! ls /etc/bash_completion.d/ | grep "infispectorAutocomplete" > /dev/null + then + printf "Moving autocomplete file to /etc/bash_completion.d/ (requires permission) ...." + sudo cp ${infispector_location}/infispectorAutocomplete /etc/bash_completion.d/ + if [[ $? -eq 1 ]] + then + printf " ${RED}FAIL${NC}\n" + else + printf " ${GREEN}OK${NC}\n" + fi + fi +} + +npmInstall() { + #check if npm is installed + npm --version > /dev/null + #npm install + npm config set loglevel warn + if [[ $? -ne 0 ]] + then + printf "${RED}npm is required${NC}" + printf "Please install npm and run this script again\n" >&2 + exit 1 + else + echo -n "npm install ...." + npm install + if [[ $? -eq 0 ]] + then + printf " ${GREEN}OK${NC}\n" + else + printf " ${RED}FAIL${NC}\n" + printf "Error log available in file $infispector_location/npm_err.log\n" >&2 + exit 1 + fi + fi +} + +kindlyAsk() { + printf "$1.\n" + while true; + do + read -p "Do you wish to install $2? [y/n] " yn + case $yn in + [Yy]* ) $4; break;; + [Nn]* ) printf "$3"; exit 0;; + * ) echo "Please answer y or n.";; + esac + done +} + downloadMaven() { printf "Downloading maven...\n" - wget -q --show-progress $URL_MAVEN + wget ${_PROGRESS_OPT} ${URL_MAVEN} tar zxvf apache-maven-3.5.2-bin.tar.gz -C $HOME > /dev/null /bin/rm apache-maven-3.5.2-bin.tar.gz > /dev/null M2_HOME=$HOME/apache-maven-3.5.2 @@ -12,7 +164,7 @@ downloadMaven() { echo "M2_HOME='$M2_HOME'" >> ~/.bashrc echo "export M2_HOME" >> ~/.bashrc echo 'PATH=$M2_HOME/bin:$PATH' >> ~/.bashrc - echo "export PATH" >> ~/.bashrc + echo "export PATH" >> ~/.bashrc else sed "/PATH=.*/i\ M2_HOME='$M2_HOME'\nexport M2_HOME\n\n" -i ~/.bashrc @@ -30,182 +182,32 @@ GREEN='\033[0;32m' WHITE='\033[1;37m' #urls -URL_DRUID="http://static.druid.io/artifacts/releases/druid-0.8.3-bin.tar.gz" -URL_KAFKA="https://archive.apache.org/dist/kafka/0.8.2.0/kafka_2.10-0.8.2.0.tgz" -URL_MAVEN="http://mirror.hosting90.cz/apache/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz" - -if [[ $EUID -eq 0 ]] -then - printf "Please, run this script as a ${WHITE}superuser${NC}, not root.\n" >&2 - exit 1 -fi - -wget -q --spider http://google.com - -if [ $? -ne 0 ] -then - printf "Internet connection is necessary in order to run this script\n" >&2 - exit 1 -fi - -printf "Looking for a druid-0.8.3 folder in device ...." -druid_location=`find /home -type d -name druid-0.8.3 2> /dev/null` -if echo $druid_location | grep "Trash" > /dev/null -then - rm -rf $druid_location - druid_location="" -fi - -if [ -z "$druid_location" ] -then - printf " ${RED}NOT FOUND${NC}.\n" - wget -q --show-progress $URL_DRUID - if [ $? -eq 0 ] - then - tar -xvzf druid-0.8.3-bin.tar.gz -C $HOME > /dev/null - /bin/rm -rf druid-0.8.3-bin.tar.gz > /dev/null - else - printf "Druid download failed\n" >&2 - exit 1 - fi -else - printf " ${GREEN}FOUND${NC}.\nDownload will be skipped.\n" -fi - -printf "Looking for a kafka_2.10-0.8.2.0 folder in device ...." -kafka_location=`find /home -type d -name kafka_2.10-0.8.2.0 2> /dev/null` - -if echo $kafka_location | grep "Trash" > /dev/null -then - rm -rf $kafka_location - kafka_location="" -fi - -if [ -z "$kafka_location" ] -then - printf " ${RED}NOT FOUND${NC}.\n" - wget -q --show-progress $URL_KAFKA - if [ $? -eq 0 ] - then - tar -xvzf kafka_2.10-0.8.2.0.tgz -C $HOME > /dev/null - /bin/rm -rf kafka_2.10-0.8.2.0.tgz > /dev/null - chmod +x $HOME/kafka_2.10-0.8.2.0/bin/*.sh - else - printf "Kafka download failed\n" >&2 - fi -else - printf " ${GREEN}FOUND${NC}. Download will be skipped.\n" -fi - -#sets alias infispector to start script infispector.sh - -infispector_location="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -if [ -z "$infispector_location" ] -then - printf "${RED}Unable to find infispector directory. It cannot be renamed for this script to work${NC}\n" >&2 - exit 1 -fi - -if ! grep "#infispector" < ~/.bashrc > /dev/null -then - printf "Modifying .bashrc file ...." - printf "\n\n#infispector\n" >> ~/.bashrc -fi - -if ! grep "alias infispector='${infispector_location}/infispector.sh'" < ~/.bashrc > /dev/null -then - printf "alias infispector='${infispector_location}/infispector.sh'\n" >> ~/.bashrc -fi - -#create new file with autocomplete - requires permission - -if ! grep "source /etc/bash_completion.d/infispectorAutocomplete" < ~/.bashrc > /dev/null -then - printf "source /etc/bash_completion.d/infispectorAutocomplete\n" >> ~/.bashrc - printf " ${GREEN}OK${NC}\n" -fi -if ! ls /etc/bash_completion.d/ | grep "infispectorAutocomplete" > /dev/null -then - printf "Moving autocomplete file to /etc/bash_completion.d/ (requires permission) ...." - sudo cp $infispector_location/infispectorAutocomplete /etc/bash_completion.d/ - if [ $? -eq 1 ] - then - printf " ${RED}FAIL${NC}\n" - else - printf " ${GREEN}OK${NC}\n" - fi -fi -cd $infispector_location - -#check if npm is installed -npm --version > /dev/null -#npm install -npm config set loglevel warn -if [ $? -ne 0 ] -then - printf "${RED}npm is required${NC}" - printf "Please install npm and run this script again\n" >&2 - exit 1 -else - echo -n "npm install ...." - npm -s install 2> $infispector_location/npm_err.log > /dev/null - if [ $? -eq 0 ] - then - printf " ${GREEN}OK${NC}\n" - else - printf " ${RED}FAIL${NC}\n" - printf "Error log available in file $infispector_location/npm_err.log\n" >&2 - exit 1 - fi -fi - -if [ ! -s $infispector_location/npm_err.log ] -then - rm $infispector_location/npm_err.log -fi - -#check if mvn is installed -java -version > /dev/null -if [ $? -ne 0 ] -then - printf "Please install java and run this script again\n" >&2 - exit 1 -fi - +export URL_DRUID="http://static.druid.io/artifacts/releases/druid-0.8.3-bin.tar.gz" +export URL_KAFKA="https://archive.apache.org/dist/kafka/0.8.2.0/kafka_2.10-0.8.2.0.tgz" +export URL_MAVEN="http://mirror.hosting90.cz/apache/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz" + +#set wget options +wget --help | grep -q '\--show-progress' && \ + _PROGRESS_OPT="-q --show-progress" || _PROGRESS_OPT="" +export _PROGRESS_OPT +# get infispector location +export infispector_location="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +checkRequirements +downloadDruid +downloadKafka +modifyBashrc +cd ${infispector_location} +npmInstall mvn --version > /dev/null 2> /dev/null -if [ $? -ne 0 ] +if [[ $? -ne 0 ]] then - printf "Maven is necessary to run infispector.\n" - while true; - do - read -p "Do you wish to install maven? [y/n] " yn - case $yn in - [Yy]* ) downloadMaven; break;; - [Nn]* ) printf "Run ${GREEN}mvn clean install${NC} in ${WHITE}$infispector_location/infinispan_example_app/${NC} folder when you install maven."; exit 0;; - * ) echo "Please answer y or n.";; - esac - done + kindlyAsk "Maven is necessary to run infispector" "maven" "Run ${GREEN}mvn clean install${NC} in ${WHITE}$infispector_location/infinispan_example_app/${NC} folder when you install maven." downloadMaven fi -printf "mvn install ...." -cd $infispector_location/infinispan_example_app/ -mvn -q clean install 2> $infispector_location/mvn_err.log -if [ $? -eq 0 ] +if [[ ! -f "/etc/bash_completion.d" ]] then - printf " ${GREEN}OK${NC}\n" -else - printf " ${RED}FAIL${NC}\n" - printf "Error log available in file $infispector_location/mvn_err.log\n" >&2 - exit 1 + kindlyAsk "To make InfiSpector more easy to use we require to enable autocompletion (requires permission)" "autocompletion" "Move infispectorAutocomplete to /etc/bash_completion.d in case you change your mind" autocompletion fi -if [ ! -s $infispector_location/mvn_err.log ] -then - rm $infispector_location/mvn_err.log -fi - -source ~/.bashrc - printf "${WHITE}Infispector will be ready for use after terminal restart!\n" printf "if you need help type word infispector in you terminal${NC}\n" -exit 0 diff --git a/package.json b/package.json index 2253556f..1b2dd21f 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,11 @@ "mongoose": ">= 3.6.1", "infinispan": "0.2.0", "jsonfile": "2.3.0", - "rsvp":"3.2.1", + "rsvp": "3.2.1", "crypto": ">= 0.0.3", "passport": ">= 0.1.6", "passport-local": ">= 0.1.6", "nodemailer": ">= 0.4.1", - "nodemon": "1.3.7", "is-online": ">=7.0.0", "jasmine": "^2.8.0", "request": "2.81.0" @@ -39,10 +38,11 @@ "grunt-nodemon": "^0.4.0", "grunt-processhtml": "~0.2.7", "grunt-shell": "^1.1.2", - "load-grunt-tasks": "^3.1.0" + "load-grunt-tasks": "^3.1.0", + "nodemon": "^1.18.3" }, "scripts": { - "start": "node app.js", + "start": "node app.js", "test": "jasmine spec/postRequestsTest.js" } } diff --git a/testFunctionality.sh b/testFunctionality.sh index 44d67e16..8da20c8d 100755 --- a/testFunctionality.sh +++ b/testFunctionality.sh @@ -7,6 +7,8 @@ cleanUp() { rm tmp2 } +$SHELL --version +export infispector_location=`readlink -f .` grunt > tmp & while true diff --git a/uninstall.sh b/uninstall.sh new file mode 100644 index 00000000..1f98bdb0 --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +modifyBashrc() { + sed -i "/#infispector/d" ~/.bashrc + sed -i "/alias infispector=.*/d" ~/.bashrc + sed -i "/.*infispectorAutocomplete/d" ~/.bashrc + sed -i "/infispector_location=.*/d" ~/.bashrc + sed -i "/export infispector_location/d" ~/.bashrc +} + +removeDruid() { + druid_location=`find /home -type d -name druid-0.8.3 2> /dev/null` + if [[ -z "$druid_location" ]] + then + read -p "Do you wish to remove druid? [y/n] " yn + case $yn in + [Yy]* ) /bin/rm -rf ${druid_location}; break;; + [Nn]* ) break;; + * ) echo "Please answer y or n.";; + esac + fi +} + +removeKafka() { + kafka_location=`find /home -type d -name kafka_2.10-0.8.2.0 2> /dev/null` + if [[ -z "kafka_location" ]] + then + read -p "Do you wish to remove kafka? [y/n] " yn + case $yn in + [Yy]* ) /bin/rm -rf ${kafka_location}; break;; + [Nn]* ) break;; + * ) echo "Please answer y or n.";; + esac + fi +} + +removeAutocompletion() { + if ls /etc/bash_completion.d/ | grep "infispectorAutocomplete" > /dev/null + then + echo "Removing autocompletion for infispector. Root permission required." + sudo rm -rf /etc/bash_completion.d/infispectorAutocomplete + fi +} + +SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" + +while true; +do + read -p "Are you sure you want to uninstall InfiSpector? [y/n] " yn + case $yn in + [Yy]* ) echo "Uninstalling..."; break;; + [Nn]* ) exit 0;; + * ) echo "Please answer y or n.";; + esac +done +modifyBashrc +removeDruid +removeKafka +removeAutocompletion +/bin/rm -rf ${SCRIPTPATH}