-
Notifications
You must be signed in to change notification settings - Fork 3
/
uninstall.sh
88 lines (67 loc) · 2.67 KB
/
uninstall.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
#!/usr/bin/env bash
if [ "$EUID" -ne 0 ]
then echo "Please run as the root user."
exit
fi
read -p "Are you want to remove django-fulcrum and all of the associated data? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
FULCRUM_STORE=/opt/geonode/geoserver_data/fulcrum_data
EXCHANGE_SETTINGS=/etc/profile.d/exchange-settings.sh
EXCHANGE_DIR=/opt/boundless/exchange/
BEX_SETTINGS=$EXCHANGE_DIR/bex/settings.py
EXCHANGE_URLS=$EXCHANGE_DIR/.venv/lib/python2.7/site-packages/exchange/urls.py
PIP=$EXCHANGE_DIR/.venv/bin/pip
PYTHON=$EXCHANGE_DIR/.venv/bin/python
MANAGE=$EXCHANGE_DIR/manage.py
CELERY_BEAT_SCRIPT=$EXCHANGE_DIR/celery-beat.sh
grep FULCRUM_UPLOAD $EXCHANGE_SETTINGS && \
sed -i -e "s|export FULCRUM_UPLOAD=.*$||" $EXCHANGE_SETTINGS
cd $EXCHANGE_DIR
$PYTHON - <<END
import django
import os
from string import Template
os.environ['DJANGO_SETTINGS_MODULE'] = 'bex.settings'
django.setup()
from django.db import connection
from django.db.utils import ProgrammingError
from djcelery.models import PeriodicTask
try:
PeriodicTask.objects.get(name='django_fulcrum.tasks.task_update_layers').delete()
print("Successfully removed PeriodicTask: django_fulcrum.tasks.task_update_layers")
except PeriodicTask.DoesNotExist as e:
print("Unable to remove PeriodicTask: django_fulcrum.tasks.task_update_layers")
print(e)
try:
PeriodicTask.objects.get(name='django_fulcrum.tasks.pull_s3_data').delete()
print("Successfully removed PeriodicTask: django_fulcrum.tasks.pull_s3_data")
except PeriodicTask.DoesNotExist as e:
print("Unable to remove PeriodicTask: django_fulcrum.tasks.pull_s3_data")
print(e)
from geonode.base.models import TopicCategory
try:
TopicCategory.objects.get(gn_description='Fulcrum').delete()
print("Successfully removed TopicCategory: Fulcrum")
except TopicCategory.DoesNotExist as e:
print("Unable to remove TopicCategory: Fulcrum")
print(e)
END
cd -
$PYTHON $MANAGE migrate django_fulcrum zero
$PIP uninstall -y django_fulcrum
rm -rf $FULCRUM_STORE
# Other content may exist in the file-service-store, so it doesn't make sense to remove it,
# unless only being used for django-fulcrum
# rm -rf $FILE_SERVICE_STORE
#add to ${EXCHANGE_URLS}:
grep -qF 'from django_fulcrum.urls import urlpatterns as django_fulcrum_urls' $EXCHANGE_URLS && \
sed -i -e "s|from django_fulcrum.urls import urlpatterns as django_fulcrum_urls||" $EXCHANGE_URLS && \
sed -i -e "s|urlpatterns += django_fulcrum_urls||" $EXCHANGE_URLS
#add django_fulrum to bex.settings
grep -qF 'from django_fulcrum.settings import *' ${BEX_SETTINGS} && \
sed -i -e "s|from django_fulcrum.settings import.*$||" ${BEX_SETTINGS}
# django celery migration problem
service exchange restart
fi