-
Notifications
You must be signed in to change notification settings - Fork 26
/
populate_wiki
executable file
·114 lines (87 loc) · 4.03 KB
/
populate_wiki
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
#!/bin/bash
me=$(basename $0)
full_usage="
Usage:
$me: imports a directory of wiki content into the local wiki
usage: $me <content directory> <basic auth credentials>
example: $me full_wiki_20170113 wiki_test:foobarbaz
This script consumes the output of the 'run_full_pipeline' script, loading it
into the wiki running on localhost. You can run this script multiple times on
a host and it will overwrite whatever content is already present. Note that it
does not delete existing pages that do not appear in the content directory.
Page pruning is best done by blowing away the wiki and starting over.
The file structure of content_dir should be:
/All_Chemicals: a list of all chemicals
/Reachables/: a directory of per-chemical wiki pages
/Pathways/: a directory of per-pathway wiki pages
/Sequences/: a directory of plain-text DNA design files
/renderings/: a directory of all images (molecules, word clouds, cascades)
"
content_dir=$1
if [[ ! -e $content_dir ]]; then
echo "Error: no content directory specified."
echo "$full_usage"
exit 1
fi
basic_auth_creds=$2
if [[ -z $basic_auth_creds ]]; then
echo "Error: no basic auth credentials specified."
echo "Please provide <username>:<password> argument."
echo $full_usage
exit 1
fi
# ----------------------------------------
# Import supporting files
echo "Importing renderings."
sudo -u www-data php /var/www/mediawiki/maintenance/importImages.php --overwrite --extensions png ${content_dir}/renderings
echo "Done importing renderings."
echo "Importing sequence designs."
sudo -u www-data php /var/www/mediawiki/maintenance/importImages.php --overwrite --extensions txt ${content_dir}/Sequences
echo "Done importing sequence designs."
# ----------------------------------------
# Import pages
echo "Importing pathway pages."
find ${content_dir}/Pathways -type f | sort -S1G | xargs sudo -u www-data php /var/www/mediawiki/maintenance/importTextFiles.php --overwrite
echo "Done importing pathway pages."
echo "Importing molecule pages."
find ${content_dir}/Reachables -type f | sort -S1G | xargs sudo -u www-data php /var/www/mediawiki/maintenance/importTextFiles.php --overwrite
echo "Done importing molecule pages."
echo "Importing all chemicals page."
sudo -u www-data php /var/www/mediawiki/maintenance/importTextFiles.php --overwrite ${content_dir}/All_Chemicals
echo "Done importing all chemicals page."
echo "Importing category pages."
find ${content_dir}/Categories -type f | sort -S1G | xargs sudo -u www-data php /var/www/mediawiki/maintenance/importTextFiles.php --overwrite
echo "Done importing all category page."
echo "TODO: import category pages once they are generated."
# ----------------------------------------
# Rebuild pages
function rebuild() {
for i in $(ls $1); do
echo $i;
curl --user "$basic_auth_creds" --insecure -vvv -X POST "https://localhost/api.php?action=purge&titles=${i}&format=json" 2>&1 | grep "HTTP";
done;
}
echo "Rebuilding reachables pages."
rebuild ${content_dir}/Reachables
echo "Done rebuilding reachables pages."
echo "Rebuilding pathways pages."
rebuild ${content_dir}/Pathways
echo "Done rebuilding pathways pages."
echo "Copying molecule images to assets directory."
sudo find ${content_dir}/renderings -type f -name 'molecule-*.png' -exec cp {} /var/www/mediawiki/assets/img \;
sudo chown -R www-data:www-data /var/www/mediawiki/assets/img
# ----------------------------------------
# Update wiki web services
echo "Installing reachables list."
sudo cp ${content_dir}/reachables /etc/wiki_web_services/reachables
sudo chown root:root /etc/wiki_web_services/reachables
echo "Restarting wiki web services to read reachables list."
sudo /etc/init.d/substructure_search restart
sudo /etc/init.d/orders_service restart
echo "Checking substructure search service status:"
sudo /etc/init.d/substructure_search status
echo "Checking orders service status:"
sudo /etc/init.d/orders_service status
echo "----------------------------------------"
echo "Done with import process."
echo "Wiki should be ready for use."