* Support globbing in the source attribute of environment.etc entries.
svn path=/nixos/trunk/; revision=34158
This commit is contained in:
parent
c10b41ad99
commit
91acb81b11
|
@ -90,10 +90,10 @@ in
|
|||
{ source = jailConf;
|
||||
target = "fail2ban/jail.conf";
|
||||
}
|
||||
{ source = "${pkgs.fail2ban}/etc/fail2ban/action.d";
|
||||
{ source = "${pkgs.fail2ban}/etc/fail2ban/action.d/*.conf";
|
||||
target = "fail2ban/action.d";
|
||||
}
|
||||
{ source = "${pkgs.fail2ban}/etc/fail2ban/filter.d";
|
||||
{ source = "${pkgs.fail2ban}/etc/fail2ban/filter.d/*.conf";
|
||||
target = "fail2ban/filter.d";
|
||||
}
|
||||
];
|
||||
|
|
|
@ -1,23 +1,42 @@
|
|||
source $stdenv/setup
|
||||
|
||||
ensureDir $out/etc
|
||||
mkdir -p $out/etc
|
||||
|
||||
set -f
|
||||
sources_=($sources)
|
||||
targets_=($targets)
|
||||
modes_=($modes)
|
||||
set +f
|
||||
|
||||
for ((i = 0; i < ${#targets_[@]}; i++)); do
|
||||
ensureDir $out/etc/$(dirname ${targets_[$i]})
|
||||
if ! test -e $out/etc/${targets_[$i]}; then
|
||||
ln -s ${sources_[$i]} $out/etc/${targets_[$i]};
|
||||
source="${sources_[$i]}"
|
||||
target="${targets_[$i]}"
|
||||
|
||||
if [[ "$source" =~ '*' ]]; then
|
||||
|
||||
# If the source name contains '*', perform globbing.
|
||||
mkdir -p $out/etc/$target
|
||||
for fn in $source; do
|
||||
ln -s "$fn" $out/etc/$target/
|
||||
done
|
||||
|
||||
else
|
||||
echo "Duplicate entry ${targets_[$i]} -> ${sources_[$i]}"
|
||||
if test "$(readlink $out/etc/${targets_[$i]})" != "${sources_[$i]}"; then
|
||||
echo "Mismatched duplicate entry $(readlink $out/etc/${targets_[$i]}) <-> ${sources_[$i]}"
|
||||
exit 1
|
||||
|
||||
mkdir -p $out/etc/$(dirname $target)
|
||||
if ! [ -e $out/etc/$target ]; then
|
||||
ln -s $source $out/etc/$target
|
||||
else
|
||||
echo "Duplicate entry $target -> $source"
|
||||
if test "$(readlink $out/etc/$target)" != "$source"; then
|
||||
echo "Mismatched duplicate entry $(readlink $out/etc/$target) <-> $source"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi;
|
||||
if test "${modes_[$i]}" != symlink; then
|
||||
echo "${modes_[$i]}" > $out/etc/${targets_[$i]}.mode
|
||||
|
||||
if test "${modes_[$i]}" != symlink; then
|
||||
echo "${modes_[$i]}" > $out/etc/$target.mode
|
||||
fi
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in a new issue