-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.sh
executable file
·82 lines (71 loc) · 2.54 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
################################################################################
################################################################################
#
# This script will promt the user to
# 1. install PostgreSQL
# taken from official source
# 2. setup the database and user
# creates uav_db and the current user
# 3. setup the table schema
# executes table_schema.sql
# 4. setup defaults
# executes setup_defaults.sql
#
# Tim Darrah
# NASA Fellow
# PhD Student
# Vanderbilt University
#
################################################################################
################################################################################
# install PostgreSQL
read -p "install postgreSQL? (y/n): " ans
if [[ $ans = y ]]
then
# Create the file repository configuration:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
# # Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# # Update the package lists:
sudo apt-get update
# # Install the latest version of PostgreSQL.
# # If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt-get -y install postgresql postgresql-contrib
fi
unset ans
# create the database and user
read -p "setup database? (y/n): " ans
if [[ $ans = y ]]
then
read -p "enter your password: " passwd
sudo -u postgres psql -f sql/setup_db_user.sql -v user="$USER" -v passwd="'$passwd'"
fi
unset ans
# create the tables
read -p "setup table schema? (y/n): " ans
if [[ $ans = y ]]
then
psql -d uav2_db -f sql/setup_table_schema.sql -U $USER
fi
unset ans
# create a uav and degradation processes with default parameters
read -p "setup defaults? (y/n): " ans
if [[ $ans = y ]]
then
psql -d uav2_db -f sql/setup_defaults.sql -U $USER
psql -d uav2_db -f sql/create_tarot_uav.sql -U $USER
fi
unset ans
# setup a readonly user? Note, access to future tables will have to be granted manually.
read -p "create a guest user account? (y/n): " ans
if [[ $ans = y ]]
then
psql -d uav2_db -f sql/setup_readonly_guest.sql
fi
echo 'restarting postgresql service...'
sudo service postgresql restart
echo 'service restarted...'
echo 'configuration complete.'
echo ' '