diff options
Diffstat (limited to 'SuckIt')
| -rwxr-xr-x | SuckIt | 140 |
1 files changed, 95 insertions, 45 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,31 +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 | if [[ "${base}" == "Main" ]]; then | 46 | fi |
| 45 | dest="unsorted" | 47 | if [[ ${doit} == "true" ]]; then |
| 46 | mkdir -p `dirname users/${file}` | 48 | realURL=${ogWiki}/${base}/${file} |
| 47 | sed -i -E ${ogWiki}/${base}/${file}.HTM -e "s%<a href=\"/System/UserForm\">UserForm</a>%%w users/${file}_fos.SED" | 49 | time=`date --rfc-3339=seconds -ur /opt/Foswiki/data/${base}/${file}.txt | cut -d '+' -f 1` |
| 48 | if [ -s users/${file}_fos.SED ]; then | 50 | mkdir -p ${ogWiki}/${base} |
| 49 | dest="users" | 51 | mkdir -p ${ogWiki}/${base}/`dirname ${file}` |
| 52 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | ||
| 53 | echo "downloading ${ogURL}/${base}/${file}?cover=print" | ||
| 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 | ||
| 82 | fi | ||
| 83 | |||
| 84 | if [[ "${dest}" != "" ]]; then | ||
| 85 | mkdir -p `dirname ${dest}/${file}` | ||
| 86 | realURL=${dest}/${file} | ||
| 87 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}_fos\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | ||
| 88 | touch ${ogWiki}/${base}/${file}.md | ||
| 89 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_fos.md | ||
| 90 | ln -sfr ${ogWiki}/${base}/${file}.md.md ${dest}/${file}_fos.md.md | ||
| 91 | rm ${ogWiki}/${base}/${file}.md | ||
| 50 | fi | 92 | fi |
| 51 | rm users/${file}_fos.SED | ||
| 52 | rm -d `dirname users/${file}` >/dev/null 2>&1 | ||
| 53 | mkdir -p `dirname ${dest}/${file}` | ||
| 54 | realURL=${dest}/${file} | ||
| 55 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}_fos\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | ||
| 56 | touch ${ogWiki}/${base}/${file}.md | ||
| 57 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_fos.md | ||
| 58 | ln -sfr ${ogWiki}/${base}/${file}.md.md ${dest}/${file}_fos.md.md | ||
| 59 | rm ${ogWiki}/${base}/${file}.md | ||
| 60 | fi | 93 | fi |
| 61 | fi | 94 | fi |
| 62 | done | 95 | done |
| @@ -79,23 +112,38 @@ do | |||
| 79 | base=`echo "${line}" | cut -d '.' -f 1` | 112 | base=`echo "${line}" | cut -d '.' -f 1` |
| 80 | file=`echo "${line}" | cut -d '.' -f 2` | 113 | file=`echo "${line}" | cut -d '.' -f 2` |
| 81 | if [[ "${base}" != "Site" ]]; then | 114 | if [[ "${base}" != "Site" ]]; then |
| 82 | realURL=${ogWiki}/${base}/${file} | 115 | doit='false' |
| 83 | time=`date --rfc-3339=seconds -ur /opt/pmwiki/wiki.d/${base}.${file} | cut -d '+' -f 1` | 116 | if [ ! -s ${ogWiki}/${base}/${file}.HTM ]; then |
| 84 | mkdir -p ${ogWiki}/${base} | 117 | echo "NEW /opt/pmwiki/wiki.d/${base}.${file} ${ogWiki}/${base}/${file}.HTM" |
| 85 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | 118 | doit='true' |
| 86 | # echo "downloading ${ogURL}/?n=${base}.${file}?action=markdown" | 119 | elif [ /opt/pmwiki/wiki.d/${base}.${file} -nt ${ogWiki}/${base}/${file}.HTM ]; then |
| 87 | # curl --no-progress-meter ${ogURL}/?n=${base}.${file}?action=markdown -o ${ogWiki}/${base}/${file}.MARKDOWN | 120 | echo "NEWER /opt/pmwiki/wiki.d/${base}.${file}" |
| 88 | echo "downloading ${ogURL}/?n=${base}.${file}?action=print" | 121 | date --rfc-3339=seconds -ur /opt/pmwiki/wiki.d/${base}.${file} |
| 89 | 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 |
| 90 | # 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' |
| 91 | if [[ "${base}" == "Profiles" ]]; then | 124 | fi |
| 92 | dest="unsorted" | 125 | if [[ ${doit} == "true" ]]; then |
| 93 | realURL=${dest}/${file} | 126 | realURL=${ogWiki}/${base}/${file} |
| 94 | 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` |
| 95 | touch ${ogWiki}/${base}/${file}.md | 128 | mkdir -p ${ogWiki}/${base} |
| 96 | 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 |
| 97 | ln -sfr ${ogWiki}/${base}/${file}.md.md ${dest}/${file}_pm.md.md | 130 | # echo "downloading ${ogURL}/?n=${base}.${file}?action=markdown" |
| 98 | 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 | ||
| 99 | fi | 147 | fi |
| 100 | 148 | ||
| 101 | # TODO - groups are PmWiki/Onefang and PmWiki/Tiki | 149 | # TODO - groups are PmWiki/Onefang and PmWiki/Tiki |
| @@ -107,6 +155,8 @@ done | |||
| 107 | 155 | ||
| 108 | 156 | ||
| 109 | 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 | ||
| 110 | 160 | ||
| 111 | popd | 161 | popd |
| 112 | } | 162 | } |
