diff options
Diffstat (limited to '')
-rwxr-xr-x | SuckIt | 157 | ||||
-rwxr-xr-x | SuckItClean | 13 |
2 files changed, 105 insertions, 65 deletions
@@ -4,14 +4,15 @@ 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 | #mkdir -p users | 14 | #rm -fr users/* |
15 | mkdir -p users | ||
15 | cp -r /opt/nyaw_EMPTY/users . | 16 | cp -r /opt/nyaw_EMPTY/users . |
16 | 17 | ||
17 | # Copy across things like images that where uploaded. | 18 | # Copy across things like images that where uploaded. |
@@ -33,50 +34,62 @@ do | |||
33 | base=`echo "${line}" | cut -d '/' -f 1` | 34 | base=`echo "${line}" | cut -d '/' -f 1` |
34 | 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` |
35 | 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 |
36 | realURL=${ogWiki}/${base}/${file} | 37 | doit='false' |
37 | time=`date --rfc-3339=seconds -ur /opt/Foswiki/data/${base}/${file}.txt | cut -d '+' -f 1` | 38 | if [ ! -s ${ogWiki}/${base}/${file}.HTM ]; then |
38 | mkdir -p ${ogWiki}/${base} | 39 | echo "NEW /opt/Foswiki/data/${base}/${file}.txt" |
39 | mkdir -p ${ogWiki}/${base}/`dirname ${file}` | 40 | doit='true' |
40 | 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 |
41 | echo "downloading ${ogURL}/${base}/${file}?cover=print" | 42 | echo "NEWER /opt/Foswiki/data/${base}/${file}.txt" |
42 | # 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 |
43 | 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 |
44 | # Attempt to separate user profiles from user content. Doesn't work when people turn their profiles into content. | 45 | doit='true' |
45 | dest="" | ||
46 | if [[ "${base}" == "Main" ]]; then | ||
47 | dest="unsorted" | ||
48 | if [ -L users/${file}_fos.md ]; then | ||
49 | dest='users' | ||
50 | fi | ||
51 | mkdir -p `dirname users/${file}` | ||
52 | sed -i -E ${ogWiki}/${base}/${file}.HTM -e "s%<a href=\"/System/UserForm\">UserForm</a>%%w users/${file}_fos.SED" | ||
53 | if [ -s users/${file}_fos.SED ]; then | ||
54 | dest="users" | ||
55 | fi | ||
56 | rm users/${file}_fos.SED >/dev/null 2>&1 | ||
57 | rm -d `dirname users/${file}` >/dev/null 2>&1 | ||
58 | fi | 46 | fi |
59 | # "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 |
60 | # Skipping anything with "<a href="/Main/UnknownUser">UnknownUser</a></span></div>". | 48 | realURL=${ogWiki}/${base}/${file} |
61 | if [[ "${base}" == "Sandbox" ]]; then | 49 | time=`date --rfc-3339=seconds -ur /opt/Foswiki/data/${base}/${file}.txt | cut -d '+' -f 1` |
62 | dest="unsorted" | 50 | mkdir -p ${ogWiki}/${base} |
63 | mkdir -p `dirname users/${file}` | 51 | mkdir -p ${ogWiki}/${base}/`dirname ${file}` |
64 | 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 |
65 | if [ -s users/${file}_fos.SED ]; then | 53 | echo "downloading ${ogURL}/${base}/${file}?cover=print" |
66 | 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 | ||
67 | fi | 82 | fi |
68 | rm users/${file}_fos.SED >/dev/null 2>&1 | ||
69 | rm -d `dirname users/${file}` >/dev/null 2>&1 | ||
70 | fi | ||
71 | 83 | ||
72 | if [[ "${dest}" != "" ]]; then | 84 | if [[ "${dest}" != "" ]]; then |
73 | mkdir -p `dirname ${dest}/${file}` | 85 | mkdir -p `dirname ${dest}/${file}` |
74 | realURL=${dest}/${file} | 86 | realURL=${dest}/${file} |
75 | 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 |
76 | touch ${ogWiki}/${base}/${file}.md | 88 | touch ${ogWiki}/${base}/${file}.md |
77 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_fos.md | 89 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_fos.md |
78 | 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 |
79 | rm ${ogWiki}/${base}/${file}.md | 91 | rm ${ogWiki}/${base}/${file}.md |
92 | fi | ||
80 | fi | 93 | fi |
81 | fi | 94 | fi |
82 | done | 95 | done |
@@ -99,26 +112,38 @@ do | |||
99 | base=`echo "${line}" | cut -d '.' -f 1` | 112 | base=`echo "${line}" | cut -d '.' -f 1` |
100 | file=`echo "${line}" | cut -d '.' -f 2` | 113 | file=`echo "${line}" | cut -d '.' -f 2` |
101 | if [[ "${base}" != "Site" ]]; then | 114 | if [[ "${base}" != "Site" ]]; then |
102 | realURL=${ogWiki}/${base}/${file} | 115 | doit='false' |
103 | time=`date --rfc-3339=seconds -ur /opt/pmwiki/wiki.d/${base}.${file} | cut -d '+' -f 1` | 116 | if [ ! -s ${ogWiki}/${base}/${file}.HTM ]; then |
104 | mkdir -p ${ogWiki}/${base} | 117 | echo "NEW /opt/pmwiki/wiki.d/${base}.${file} ${ogWiki}/${base}/${file}.HTM" |
105 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | 118 | doit='true' |
106 | # echo "downloading ${ogURL}/?n=${base}.${file}?action=markdown" | 119 | elif [ /opt/pmwiki/wiki.d/${base}.${file} -nt ${ogWiki}/${base}/${file}.HTM ]; then |
107 | # curl --no-progress-meter ${ogURL}/?n=${base}.${file}?action=markdown -o ${ogWiki}/${base}/${file}.MARKDOWN | 120 | echo "NEWER /opt/pmwiki/wiki.d/${base}.${file}" |
108 | echo "downloading ${ogURL}/?n=${base}.${file}?action=print" | 121 | date --rfc-3339=seconds -ur /opt/pmwiki/wiki.d/${base}.${file} |
109 | 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 |
110 | # 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' |
111 | if [[ "${base}" == "Profiles" ]]; then | 124 | fi |
112 | dest="unsorted" | 125 | if [[ ${doit} == "true" ]]; then |
113 | if [ -L users/${file}_pm.md ]; then | 126 | realURL=${ogWiki}/${base}/${file} |
114 | dest='users' | 127 | time=`date --rfc-3339=seconds -ur /opt/pmwiki/wiki.d/${base}.${file} | cut -d '+' -f 1` |
128 | mkdir -p ${ogWiki}/${base} | ||
129 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | ||
130 | # echo "downloading ${ogURL}/?n=${base}.${file}?action=markdown" | ||
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 | ||
115 | fi | 146 | fi |
116 | realURL=${dest}/${file} | ||
117 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}_pm\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | ||
118 | touch ${ogWiki}/${base}/${file}.md | ||
119 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_pm.md | ||
120 | ln -sfr ${ogWiki}/${base}/${file}.md.md ${dest}/${file}_pm.md.md | ||
121 | rm ${ogWiki}/${base}/${file}.md | ||
122 | fi | 147 | fi |
123 | 148 | ||
124 | # TODO - groups are PmWiki/Onefang and PmWiki/Tiki | 149 | # TODO - groups are PmWiki/Onefang and PmWiki/Tiki |
@@ -130,6 +155,8 @@ done | |||
130 | 155 | ||
131 | 156 | ||
132 | time notYetAnotherWiki.lua | 157 | time notYetAnotherWiki.lua |
158 | # No idea why yet, but needs a second run to sort out everything. Shouldn't take long anyway. | ||
159 | time notYetAnotherWiki.lua | ||
133 | 160 | ||
134 | popd | 161 | popd |
135 | } | 162 | } |
diff --git a/SuckItClean b/SuckItClean new file mode 100755 index 0000000..1b8a025 --- /dev/null +++ b/SuckItClean | |||
@@ -0,0 +1,13 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | TIMEFORMAT=" took %lR using %P%% CPU" | ||
4 | time { | ||
5 | pushd /opt/nyaw | ||
6 | |||
7 | rm -fr Foswiki/* | ||
8 | rm -fr PmWiki/* | ||
9 | rm -fr unsorted | ||
10 | rm -fr users/* | ||
11 | popd | ||
12 | ./SuckIt | ||
13 | } | ||