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"
2021-12-30 11:43:53 +01:00
YAML_SYSTEM = "/var/www/disroot.lan/user/config/system.yaml"
YAML_SITE = "/var/www/disroot.lan/user/config/site.yaml"
2021-12-22 07:29:56 +01:00
GRAV_VERSION = "1.7.24"
2019-03-09 08:55:17 +01:00
# Provisioning actions
2020-02-16 12:18:06 +01:00
apt install dialog
2019-03-09 08:55:17 +01:00
2020-02-18 09:56:48 +01:00
# Avoid Postfix installation interactive screens by preconfiguring this information
sudo debconf-set-selections <<< "postfix postfix/main_mailer_type select No configuration"
sudo debconf-set-selections <<< " postfix postfix/mailname string ${ WEB_NAME } "
2021-12-22 07:29:56 +01:00
# Add sury repository to sources.list for php8.0
2021-02-09 22:43:10 +01:00
echo "set grub-pc/install_devices /dev/sda" | debconf-communicate # Fix grub error
2019-10-13 23:18:15 +02:00
sudo apt-get -y update
2021-02-14 11:30:15 +01:00
sudo apt-get -y dist-upgrade
2019-10-13 23:18:15 +02:00
sudo apt-get -y install ca-certificates apt-transport-https
2021-02-06 00:20:12 +01:00
if ! grep -q "^deb .*sury" /etc/apt/sources.list /etc/apt/sources.list.d/*; then
2021-02-14 11:30:15 +01:00
sudo sh -c 'echo "deb https://packages.sury.org/php/ buster main" > /etc/apt/sources.list.d/php.list'
2021-02-06 00:20:12 +01:00
fi
2019-12-28 09:12:23 +01:00
2021-12-22 07:29:56 +01:00
# Sury Key for php8.0
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
2021-12-22 07:29:56 +01:00
echo "Installing php8.0..."
sudo apt-get install -y php8.0 php8.0-zip php8.0-cli php8.0-curl php8.0-gd php8.0-mbstring php8.0-xml php8.0-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
2021-02-06 00:20:12 +01:00
echo "Installing Nginx config files..."
2019-10-13 23:18:15 +02:00
sudo rsync -cr /vagrant/provision/etc/nginx/sites-available /etc/nginx/
2021-02-14 11:30:15 +01:00
if [ ! -f /etc/nginx/sites-enabled/" ${ WEB_NAME } " .conf ] ; then
sudo ln -s /etc/nginx/sites-available/" ${ WEB_NAME } " .conf /etc/nginx/sites-enabled/" ${ WEB_NAME } " .conf
fi
if [ -f /etc/nginx/sites-enabled/default ] ; then
sudo rm /etc/nginx/sites-enabled/default
fi
2019-10-13 23:18:15 +02:00
sudo service nginx restart
2019-03-09 08:55:17 +01:00
# Install GRAV in webroot
2021-02-06 00:20:12 +01:00
echo "Installing GRAV..."
2019-10-13 23:18:15 +02:00
sudo chown -R ${ WWW_USER } :${ WWW_USER } " ${ WEB_ROOT } "
2021-02-06 00:20:12 +01:00
if [ ! -f " ${ WEB_ROOT } " " ${ WEB_NAME } " ] ; then
sudo -u " ${ WWW_USER } " mkdir " ${ WEB_ROOT } " " ${ WEB_NAME } "
fi
## Specific version
FILE = " ${ WEB_ROOT } " grav-v" ${ GRAV_VERSION } " .zip
if [ ! -f " $FILE " ] ; then
echo "Downloading grav-v" ${ GRAV_VERSION } ".zip"
sudo -u " ${ WWW_USER } " wget https://github.com/getgrav/grav/releases/download/" ${ GRAV_VERSION } " /grav-v" ${ GRAV_VERSION } " .zip -P " ${ WEB_ROOT } "
sudo -u " ${ WWW_USER } " unzip -o " ${ WEB_ROOT } " grav-v" ${ GRAV_VERSION } " .zip -d " ${ WEB_ROOT } "
sudo -u " ${ WWW_USER } " cp -r " ${ WEB_ROOT } " grav/* " ${ WEB_ROOT } " " ${ WEB_NAME } "
else
echo "grav-v" ${ GRAV_VERSION } ".zip already exists"
2021-11-04 09:47:26 +01:00
sudo -u " ${ WWW_USER } " unzip -o " ${ WEB_ROOT } " grav-v" ${ GRAV_VERSION } " .zip -d " ${ WEB_ROOT } "
sudo -u " ${ WWW_USER } " cp -r " ${ WEB_ROOT } " grav/* " ${ WEB_ROOT } " " ${ WEB_NAME } "
2021-02-06 00:20:12 +01:00
fi
# Directly from Master
# if [ ! -f /usr/local/bin/composer ]; then
# sudo wget https://getcomposer.org/download/1.9.1/composer.phar -O /usr/local/bin/composer && sudo chmod 755 /usr/local/bin/composer
# fi
# 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}"
# sudo chmod 775 -R bin/
# sudo -u "${WWW_USER}" bin/grav install
2020-10-25 00:15:21 +02:00
#sudo -u "${WWW_USER}" bin/gpm install disroot
2020-12-06 00:17:27 +01:00
#sudo -u "${WWW_USER}" bin/gpm install language-selector -> Disabled as we're using grav-plugin-language-selector Disroot repo
2020-10-25 00:15:21 +02:00
2021-02-06 00:20:12 +01:00
echo "Enter git"
cd " ${ WEB_ROOT } " " ${ WEB_NAME } "
2021-12-22 07:29:56 +01:00
yes | sudo -u " ${ WWW_USER } " php8.0 bin/gpm install themer
2020-10-25 00:15:21 +02:00
# https://github.com/sommerregen/grav-plugin-themer
2021-12-22 07:29:56 +01:00
yes | sudo -u " ${ WWW_USER } " php8.0 bin/gpm install tagcloud
2020-12-06 00:17:27 +01:00
# https://github.com/Perlkonig/grav-plugin-tagcloud
2021-12-22 07:29:56 +01:00
yes | sudo -u " ${ WWW_USER } " php8.0 bin/gpm install form
2022-06-01 17:01:22 +02:00
# https://github.com/getgrav/grav-plugin-form
2019-12-30 13:12:05 +01:00
# 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")
2021-12-30 11:43:53 +01:00
# Create the Nginx config files and restart webserver
echo "Installing Grav config file config file..."
sudo rsync -cr " /vagrant/provision/ ${ YAML_SYSTEM } " " ${ YAML_SYSTEM } "
sudo rsync -cr " /vagrant/provision/ ${ YAML_SITE } " " ${ YAML_SITE } "
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
2021-02-06 00:20:12 +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
2021-02-06 00:20:12 +01:00
# Add Disroot theme in GRAV
2021-12-30 11:43:53 +01:00
echo "Installing Disroot theme in GRAV..."
2021-02-14 11:30:15 +01:00
if [ ! -d " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/themes/disroot/grav-theme-disroot ] ; then
sudo -u " ${ WWW_USER } " ln -s " ${ WEB_ROOT } " grav-theme-disroot " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/themes/disroot
fi
2020-01-02 19:08:21 +01:00
2021-02-06 00:20:12 +01:00
# Add Disroot Blog theme in GRAV
2021-12-30 11:43:53 +01:00
echo "Installing Disroot Blog theme in GRAV..."
2021-02-14 11:30:15 +01:00
if [ ! -d " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/themes/disrootblog/grav-theme-disrootblog ] ; then
sudo -u " ${ WWW_USER } " ln -s " ${ WEB_ROOT } " grav-theme-disrootblog " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/themes/disrootblog
fi
2020-10-24 23:16:17 +02:00
2021-02-06 00:20:12 +01:00
# Add language-selector in GRAV
2021-12-30 11:43:53 +01:00
echo "Installing language-selector in GRAV..."
2021-02-14 11:30:15 +01:00
if [ ! -d " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/plugins/language-selector/grav-plugin-language-selector ] ; then
sudo -u " ${ WWW_USER } " ln -s " ${ WEB_ROOT } " grav-plugin-language-selector " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/plugins/language-selector
fi
2020-01-02 19:08:21 +01:00
2021-03-20 11:46:26 +01:00
# Add Privacy pages in GRAV
2021-12-30 11:43:53 +01:00
echo "Installing Privacy pages in GRAV..."
2021-03-20 11:46:26 +01:00
if [ ! -d " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/pages/privacy_policy/_pp ] ; then
sudo -u " ${ WWW_USER } " ln -s " ${ WEB_ROOT } " privacy_policy " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/pages/privacy_policy/_pp
fi
# Add Changelog pages in GRAV
2021-12-30 11:43:53 +01:00
echo "Installing Changelog pages in GRAV..."
2021-03-29 08:01:20 +02:00
if [ ! -d " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/pages/changelog/_main ] ; then
2021-03-22 12:27:09 +01:00
sudo -u " ${ WWW_USER } " ln -s " ${ WEB_ROOT } " changelog " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/pages/changelog/_main
2021-03-20 11:46:26 +01:00
fi
2021-03-29 08:01:20 +02:00
2021-04-01 22:05:48 +02:00
# Changelog pages name in GRAV
if [ -f " ${ WEB_ROOT } " changelog/CHANGELOG ] ; then
sudo -u " ${ WWW_USER } " cp " ${ WEB_ROOT } " changelog/CHANGELOG " ${ WEB_ROOT } " changelog/fullbar.en.md
fi
2021-12-30 11:43:53 +01:00
# Remove the default grav files and folder from new installation
echo "Remove the default grav files and folder from new installation..."
if [ -d " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/pages/02.typography ] ; then
rm -r " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/pages/02.typography
fi
if [ -f " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/pages/01.home/default.md ] ; then
rm " ${ WEB_ROOT } " " ${ WEB_NAME } " /user/pages/01.home/default.md
fi
2019-03-09 08:55:17 +01:00
exit 0