This repository has been archived by the owner on Oct 27, 2022. It is now read-only.
forked from yeshuj/1st-CLaaS
-
Notifications
You must be signed in to change notification settings - Fork 2
/
init
executable file
·148 lines (126 loc) · 5.16 KB
/
init
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
#!/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' # python-tornado removed -- redundant w/ pip install of tornado
DEBUG_PACKAGES='vim htop tmux'
if [[ -n "$(which apt-get 2> /dev/null)" ]]
then
# Ubuntu
sudo apt-get update
sudo apt-get -y install curl g++ python3 python3-pip python3-pil $COMMON_PACKAGES
sudo apt -y install $DEBUG_PACKAGES
#sudo python3 -m pip install Pillow
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 # this will install python3.6 version
# To look like Ubuntu, we need python3 and pip3.
sudo yum -y install $COMMON_PACKAGES # python-tornado python-imaging redundant w/ pip install?
sudo yum -y install $DEBUG_PACKAGES
## bash lives at /usr/bin/bash in CentOS, but in /bin/bash for Ubuntu. Create /bin/bash.
#sudo ln -s /bin/bash /usr/bin/bash # TODO: So far, untested. Test and delete this comment.
fi
# Install python libraries for user only so as not to affect system installs.
echo "Installing Python packages for user $USER."
sudo python3 -m pip install --upgrade pip
USER_PYTHON_PACKAGES='Pillow tornado awscli boto3 sandpiper-saas'
python3 -m pip install --user --upgrade $USER_PYTHON_PACKAGES
sudo python3 -m pip install --user --upgrade $USER_PYTHON_PACKAGES
# 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/0.12.4/terraform_0.12.4_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