aboutsummaryrefslogtreecommitdiff
path: root/scripts/provision
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2023-09-01 14:37:27 -0300
committerSilvio Rhatto <rhatto@riseup.net>2023-09-01 14:37:27 -0300
commit4c7568be6b5b4ee551ff8d5a591df6004bf0ad58 (patch)
tree7dc44bf6c1c9ef36f8ba7c2623b5c9646a692406 /scripts/provision
parentf8b0494a27f37233546fc558d6fe6bebdd0654a3 (diff)
downloadcopyfarai-4c7568be6b5b4ee551ff8d5a591df6004bf0ad58.tar.gz
copyfarai-4c7568be6b5b4ee551ff8d5a591df6004bf0ad58.tar.bz2
Fix: provision: check for sudo
Diffstat (limited to 'scripts/provision')
-rwxr-xr-xscripts/provision15
1 files changed, 10 insertions, 5 deletions
diff --git a/scripts/provision b/scripts/provision
index 2bd7dbd..c6916de 100755
--- a/scripts/provision
+++ b/scripts/provision
@@ -12,17 +12,22 @@ DEPENDENCIES="mkdocs apache2 python3-pip pandoc pandoc-citeproc"
# PyPI dependencies
DEPENDENCIES_PIP="mkdocs-bibtex mkdocs-material mkdocs-awesome-pages-plugin mkdocs-static-i18n"
+# Check for sudo
+if [ "`whoami`" != "root" ]; then
+ SUDO="sudo"
+fi
+
# Ensure an up-to-date system
-sudo apt-get update && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y && sudo apt-get clean
+$SUDO apt-get update && $SUDO apt-get dist-upgrade -y && $SUDO apt-get autoremove -y && $SUDO apt-get clean
# Install dependencies
-sudo apt install -y $DEPENDENCIES
+$SUDO apt install -y $DEPENDENCIES
# Install python dependencies
pip3 install $DEPENDENCIES_PIP
# Configure virtual host for the local service
-cat <<-EOF | sudo tee /etc/apache2/sites-available/local.conf > /dev/null
+cat <<-EOF | $SUDO tee /etc/apache2/sites-available/local.conf > /dev/null
<VirtualHost *:80>
ServerName estudo.local
DocumentRoot "/srv/shared/site"
@@ -36,8 +41,8 @@ cat <<-EOF | sudo tee /etc/apache2/sites-available/local.conf > /dev/null
EOF
# Enable virtual host
-sudo a2ensite local
-sudo systemctl reload apache2
+$SUDO a2ensite local
+$SUDO systemctl reload apache2
# Configure PATH
mkdir -p ~/.custom