~aleteoryx/muditaos

muditaos/tools/macflash_setup.sh -rw-r--r-- 1.2 KiB
a405cad6Aleteoryx trim readme 6 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

BREW_PKGS="
    coreutils
"

function test_if_run_as_root() {
    MY_NAME=$(whoami)
    if [[ "${MY_NAME}" == "root" ]]; then
        cat <<-MSGEND
			Please do not run this script as a root.
			Script will ask for your password for tasks it needs
			to run as a root (sudo ...)
			MSGEND
        exit 1
    fi
}

function install_homebrew() {
    if command -v brew &> /dev/null; then
        echo "Homebrew already installed"
        return
    fi

    echo "This action is going to change your system by installing Homebrew package manager and later other packages"
    echo "Press CTRL+C if you do not want changes to your system, or press enter to continue..."
    read user_consent

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
}

function install_brew_packages() {
    echo "Installing necessary packages..."

    BREW_PKGS=$(echo "${BREW_PKGS}" | tr "\n" " "|tr -s " ")
    brew update

    for pkg in $BREW_PKGS
    do
        brew install $pkg
    done
}

test_if_run_as_root
install_homebrew
install_brew_packages