diff --git a/vagrant/bootstrap.sh b/vagrant/bootstrap.sh index ecd88eca..ba9a4a7b 100755 --- a/vagrant/bootstrap.sh +++ b/vagrant/bootstrap.sh @@ -4,7 +4,8 @@ WEB_NAME="disroot.lan" WEB_ROOT="/var/www/" WWW_USER="www-data" -YAML="/var/www/disroot.lan/user/config/system.yaml" +YAML_SYSTEM="/var/www/disroot.lan/user/config/system.yaml" +YAML_SITE="/var/www/disroot.lan/user/config/site.yaml" GRAV_VERSION="1.7.24" # Provisioning actions @@ -96,42 +97,12 @@ yes | sudo -u "${WWW_USER}" php8.0 bin/gpm install tagcloud # https://github.com/Perlkonig/grav-plugin-tagcloud yes | sudo -u "${WWW_USER}" php8.0 bin/gpm install form -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 " -languages: - supported: - - en - - es - - fr - - it - - pt - - de - - 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}" -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}" # sed is missing, but creates an error anyway as "markdown: extra: true" gives an error +# 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}" # Add website domain to local /etc/hosts file sudo sed -i "s/127.0.0.1\tlocalhost/127.0.0.1\tlocalhost $WEB_NAME/" /etc/hosts @@ -141,26 +112,31 @@ 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 # Add Disroot theme in GRAV +echo "Installing Disroot theme in GRAV..." 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 # Add Disroot Blog theme in GRAV +echo "Installing Disroot Blog theme in GRAV..." 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 # Add language-selector in GRAV +echo "Installing language-selector in GRAV..." 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 # Add Privacy pages in GRAV +echo "Installing Privacy pages in GRAV..." 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 +echo "Installing Changelog pages in GRAV..." if [ ! -d "${WEB_ROOT}""${WEB_NAME}"/user/pages/changelog/_main ]; then sudo -u "${WWW_USER}" ln -s "${WEB_ROOT}"changelog "${WEB_ROOT}""${WEB_NAME}"/user/pages/changelog/_main fi @@ -170,4 +146,13 @@ if [ -f "${WEB_ROOT}"changelog/CHANGELOG ]; then sudo -u "${WWW_USER}" cp "${WEB_ROOT}"changelog/CHANGELOG "${WEB_ROOT}"changelog/fullbar.en.md fi +# 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 + exit 0