-
Notifications
You must be signed in to change notification settings - Fork 47
/
requirements.sh
80 lines (63 loc) · 1.93 KB
/
requirements.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
# Definitions.
HOME_DIR=/home/repl
HOME_COPY=/.course_home
USER_GROUP=repl:repl
COURSE_ID=course_5065
FILESYS=filesys.zip
SOLUTIONS=solutions.zip
# Report start.
echo ''
echo '----------------------------------------'
echo 'START TIME:' $(date)
echo 'HOME_DIR: ' ${HOME_DIR}
echo 'USER_GROUP: ' ${USER_GROUP}
echo 'COURSE_ID: ' ${COURSE_ID}
echo 'FILESYS: ' ${FILESYS}
echo
# Make sure we're in the home directory.
cd ${HOME_DIR}
# Get the zip files.
wget https://s3.amazonaws.com/assets.datacamp.com/production/${COURSE_ID}/datasets/${FILESYS}
wget https://s3.amazonaws.com/assets.datacamp.com/production/${COURSE_ID}/datasets/${SOLUTIONS}
# Make sure we have nano and unzip.
apt-get update
apt-get -y install nano
apt-get -y install unzip
# Unminimize the docker image so the man command is available
yes | unminimize
# Unpack to the local directory.
unzip ./${FILESYS}
# Remove the zip file.
rm -f ./${FILESYS}
# Make the `backup` and `bin` directories (which start off empty, so are not in Git).
mkdir ./backup
mkdir ./bin
# Change ownership.
chown -R ${USER_GROUP} .
# Unpack the solutions (used for file comparison in SCTs).
unzip -d / ./${SOLUTIONS}
rm -f ./${SOLUTIONS}
# Change prompt.
echo "export PS1='\$ '" >> ${HOME_DIR}/.bashrc
# Ensure ~/bin is on the user's path.
echo 'export PATH=$PATH:$HOME/bin' >> ${HOME_DIR}/.bashrc
# Make copy for resetting exercises.
# Files there will replace /home/repl each exercise.
# IMPORTANT: Trailing slashes after directory names force rsync to do the right thing.
rsync -a ${HOME_DIR}/ ${HOME_COPY}/
chown -R ${USER_GROUP} ${HOME_COPY}
# Show what's been done where.
echo 'Installed in home directory:'
ls -R ${HOME_DIR}/*
echo
echo 'Last 10 lines of .bashrc'
tail -n 10 ${HOME_DIR}/.bashrc
echo 'home backup directory:'
ls -R ${HOME_COPY}
echo 'solutions directory'
ls -lR /solutions
# Report end of installation.
echo
echo 'ENDING requirements.sh'
echo '----------------------------------------'
echo ''