nixpkgs/test/test-upstart-job.sh
Eelco Dolstra c341a03404 * A little script to test changes to individual Upstart jobs,
i.e., only the specified jobs are rebuilt and restarted.
  Example:

  $ test/test-upstart-job.sh udev

  will rebuild and restart just the udev service.  This is useful
  e.g. when making changes to the udev package, which would
  normally entail rebuilding lots of other services as well 
  (e.g. the X service might depend on KDE, which depends on HAL,
  which depends on udev...).

  It's implemented by making a copy of the current /etc/event.d 
  in /tmp/event.d, then replacing only those jobs indicated on the
  command line, symlinking /etc/event.d to /tmp/event.d, and 
  restarting init.

svn path=/nixos/trunk/; revision=12217
2008-06-29 22:18:39 +00:00

26 lines
485 B
Bash
Executable file

#! /bin/sh -e
tmpDir=/tmp/event.d
rm -rf $tmpDir
cp -prd $(readlink -f /etc/event.d) /tmp/event.d
for i in $*; do
echo "building job $i..."
nix-build /etc/nixos/nixos -A "upstartJobs.$i" -o $tmpDir/.result
ln -sfn $(readlink -f $tmpDir/.result)/etc/event.d/* /tmp/event.d/
done
ln -sfn /tmp/event.d /etc/event.d
echo "restarting init..."
kill -TERM 1
for i in $*; do
echo "restarting job $i..."
initctl stop "$i"
sleep 1
initctl start "$i"
done