forked from Anupama-Github/rasi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·52 lines (42 loc) · 1.15 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
#!/bin/bash
# Dependency check
DEPENDENCIES='apache2'
DEPENDENCIES+=' mysql-server'
DEPENDENCIES+=' php5'
# TODO: Can add an additional check to filter out and install only missing packages
echo "Installing dependencies..."
sudo apt-get --force-yes --yes install $DEPENDENCIES
# Create a symlink in /var/www/ to the current directory
CWD=$(pwd)
DEPLOY_DIR='/var/www/rasi'
echo "Linking $CWD to /var/www/rasi"
if [[ -f $DEPLOY_DIR ]]
then
rm -f $DEPLOY_DIR
fi
sudo ln -vs $CWD $DEPLOY_DIR
# Setup the base db from the db dump
# TODO: Should avoid using 'root'...
echo ""
echo "Creating database..."
echo "Enter MySQL root password..."
echo "CREATE DATABASE rasi" | mysql -u root -p
ret=$?
if [[ $ret -ne 0 ]]
then
echo "Couldn't create database... Check if a database by name 'rasi' already exists"
fi
echo ""
echo "Setting up the database..."
echo "Enter MySQL root password..."
mysql -u root rasi -p < ${CWD}/rasi-rating.sql
ret=$?
if [[ $ret -ne 0 ]]
then
echo "Something went wrong. Please check the error message."
exit 1
else
echo "Completed setup. Go to http://localhost/rasi"
exit 0
fi
#TODO: Setup the dbConfig.php script with the db password.