mklinks() {
  local f="$1" dst="$2"
  shift 2
  for i in "$@"; do
    mkdir -p "$dst/$i" &&
    ln -sf "../../wpa_supplicant/$f" "$dst/$i/${f%.sh}" || return
  done
}

install -m755 -D -t "$INSTAL_ROOT"/etc/wpa_supplicant/ \
	action_wpa.sh \
	functions.sh \
	wpasupplicant.sh \
	hostapd.sh &&

install -m644 -D -t "$INSTALL_ROOT"/usr/share/man/man8/ \
	wpa_action.8 &&

install -m755 -D -t "$INSTALL_ROOT"/usr/sbin/ \
	wpa_action &&

mklinks hostapd.sh \
	"$INSTALL_ROOT/etc/network" \
	if-pre-up.d if-post-down.d &&

mklinks wpasupplicant.sh \
	"$INSTALL_ROOT/etc/network" \
	if-pre-up.d if-up.d if-down.d if-post-down.d &&

mklinks action_wpa.sh \
	"$INSTALL_ROOT"/etc/ifplugd \
	action.d
