Skip to content

Instantly share code, notes, and snippets.

  • Save lakshmankashyap/fe69630797885c90bc4679a7c3a06fa8 to your computer and use it in GitHub Desktop.
Save lakshmankashyap/fe69630797885c90bc4679a7c3a06fa8 to your computer and use it in GitHub Desktop.
#!/bin/bash
###################################
# Usage: sudo ./installer.sh [os] #
###################################
OS=$1;
UBUNTU="ubuntu";
#############
# Functions #
#############
check_os() {
if [ "$OS" = "$UBUNTU" ]; then
echo "Target OS is $OS";
else
echo "$OS is not supported";
exit 1;
fi
}
update() {
echo "Updating";
if [ "$OS" = "$UBUNTU" ]; then
`echo apt-get update`;
fi
}
install_git() {
echo "Installing git";
if [ "$OS" = "$UBUNTU" ]; then
`echo apt-get install git-all`;
fi
}
install_nginx() {
echo "Installing nginx";
if [ "$OS" = "$UBUNTU" ]; then
`echo apt-get install nginx`;
fi
}
install_mysql() {
echo "Installing mysql";
if [ "$OS" = "$UBUNTU" ]; then
`echo apt-get install mysql-server`;
`echo mysql_secure_installation`;
`echo mysql_install_db`;
fi
}
install_mongodb() {
echo "Installing mongodb";
if [ "$OS" = "$UBUNTU" ]; then
`echo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927`;
`echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list`;
update;
`echo apt-get install -y mongodb-org`;
fi
}
install_redis() {
echo "Installing redis";
if [ "$OS" == "$UBUNTU" ]; then
`echo apt-get install build-essential`;
`echo apt-get install tcl8.5`;
`echo wget http://download.redis.io/releases/redis-stable.tar.gz && tar xzf redis-stable.tar.gz`;
`echo cd redis-stable`;
`echo make`;
`echo make test`;
`echo make install`;
`echo cd utils`;
`echo ./install_server.sh`;
fi
}
install_nodejs() {
echo "Installing node.js";
if [ "$OS" = "$UBUNTU" ]; then
# install node.js
`echo apt-get install nodejs`;
# install nvm
`echo curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash`;
fi
}
install_mono() {
echo "Installing mono";
if [ "$OS" = "$UBUNTU" ]; then
`echo sudo apt-get install mono-complete`;
fi
}
##############
# Operations #
##############
check_os;
install_git;
install_nginx;
install_mysql;
install_mongodb;
install_redis;
install_nodejs;
install_mono;
echo "All done";
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment