Skip to content

Instantly share code, notes, and snippets.

@ellipsonic
Last active August 29, 2015 14:25
Show Gist options
  • Save ellipsonic/6954eaa2267e9118d370 to your computer and use it in GitHub Desktop.
Save ellipsonic/6954eaa2267e9118d370 to your computer and use it in GitHub Desktop.
Yaml file to bring up mysql instance on ubuntu server
# MyMysqlDB
# New mysql profile for magento
# Globals
globals:
-
name: mysql_port
value: '3306'
-
name: username
value: root
-
name: password
value: root
version: 0
name: 'Mysql server'
description: 'New mysql server'
# Interfaces
requires: []
provides:
-
subtype: "mysql"
multi: true
type: "database"
name: "mysqldb"
attributes:
ip: '{{context.ip}}'
port: '{{globals.mysql_port}}'
user: '{{globals.username}}'
password: '{{globals.password}}'
# Events
events:
init:
type: script
show: false
timeout: 300
script: "#!/bin/bash\n \n#Instructions to use this script \n#\n#chmod +x SCRIPTNAME.sh\n#\n#sudo ./SCRIPTNAME.sh\n \necho \"###################################################################################\"\necho \"Please be Patient: Installation will start now.......and it will take some time :)\"\necho \"###################################################################################\"\n \n#Update the repositories\napt-get update \napt-get -y install sudo\napt-get -y install nano\n \nsudo su\n \nsudo apt-get update\n \n#MySQL and required packages installation\nsudo apt-get -y install curl\nsudo apt-get -y install git \n \n#The following commands set the MySQL root password to root when you install the mysql-server package.\n \nsudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'\nsudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'\n \nsudo apt-get -y install mysql-server\n \n# Create DB\necho \"GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION\" | mysql -u root -proot\necho \"GRANT PROXY ON ''@'' TO 'root'@'%' WITH GRANT OPTION\" | mysql -u root -proot\nmysql -u root -e \"CREATE DATABASE IF NOT EXISTS magento_5\" -proot\nmysql -u root -e \"GRANT ALL PRIVILEGES ON magento_5.* TO 'root'@'localhost' IDENTIFIED BY 'root'\" -proot\n \n#Let any server access this database, if the username is root and password is root\nmysql -u root -e \"GRANT ALL ON magento_5.* TO 'root'@'%' IDENTIFIED BY 'root'\" -proot\nmysql -u root -e \"FLUSH PRIVILEGES\" -proot\nsleep 15s\n \n# Git all mysql files\ncd /tmp\ngit clone https://github.com/ellipsonic/magekart_db.git .\nmysql -u root magento_5 < /tmp/magento_5.sql -proot\n \n# Allow any server to connect \nsed -i \"s/bind-addressundefineds*=undefineds*127.0.0.1/bind-address = 0.0.0.0/\" /etc/mysql/my.cnf\necho \"USE magento_5;update core_config_data set value = '{{base_url}}' where path = 'web/unsecure/base_url';\" | mysql -u root -proot\necho \"USE magento_5;update core_config_data set value = '{{base_url}}' where path = 'web/secure/base_url';\" | mysql -u root -proot\n \n \n \n#Restart all the installed services to verify that everything is installed properly\necho -e \"undefinedn\"\n \nservice apache2 stop && service mysql restart > /dev/null\n \necho -e \"undefinedn\"\n \nif [ $? -ne 0 ]; then\n echo \"Please Check the Install Services, There is some $(tput bold)$(tput setaf 1)Problem$(tput sgr0)\"\nelse\n echo \"Installed Services run $(tput bold)$(tput setaf 2)Sucessfully$(tput sgr0)\"\nfi\n \necho -e "
files: []
fetch: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment