-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·47 lines (38 loc) · 1.42 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# Install MySQL server
sudo apt-get install mysql-common
# Start MySQL service
sudo service mysql start
# Log in to MySQL as root and execute SQL scripts
sudo mysql -u root <<'END_SQL'
-- Create a user
CREATE USER IF NOT EXISTS 'BloodBank'@'localhost' IDENTIFIED BY 'BloodBank';
GRANT ALL PRIVILEGES ON *.* TO 'BloodBank'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
-- Create the database
CREATE DATABASE IF NOT EXISTS BloodBank;
USE BloodBank;
-- Create the staff table
CREATE TABLE IF NOT EXISTS staff (
staff_id INT PRIMARY KEY,
staff_name VARCHAR(255) NOT NULL,
position VARCHAR(255),
contact_number VARCHAR(255) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
address VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
enabled BOOLEAN NOT NULL,
created_at DATETIME NOT NULL,
updated_at DATETIME
);
-- Insert an initial admin into the staff table
INSERT INTO staff (staff_id, staff_name, position, contact_number, email, address, password, enabled, created_at, updated_at)
VALUES (1,'Admin','Manager','0000000000','Admin@gmail.com','AdminAddress','$2a$12$zn5nIdsS5llI26.vwXSJne27fqC9AkJhgrBPtkkT5Q3gFXfYiJMlu', true, NOW(), null);
END_SQL
# Restart MySQL service to apply changes
sudo service mysql restart
# Run database migrations or initialize the schema
# Adjust this based on your project structure and build tools
mvn clean install
# Start your application
mvn spring-boot:run