-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·65 lines (59 loc) · 1.7 KB
/
setup.sh
File metadata and controls
executable file
·65 lines (59 loc) · 1.7 KB
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
#!/usr/bin/env bash
set -e
# User config
while true; do
read -p "Choose a database 1: MySQL, 2: SQLite [2] " database
case $database in
"1" ) break;;
"2" ) break;;
"" ) database="2"; break;;
* ) echo "Invalid choice";;
esac
done
# Create .env file
path=$(dirname $(realpath $0))
echo ""
echo "Creating environment at $path"
if [ $database == "1" ] # MySQL
then
read -p "Database name [shika]: " dataname
if [ -z $dataname ]
then
dataname=shika
fi
read -p "Database username [admin]: " username
if [ -z $username ]
then
username=admin
fi
while [ -z $password ]
do
read -p "Database password: " password
done
echo -e "DB_DSN=mysql:host=localhost;dbname=$dataname\nDB_USERNAME=$username\nDB_PASSWORD=$password" > .env
elif [ $database == "2" ] #Sqlite
then
echo -e "DB_DSN=sqlite:$path/data/database.sqlite\nDB_USERNAME=\nDB_PASSWORD=" > .env
if [ -f data/database.sqlite ]; then
echo "Database file already exists at data/database.sqlite, if this is unexpected you might have to delete it manually and run this script again"
else
mkdir -p data
touch data/database.sqlite
fi
echo "Needing sudo password to give permission to database file"
read -p "Webserver user [www-data]: " webuser
if [ -z $webuser ]
then
webuser=www-data
fi
sudo chmod 775 data/database.sqlite
sudo chown $webuser:$webuser data
sudo chown $webuser:$webuser data/database.sqlite
fi
# Run php script
echo ""
echo "Running migration script"
php bin/migrate
echo ""
echo "Creating admin user, please fill the following data with the administrator credentials"
php bin/adduser