-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathinstall_linux.sh
More file actions
executable file
·157 lines (136 loc) · 6.62 KB
/
install_linux.sh
File metadata and controls
executable file
·157 lines (136 loc) · 6.62 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/env bash
set -euo pipefail
if [[ $(uname) != "Linux" ]]; then
echo "Error: This script can only be run on Linux."
exit 1
fi
source lib/install_shared.sh # will parse opts immediately
prepare_config
checkout_submodules
setup_python
build_containers
if [[ $activate_scenario_runner == true ]] ; then
print_message "Installing needed binaries for building ..."
if cat /etc/os-release | grep -q "Fedora"; then
sudo dnf -y install glib2 glib2-devel tinyproxy stress-ng lshw libcurl-devel
elif cat /etc/os-release | grep -q "openSUSE"; then
sudo zypper -n in glib2-tools glib2-devel tinyproxy stress-ng lshw libcurl-devel
else
sudo apt-get update
sudo apt-get install -y libglib2.0-0 libglib2.0-dev tinyproxy stress-ng lshw libcurl4-openssl-dev
fi
if cat /etc/os-release | grep -q "Fedora"; then
if ! sudo dnf -y install lm_sensors lm_sensors-devel; then
print_message "Failed to install lm_sensors lm_sensors-devel;" >&2
print_message "You can add -S to the install script to skip installing lm_sensors. However cluster mode and temperature reporters will not work then." >&2
exit 1
fi
elif cat /etc/os-release | grep -q "openSUSE"; then
if ! sudo zypper -n in sensors libsensors4-devel; then
print_message "Failed to install sensors libsensors4-devel; continuing without Sensors."
fi
else
if ! sudo apt-get install -y lm-sensors libsensors-dev; then
print_message "Failed to install lm-sensors libsensors-dev;" >&2
print_message "You can add -S to the install script to skip installing lm_sensors. However cluster mode and temperature reporters will not work then." >&2
exit 1
fi
fi
sudo systemctl stop tinyproxy
sudo systemctl disable tinyproxy
if [[ $install_nvidia_toolkit_headers == true ]] ; then
print_message "Installing nvidia toolkit headers"
if cat /etc/os-release | grep -q "Fedora"; then
curl -O https://developer.download.nvidia.com/compute/cuda/repos/fedora$(rpm -E %fedora)/x86_64/cuda-fedora$(rpm -E %fedora).repo
sudo mv cuda-fedora$(rpm -E %fedora).repo /etc/yum.repos.d/
sudo dnf makecache
if ! sudo dnf -y install libnvidia-ml cuda-nvml-devel-12-9; then
print_message "Failed to install nvidia toolkit headers; Please remove --nvidia-gpu flag and install manually" >&2
exit 1
else
sudo ln -s /usr/lib64/libnvidia-ml.so.1 /usr/lib64/libnvidia-ml.so
fi
else
if ! sudo apt-get install -y libnvidia-ml-dev; then
print_message "Failed to install nvidia toolkit headers; Please remove --nvidia-gpu flag and install manually" >&2
exit 1
fi
fi
fi
print_message "Building C libs"
make -C "lib/c"
build_binaries
if [[ $build_sgx == true ]] ; then
print_message "Building sgx binaries"
make -C lib/sgx-software-enable
mv lib/sgx-software-enable/sgx_enable tools/
rm lib/sgx-software-enable/sgx_enable.o
fi
print_message "Enabling cache cleanup without sudo via sudoers entry"
echo "${USER} ALL=(ALL) NOPASSWD:/usr/sbin/sysctl -w vm.drop_caches=3" | sudo tee /etc/sudoers.d/green-coding-drop-caches
sudo chmod 500 /etc/sudoers.d/green-coding-drop-caches
print_message "Setting the cluster cleanup.sh file to be owned by root"
sudo cp -f $PWD/tools/cluster/cleanup_original.py $PWD/tools/cluster/cleanup.py
sudo chown root:root $PWD/tools/cluster/cleanup.py
sudo chmod 755 $PWD/tools/cluster/cleanup.py
sudo chmod +x $PWD/tools/cluster/cleanup.py
if [[ $install_msr_tools == true ]] ; then
print_message "Installing msr-tools"
print_message "Important: If this step fails it means msr-tools is not available on you system"
print_message ""
if cat /etc/os-release | grep -q "Fedora"; then
if ! sudo dnf -y install msr-tools; then
print_message "Failed to install msr-tools; If you do not plan to use RAPL you can skip the installation by appending '-r'" >&2
exit 1
fi
elif cat /etc/os-release | grep -q "openSUSE"; then
if ! sudo zypper -n in msr-tools; then
print_message "Failed to install msr-tools; continuing without RAPL."
fi
else
if ! sudo apt-get install -y msr-tools; then
print_message "Failed to install msr-tools; If you do not plan to use RAPL you can skip the installation by appending '-r'" >&2
exit 1
fi
fi
fi
if [[ $install_ipmi == true ]] ; then
print_message "Installing IPMI tools"
print_message "Important: If this step fails it means ipmitool is not available on you system"
{
if cat /etc/os-release | grep -q "Fedora"; then
sudo dnf -y install freeipmi ipmitool
elif cat /etc/os-release | grep -q "openSUSE"; then
sudo zypper -n in freeipmi ipmitool
else
sudo apt-get install -y freeipmi-tools ipmitool
fi
print_message "Adding IPMI to sudoers file"
ipmi_dcmi_path=$(readlink -f "/usr/sbin/ipmi-dcmi")
check_file_permissions $ipmi_dcmi_path
echo "${USER} ALL=(ALL) NOPASSWD:${ipmi_dcmi_path} --get-system-power-statistics" | sudo tee /etc/sudoers.d/green-coding-ipmi-get-machine-energy-stat
sudo chmod 500 /etc/sudoers.d/green-coding-ipmi-get-machine-energy-stat
# remove old file name
sudo rm -f /etc/sudoers.d/ipmi_get_machine_energy_stat
} || {
print_message "Failed to install and configure IPMI tools. Please try to install manually ..." >&2
print_message "If you do not plan to use IPMI you can skip the installation by appending '-i'" >&2
exit 1
}
fi
fi
if ! findmnt -n -o FSTYPE /tmp | grep tmpfs && [[ $ask_tmpfs == true ]]; then
read -p "We strongly recommend mounting /tmp on a tmpfs. Do you want to do that? (y/N)" tmpfs
if [[ "$tmpfs" == "Y" || "$tmpfs" == "y" ]] ; then
if cat /etc/os-release | grep -q "Fedora"; then
sudo systemctl unmask --now tmp.mount
elif cat /etc/os-release | grep -q "openSUSE"; then
print_message "Please mount /tmp manually as tmpfs. GMT cannot handle this in the install script" >&2
exit 1
else
sudo systemctl enable /usr/share/systemd/tmp.mount
fi
reboot_echo_flag=true
fi
fi
finalize