Added rudimentary installation script

master
Joel Leclerc 2012-05-01 16:20:19 -06:00
parent 4851413b6e
commit 5d6229a9c0
3 changed files with 337 additions and 0 deletions

1
util/2 Normal file
View File

@ -0,0 +1 @@
Invalid

88
util/install.sh Executable file
View File

@ -0,0 +1,88 @@
#!/bin/bash
#################################################
## ___ _ _ ___ _ _ ##
## | _ ) |___ __| |_| _ \ |__ _ _ _ ___| |_ ##
## | _ \ / _ \/ _| / / _/ / _` | ' \/ -_) _| ##
## |___/_\___/\__|_\_\_| |_\__,_|_||_\___|\__| ##
## ##
#################################################
# Copyright (c) MiJyn, Joel Leclerc <mijyn@mail.com>
#########################
## Installation Script ##
#########################
# Include utility script
. `readlink -f $0 | sed 's:\(.*\)/.*:\1/utility.sh:g'`
# Globals
VERSION=0.1
TARGET=`readlink -f "."`
NOTARGET=1
usage()
{
echo "BlockPlanet Installation Script"
echo "Usage: $0 [args]"
echo
displayhelp "-h" "Shows this help message" "-v" "Shows the version of this script" "-t TARGET" "Sets the target directory"
echo
echo "Copyright (c) MiJyn, Joel Leclerc <mijyn@mail.com>"
exit $1
}
version()
{
echo "BlockPlanet Installation Script version $VERSION"
exit $1
}
while getopts ":hvt:" opt
do
case $opt in
h) usage;;
v) version;;
t) TARGET=`readlink -f $OPTARG`;NOTARGET=0;;
\?) echo "Invalid option: $OPTARG"; usage 1;;
:) echo "Option requires an argument: $OPTARG"; usage 1;;
esac
done
if [ $NOTARGET -eq 1 ]
then
echo "FATAL: No target specified"
usage 1
fi
if [ -e $TARGET ]
then
echo "FATAL: Target already exists"
exit 1
fi
bboxes "BlockPlanet Installation Script"
echo
inst build-essential Essential_Build_Utilities libirrlicht-dev Irrlicht_Development_Files cmake CMake libbz2-dev BZ2_Development_Files libpng12-dev PNG_Development_Files libjpeg8-dev JPEG_Development_Files libxxf86vm-dev X11_Free86_Development_Files libgl1-mesa-dev GL_Development_Files libsqlite3-dev SQLite_Development_Files libogg-dev OGG_Development_Files libvorbis-dev Vorbis_Development_Files libopenal-dev OpenAL_Development_Files libcurl3 cURL_Library libcurl4-gnutls-dev cURL_Development_Files unzip Unzipper
echo
echo "Downloading BlockPlanet Source"
rm -f /tmp/blockplanet.zip
wget https://github.com/MiJyn/BlockPlanet/zipball/master -O /tmp/blockplanet.zip
mkdir -p $TARGET &> /dev/null
cd $TARGET
unzip /tmp/blockplanet.zip &> /dev/null
cd *
echo
echo "Compiling BlockPlanet"
mkdir build
cd build
cmake .. && make
echo
echo "Installing BlockPlanet"
sudo make install
#EOF

248
util/utility.sh Executable file
View File

