This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset-failover.sh
executable file
·99 lines (74 loc) · 2.96 KB
/
reset-failover.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
#!/bin/bash
######
# reset-failover.sh
#
# this script will re-initialize and republish all hunt team info and team directories
# but will preserve the database
# use this if you're failing over to a new server with an existing hunt database
# or if you otherwise just want to rebuild the system-side of the config but not destroy hunt
######
OWNER="www-data"
cd /home/djangoapps/spoilr
MANAGE=python\ manage.py
if (( "$UID" != "0" )); then
echo YOU NEED TO BE ROOT TO RUN THIS SCRIPT!
echo go away.
echo
exit 255
fi
echo "This script recreates the /var/www/spoilr docroot and prepares for a republish_all in case we are failing over to a slave. You want to run this on a slave after corey is shut down and DNS has been failed over. Press ENTER to continue."
read WAIT
umount -f /var/www/spoilr
umount -f /home/hunt/htpasswd
umount -f /var/cache/spoilr
echo "Creating /var/www/spoilr docroot..."
mkdir -pv /var/www/spoilr
chown www-data /var/www/spoilr
chmod 755 /var/www/spoilr
echo "Creating /var/www/spoilr symlinks into /home/hunt..."
ln -s /home/hunt/spoilrdocroot/hq /var/www/spoilr/hq
ln -s /home/hunt/spoilrdocroot/logout /var/www/spoilr/logout
ln -s /home/hunt/spoilrdocroot/static /var/www/spoilr/static
chown -R www-data /var/www/spoilr/hq
chown -R www-data /var/www/spoilr/logout
chown -R www-data /var/www/spoilr/static
chmod -R 755 /var/www/spoilr/hq
chmod -R 755 /var/www/spoilr/logout
chmod -R 755 /var/www/spoilr/static
echo "Creating /var/www/spoilr/teams and /var/www/spoilr/users"
mkdir -p /var/www/spoilr/teams
mkdir -p /var/www/spoilr/users
chown www-data.www-data /var/www/spoilr/teams
chown www-data.www-data /var/www/spoilr/users
chmod 755 /var/www/spoilr/teams
chmod 755 /var/www/spoilr/users
echo "Creating other symlinks in /var/www/spoilr"
ln -s /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin /var/www/spoilr/admin
ln -s /usr/share/php-htmlpurifier /var/www/spoilr/htmlpurifier
echo "Inserting /var/www/spoilr/.htaccess"
cp -v /home/hunt/spoilrdocroot/.htaccess /var/www/spoilr/.htaccess
#Inserting spoilr logrotate
cp -v spoilr.logrotate /etc/logrotate.d/spoilr
#Inserting spoilr rsyslog
cp -v spoilr.rsyslog /etc/rsyslog.d/10-spoilr.conf
#Copying in apache conf
cp -v spoilr.apacheconf /etc/apache2/conf.d/hunt.conf
echo "Creating Django Cache Directory..."
mkdir -p /var/cache/spoilr
chown -R $OWNER /var/cache/spoilr
#Backup database just in case
echo "Backing old spoilr mysql database into /home/hunt/spoilr.sql..."
/usr/bin/mysqldump --events --all-databases > /home/hunt/spoilr.sql
# publish team files
echo "Publishing hunt for teams..."
su -c "$MANAGE republish_all --traceback" $OWNER
# Install cron jobs
echo "Installing Cron Jobs..."
cp -v spoilrcron /etc/cron.d/spoilrcron
#Inserting spoilr logrotate
cp -v spoilr.logrotate /etc/logrotate.d/spoilr
#Inserting spoilr rsyslog
cp -v spoilr.rsyslog /etc/rsyslog.d/10-spoilr.conf
/etc/init.d/apache2 restart
/etc/init.d/rsyslog restart
echo "backup database is stored at /home/hunt/spoilr.sql"