forked from green-coding-solutions/green-metrics-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_mac.sh
More file actions
executable file
·43 lines (30 loc) · 1.33 KB
/
Copy pathinstall_mac.sh
File metadata and controls
executable file
·43 lines (30 loc) · 1.33 KB
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
#!/usr/bin/env bash
set -euo pipefail
if [[ $(uname) != "Darwin" ]]; then
echo "Error: This script can only be run on macOS."
exit 1
fi
source lib/install_shared.sh
prepare_config
checkout_submodules
setup_python
build_containers
if [[ $activate_scenario_runner == true ]] ; then
print_message "Installing needed binaries for building ..."
if ! command -v stdbuf &> /dev/null; then
print_message "Trying to install 'coreutils' via homebrew. If this fails (because you do not have brew or use another package manager), please install it manually ..."
brew install coreutils
fi
print_message "Building C libs"
make -C "lib/c"
build_binaries
print_message "Adding powermetrics and killall with path-lock to sudoers file"
powermetrics_path=$(realpath "/usr/bin/powermetrics")
killall_path=$(realpath "/usr/bin/killall")
check_file_permissions "$powermetrics_path"
check_file_permissions "$killall_path"
echo "${USER} ALL=(ALL) NOPASSWD:${powermetrics_path}" | sudo tee /etc/sudoers.d/green_coding_powermetrics
echo "${USER} ALL=(ALL) NOPASSWD:${killall_path} powermetrics" | sudo tee /etc/sudoers.d/green_coding_kill_powermetrics
echo "${USER} ALL=(ALL) NOPASSWD:${killall_path} -9 powermetrics" | sudo tee /etc/sudoers.d/green_coding_kill_powermetrics_sigkill
fi
finalize