/
as-user.sh
58 lines (52 loc) · 1.45 KB
/
as-user.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
echo "running as: $(id)"
get_notebooks() {
echo "get_notebooks()"
# pull the notebooks
examples_folder="/home/$NB_USER/growth"
# we may want to delete the existing notebooks first
echo "Deleting notebooks..."
/home/admin/start/delete_notebooks.py $examples_folder
gitpuller https://github.com/growth-astro/growth-school-2020 master $examples_folder
# and link the data
/home/admin/start/link_growth_data.py /nfs/growth-school-2020 $examples_folder
}
initialize_conda() {
echo "initialize_conda()"
conda init bash
FILE="/home/$NB_USER/.profile"
if test -f $FILE; then
echo "$FILE exists, will not alter it"
else
echo "source ~/.bashrc" > $FILE
fi
}
initialize_desktop() {
echo "initialize desktop()"
# add in some desktop icons
FILE="/nfs/misc/DS9.desktop"
DEST="/home/$NB_USER/Desktop/DS9.desktop"
if test -d "/home/$NB_USER/Desktop/"; then
echo "/home/$NB_USER/Desktop/ exists"
else
echo "Creating /home/$NB_USER/Desktop/"
mkdir /home/$NB_USER/Desktop/
fi
if test -f $DEST; then
echo "$DEST exists, will not alter it"
else
cp $FILE $DEST
echo "Copied $FILE to $DEST"
fi
}
update_path() {
BINDIR="/nfs/bin"
if [[ :$PATH: == *:"$BINDIR":* ]] ; then
echo "$BINDIR in path"
else
echo 'export PATH="/nfs/bin:$PATH"' >> /home/$NB_USER/.bashrc
fi
}
get_notebooks
initialize_conda
initialize_desktop
update_path