]> BookStack Code Mirror - devops/commitdiff
Create installation-ubuntu-16.04.sh
authorDan Brown <redacted>
Mon, 8 Aug 2016 19:35:37 +0000 (20:35 +0100)
committerGitHub <redacted>
Mon, 8 Aug 2016 19:35:37 +0000 (20:35 +0100)
scripts/installation-ubuntu-16.04.sh [new file with mode: 0644]

diff --git a/scripts/installation-ubuntu-16.04.sh b/scripts/installation-ubuntu-16.04.sh
new file mode 100644 (file)
index 0000000..6eec6ed
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+export DEBIAN_FRONTEND=noninteractive
+apt update
+apt install git nginx php7.0 php7.0-curl php7.0-mbstring php7.0-ldap php7.0-mcrypt \
+php7.0-tidy php7.0-xml php7.0-zip php7.0-gd php7.0-mysql mysql-server-5.7 mcrypt
+
+# Set up database
+echo "Setting up BookStack MySQL user and database"
+DB_PASS="$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13)"
+mysql -u root --execute="CREATE DATABASE bookstack;"
+mysql -u root --execute="CREATE USER 'bookstack'@'localhost' IDENTIFIED BY '$DB_PASS';"
+mysql -u root --execute="GRANT ALL ON bookstack.* TO 'bookstack'@'localhost';FLUSH PRIVILEGES;"
+
+# Install BookStack
+cd /var/www
+git clone https://github.com/ssddanbrown/BookStack.git --branch release --single-branch bookstack
+BOOKSTACK_DIR="/var/www/bookstack"
+cd $BOOKSTACK_DIR
+
+# Install composer
+EXPECTED_SIGNATURE=$(wget https://composer.github.io/installer.sig -O - -q)
+php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
+ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
+
+if [ "$EXPECTED_SIGNATURE" = "$ACTUAL_SIGNATURE" ]
+then
+    php composer-setup.php --quiet
+    RESULT=$?
+    rm composer-setup.php
+    exit $RESULT
+else
+    >&2 echo 'ERROR: Invalid installer signature'
+    rm composer-setup.php
+    exit 1
+fi
+
+# Install BookStack composer dependancies
+php composer.phar install
+
+# Copy and update BookStack environment variables
+cp .env.example .env
+sed -i.bak 's/DB_DATABASE=.*$/DB_DATABASE=bookstack/' .env
+sed -i.bak 's/DB_USERNAME=.*$/DB_USERNAME=bookstack/' .env
+sed -i.bak "s/DB_PASSWORD=.*\$/DB_PASSWORD=$DB_PASS/" .env
+php artisan key:generate --no-interaction
+php artisan migrate --no-interaction --force
+
+chown www-data:www-data -R bootstrap/cache public/uploads storage && chmod -R 755 bootstrap/cache public/uploads
+ storage
+