forked from jjstaats/slack-backup
-
Notifications
You must be signed in to change notification settings - Fork 1
/
provisioning_on_amazonlinux.sh
42 lines (36 loc) · 1.4 KB
/
provisioning_on_amazonlinux.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
#!/bin/sh
SLACK_CLIENT_ID=xxxxxxxx
SLACK_CLIENT_SECRET=xxxxxxxx
DIR=/usr/local/src/slack-backup
DOMAIN=localhost
# install
sudo yum install -y gcc gcc-c++ git python postgresql-server postgresql-devel
cd /usr/local/src
sudo git clone https://github.com/snakazawa/slack-backup.git
cd slack-backup/
sudo pip install -r requirements.txt
# settings
sudo cp slackbackup/settings_local_sample.py slackbackup/settings_local.py
sudo sed -i -E "s/SLACK_CLIENT_ID.*/SLACK_CLIENT_ID = '${SLACK_CLIENT_ID}'/" slackbackup/settings_local.py
sudo sed -i -E "s/SLACK_CLIENT_SECRET.*/SLACK_CLIENT_SECRET = '${SLACK_CLIENT_SECRET}'/" slackbackup/settings_local.py
sudo sed -i -E "s/DOMAIN.*/DOMAIN = 'http:\/\/${DOMAIN}'/" slackbackup/settings_local.py
# migration and crawling
sudo python manage.py migrate
sudo python manage.py parse_channels
# scheduling
sudo touch /etc/cron.d/slackbackup
sudo chmod 777 /etc/cron.d/slackbackup
cat > /etc/cron.d/slackbackup << EOS
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
*/5 * * * * root python ${DIR}/manage.py parse_channels 1>>${DIR}/logs/parse.log 2>>${DIR}/logs/parse.err.log
EOS
sudo chmod 644 /etc/cron.d/slackbackup
# run
RUN_SCRIPT="python ${DIR}/manage.py runserver 0.0.0.0:80 1>>${DIR}/logs/run.log 2>>${DIR}/logs/run.err.log"
sudo chmod 777 /etc/rc.d/rc.local
echo $RUN_SCRIPT >> /etc/rc.d/rc.local
sudo chmod 755 /etc/rc.d/rc.local
sudo sh -c "${RUN_SCRIPT} &"