summaryrefslogtreecommitdiff
path: root/scripts/epgd-dropall
blob: 65ef65b1f2be50d7bebdb04fa3458b5ac7ff3ce9 (plain)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash

MYSQL_PWD=${MYSQL_PWD:-epg}
export MYSQL_PWD

echo "------------------------"
echo "-- Drop normal tables --"
echo "------------------------"
echo "This tables contain data which is restored automatically "
echo " by downloading from internet and via the dvb stream and from your vdrs"
echo -n "Are you sure? [y/N] "

read -n 1 c
echo ""

if [ "${c}" = "y" ]; then

   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists events;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists useevents;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists fileref;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists imagerefs;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists channelmap;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists episodes;'
   mysql -u epg2vdr -Depg2vdr -e 'drop view  if exists eventsview;'
   mysql -u epg2vdr -Depg2vdr -e 'drop view  if exists eventsviewplain;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists components;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists recordingdirs;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists recordinglist;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists vdrs;'

   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists analyse;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists snapshot;'

   echo "Now you have two choices for timers and timersdone (only the pending ones):"
   echo " 1. Automatic (without dropping the timers table):"
   echo "      All created timers will be marked for delete action to force VDRs to remove them"
   echo " 2. Drop table timers - you have to cleanup the timers.conf of your VDRs by hand"
   echo " "
   echo "In both cases all still pending timers will removed from timersdone to force epgd to create it again!"
   echo " "
   echo "Proceed with 1 (otherwise 2 will done)? [y/N] "

   read -n 1 c
   echo ""

   if [ "${c}" = "y" ]; then
       mysql -u epg2vdr -Depg2vdr -e "update timers set action = 'D' where state in ('P', 'R');"
   else
       mysql -u epg2vdr -Depg2vdr -e 'drop table if exists timers;'
   fi

   mysql -u epg2vdr -Depg2vdr -e "delete from timersdone where state in ('C', 'Q');"

   echo ""
   echo "Tables dropped!"
fi

echo "---------------------"
echo "-- Drop procedures --"
echo "---------------------"
echo -n "Are you sure? [y/N] "

read -n 1 c
echo ""

if [ "${c}" = "y" ]; then
   mysql -u epg2vdr -Depg2vdr -e 'drop procedure if exists reverseepg;'
   mysql -u epg2vdr -Depg2vdr -e 'drop procedure if exists mergeepg;'

   mysql -u epg2vdr -Depg2vdr -e 'drop function if exists getupdflg;'
   mysql -u epg2vdr -Depg2vdr -e 'drop function if exists getcrosslvr;'
   mysql -u epg2vdr -Depg2vdr -e 'drop function if exists getlvrmin;'

   echo ""
   echo "Procedures and Functions dropped!"
fi

echo "-------------------"
echo "--  Drop images  --"
echo "-------------------"
echo "In most cases you do not need to drop the image table."
echo -n "Drop image tables? [y/N] "

read -n 1 i
echo ""

if [ "${i}" = "y" ]; then
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists images;'

   echo ""
   echo "Table images dropped!"
fi

echo "----------------------"
echo "--  Scraper tables  --"
echo "-----------------------"
echo "In most cases you don't need to drop the scarper tables!"
echo -n "Drop scraper tables? [y/N] "

read -n 1 i
echo ""

if [ "${i}" = "y" ]; then
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists series;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists series_episode;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists series_media;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists series_actor;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists movie;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists movie_actor;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists movie_actors;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists movie_media;'
   mysql -u epg2vdr -Depg2vdr -e 'drop view  if exists thetvdbview;'

   mysql -u epg2vdr -Depg2vdr -e 'update events set scrseriesid = null, scrseriesepisode = null, scrmovieid = null, scrsp = null;'
   mysql -u epg2vdr -Depg2vdr -e 'update recordinglist set scrseriesid = null, scrseriesepisode = null, scrmovieid = null, scrnew = null, scrsp = null;'

   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists usevents;'

   echo ""
   echo "Scraper tables dropped!"
fi

echo "-----------------------------"
echo "--  Tables with User Data  --"
echo "-----------------------------"
echo "In most cases you DON'T LIKE to drop tables with the USER data!"
echo "If you proceed in the next step you will to backup it"
echo -n "Drop tables with user data? [y/N] "

read -n 1 i
echo ""

if [ "${i}" = "y" ]; then

   echo -n "Backup User Data Tables now? [y/N] "

   read -n 1 i
   echo ""

   if [ "${i}" = "y" ]; then
       mysqldump --opt -u epg2vdr epg2vdr parameters | gzip > ./parameters-dump.sql.gz
       echo "Table parameters dumped to ./parameters-dump.sql.gz"

       mysqldump --opt -u epg2vdr epg2vdr users | gzip > ./users-dump.sql.gz
       echo "Table users dumped to ./users-dump.sql.gz"

       mysqldump --opt -u epg2vdr epg2vdr timersdone | gzip > ./timersdone-sump.sql.gz
       echo "Table timersdone dumped to ./timersdone-dump.sql.gz"

       mysqldump --opt -u epg2vdr epg2vdr searchtimers | gzip > ./searchtimers-sump.sql.gz
       echo "Table searchtimers dumped to ./searchtimers-dump.sql.gz"
   fi

   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists parameters;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists searchtimers;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists timersdone;'
   mysql -u epg2vdr -Depg2vdr -e 'drop table if exists users;'

   echo ""
   echo "User Data tables dropped!"
fi