diff options
Diffstat (limited to 'SuckIt')
-rwxr-xr-x | SuckIt | 150 |
1 files changed, 91 insertions, 59 deletions
@@ -4,14 +4,16 @@ TIMEFORMAT=" took %lR using %P%% CPU" | |||
4 | time { | 4 | time { |
5 | pushd /opt/nyaw | 5 | pushd /opt/nyaw |
6 | 6 | ||
7 | rm -fr Foswiki/* | 7 | #rm -fr Foswiki/* |
8 | cp -r /opt/nyaw_EMPTY/Foswiki . | 8 | cp -r /opt/nyaw_EMPTY/Foswiki . |
9 | rm -fr PmWiki/* | 9 | #rm -fr PmWiki/* |
10 | cp -r /opt/nyaw_EMPTY/PmWiki . | 10 | cp -r /opt/nyaw_EMPTY/PmWiki . |
11 | rm -fr unsorted | 11 | #rm -fr unsorted |
12 | mkdir -p unsorted | 12 | mkdir -p unsorted |
13 | rm -fr users | 13 | cp -r /opt/nyaw_EMPTY/unsorted . |
14 | #rm -fr users/* | ||
14 | mkdir -p users | 15 | mkdir -p users |
16 | cp -r /opt/nyaw_EMPTY/users . | ||
15 | 17 | ||
16 | # Copy across things like images that where uploaded. | 18 | # Copy across things like images that where uploaded. |
17 | mkdir -p /opt/nyaw/Foswiki/pub/ | 19 | mkdir -p /opt/nyaw/Foswiki/pub/ |
@@ -32,47 +34,62 @@ do | |||
32 | base=`echo "${line}" | cut -d '/' -f 1` | 34 | base=`echo "${line}" | cut -d '/' -f 1` |
33 | file=`echo "${line}" | cut -d '/' -f 2- | rev | cut -b 5- | rev` | 35 | file=`echo "${line}" | cut -d '/' -f 2- | rev | cut -b 5- | rev` |
34 | if [[ ! ${file} =~ (AdminGroup|AdminUser|AdminUserLeftBar|CommentPluginExamples|EditorGroup|GroupTemplate|GroupViewTemplate|NobodyGroup|PatternSkinUserViewTemplate|ProjectContributor|RegistrationAgent|SitePreferences|UnprocessedRegistrations|UnprocessedRegistrationsLog|UserHomepageHeader|UserList|UserListByDateJoined|UserListByLocation|UserList|UserListHeader|WebAtom|WebChanges|WebCreateNewTopic|WebHome|WebIndex|WebLeftBar|WebLeftBarExample|WebNotify|WebPreferences|WebRss|WebSearch|WebSearchAdvanced|WebTopicList|WikiGroups|WikiUsers)$ ]]; then | 36 | if [[ ! ${file} =~ (AdminGroup|AdminUser|AdminUserLeftBar|CommentPluginExamples|EditorGroup|GroupTemplate|GroupViewTemplate|NobodyGroup|PatternSkinUserViewTemplate|ProjectContributor|RegistrationAgent|SitePreferences|UnprocessedRegistrations|UnprocessedRegistrationsLog|UserHomepageHeader|UserList|UserListByDateJoined|UserListByLocation|UserList|UserListHeader|WebAtom|WebChanges|WebCreateNewTopic|WebHome|WebIndex|WebLeftBar|WebLeftBarExample|WebNotify|WebPreferences|WebRss|WebSearch|WebSearchAdvanced|WebTopicList|WikiGroups|WikiUsers)$ ]]; then |
35 | realURL=${ogWiki}/${base}/${file} | 37 | doit='false' |
36 | time=`date --rfc-3339=seconds -ur /opt/Foswiki/data/${base}/${file}.txt | cut -d '+' -f 1` | 38 | if [ ! -s ${ogWiki}/${base}/${file}.HTM ]; then |
37 | mkdir -p ${ogWiki}/${base} | 39 | echo "NEW /opt/Foswiki/data/${base}/${file}.txt" |
38 | mkdir -p ${ogWiki}/${base}/`dirname ${file}` | 40 | doit='true' |
39 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | 41 | elif [ /opt/Foswiki/data/${base}/${file}.txt -nt ${ogWiki}/${base}/${file}.HTM ]; then |
40 | echo "downloading ${ogURL}/${base}/${file}?cover=print" | 42 | echo "NEWER /opt/Foswiki/data/${base}/${file}.txt" |
41 | # Doesn't help with redownloads, coz natch a dynamic site isn't cached. But I can at least comment out the curl command during testing to save time. | 43 | date --rfc-3339=seconds -ur /opt/Foswiki/data/${base}/${file}.txt |
42 | curl --silent --no-progress-meter ${ogURL}/${base}/${file}?cover=print -o ${ogWiki}/${base}/${file}.HTM | 44 | date --rfc-3339=seconds -ur ${ogWiki}/${base}/${file}.HTM |
43 | # Attempt to separate user profiles from user content. Doesn't work when people turn their profiles into content. | 45 | doit='true' |
44 | dest="" | ||
45 | if [[ "${base}" == "Main" ]]; then | ||
46 | dest="unsorted" | ||
47 | mkdir -p `dirname users/${file}` | ||
48 | sed -i -E ${ogWiki}/${base}/${file}.HTM -e "s%<a href=\"/System/UserForm\">UserForm</a>%%w users/${file}_fos.SED" | ||
49 | if [ -s users/${file}_fos.SED ]; then | ||
50 | dest="users" | ||
51 | fi | ||
52 | rm users/${file}_fos.SED >/dev/null 2>&1 | ||
53 | rm -d `dirname users/${file}` >/dev/null 2>&1 | ||
54 | fi | 46 | fi |
55 | # "Devuan" is only two pages that get sorted. "Sandbox" is a mixture of standard examples, stuff that was copied to PmWiki, and other things that should get unsorted. | 47 | if [[ ${doit} == "true" ]]; then |
56 | # Skipping anything with "<a href="/Main/UnknownUser">UnknownUser</a></span></div>". | 48 | realURL=${ogWiki}/${base}/${file} |
57 | if [[ "${base}" == "Sandbox" ]]; then | 49 | time=`date --rfc-3339=seconds -ur /opt/Foswiki/data/${base}/${file}.txt | cut -d '+' -f 1` |
58 | dest="unsorted" | 50 | mkdir -p ${ogWiki}/${base} |
59 | mkdir -p `dirname users/${file}` | 51 | mkdir -p ${ogWiki}/${base}/`dirname ${file}` |
60 | sed -i -E ${ogWiki}/${base}/${file}.HTM -e "s%<a href=\"/Main/UnknownUser\">UnknownUser</a></span></div>%%w users/${file}_fos.SED" | 52 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md |
61 | if [ -s users/${file}_fos.SED ]; then | 53 | echo "downloading ${ogURL}/${base}/${file}?cover=print" |
62 | dest="" | 54 | # Doesn't help with redownloads, coz natch a dynamic site isn't cached. But I can at least comment out the curl command during testing to save time. |
55 | curl --silent --no-progress-meter ${ogURL}/${base}/${file}?cover=print -o ${ogWiki}/${base}/${file}.HTM | ||
56 | # Attempt to separate user profiles from user content. Doesn't work when people turn their profiles into content. | ||
57 | dest="" | ||
58 | if [[ "${base}" == "Main" ]]; then | ||
59 | dest="unsorted" | ||
60 | if [ -L users/${file}_fos.md ]; then | ||
61 | dest='users' | ||
62 | fi | ||
63 | mkdir -p `dirname users/${file}` | ||
64 | sed -i -E ${ogWiki}/${base}/${file}.HTM -e "s%<a href=\"/System/UserForm\">UserForm</a>%%w users/${file}_fos.SED" | ||
65 | if [ -s users/${file}_fos.SED ]; then | ||
66 | dest="users" | ||
67 | fi | ||
68 | rm users/${file}_fos.SED >/dev/null 2>&1 | ||
69 | rm -d `dirname users/${file}` >/dev/null 2>&1 | ||
70 | fi | ||
71 | # "Devuan" is only two pages that get sorted. "Sandbox" is a mixture of standard examples, stuff that was copied to PmWiki, and other things that should get unsorted. | ||
72 | # Skipping anything with "<a href="/Main/UnknownUser">UnknownUser</a></span></div>". | ||
73 | if [[ "${base}" == "Sandbox" ]]; then | ||
74 | dest="unsorted" | ||
75 | mkdir -p `dirname users/${file}` | ||
76 | sed -i -E ${ogWiki}/${base}/${file}.HTM -e "s%<a href=\"/Main/UnknownUser\">UnknownUser</a></span></div>%%w users/${file}_fos.SED" | ||
77 | if [ -s users/${file}_fos.SED ]; then | ||
78 | dest="" | ||
79 | fi | ||
80 | rm users/${file}_fos.SED >/dev/null 2>&1 | ||
81 | rm -d `dirname users/${file}` >/dev/null 2>&1 | ||
63 | fi | 82 | fi |
64 | rm users/${file}_fos.SED >/dev/null 2>&1 | ||
65 | rm -d `dirname users/${file}` >/dev/null 2>&1 | ||
66 | fi | ||
67 | 83 | ||
68 | if [[ "${dest}" != "" ]]; then | 84 | if [[ "${dest}" != "" ]]; then |
69 | mkdir -p `dirname ${dest}/${file}` | 85 | mkdir -p `dirname ${dest}/${file}` |
70 | realURL=${dest}/${file} | 86 | realURL=${dest}/${file} |
71 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}_fos\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | 87 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}_fos\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md |
72 | touch ${ogWiki}/${base}/${file}.md | 88 | touch ${ogWiki}/${base}/${file}.md |
73 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_fos.md | 89 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_fos.md |
74 | ln -sfr ${ogWiki}/${base}/${file}.md.md ${dest}/${file}_fos.md.md | 90 | ln -sfr ${ogWiki}/${base}/${file}.md.md ${dest}/${file}_fos.md.md |
75 | rm ${ogWiki}/${base}/${file}.md | 91 | rm ${ogWiki}/${base}/${file}.md |
92 | fi | ||
76 | fi | 93 | fi |
77 | fi | 94 | fi |
78 | done | 95 | done |
@@ -95,23 +112,38 @@ do | |||
95 | base=`echo "${line}" | cut -d '.' -f 1` | 112 | base=`echo "${line}" | cut -d '.' -f 1` |
96 | file=`echo "${line}" | cut -d '.' -f 2` | 113 | file=`echo "${line}" | cut -d '.' -f 2` |
97 | if [[ "${base}" != "Site" ]]; then | 114 | if [[ "${base}" != "Site" ]]; then |
98 | realURL=${ogWiki}/${base}/${file} | 115 | doit='false' |
99 | time=`date --rfc-3339=seconds -ur /opt/pmwiki/wiki.d/${base}.${file} | cut -d '+' -f 1` | 116 | if [ ! -s ${ogWiki}/${base}/${file}.HTM ]; then |
100 | mkdir -p ${ogWiki}/${base} | 117 | echo "NEW /opt/pmwiki/wiki.d/${base}.${file} ${ogWiki}/${base}/${file}.HTM" |
101 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | 118 | doit='true' |
102 | # echo "downloading ${ogURL}/?n=${base}.${file}?action=markdown" | 119 | elif [ /opt/pmwiki/wiki.d/${base}.${file} -nt ${ogWiki}/${base}/${file}.HTM ]; then |
103 | # curl --no-progress-meter ${ogURL}/?n=${base}.${file}?action=markdown -o ${ogWiki}/${base}/${file}.MARKDOWN | 120 | echo "NEWER /opt/pmwiki/wiki.d/${base}.${file}" |
104 | echo "downloading ${ogURL}/?n=${base}.${file}?action=print" | 121 | date --rfc-3339=seconds -ur /opt/pmwiki/wiki.d/${base}.${file} |
105 | curl --no-progress-meter ${ogURL}/?n=${base}.${file}?action=print -o ${ogWiki}/${base}/${file}.HTM | 122 | date --rfc-3339=seconds -ur ${ogWiki}/${base}/${file}.HTM |
106 | # Seems there's no way to tell user profiles apart from user content. Unless I can find a list of users somewhere. Don't think there is one. | 123 | doit='true' |
107 | if [[ "${base}" == "Profiles" ]]; then | 124 | fi |
108 | dest="unsorted" | 125 | if [[ ${doit} == "true" ]]; then |
109 | realURL=${dest}/${file} | 126 | realURL=${ogWiki}/${base}/${file} |
110 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}_pm\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | 127 | time=`date --rfc-3339=seconds -ur /opt/pmwiki/wiki.d/${base}.${file} | cut -d '+' -f 1` |
111 | touch ${ogWiki}/${base}/${file}.md | 128 | mkdir -p ${ogWiki}/${base} |
112 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_pm.md | 129 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md |
113 | ln -sfr ${ogWiki}/${base}/${file}.md.md ${dest}/${file}_pm.md.md | 130 | # echo "downloading ${ogURL}/?n=${base}.${file}?action=markdown" |
114 | rm ${ogWiki}/${base}/${file}.md | 131 | # curl --no-progress-meter ${ogURL}/?n=${base}.${file}?action=markdown -o ${ogWiki}/${base}/${file}.MARKDOWN |
132 | echo "downloading ${ogURL}/?n=${base}.${file}?action=print" | ||
133 | curl --no-progress-meter ${ogURL}/?n=${base}.${file}?action=print -o ${ogWiki}/${base}/${file}.HTM | ||
134 | # Seems there's no way to tell user profiles apart from user content. Unless I can find a list of users somewhere. Don't think there is one. | ||
135 | if [[ "${base}" == "Profiles" ]]; then | ||
136 | dest="unsorted" | ||
137 | if [ -L users/${file}_pm.md ]; then | ||
138 | dest='users' | ||
139 | fi | ||
140 | realURL=${dest}/${file} | ||
141 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}_pm\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | ||
142 | touch ${ogWiki}/${base}/${file}.md | ||
143 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_pm.md | ||
144 | ln -sfr ${ogWiki}/${base}/${file}.md.md ${dest}/${file}_pm.md.md | ||
145 | rm ${ogWiki}/${base}/${file}.md | ||
146 | fi | ||
115 | fi | 147 | fi |
116 | 148 | ||
117 | # TODO - groups are PmWiki/Onefang and PmWiki/Tiki | 149 | # TODO - groups are PmWiki/Onefang and PmWiki/Tiki |