Skip to content

Instantly share code, notes, and snippets.

@remram44
Created May 19, 2023 17:07
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 remram44/b4e144e8366f15a2007c8f411139edb5 to your computer and use it in GitHub Desktop.
Save remram44/b4e144e8366f15a2007c8f411139edb5 to your computer and use it in GitHub Desktop.
ReproZip wrapper script for mysql+apache2
#!/bin/sh
if [ "$(id -u)" != 0 ]; then echo "This script needs to run as root so that it can execute MySQL" >&2; exit 1; fi
# Start MySQL (in the background)
runuser -u mysql -- /usr/sbin/mysqld --pid-file=/run/mysqld/mysqld.pid &
sleep 5
# Need to set this to avoid apachectl talking to systemd
export APACHE_STARTED_BY_SYSTEMD=true
# Start Apache (in the background)
apachectl start
# Don't exit the whole script on Ctrl+C, do the graceful shutdown
trap ' ' INT
# Wait until we are done interacting with the site (user presses Ctrl+C)
sleep infinity
trap - INT
# Graceful shutdown
apachectl stop
/usr/bin/mysqladmin shutdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment