Skip to content

Commit

Permalink
Added installation script for MacOS - Darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
devdattakulkarni committed Aug 22, 2017
1 parent 2ba497a commit 97bf000
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 46 deletions.
69 changes: 23 additions & 46 deletions install.sh
@@ -1,53 +1,30 @@
#!/bin/bash

# define installation log file
truncate -s 0 install.log
install_log="install.log"
echo "Installing CloudARK. Installation logs stored in $install_log"

virtenv="cloudark-virtenv"
virtenvbin=`pwd`/$virtenv/bin
echo "Creating virtual environment $virtenv" &>> $install_log
virtualenv $virtenv &>> $install_log
source $virtenv/bin/activate &>> $install_log

pip install -r requirements.txt &>> $install_log
cd client
../$virtenv/bin/python setup.py install &>> $install_log

[[ ":$PATH:" != *":`pwd`:"* ]] && PATH="`pwd`:${PATH}"
[[ ":$PATH:" != *":$virtenvbin:"* ]] && PATH="$virtenvbin:${PATH}"
echo '### Added by CloudARK' >> ~/.profile
echo "export PATH=$PATH" >> ~/.profile
echo '### Added by CloudARK' >> ~/.bashrc
echo "export PATH=$PATH" >> ~/.bashrc

[[ ":$PYTHONPATH:" != *":`pwd`:"* ]] && PYTHONPATH="`pwd`:${PYTHONPATH}"
[[ ":$PYTHONPATH:" != *":$virtenvbin:"* ]] && PYTHONPATH="$virtenvbin:${PYTHONPATH}"
echo '### Added by CloudARK' >> ~/.profile
echo "export PYTHONPATH=$PYTHONPATH" >> ~/.profile
echo '### Added by CloudARK' >> ~/.bashrc
echo "export PYTHONPATH=$PYTHONPATH" >> ~/.bashrc

echo "Installing cloudark client done." &>> $install_log

cd ..
echo "Starting server.." &>> $install_log
ps -eaf | grep 'python server/fmserver.py' | awk '{print $2}' | xargs kill &>> $install_log
python server/fmserver.py 1>>cld-server.log 2>&1 &

has_server_started=`ps -eaf | grep fmserver`

if [[ ! -z "${has_server_started}" ]]; then
echo "CloudARK successfully installed."
echo "Next steps:"
echo "- Quick test: Run 'cld --help'"
echo "- Try sample programs from cloudark-samples repository (https://github.com/cloud-ark/cloudark-samples.git)"
# Check if running as root -- if so, exit
if (( $EUID == 0 )); then
echo "Looks like you are trying to run install.sh as root."
echo "That is not required actually."
echo "Just run ./install.sh as regular user."
exit
fi

# Check if the platform is one that we support
declare -a supported_platform_list=("Ubuntu 14.04", "Ubuntu 16.04", "OS X - Darwin");
platform=`uname -a | grep -E "Ubuntu|Darwin"`

# Activate virtual environment
/bin/bash -c ". $virtenv/bin/activate; exec /bin/bash -i"

if [[ -z "$platform" ]]; then
echo "Unsupported platform. Currently supported platforms: ${supported_platform_list[@]}"
exit
fi

host_platform=`uname -a | awk '{print $4}'`

if [ "$host_platform" = "Darwin" ]; then
echo "Host OS: Mac OS X"
source lib/install-mac.sh
elif [[ "$host_platform" =~ "Ubuntu" ]]; then
echo "Host OS: Ubuntu"
source lib/install-ubuntu.sh
else
echo "Unknown platform"
fi
54 changes: 54 additions & 0 deletions lib/install-mac.sh
@@ -0,0 +1,54 @@
#!/bin/bash

# define installation log file
rm -rf install.log
touch install.log
install_log="install.log"
echo "Installing CloudARK. Installation logs stored in $install_log"

virtenv="cloudark-virtenv"
virtenvbin=`pwd`/$virtenv/bin
echo "Creating virtual environment $virtenv" >> $install_log
virtualenv $virtenv >> $install_log
source $virtenv/bin/activate >> $install_log

pip install -r requirements.txt >> $install_log
cd client
../$virtenv/bin/python setup.py install >> $install_log

[[ ":$PATH:" != *":`pwd`:"* ]] && PATH="`pwd`:${PATH}"
[[ ":$PATH:" != *":$virtenvbin:"* ]] && PATH="$virtenvbin:${PATH}"
echo '### Added by CloudARK' >> ~/.profile
echo "export PATH=$PATH" >> ~/.profile
echo '### Added by CloudARK' >> ~/.bashrc
echo "export PATH=$PATH" >> ~/.bashrc

[[ ":$PYTHONPATH:" != *":`pwd`:"* ]] && PYTHONPATH="`pwd`:${PYTHONPATH}"
[[ ":$PYTHONPATH:" != *":$virtenvbin:"* ]] && PYTHONPATH="$virtenvbin:${PYTHONPATH}"
echo '### Added by CloudARK' >> ~/.profile
echo "export PYTHONPATH=$PYTHONPATH" >> ~/.profile
echo '### Added by CloudARK' >> ~/.bashrc
echo "export PYTHONPATH=$PYTHONPATH" >> ~/.bashrc

echo "Installing cloudark client done." >> $install_log

cd ..
echo "Starting server.." >> $install_log
ps -eaf | grep 'python server/fmserver.py' | awk '{print $2}' | xargs kill >> $install_log
python server/fmserver.py 1>>cld-server.log 2>&1 &

has_server_started=`ps -eaf | grep fmserver`

if [[ ! -z "${has_server_started}" ]]; then
echo "CloudARK successfully installed."
echo "Next steps:"
echo "- Quick test: Run 'cld --help'"
echo "- Try sample programs from cloudark-samples repository (https://github.com/cloud-ark/cloudark-samples.git)"
fi


# Activate virtual environment
/bin/bash -c ". $virtenv/bin/activate; exec /bin/bash -i"



53 changes: 53 additions & 0 deletions lib/install-ubuntu.sh
@@ -0,0 +1,53 @@
#!/bin/bash

# define installation log file
truncate -s 0 install.log
install_log="install.log"
echo "Installing CloudARK. Installation logs stored in $install_log"

virtenv="cloudark-virtenv"
virtenvbin=`pwd`/$virtenv/bin
echo "Creating virtual environment $virtenv" &>> $install_log
virtualenv $virtenv &>> $install_log
source $virtenv/bin/activate &>> $install_log

pip install -r requirements.txt &>> $install_log
cd client
../$virtenv/bin/python setup.py install &>> $install_log

[[ ":$PATH:" != *":`pwd`:"* ]] && PATH="`pwd`:${PATH}"
[[ ":$PATH:" != *":$virtenvbin:"* ]] && PATH="$virtenvbin:${PATH}"
echo '### Added by CloudARK' >> ~/.profile
echo "export PATH=$PATH" >> ~/.profile
echo '### Added by CloudARK' >> ~/.bashrc
echo "export PATH=$PATH" >> ~/.bashrc

[[ ":$PYTHONPATH:" != *":`pwd`:"* ]] && PYTHONPATH="`pwd`:${PYTHONPATH}"
[[ ":$PYTHONPATH:" != *":$virtenvbin:"* ]] && PYTHONPATH="$virtenvbin:${PYTHONPATH}"
echo '### Added by CloudARK' >> ~/.profile
echo "export PYTHONPATH=$PYTHONPATH" >> ~/.profile
echo '### Added by CloudARK' >> ~/.bashrc
echo "export PYTHONPATH=$PYTHONPATH" >> ~/.bashrc

echo "Installing cloudark client done." &>> $install_log

cd ..
echo "Starting server.." &>> $install_log
ps -eaf | grep 'python server/fmserver.py' | awk '{print $2}' | xargs kill &>> $install_log
python server/fmserver.py 1>>cld-server.log 2>&1 &

has_server_started=`ps -eaf | grep fmserver`

if [[ ! -z "${has_server_started}" ]]; then
echo "CloudARK successfully installed."
echo "Next steps:"
echo "- Quick test: Run 'cld --help'"
echo "- Try sample programs from cloudark-samples repository (https://github.com/cloud-ark/cloudark-samples.git)"
fi


# Activate virtual environment
/bin/bash -c ". $virtenv/bin/activate; exec /bin/bash -i"



0 comments on commit 97bf000

Please sign in to comment.