Fix some issues when doing "vagrant provision" + some other errors

This commit is contained in:
meaz 2019-12-30 13:12:05 +01:00
parent 1631b04710
commit e65176c88f
1 changed files with 22 additions and 9 deletions

View File

@ -4,6 +4,7 @@
WEB_NAME="disroot.lan"
WEB_ROOT="/var/www/"
WWW_USER="www-data"
YAML="/var/www/disroot.lan/user/config/system.yaml"
# Provisioning actions
@ -49,9 +50,16 @@ sudo -u "${WWW_USER}" bin/grav install
#sudo -u www-data bin/gpm install disroot
sudo -u "${WWW_USER}" bin/gpm install language-selector
sudo -u "${WWW_USER}" bin/gpm install form
sudo -u "${WWW_USER}" sed -i 's/quark/disroot/g' "${WEB_ROOT}""${WEB_NAME}"/user/config/system.yaml
sudo -u "${WWW_USER}" ex -s -c '13i|redirect_default_route: true' -c x "${WEB_ROOT}""${WEB_NAME}"/user/config/system.yaml
sudo -u "${WWW_USER}" echo "
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
@ -59,13 +67,18 @@ languages:
- fr
- it
- de
- ru" >> "${WEB_ROOT}""${WEB_NAME}"/user/config/system.yaml
sudo -u "${WWW_USER}" sed -i '4d' "${WEB_ROOT}""${WEB_NAME}"/user/config/system.yaml
sudo -u "${WWW_USER}" ex -s -c "4i| alias: '/home'" -c x "${WEB_ROOT}""${WEB_NAME}"/user/config/system.yaml
sudo -u "${WWW_USER}" -i 's/false/true/g' "${WEB_ROOT}""${WEB_NAME}"/user/plugins/language-selector/language-selector.yaml
- ru" >> "${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}"
# 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")
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\'/" "${WEB_ROOT}""${WEB_NAME}"/user/config/system.yaml
# 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