-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathinit
More file actions
executable file
·170 lines (146 loc) · 5.56 KB
/
Copy pathinit
File metadata and controls
executable file
·170 lines (146 loc) · 5.56 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
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/bash
# One-time initialization of this repository, to be run after cloning.
cd "$( dirname "${BASH_SOURCE[0]}" )"
mkdir -p log
LOG=log/init.log
echo "Logging stdout and stderr to $LOG"
(
# Install submodules.
git submodule update --init --recursive
# Install required packages
# Platform-specific installs.
echo "Installing linux packages."
mkdir -p local
COMMON_PACKAGES='make inotify-tools bc remmina jq perl unzip python3-tornado'
DEBUG_PACKAGES='vim htop tmux'
if [[ -n "$(which apt-get 2> /dev/null)" ]]
then
# Ubuntu
sudo apt-get update
# Keep python3 and OS libs; add pipx from apt if available.
# Note: keep python3-pil and python3-tornado via apt to avoid pip for libs.
sudo apt-get -y install curl g++ python3 python3-pip python3-pil $COMMON_PACKAGES
sudo apt -y install $DEBUG_PACKAGES
# Install pipx (preferred); fallback via pip if needed.
if ! command -v pipx >/dev/null 2>&1; then
if apt-cache show pipx >/dev/null 2>&1; then
sudo apt-get -y install pipx
else
python3 -m pip install --user -U pipx
fi
fi
# Ensure ~/.local/bin is on PATH for current shell and future shells.
pipx ensurepath || true
elif [[ -n "$(which yum 2> /dev/null)" ]]
then
# CentOS
# For Python:
sudo yum makecache
sudo yum -y install yum-utils curl
sudo yum -y install https://repo.ius.io/ius-release-el7.rpm https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm # new URLs by IUS "https://ius.io/setup"
sudo yum makecache
sudo yum -y install python3
sudo yum -y install $COMMON_PACKAGES || true
sudo yum -y install $DEBUG_PACKAGES || true
# Install pipx via pip (most reliable on older yum-based systems).
if ! command -v pipx >/dev/null 2>&1; then
python3 -m pip install --user -U pipx
fi
pipx ensurepath || true
fi
# Python CLIs via pipx
echo "Installing Python CLI tools via pipx (isolated per-app venvs)."
# Make sure the current shell can see ~/.local/bin after ensurepath.
export PATH="$HOME/.local/bin:$PATH"
# Install/upgrade CLI packages with pipx.
for app in awscli sandpiper-saas; do # Pillow tornado boto3
if pipx list 2>/dev/null | grep -q "package $app "; then
echo "pipx: upgrading $app"
pipx upgrade "$app" || true
else
echo "pipx: installing $app"
pipx install "$app" || true
fi
done
# Configure remmina to disble the tray icon (so, it isn't left running when launched via Makefile).
if [[ -e "$HOME/.remmina/remmina.pref" ]]
then
sed -i 's/^disable_tray_icon=false$/disable_tray_icon=true/' "$HOME/.remmina/remmina.pref"
else
mkdir -p "$HOME/.remmina"
echo [remmina_pref] > "$HOME/.remmina/remmina.pref"
echo 'disable_tray_icon=true' >> "$HOME/.remmina/remmina.pref"
fi
# Protect remmina.pref as this contains an encryption key. (No idea why remmina leaves this open.)
# Passwords stored in remmina can be decrypted by anyone with access to this file.
chmod 400 "$HOME/.remmina/remmina.pref"
# Make sure ~/.local/bin is in path for python installs.
echo "Making sure Python installs are in \$PATH."
if [[ $( which aws > /dev/null 2>&1 )$? != 0 ]]
then
# Need to add ~/.local/bin to $PATH.
echo
if [[ "$SHELL" == "/bin/bash" ]]
then
if [[ -e "$HOME/.bashrc" ]]
then
if ( grep fpga-webserver "$HOME/.bashrc" > /dev/null 2>&1 ) ||
( grep 1st-CLaaS "$HOME/.bashrc" > /dev/null 2>&1 )
then
echo "INFO: Strange, it looks like ~/.bashrc has already been modified, but 'aws' command is not currently in \$PATH. Might need to add ~/.local/bin to your \$PATH manually."
else
echo >> "$HOME/.bashrc"
echo "export PATH=\$PATH:$HOME/.local/bin # Added by 1st-CLaaS repository." >> ~/.bashrc
echo "==================================="
echo "Modified ~/.bashrc to add ~/.local/bin to path, and sourcing ~/.bashrc."
echo "==================================="
source "$HOME/.bashrc"
if ( ! which aws > /dev/null 2>&1 )
then
echo "WARNING: Still cannot find 'aws' command."
fi
fi
else
echo "WARNING: Cannot find ~/.bashrc. You must add ~/.local/bin to your \$PATH manually."
fi
else
echo "NOTE: You must add ~/.local/bin to your \$PATH manually."
fi
echo
fi
# Download Terraform binary.
# TODO: Move this into /local.
if [[ ! -d terraform ]]
then
echo "Downloading Terraform"
mkdir terraform
( cd terraform && \
curl https://releases.hashicorp.com/terraform/1.5.2/terraform_1.5.2_linux_amd64.zip > terraform.zip \
&& unzip terraform.zip \
&& rm terraform.zip \
&& chmod +x terraform )
fi
# Note that framework/Makefile and bin/regress use the existence of terraform/terraform to indicate that this script was run.
# Check Verilator installation.
# Need Verilator 4+ (ish).
# Installation runs long, so here, we just report what should be done.
echo -e "\e[1m\e[33m" # Report in bold yellow.
# if [[ no local install ]] && ( no verilator || verilator is not version 4+ )
if [[ ! -n "$(ls "local/verilator/bin/verilator" 2> /dev/null)" ]] && ( ! which verilator &> /dev/null || ! (( $(verilator --version | sed 's/^Verilator \([[:digit:]]\+\)\..*$/\1/') > 3 )) > /dev/null )
then
echo "Could not find Verilator 4+."
if which verilator &> /dev/null
then
echo "You have: $(verilator --version)"
if which verilator &> /dev/null
then
# Ubuntu
echo "Uninstall first (sudo apt-get remove verilator?), then:"
else
echo "Uninstall first, then:"
fi
fi
echo "Install using ./bin/install_verilator, or visit veripool.org for information about the latest version."
fi
echo -e "\e[0m" # Back to normal font.
) |& tee $LOG