@ -0,0 +1,248 @@
#!/bin/bash
#################################################
## ___ _ _ ___ _ _ ##
## | _ ) |___ __| |_| _ \ |__ _ _ _ ___| |_ ##
## | _ \ / _ \/ _| / / _/ / _` | ' \/ -_) _| ##
## |___/_\___/\__|_\_\_| |_\__,_|_||_\___|\__| ##
## ##
#################################################
# Copyright (c) MiJyn, Joel Leclerc <mijyn@mail.com>
#####################
## Utility Library ##
#####################
# Variables
# Color variables
Start='\e['
End='m'
Sep=';'
Normal='0'
Bold='1'
Underline='4'
Black='30'
Red='31'
Green='32'
Yellow='33'
Blue='34'
Purple='35'
Cyan='36'
White='37'
# Use the bak function to find out the background color value of any color
Background='10'
# Root
# 0 = not root, 1 = root
ROOT=0
if [ `id -u` -eq 0 ]
then
ROOT=1
fi
# General Utilities
# Finds the background color of any color
# # Usage: #
# bak color
# # Arguments: #
# color = Color to find the background of
# # Example: #
# BAKCOLOR=`bak $Green`
bak()
{
echo $(($1+$Background))
}
# Prints text in style
# # Usage: #
# prints text type color [bakcolor]
# # Arguments: #
# text = Text to print
# type = Type of text (normal, bold, underline)
# color = Color
# bakcolor = Background Color (you need to use the bak function to find this) [optional]
# # Example: #
# prints "Hello World" $Bold $Green `bak $Black`
prints()
{
if [ $# -lt 4 ]
then
printf $Start$2$Sep$3$End"$1"$Start$End
else
printf $Start$2$Sep$3$Sep$4$End"$1"$Start$End
fi
}
# Prints an error message
# # Usage: #
# printe text
# # Arguments: #
# text = Text to print
# # Example: #
# printe "Error displaying Hello World"
printe()
{
prints "$@" $Normal $Red &>2
}
# Prints a message using grammar
# # Usage: #
# printg arg1 arg2 arg3
# # Arguments: #
# arg = random argument to format
# # Example: #
# printg Hello World
printg()
{
NUM=0
for i in "$@"
do
NUM=$(($NUM+1))
done
NUMCLONE=$NUM
for x in "$@"
do
i=`echo $x | sed 's:_: :g'`
if [ $NUM -eq 1 ]
then
echo -n $i
NUM=$(($NUM-1))
elif [ $NUM -eq 2 ]
then
echo -n $i
if [ $NUMCLONE -eq 2 ]
then
echo -n " and "
else
echo -n ", and "
fi
NUM=$(($NUM-1))
else
echo -n $i", "
NUM=$(($NUM-1))
fi
done
echo
}
# Boxes in BASH
# # Usage: #
# bboxes text
# # Arguments: #
# text = text to format
# # Example: #
# bboxes "Hello World"
bboxes()
{
PADDING=6
CHAR="#"
i=0
TEXT="$*"
END=$((${#TEXT}+$PADDING))
while [ $i -lt $END ]
do
echo -n $CHAR
i=$(($i+1))
done
echo
echo "## $TEXT ##"
i=0
while [ $i -lt $END ]
do
echo -n $CHAR
i=$(($i+1))
done
echo
}
# Displays a help message
# # Usage: #
# displayhelp arg desc ...
# # Arguments: #
# arg = Argument
# desc = Description
# # Example: #
# displayhelp "-h" "Displays This Help Message"
displayhelp()
{
VAL=0
LONGEST=0
for i in "$@"
do
if [ $VAL -eq 0 ]
then
THIS=${#i}
if [ $THIS -gt $LONGEST ]
then
LONGEST=$THIS
fi
VAL=1
else
VAL=0
fi
done
space()
{
i=0
while [ $i -le $1 ]
do
echo -n " "
i=$(($i+1))
done
}
for i in "$@"
do
if [ $VAL -eq 0 ]
then
echo -en "$i`space $(($LONGEST-${#i}+2))`"
VAL=1
else
echo "$i"
VAL=0
fi
done
}
# Installation Utilities
# Installs packages
# # Usage: #
# inst package packagename package2 packagename2 ...
# # Arguments: #
# package = Package to install
# packagename = Name shown to the user
# # Example: #
# inst g++ GNU_C++_Compiler gcc GNU_C_Compiler
inst()
{
PAKLIST=""
PAKNAMELIST=""
VAL=0
for i in "$@"
do
if [ $VAL -eq 0 ]
then
PAKLIST="$PAKLIST $i"
VAL=1
else
PAKNAMELIST="$PAKNAMELIST $i"
VAL=0
fi
done
echo -n "Installing "
printg $PAKNAMELIST
echo
if [ $ROOT -eq 1 ]
then
apt-get install $PAKLIST
else
sudo apt-get install $PAKLIST
fi
echo
echo "Done"
}