#!/usr/bin/env bash

# Get install path
DEST="${1:?'Where to install?'}"

# Get absolute path of this directory (especially when symlinked)
SRC="$(realpath "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")")"

# Load accompanying bash library
source "$(dirname "$(dirname "$SRC")")/lib/lib.bash"

say "Installing $(basename "$SRC") services"
tl-install-svc \
  NetworkManager ntpd nftables \
  avahi-daemon \
  sshd

say "Installing $(basename "$SRC") files"
tl-install "dracut/early-kms.conf"    0 0 600 "etc/dracut.conf.d/early-kms.conf"
tl-install "dracut/macbook-2010.conf" 0 0 600 "etc/dracut.conf.d/macbook-2010.conf"

tl-install "init/91-tl-net-state.sh" 0 0 644 "etc/runit/core-services/91-tl-net-state.sh"

tl-install "sysctl/20-quiet.conf" 0 0 600 "etc/sysctl.d/20-quiet.conf"

tl-install "avahi-daemon.conf" 0 0 640 "etc/avahi/avahi-daemon.conf"
tl-install "nsswitch.conf"     0 0 644 "/etc/nsswitch.conf"
tl-install "issue"             0 0 644 "/etc/issue"
