Last active
May 30, 2017 18:45
-
-
Save sseidenthal/4174845f585b7cfc8d58a78e88dfd557 to your computer and use it in GitHub Desktop.
This Makefile will help you install mongodb or mariadb on an ubuntu 16.04 LTS
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
#description :This Makefile will help you installing mongodb or mariadb on an ubuntu 16.04 LTS machine. The goal is to add more targets which i personaly need | |
#author :Steve Seidenthal | |
#date :2017-05-25 | |
#version :0.1 | |
#usage :make, then follow the instructions | |
#notes :before using make sure you have "make" and "build-essential" installed | |
CURRENT_RELEASE := $(shell lsb_release -sr) | |
hello: | |
@echo "please use on on the following targets" | |
@echo " - make install-mongodb PASSWORD=xxxx (installs mongodb 3.4 with user admin and password you specify with argument PASSWORD)" | |
@echo " - make install-mariadb PASSWORD=xxxx (installs mariabdb 10.2 with user root and password you specify with argument PASSWORD)" | |
check-os: | |
ifneq ($(CURRENT_RELEASE),16.04) | |
$(error "this script was made for Ubuntu 16.04 LTS release only !") | |
endif | |
check-password: | |
ifndef PASSWORD | |
$(error argument PASSWORD must be given!) | |
endif | |
install-mongodb: check-os check-password | |
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 | |
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list | |
sudo apt update | |
sudo apt upgrade -y | |
sudo apt install -y mc htop curl wget unison mongodb-org | |
sudo service mongod start | |
mongo 127.0.0.1/admin --eval='db.createUser({user: "admin",pwd: "${PASSWORD}",roles: [ { role: "userAdminAnyDatabase", db: "admin" }, { role: "readWriteAnyDatabase", db: "admin" }, { role: "clusterAdmin", db: "admin" } ]})' | |
sudo sed -i 's/--quiet/--quiet --auth/g' /lib/systemd/system/mongod.service | |
sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mongod.conf | |
sudo systemctl daemon-reload | |
sudo service mongod restart | |
install-mariadb: check-os check-password | |
sudo apt-get install software-properties-common | |
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 | |
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ftp.hosteurope.de/mirror/mariadb.org/repo/10.2/ubuntu xenial main' | |
sudo apt update | |
sudo apt upgrade -y | |
sudo debconf-set-selections << "maria-db-10.2 mysql-server/root_password password ${PASSWORD}" | |
sudo debconf-set-selections << "maria-db-10.2 mysql-server/root_password_again password ${PASSWORD}" | |
sudo apt install -y mc htop curl wget unison mariadb-server | |
sudo sed -i "s/bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf | |
MYSQL=`which mysql` | |
Q1="GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '${PASSWORD}' WITH GRANT OPTION;" | |
Q2="FLUSH PRIVILEGES;" | |
SQL="${Q1}${Q2}" | |
$MYSQL -uroot -p${PASSWORD} -e "$SQL" | |
service mysql restart |
if you copy this file, please make sure that the beginning of each line stay's a "TAB" it will not work if there are "SPACES"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
please be aware that this is not meant for production use