Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing mysql to run on fedora #147

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ Instruction for spin VM and destroy:
- When you ssh into machine specify the name of the machine [ubuntu|fedora|stage]'
- When you destroy -f machine [ubuntu|fedora|stage]

#Choosing OS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is already in upstream. It should not be included in this PR.


- For fedora OS run 'vagrant up fedora'
- For ubuntu OS run 'vagrant up ubuntu'
- When you ssh into machine specify the name of the machine [fedora OR ubuntu OR stage]'
- When you destroy -f machine [fedora OR ubuntu OR stage]

# Our best practices:

- Ask questions in the Slack group.
Expand All @@ -33,7 +40,7 @@ Instruction for spin VM and destroy:
- Name: tiger + File format: pem
- Move the file from Downloads to ~/.ssh
- Windows users please address the additional steps before you countine
- run 'vagrant up aws'
- run 'vagrant up stage'

# Additional steps for Windows users

Expand Down
25 changes: 14 additions & 11 deletions scripts/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
#!/usr/bin/env bash
os=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
echo $os

set_mysql () {
systemctl enable $1
systemctl start $1
}

if [ $os == '"Ubuntu"' ]
then
echo "im ubuntu"
apt-get update
# !----------! Setting MySQL root user password root/root !----------!
debconf-set-selections <<< 'mysql-server mysql-server/root_password password LoginPass@@11223344'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password LoginPass@@11223344'
# !----------! install python and mysql !----------!
apt-get -y install python3-pip mysql-server mysql-client

set_mysql "mysql"


else
echo "im fedora"
cp /vagrant/mysql-community.repo /etc/yum.repos.d/
dnf -y update
dnf -y install python3-pip mysql-community-server

set_mysql "mysqld.service"

old_pw=$(grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}')
new_pw='LoginPass@@11223344'
mysqladmin -u root -p"$old_pw" password "$new_pw"


fi
pip3 install -r /vagrant/requirements.txt
systemctl enable mysql
systemctl start mysql

new_pw='LoginPass@@11223344'
mysql -u root -p"$new_pw" <<MYSQL_SCRIPT
CREATE DATABASE tiger;
USE tiger;
CREATE TABLE users(username VARCHAR(20), password VARCHAR(100) NOT NULL, create_date TIMESTAMP NOT NULL, PRIMARY KEY(username));
CREATE TABLE messages(username VARCHAR(20),create_date TIMESTAMP NOT NULL,content VARCHAR(100) NOT NULL,FOREIGN KEY(username) REFERENCES users(username));
SHOW TABLES;
create table users(username VARCHAR(25) NOT NULL, password VARCHAR(100) NOT NULL, create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY(username));
create table messages(message_id int NOT NULL AUTO_INCREMENT, username VARCHAR(25) NOT NULL, content text,
create_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, primary key(message_id), foreign key(username) references users(username));
DESCRIBE users;
DESCRIBE messages;
MYSQL_SCRIPT

chmod 755 /vagrant/app.py
nohup python3 /vagrant/app.py > /dev/null 2>&1 &
nohup python3 /vagrant/app.py > /dev/null 2>&1 &