-
Notifications
You must be signed in to change notification settings - Fork 1
/
install-common.sh
executable file
·144 lines (111 loc) · 4.56 KB
/
install-common.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
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
#!/usr/bin/env bash
################################################################################
# Preamble
################################################################################
# Cause the script to exit on any errors
#
# Reference:
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -u
REPO_LINK="https://github.com/elsa-lab/base-env"
INSTALL_PATH="/opt/base-env"
MOTD_PATH="/etc/update-motd.d"
BIN_PATH="/usr/local/bin"
################################################################################
# System settings
################################################################################
# Extends the sudo timeout for another 15 mins
sudo -v
# Set DIR_MODE of adduser
#
# Reference:
# http://manpages.ubuntu.com/manpages/focal/man5/adduser.conf.5.html
sudo sed -i "s/DIR_MODE=0755/DIR_MODE=0700/" /etc/adduser.conf
chmod 700 ${HOME}
# Set timezone to Taipei
#
# Reference:
# http://manpages.ubuntu.com/manpages/focal/man1/timedatectl.1.html
sudo timedatectl set-timezone Asia/Taipei
# Generate keys for the elsa server to download installers
ssh-keygen -f ~/.ssh/elsa-server
ssh-copy-id -i ~/.ssh/elsa-server elsa.cs.nthu.edu.tw
################################################################################
# Installation
################################################################################
sudo git clone "${REPO_LINK}" "${INSTALL_PATH}"
# Update this package frequently
#
# Reference:
# https://stackoverflow.com/a/16068840
(sudo crontab -u root -l; echo "0 0 * * * cd ${INSTALL_PATH}; git pull") |
sudo crontab -u root -
#=====================================================================
# Part I: Package
#=====================================================================
cd ${INSTALL_PATH}/Package
#-----------------------------------------------------------
# Dependency and Service
#-----------------------------------------------------------
./Dependency/install-essential.sh
./Dependency/install-docker.sh
./Dependency/install-mujoco-roboti.sh
./Dependency/install-mujoco-deepmind.sh
./Dependency/install-python36-37.sh
# Service
./Dependency/install-fail2ban.sh
./Dependency/install-hosts-monitor.sh
./Dependency/install-netdata.sh
#-----------------------------------------------------------
# NVIDIA related
#-----------------------------------------------------------
./NVIDIA/install-nv-driver.sh
./NVIDIA/install-cuda-cudnn.sh
./NVIDIA/install-nv-docker.sh
#-----------------------------------------------------------
# TigerVNC
#-----------------------------------------------------------
./TigerVNC/install-xfce4.sh
./TigerVNC/install-vncserver.sh
#-----------------------------------------------------------
# VirtualGL
#-----------------------------------------------------------
# ./Dependency/install-virtualgl.sh
#=====================================================================
# Part II: Script
#=====================================================================
cd ${INSTALL_PATH}/Script
#-----------------------------------------------------------
# User scripts
#-----------------------------------------------------------
for s in $(ls -A -I profile.d); do
for ss in $(ls ${s}); do
sudo ln -fns $(pwd)/${s}/${ss} ${BIN_PATH}/${ss}
done
done
# VNC starting script shall be in the same path of Xvnc and vncpasswd (i.e., /usr/bin)
sudo rm /usr/local/bin/vncserver
# using ${INSTALL_PATH}/Script/vnc/vncserver to provide /usr/bin/vncserver (vncserver) in auto mode
sudo update-alternatives --install /usr/bin/vncserver vncserver ${INSTALL_PATH}/Script/vnc/vncserver 90
#-----------------------------------------------------------
# profile.d
#-----------------------------------------------------------
for ss in $(ls -A profile.d); do
sudo ln -fns $(pwd)/profile.d/${ss} /etc/profile.d/${ss}
done
#-----------------------------------------------------------
# motd
#-----------------------------------------------------------
# Enable necessary motds
sudo chmod -x ${MOTD_PATH}/*
sudo chmod +x ${MOTD_PATH}/00-header
sudo chmod +x ${MOTD_PATH}/97-overlayroot
sudo chmod +x ${MOTD_PATH}/98-fsck-at-reboot
sudo chmod +x ${MOTD_PATH}/98-reboot-required
# Install customized motds
sudo ln -fns $(pwd)/motd/fest-welcome ${MOTD_PATH}/02-fest-welcome
sudo ln -fns $(pwd)/motd/landscape-sysinfo ${MOTD_PATH}/50-landscape-sysinfo
sudo ln -fns $(pwd)/server_status/hdd-status ${MOTD_PATH}/51-hdd-status
sudo ln -fns $(pwd)/server_status/gpu-status ${MOTD_PATH}/52-gpu-status
sudo ln -fns $(pwd)/server_status/vnc-status ${MOTD_PATH}/53-vnc-status
sudo ln -fns $(pwd)/motd/ssh-banner-short ${MOTD_PATH}/56-ssh-banner-short