-
Notifications
You must be signed in to change notification settings - Fork 4
/
install_lichen.sh
executable file
·80 lines (61 loc) · 3.26 KB
/
install_lichen.sh
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
#!/usr/bin/env bash
# this script must be run by root or sudo
if [[ "$UID" -ne "0" ]] ; then
echo "ERROR: This script must be run by root or sudo"
exit 1
fi
echo -e "Installing lichen... "
lichen_repository_dir=/usr/local/submitty/GIT_CHECKOUT/Lichen
lichen_installation_dir=/usr/local/submitty/Lichen
lichen_vendor_dir=/usr/local/submitty/Lichen/vendor
rm -rf "$lichen_installation_dir"
mkdir "$lichen_installation_dir"
cp -r "$lichen_repository_dir"/* "$lichen_installation_dir"
####################################################################################################
# install C++ dependencies
apt-get update
apt-get install -y clang-14 libboost-all-dev
####################################################################################################
# Install Python Dependencies locally (for concatenation)
pip install -r "${lichen_repository_dir}/requirements.txt"
# These permissions changes are copied from Submitty/.setup/INSTALL_SUBMITTY_HELPER.sh
# Setting the permissions are necessary as pip uses the umask of the user/system, which
# affects the other permissions (which ideally should be o+rx, but Submitty sets it to o-rwx).
# This gets run here in case we make any python package changes.
find /usr/local/lib/python*/dist-packages -type d -exec chmod 755 {} +
find /usr/local/lib/python*/dist-packages -type f -exec chmod 755 {} +
find /usr/local/lib/python*/dist-packages -type f -name '*.py*' -exec chmod 644 {} +
find /usr/local/lib/python*/dist-packages -type f -name '*.pth' -exec chmod 644 {} +
####################################################################################################
# get tools/source code from vendor repositories
mkdir -p "${lichen_vendor_dir}/nlohmann"
NLOHMANN_JSON_VERSION=3.9.1
echo "Checking for nlohmann/json: ${NLOHMANN_JSON_VERSION}"
if [ -f "${lichen_vendor_dir}/nlohmann/json.hpp" ] && head -n 10 "${lichen_vendor_dir}/nlohmann/json.hpp" | grep -q "version ${NLOHMANN_JSON_VERSION}"; then
echo " already installed"
else
echo " downloading"
wget -O "${lichen_vendor_dir}/nlohmann/json.hpp" "https://github.com/nlohmann/json/releases/download/v${NLOHMANN_JSON_VERSION}/json.hpp" > /dev/null
fi
####################################################################################################
# compile & install the hash comparison tool
pushd "${lichen_repository_dir}" > /dev/null
clang++ -I "${lichen_vendor_dir}" -lboost_system -lboost_filesystem -Wall -Wextra -Werror -g -Ofast -flto -funroll-loops -std=c++11 compare_hashes/compare_hashes.cpp compare_hashes/submission.cpp -o "${lichen_installation_dir}/compare_hashes/compare_hashes.out"
if [ "$?" -ne 0 ]; then
echo -e "ERROR: FAILED TO BUILD HASH COMPARISON TOOL\n"
exit 1
fi
popd > /dev/null
####################################################################################################
# pull or build Lichen Docker image
if [[ "$#" -ge 1 && "$1" == "build" ]]; then
docker build -t submitty/lichen "$lichen_repository_dir"
else
docker pull submitty/lichen:latest
docker tag submitty/lichen:latest lichen
fi
#####################################################################################################
# fix permissions
chown -R root:root ${lichen_installation_dir}
chmod -R 755 ${lichen_installation_dir}
echo "done"