--- /dev/null
+#!/bin/bash
+
+echo "Enter the full version (v0.25.5) and press [ENTER]:"
+read version
+
+echo ""
+echo ""
+
+# Translator Attribution Update
+echo "bookstack-update-translators"
+echo "git commit -a -m \"Updated translator attribution before release ${version}\""
+
+# Merge codebase from master
+echo "git checkout release"
+echo "git merge master"
+echo ""
+
+# Builds deps and increment version
+echo "npm run production"
+echo "echo \"${version}\" > version"
+echo "git commit -a -m \"Updated version and assets for release ${version}\""
+echo ""
+
+
+# Tag release and push it to GitHub
+echo "git tag -a ${version} -m \"Beta Release ${version}\" -s"
+echo "git push origin release"
+echo "git push origin ${version}"
\ No newline at end of file
--- /dev/null
+#!/usr/bin/env php
+<?php
+
+// Script to fetch translators from crowdin via the API
+// and format into a BookStack attribution file.
+$key = getenv('CROWDIN_PROJECT_KEY');
+if (!$key) {
+ echo "Crowdin project key needs to be set on [CROWDIN_PROJECT_KEY] environment variable to run this script";
+ exit(0);
+}
+
+// Get the location of the attribution report.
+$reportLocation = getcwd() . '/.github/translators.txt';
+if (!file_exists($reportLocation)) {
+ echo "Could not find the translators file at [{$reportLocation}]";
+ echo "Are you running this script from the BookStack root folder?";
+ exit(0);
+}
+
+$reportDelimiter = ' :: ';
+
+$reportMap = loadExistingReportIntoMap($reportDelimiter, $reportLocation);
+$csvReport = exportTopMembersReport($key);
+$csvData = csv_to_array($csvReport);
+mergeCsvDataIntoReportMap($reportMap, $csvData, $reportDelimiter);
+formatAndWriteOutput($reportLocation, $reportMap, $reportDelimiter);
+
+function formatAndWriteOutput(string $reportLocation, array $reportMap, string $reportDelimiter) {
+ $output = "Name :: Languages\n";
+ foreach ($reportMap as $name => $languages) {
+ if (count($languages) === 0 || (count($languages) === 1 && empty($languages[0]))) continue;
+ if ($name === 'Dan Brown (ssddanbrown)' || $name === 'Name') continue;
+ $output .= $name . $reportDelimiter . implode('; ', $languages) . "\n";
+ }
+
+ file_put_contents($reportLocation, $output);
+}
+
+function mergeCsvDataIntoReportMap(array &$reportMap, array $csvData, string $reportDelimiter) {
+ foreach ($csvData as $csvLine) {
+ $name = $csvLine['Name'];
+ $name = str_replace($reportDelimiter, '', $name);
+ $languages = explode('; ', $csvLine['Languages']);
+ if (isset($reportMap[$name])) {
+ $languages = array_unique(array_merge($languages, $reportMap[$name]));
+ }
+ $reportMap[$name] = $languages;
+ }
+}
+
+function loadExistingReportIntoMap($reportDelimiter, $reportLocation) {
+ try {
+ $reportData = file_get_contents($reportLocation);
+ } catch (Exception $exception) {
+ $reportData = '';
+ }
+ $reportLines = explode("\n", $reportData);
+ $reportMap = [];
+ foreach ($reportLines as $reportLine) {
+ if (empty($reportLine)) continue;
+ [$name, $langs] = explode($reportDelimiter, $reportLine);
+ $splitLangs = explode('; ', $langs);
+ $reportMap[$name] = $splitLangs;
+ }
+ return $reportMap;
+}
+
+function exportTopMembersReport($key) {
+ $result = makeMemberExportReport($key);
+
+ $exportHash = $result->hash;
+ $csv = downloadMemberReport($exportHash, $key);
+
+ return $csv;
+}
+
+function makeMemberExportReport(string $key) {
+ $url = 'https://api.crowdin.com/api/project/bookstack/reports/top-members/export';
+ $postData = [
+ 'date_from' => '2019-10-01',
+ 'date_to' => date('Y-m-d'),
+ 'format' => 'csv',
+ 'json' => true,
+ 'key' => $key,
+ ];
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 15);
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
+
+ $result = curl_exec($ch);
+ curl_close($ch);
+
+ $data = json_decode($result);
+ return $data;
+}
+
+function downloadMemberReport(string $exportHash, string $key) {
+ $params = [
+ 'hash' => $exportHash,
+ 'key' => $key
+ ];
+ $url = 'https://api.crowdin.com/api/project/bookstack/reports/top-members/download';
+ $url .= '?' . http_build_query($params);
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 15);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+ $result = curl_exec($ch);
+ curl_close($ch);
+
+ return $result;
+}
+
+/**
+ * Convert a comma separated string into an associated array.
+ * @link http://gist.github.com/385876 (Modified)
+ * @author Jay Williams <http://myd3.com/> (Modified)
+ * @copyright Copyright (c) 2010, Jay Williams (Modified)
+ * @license http://www.opensource.org/licenses/mit-license.php MIT License
+ */
+function csv_to_array(string $csvString): array
+{
+
+ $header = null;
+ $data = [];
+ $lines = explode("\n", trim($csvString));
+ foreach ($lines as $line) {
+ $csvLine = str_getcsv($line);
+ if (!$header) {
+ $header = $csvLine;
+ } else {
+ $data[] = array_combine($header, $csvLine);
+ }
+ }
+
+ return $data;
+}
--- /dev/null
+#!/bin/sh
+echo "This script will install a new BookStack instance on a fresh CentOS 7 server."
+echo "This script is experimental and does not attend to system security."
+
+# Fetch domain to use from first provided parameter,
+# Otherwise request the user to input their domain
+DOMAIN=$1
+if [ -z $1 ]
+then
+echo ""
+printf "Enter the domain you want to host BookStack and press [ENTER]\nExamples: my-site.com or docs.my-site.com\n"
+read DOMAIN
+fi
+
+# Get the current machine IP address
+CURRENT_IP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
+
+# Install core system packages and remi php repository
+yum check-update
+yum install -y git httpd curl wget yum-utils mariadb-server
+wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
+wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
+rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
+yum-config-manager --enable remi-php73
+yum install -y php php-cli php-common php-gd php-json php-ldap php-mysqlnd php-mbstring php-tidy php-xml php-zip php-mcrypt php-opcache
+
+# Start Apache & Mariadb
+systemctl start httpd
+systemctl start mariadb
+# Set Apache and Mariadb to start on system boot
+systemctl enable httpd
+systemctl enable mariadb
+
+# Set up 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;"
+
+# Download BookStack
+cd /var/www
+git clone https://github.com/BookStackApp/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)
+curl -s 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 -f composer-setup.php
+else
+ >&2 echo 'ERROR: Invalid composer installer signature'
+ rm -f 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
+echo "APP_URL="
+# Generate the application key
+php artisan key:generate --no-interaction --force
+# Migrate the databases
+php artisan migrate --no-interaction --force
+
+# Set BookStack file and folder permissions
+chown apache:apache -R bootstrap/cache public/uploads storage && chmod -R 755 bootstrap/cache public/uploads storage
+
+# Set up Apache VirtualHost
+mkdir /etc/httpd/sites-available /etc/httpd/sites-enabled
+echo "IncludeOptional sites-enabled/*.conf" >> /etc/httpd/conf/httpd.conf
+cat >/etc/httpd/sites-available/bookstack.conf <<EOL
+<VirtualHost *:80>
+ ServerName ${DOMAIN}
+
+ ServerAdmin webmaster@localhost
+ DocumentRoot /var/www/bookstack/public/
+
+ <Directory /var/www/bookstack/public/>
+ Options Indexes FollowSymLinks
+ AllowOverride None
+ Require all granted
+ <IfModule mod_rewrite.c>
+ <IfModule mod_negotiation.c>
+ Options -MultiViews -Indexes
+ </IfModule>
+
+ RewriteEngine On
+
+ # Handle Authorization Header
+ RewriteCond %{HTTP:Authorization} .
+ RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
+
+ # Redirect Trailing Slashes If Not A Folder...
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_URI} (.+)/$
+ RewriteRule ^ %1 [L,R=301]
+
+ # Handle Front Controller...
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^ index.php [L]
+ </IfModule>
+ </Directory>
+
+ ErrorLog /var/log/httpd/bookstack-error.log
+ CustomLog /var/log/httpd/bookstack-access.log combined
+
+</VirtualHost>
+EOL
+
+ln -s /etc/httpd/sites-available/bookstack.conf /etc/httpd/sites-enabled/bookstack.conf
+
+# Restart apache to load new config
+systemctl restart httpd
+
+# Open up the firewall
+firewall-cmd --permanent --zone=public --add-service=http
+firewall-cmd --permanent --zone=public --add-service=https
+firewall-cmd --reload
+
+# Update SELinux to allow Apache to write to BookStack locations
+chcon -Rv --type=httpd_sys_rw_content_t /var/www/bookstack/bootstrap/cache
+chcon -Rv --type=httpd_sys_rw_content_t /var/www/bookstack/public/uploads
+chcon -Rv --type=httpd_sys_rw_content_t /var/www/bookstack/storage
+
+echo ""
+echo "Setup Finished, Your BookStack instance should now be installed."
+echo "MySQL was installed without a root password, It is recommended that you set a root MySQL password."
+echo ""
+echo "You should be able to access your BookStack instance at: http://$CURRENT_IP/ or http://$DOMAIN/"