Skip to content

Instantly share code, notes, and snippets.

@trendels
Created December 3, 2022 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trendels/b72b8ebd87fabaddd27fa6ad5b859541 to your computer and use it in GitHub Desktop.
Save trendels/b72b8ebd87fabaddd27fa6ad5b859541 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eu -o pipefail
echo "###########################################################################"
echo "# Uninstalling nginx and removing the log directory to have a clean state."
echo "###########################################################################"
echo -n "Press Enter to continue, or Ctrl-C to exit. "
read answer
systemctl stop nginx || true
dnf remove -y nginx
rm -rf /var/log/nginx
echo "###########################################################################"
echo "# Installing nginx and starting the nginx service."
echo "###########################################################################"
echo -n "Press Enter to continue, or Ctrl-C to exit. "
read answer
dnf install -y nginx
systemctl start nginx
echo "###########################################################################"
echo "# Making an HTTP request to localhost."
echo "###########################################################################"
curl --silent http://localhost/ > /dev/null
echo "###########################################################################"
echo "# Listing the log files in /var/log/nginx"
echo "###########################################################################"
echo -n "Press Enter to continue, or Ctrl-C to exit. "
read answer
ls -lha /var/log/nginx/
echo "###########################################################################"
echo "# Running logrotate"
echo "###########################################################################"
logrotate -f /etc/logrotate.conf 2>/dev/null || true
echo "###########################################################################"
echo "# Making another HTTP request to localhost."
echo "###########################################################################"
curl --silent http://localhost/ > /dev/null
echo "###########################################################################"
echo "# Listing the log files in /var/log/nginx"
echo "###########################################################################"
echo -n "Press Enter to continue, or Ctrl-C to exit. "
read answer
ls -lha /var/log/nginx/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment