mietek/halcyon

setup.sh should check for sudo on systems where it is not installed by default.

Closed this issue · 2 comments

For instance, on Arch Linux, you could do something like this, instead of requiring that the script be run as root.

    'linux-arch'*)
        pacman_command="pacman --sync --needed --noconfirm base-devel git pigz zlib"
        # NOTE: There is no sudo on Arch Linux.
        if [ "$(which sudo)" == "/usr/bin/sudo"] ; then
             sudo ${pacman_command} || return 1
        elif [ "${uid}" -eq 0 ]; then
            ${pacman_command} || return 1
        else
            echo '   *** WARNING: Cannot install OS packages' >&2
            echo '   *** WARNING: Ensure the following OS packages are installed:' >&2
            echo '       $ pacman --sync --needed --noconfirm base-devel git pigz zlib' >&2
        fi
        ;;

(Apparently your script uses tabs, not spaces)

You mentioned that some systems don't have which. What about this:

for i in $(echo $PATH | sed 's/:/\n/g'); do
    \ls $i
done >& /dev/null | \grep -x sudo

Albeit, some systems might not have sed and grep

Thanks. This is already tracked as #63, and will also be resolved soon.