Skip to content
Merged
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
56 changes: 56 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/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/database.sqlite\nDB_USERNAME=\nDB_PASSWORD=" > .env
if [ -f database.sqlite ]; then
echo "Database file already exists at database.sqlite, if this is unexpected you might have to delete it manually and run this script again"
else
touch database.sqlite
fi
echo "Needing sudo password to give permission to database file"
sudo chmod 775 database.sqlite
sudo chown www-data:www-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