#!/bin/env fish
begin
    set -l dir (status dirname)
    source "$dir/../../lib/software.fish"
    inherit "$dir/../../../Common/Software/aliae/main.fish"

    function installSW
        yayinst nginx
    end

    function configureSW
        set -l file "/etc/nginx/nginx.conf"
        set -l config "include /etc/nginx/conf.d/*.conf;"

        if not grep --fixed-strings "$config" "$file" >/dev/null
            sudo sed -i "$file" -e "/^http {/,/^}/{ /^}/{" -e "i\\" -e "" -e "i \    $config" -e "} }"
        end

        sudo systemctl enable --now nginx
    end

    runInstaller $argv
end