Created
June 25, 2011 23:25
-
-
Save webus/1047023 to your computer and use it in GitHub Desktop.
play_cntrl bash script
This file contains 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 | |
set +v | |
clear | |
PLAY_VERSION=$1 | |
PLAY_DIR="/usr/local/share/play" | |
PLAY_EXT_PATH=$PLAY_DIR/play-$PLAY_VERSION | |
main() { | |
echo "check for availability in the system..." | |
if [ ! -d $PLAY_DIR/$PLAY_VERSION ]; then | |
down_version; | |
set_links_to_play; | |
else | |
echo "play version $PLAY_VERSION available in the system" | |
echo "do change the default version to $PLAY_VERSION" | |
set_links_to_play; | |
fi | |
} | |
set_links_to_play() { | |
cd $PLAY_DIR | |
check_link_dir $PLAY_VERSION | |
ln -s play-$PLAY_VERSION $PLAY_VERSION | |
check_link_exists /usr/local/bin/play | |
ln -s $PLAY_DIR/$PLAY_VERSION/play /usr/local/bin/play | |
} | |
check_play_ext_path() { | |
if [ -d $PLAY_EXT_PATH ]; then | |
rm -RI $PLAY_EXT_PATH; | |
fi; | |
}; | |
check_link_dir() { | |
if [ -d $1 ]; then | |
rm $1; | |
fi; | |
} | |
check_link_exists() { | |
if [ -f $1 ]; then | |
rm $1; | |
fi; | |
}; | |
check_main_path() { | |
if [ ! -d $PLAY_DIR ]; then | |
mkdir $PLAY_DIR; | |
fi | |
}; | |
down_version() { | |
echo "downloading $PLAY_VERSION" | |
check_main_path | |
cd $PLAY_DIR | |
if [ ! -f play-$PLAY_VERSION ]; then | |
wget -c http://download.playframework.org/releases/play-$PLAY_VERSION.zip | |
fi | |
if [ -d $PLAY_DIR ]; then | |
#directory exists | |
check_play_ext_path | |
unzip play-$PLAY_VERSION.zip -d $PLAY_DIR | |
else | |
#dir not exists | |
mkdir $PLAY_DIR | |
unzip play-$PLAY_VERSION.zip -d $PLAY_DIR | |
fi | |
set_links_to_play; | |
}; | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment