Created
August 27, 2015 00:05
-
-
Save keiono/b84cebff935ab88b53d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#################################### | |
# System checker script for Linux | |
#################################### | |
# Target Cytoscape version for this script | |
CYTOSCAPE_VERSION="3.3.0" | |
# Supported Distributions | |
SUPPORTED_DISTRIBUTIONS=("ubuntu" "centos" "fedora") | |
UBUNTU_VERSIONS=() | |
CENTOS_VERSIONS=() | |
FEDORA_VERSIONS=() | |
# Supported Java verisons | |
SUPPORTED_JAVA_VERSIONS=("1.8.0") | |
# This user's shell | |
shell=$(echo $SHELL | awk -F'/' '{print $(NF)}') | |
echo "############# Cytoscape System Requirements Checker for Linux ##############" | |
echo "Target Cytoscape version: $CYTOSCAPE_VERSION" | |
echo "Your shell is $shell" | |
# Extract major version | |
distribution=$(lsb_release -si) | |
os_version=$(lsb_release -sr) | |
# Check distribution | |
dist_lower=$(echo $distribution | awk '{print tolower($0)}') | |
echo "Linux Distribution: $dist_lower" | |
echo "OS Version: $os_version" | |
os_pass=0 | |
for dist in "${SUPPORTED_DISTRIBUTIONS[@]}" | |
do | |
echo "Checking: $dist" | |
if [[ $dist == $dist_lower ]]; then | |
echo "Compatible distribution found: $dist_lower" | |
os_pass=1 | |
break | |
fi | |
done | |
if [ "$os_pass" -eq 1 ] | |
then | |
echo " - Pass: Distribution = $distribution" | |
else | |
echo "Fail: This Linux distribution is not supported: $distribution" | |
echo "Please upgrade your system to any of the following:" | |
echo ${SUPPORTED_DISTRIBUTIONS[0]} | |
for dist in "${SUPPORTED_DISTRIBUTIONS[@]}" | |
do | |
echo " - $dist" | |
done | |
exit 1 | |
fi | |
# Check version of the distribution | |
# | |
# TODO | |
# Test 2: Try java -version command | |
java_version_original=$(java -version 2>&1) | |
java_version=$(echo $java_version_original | awk 'NR==1{gsub(/"/,""); print $3}') | |
java_major_version=$(echo $java_version | awk -F'_' '{print $1}') | |
if [[ $java_major_version == ${SUPPORTED_JAVA_VERSIONS[0]} ]] | |
then | |
echo " - Pass: Current Java Version = $java_version" | |
else | |
echo "Fail: Java is not reachable. Need to set PATH to JAVA_HOME/bin " | |
echo "Your current path:" | |
echo $PATH | |
fi | |
# Tets 3: Check Java Home | |
if [[ $JAVA_HOME != "" ]]; then | |
echo " - Pass: JAVA_HOME found: $JAVA_HOME" | |
else | |
echo "JAVA_HOME is not set." | |
echo "Please add the following to your .${shell}rc file:" | |
echo "export JAVA_HOME=/YOUR_JDK_DIRECTORY/jdk1.8.0_*" | |
echo "where * is the latest Java 8 update number." | |
echo "And then type 'source ~/.${shell}rc'" | |
exit 1 | |
fi | |
# Test 4: Connect to App Store | |
NUM_TRY=5 | |
echo "Checking connection to Cytoscape App Store..." | |
ping_result=$(ping -c $NUM_TRY -t 15 apps.cytoscape.org | grep loss) | |
num_success=$(echo $ping_result | awk '{print $4}') | |
echo $ping_result | |
if [[ $num_success -eq $NUM_TRY ]]; then | |
echo "Done! You are ready to run Cytoscape $CYTOSCAPE_VERSION" | |
else | |
echo "Looks connection to App Store is unstable." | |
echo "traceroute result:" | |
traceroute apps.cytoscape.org | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment