forked from snakazawa/slack-backup
-
Notifications
You must be signed in to change notification settings - Fork 4
/
provisioning_on_centos7.sh
55 lines (46 loc) · 1.7 KB
/
provisioning_on_centos7.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
#!/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 python-pip
sudo yum install -y uwsgi uwsgi-router-http uwsgi-plugin-python
#sudo yum install -y postgresql-server postgresql-devel
cd /usr/local/src
sudo git clone https://github.com/menemy/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 makemigrations
sudo python manage.py migrate
sudo python manage.py installwatson
sudo python manage.py parse_channels
# prepare static files
mkdir /usr/local/src/slack-backup/static
sudo python manage.py collectstatic --noinput
#open firewall
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
# 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="/usr/sbin/uwsgi --ini ${DIR}/uwsgi.ini"
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}"