2019-03-09 08:55:17 +01:00
#!/usr/bin/env bash
# Custom configuration
2019-10-13 23:18:15 +02:00
WEB_NAME = "disroot.lan"
WEB_ROOT = "/var/www/"
WWW_USER = "www-data"
2019-12-30 13:12:05 +01:00
YAML = "/var/www/disroot.lan/user/config/system.yaml"
2019-03-09 08:55:17 +01:00
# Provisioning actions
2019-12-28 09:12:23 +01:00
# Add sury repository to sources.list for PHP7.4
2019-10-13 23:18:15 +02:00
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y install ca-certificates apt-transport-https
2019-09-05 12:50:21 +02:00
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee -a /etc/apt/sources.list.d/php.list
2019-12-28 09:12:23 +01:00
# Sury Key for PHP7.4
2019-09-05 12:50:21 +02:00
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
2019-03-09 08:55:17 +01:00
sudo apt-get -y update
2019-12-28 09:12:23 +01:00
echo "Installing nginx..."
sudo apt-get install -y nginx-full
echo "Installing composer..."
sudo apt-get install -y composer
echo "Installing php7..."
sudo apt-get install -y php7.4-zip php7.4-cli php7.4-curl php7.4-gd php7.4-mbstring php7.4-xml php7.4-fpm
2019-03-09 08:55:17 +01:00
2019-12-28 09:12:23 +01:00
# Create the Nginx config files and restart webserver
2019-10-13 23:18:15 +02:00
sudo rsync -cr /vagrant/provision/etc/nginx/sites-available /etc/nginx/
sudo ln -s /etc/nginx/sites-available/" ${ WEB_NAME } " .conf /etc/nginx/sites-enabled/" ${ WEB_NAME } " .conf
sudo rm /etc/nginx/sites-enabled/default
sudo service nginx restart
2019-03-09 08:55:17 +01:00
# Install GRAV in webroot
2019-10-13 23:18:15 +02:00
sudo chown -R ${ WWW_USER } :${ WWW_USER } /var/www
2019-12-28 09:12:23 +01:00
sudo wget https://getcomposer.org/download/1.9.1/composer.phar -O /usr/local/bin/composer && sudo chmod 755 /usr/local/bin/composer
2019-10-13 23:18:15 +02:00
echo "Git"
git clone -b master https://github.com/getgrav/grav.git " ${ WEB_ROOT } " " ${ WEB_NAME } "
sudo chown -R ${ WWW_USER } :${ WWW_USER } " ${ WEB_ROOT } "
echo "enter git"
cd " ${ WEB_ROOT } " " ${ WEB_NAME } "
echo "composer"
sudo -u " ${ WWW_USER } " composer install --no-dev -o
sudo chown -R ${ WWW_USER } :${ WWW_USER } " ${ WEB_ROOT } "
2019-03-09 08:55:17 +01:00
sudo chmod 775 -R bin/
2019-10-13 23:18:15 +02:00
sudo -u " ${ WWW_USER } " bin/grav install
2019-03-09 08:55:17 +01:00
#sudo -u www-data bin/gpm install disroot
2020-01-02 19:08:21 +01:00
#sudo -u "${WWW_USER}" bin/gpm install language-selector
2019-10-13 23:18:15 +02:00
sudo -u " ${ WWW_USER } " bin/gpm install form
2019-12-30 13:12:05 +01:00
sudo -u " ${ WWW_USER } " sed -i 's/quark/disroot/g' " ${ YAML } "
# Add Grav config (the second extra false should be set to true, but it creates an error in Grav ("Trying to access array offset on value of type null")
if ! grep -q auto_line_breaks " ${ YAML } " ; then
sudo -u " ${ WWW_USER } " sed -i "s/extra:\ false/\extra:\ false\n\ auto_line_breaks:\ true\n\ auto_url_links:\ true\n\ escape_markup:\ false\n\ special_chars:\n\ \'\>\':\ \'gt\'\n\ \'\<\':\ \'lt\'/" " ${ YAML } "
fi
if ! grep -q languages " ${ YAML } " ; then
sudo -u " ${ WWW_USER } " echo "
2019-03-09 08:55:17 +01:00
languages:
supported:
- en
- es
- fr
2019-11-05 14:35:57 +01:00
- it
2020-01-05 11:05:02 +01:00
- pt
2019-11-05 14:35:57 +01:00
- de
2020-01-03 10:22:47 +01:00
- ru
include_default_lang: true
pages_fallback_only: false
translations: true
translations_fallback: true
session_store_active: true
http_accept_language: true
override_locale: false" >> " ${ YAML } "
2019-12-30 13:12:05 +01:00
fi
sudo -u " ${ WWW_USER } " ex -s -c "4i| alias: '/home'" -c x " ${ YAML } "
sudo -u " ${ WWW_USER } " sed -i '4d' " ${ YAML } "
if ! grep -q redirect_default_route " ${ YAML } " ; then
sudo -u " ${ WWW_USER } " ex -s -c '16i| redirect_default_route: true' -c x " ${ YAML } "
fi
sudo -u " ${ WWW_USER } " -i 's/false/true/g' " ${ YAML } "
2019-03-09 08:55:17 +01:00
2019-12-28 12:43:50 +01:00
2019-03-09 08:55:17 +01:00
# Add website domain to local /etc/hosts file
2019-10-13 23:18:15 +02:00
sudo sed -i " s/127.0.0.1\tlocalhost/127.0.0.1\tlocalhost $WEB_NAME / " /etc/hosts
2019-03-09 08:55:17 +01:00
#Add website pages in GRAV
2019-10-13 23:18:15 +02:00
sudo mount -o bind /var/www/pages " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/pages
chown " ${ WWW_USER } " :" ${ WWW_USER } " -R " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/pages
2020-01-02 19:08:21 +01:00
#Add Disroot theme in GRAV
2020-01-02 19:47:48 +01:00
sudo -u " ${ WWW_USER } " ln -s " ${ WEB_ROOT } " /grav-theme-disroot " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/themes/disroot
2020-01-02 19:08:21 +01:00
#Add language-selector in GRAV
2020-01-02 19:47:48 +01:00
sudo -u " ${ WWW_USER } " ln -s " ${ WEB_ROOT } " /grav-plugin-language-selector " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/plugins/language-selector
2020-01-02 19:08:21 +01:00
2019-03-09 08:55:17 +01:00
exit 0