-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoinit_own.sh
executable file
·61 lines (48 loc) · 2.87 KB
/
autoinit_own.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
#!/bin/bash
# Skript: autoinit_own.sh
# Globale Variablen
SCRIPTNAME=$(basename $0 .sh)
EXIT_SUCCESS=0
EXIT_FAILURE=1
EXIT_ERROR=2
EXIT_BUG=10
source ${0%/*}/config
msearch_opt_args="-pkr40" #example "-v"
echo "---------------------------------------------------------------------------"
echo ""
echo -e "\E[96m Tips: "; tput sgr0
echo "---------------------------------------------------------------------------"
echo ""
if [ -e $ramdisk/category/tips ] ; then # test -e /mnt/... ; then
POSITION=$[ ( $RANDOM % `msearch $msearch_opt_args -ci -x "done" tips ` ) ]
msearch $msearch_opt_args -i -o1 -t$POSITION -x "done" tips
fi
echo "---------------------------------------------------------------------------"
echo ""
echo -e "\E[96m Citation: "; tput sgr0
echo "---------------------------------------------------------------------------"
echo ""
if [ -e $ramdisk/category/citation ] ; then # test -e /mnt/... ; then
POSITION=$[ ( $RANDOM % `msearch $msearch_opt_args -ci -x "done" citation ` ) ]
msearch $msearch_opt_args -i -o1 -t$POSITION -x "done" citation
#adding pub_dbs
for i in 8 9 10; do
cp $infosystem/template.db $infosystem/pub_dbs/infosystem_$i.db #begin with initial database
sqlite3 -header -csv $database "select * from infos where zone in (select zone from zones where zones.zones=$i);" > $ramdisk/infosystem_$i.dump
sqlite3 -header -csv $infosystem/pub_dbs/infosystem_$i.db ".import $ramdisk/infosystem_$i.dump infos" 2> /dev/null
sqlite3 -header -csv $database "select * from links where zone in (select zone from zones where zones.zones=$i);" > $ramdisk/infosystem_$i.dump
sqlite3 -header -csv $infosystem/pub_dbs/infosystem_$i.db ".import $ramdisk/infosystem_$i.dump links" 2> /dev/null
sqlite3 -header -csv $database "select * from category_item where ((item_type_id=1 and item_id in (select id from infos where zone in (select zone from zones where zones.zones=$i)) or (item_type_id=2 and item_id in (select id from links where zone in (select zone from zones where zones.zones=$i)))));" > $ramdisk/infosystem_$i.dump
sqlite3 -header -csv $infosystem/pub_dbs/infosystem_$i.db ".import $ramdisk/infosystem_$i.dump category_item" 2> /dev/null
sqlite3 -header -csv $database "select * from category where zone in (select zone from zones where zones.zones=$i);" > $ramdisk/infosystem_$i.dump
sqlite3 -header -csv $infosystem/pub_dbs/infosystem_$i.db ".import $ramdisk/infosystem_$i.dump category" 2> /dev/null
#maybe also adding item_ref later
#delete todo's in public'dbs
sqlite3 $infosystem/pub_dbs/infosystem_$i.db "delete from category_item where category_id=5;";
done
#then you have to choose where you want upload your public db's
# scp -P 22 $infosystem/pub_dbs/infosystem_8.db public@shared_server:html
# scp $infosystem/pub_dbs/infosystem_9.db user@your_server:/var/www
# scp $infosystem/pub_dbs/infosystem_10.db user@server_at_work:
fi
# You can add further searches here