-
Notifications
You must be signed in to change notification settings - Fork 13
/
install.sh
executable file
·113 lines (90 loc) · 3.94 KB
/
install.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
#!/usr/bin/env bash
source .env
if [ "$EUID" -ne 0 ]
then echo "Please run with sudo"
exit
fi
apt update && apt install -y wget curl software-properties-common python3.6 python3-pip bzip2 ca-certificates git libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6
### Conda
wget -nc https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh -O ~/anaconda.sh
bash ~/anaconda.sh -b -p ${CONDA_DIR}
ln -s ${CONDA_DIR}/etc/profile.d/conda.sh /etc/profile.d/conda.sh
/opt/conda/bin/conda init bash
source ~/.bashrc
source /etc/profile.d/conda.sh
### Groups && Dirs
groupadd -f etl
mkdir /var/etl
mkdir /media/etl
chgrp -R etl /var/etl
chgrp -R etl /media/etl
### NodeJS
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
apt update && apt install -y nodejs
### JupyterHub && JupyterLab
/opt/conda/bin/conda create -y --prefix=/opt/jupyterhub/ wheel jupyterhub jupyterlab ipywidgets sqlalchemy psycopg2
mkdir -p /opt/jupyterhub/etc/jupyterhub/
cp jupyterhub/jupyterhub_config.py /opt/jupyterhub/etc/jupyterhub/
cp systemd/jupyterhub.service /etc/systemd/system/jupyterhub.service
systemctl daemon-reload
systemctl enable jupyterhub.service
systemctl start jupyterhub.service
### Papermill
pip3 install papermill
### Conda ENV Dev
/opt/conda/bin/conda create -y --prefix=/opt/conda/envs/dev python=3.6 petl ipykernel wheel requests pandas sqlalchemy psycopg2 openpyxl
${CONDA_DIR}/envs/dev/bin/python -m ipykernel install --prefix=/usr/local --name 'dev' --display-name "Python (Dev Env)"
### Conda ENV Prod
/opt/conda/bin/conda create -y --prefix=/opt/conda/envs/prod python=3.6 petl ipykernel wheel requests pandas sqlalchemy psycopg2 openpyxl
${CONDA_DIR}/envs/prod/bin/python -m ipykernel install --prefix=/usr/local --name 'prod' --display-name "Python (Prod Env)"
### Cronicle
curl -s https://raw.githubusercontent.com/jhuckaby/Cronicle/master/bin/install.js | node
/opt/cronicle/bin/control.sh setup
cp systemd/cronicle.service /etc/systemd/system/cronicle.service
systemctl daemon-reload
systemctl enable cronicle.service
systemctl start cronicle.service
cp cronicle_useradd.js /opt/cronicle/bin/
### Nginx && CertBot
add-apt-repository -y universe && add-apt-repository -y ppa:certbot/certbot
apt update && apt install -y nginx certbot python3-certbot-nginx
rm /etc/nginx/sites-enabled/default
cp nginx/default.conf /etc/nginx/conf.d/default.conf
service nginx restart
cp -r html /var/www
### S3FS && Rsync
apt install -y s3fs rsync
cp s3fs.sh /etc/cron.daily/s3fs
chmod 700 /etc/cron.daily/s3fs
echo ${ACCESS_KEY_ID}:${SECRET_ACCESS_KEY} > /etc/passwd-s3fs
chmod 600 /etc/passwd-s3fs
./s3fs.sh
### PostgreSQL
apt install -y postgresql postgresql-contrib
cp postgresql/postgresql.conf /etc/postgresql/10/main/
cp postgresql/pg_hba.conf /etc/postgresql/10/main/
service postgresql restart
sudo -u postgres bash -c "psql -c \"CREATE USER ${PSQL_USER} WITH PASSWORD '${POSTGRES_PASSWORD}';\""
sudo -u postgres bash -c "psql -c \"CREATE DATABASE ${PSQL_DB};\""
sudo -u postgres bash -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE ${PSQL_DB} TO ${PSQL_USER};\""
sudo -u postgres bash -c "psql -c \"CREATE USER demo WITH PASSWORD 'demo';\""
cp tutorials/datasets/DEMO.SQL /var/etl
chown postgres /var/etl/DEMO.SQL
sudo -u postgres bash -c "psql -f /var/etl/DEMO.SQL"
rm /var/etl/DEMO.SQL
sudo -u postgres bash -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE demo TO demo;\""
sudo -u postgres bash -c "psql -d demo -c \"GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO demo;\""
echo "Configuring hostname/domain..."
bash ./conf.sh -h
if [ ${DOMAIN} != "" ];
then
echo "Configuring HTTPS..."
bash ./conf.sh -ssl
fi
echo "Adding first user account..."
bash ./conf.sh -u
echo "Configuring Cronicle access..."
bash ./conf.sh -a
echo "Configuring PostgresSQL access..."
bash ./conf.sh -p
echo "Installation finished. Please restart the server, otherwise hostname change might not be in effect and Cronicle might not start properly."