Added loadDumps option, which makes it possible to load a specific ejabberd configuration on the first startup

svn path=/nixos/branches/upstart-0.6/; revision=18461
This commit is contained in:
Sander van der Burg 2009-11-19 15:12:05 +00:00
parent a5cdfcbdb2
commit 9b000b3dcf

View file

@ -41,6 +41,11 @@ in
description = "Virtualhosts that ejabberd should host. Hostnames are surrounded with doublequotes and separated by commas";
};
loadDumps = mkOption {
default = [];
description = "Configuration dump that should be loaded on the first startup";
example = [ ./myejabberd.dump ];
};
};
};
@ -68,6 +73,7 @@ in
if ! test -d ${cfg.spoolDir}
then
initialize=1
cp -av ${pkgs.ejabberd}/var/lib/ejabberd /var/lib
fi
@ -79,6 +85,33 @@ in
fi
ejabberdctl --config-dir ${cfg.confDir} --logs ${cfg.logsDir} --spool ${cfg.spoolDir} start
${if cfg.loadDumps == [] then "" else
''
# Wait until the ejabberd server is available for use
count=0
while ! ejabberdctl --config-dir ${cfg.confDir} --logs ${cfg.logsDir} --spool ${cfg.spoolDir} status
do
if [ $count -eq 30 ]
then
echo "Tried 30 times, giving up..."
exit 1
fi
echo "Ejabberd daemon not yet started. Waiting for 1 second..."
count=$((count++))
sleep 1
done
if [ "$initialize" = "1" ]
then
${concatMapStrings (dump:
''
echo "Importing dump: ${dump}"
ejabberdctl --config-dir ${cfg.confDir} --logs ${cfg.logsDir} --spool ${cfg.spoolDir} load ${dump}
'') cfg.loadDumps}
fi
''}
'';
postStop =