1

Back in the good old days I was able to patch /etc/rc.d/init.d/httpd with some additional lines of code that executed on every apache start:

start() {
  echo "Setting variables..."
  source /path/to/my/script.sh
  echo -n $"Starting $prog: "
  check13 || exit 1
  LANG=$HTTPD_LANG daemon $httpd $OPTIONS
  RETVAL=$?
  echo
  [ $RETVAL = 0 ] && touch ${lockfile}
  return $RETVAL
}

source /path/to/my/script.sh is responsible to setup some environment variables needed for a PHP extension to work.

Anyway, after systemd, systemctl prevailed I'm not able to configure my system to automatically load script.sh variables before apache starts. When executing manually:

/usr/sbin/httpd -k stop
source /path/to/my/script.sh
/usr/sbin/httpd -k start

everything works fine.

What is the proper way to achieve this on Fedora 4.0 and similar systems using systemd service manager?

  • 1
    Add them to the unit's Environment= or EnvironmentFile= – Michael Hampton Jul 7 '15 at 19:26
0

You must use the ExecStartPre option in the unit configuration file. Plz, read http://www.freedesktop.org/software/systemd/man/systemd.service.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.