diff options
Diffstat (limited to 'SuckIt')
| -rwxr-xr-x | SuckIt | 148 |
1 files changed, 86 insertions, 62 deletions
| @@ -4,9 +4,9 @@ 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 |
| @@ -33,50 +33,62 @@ do | |||
| 33 | base=`echo "${line}" | cut -d '/' -f 1` | 33 | base=`echo "${line}" | cut -d '/' -f 1` |
| 34 | file=`echo "${line}" | cut -d '/' -f 2- | rev | cut -b 5- | rev` | 34 | 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 | 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 | realURL=${ogWiki}/${base}/${file} | 36 | doit='false' |
| 37 | time=`date --rfc-3339=seconds -ur /opt/Foswiki/data/${base}/${file}.txt | cut -d '+' -f 1` | 37 | if [ ! -s ${ogWiki}/${base}/${file}.HTM ]; then |
| 38 | mkdir -p ${ogWiki}/${base} | 38 | echo "NEW /opt/Foswiki/data/${base}/${file}.txt" |
| 39 | mkdir -p ${ogWiki}/${base}/`dirname ${file}` | 39 | doit='true' |
| 40 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | 40 | elif [ /opt/Foswiki/data/${base}/${file}.txt -nt ${ogWiki}/${base}/${file}.HTM ]; then |
| 41 | echo "downloading ${ogURL}/${base}/${file}?cover=print" | 41 | 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. | 42 | 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 | 43 | 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. | 44 | 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 | 45 | 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. | 46 | if [[ ${doit} == "true" ]]; then |
| 60 | # Skipping anything with "<a href="/Main/UnknownUser">UnknownUser</a></span></div>". | 47 | realURL=${ogWiki}/${base}/${file} |
| 61 | if [[ "${base}" == "Sandbox" ]]; then | 48 | time=`date --rfc-3339=seconds -ur /opt/Foswiki/data/${base}/${file}.txt | cut -d '+' -f 1` |
| 62 | dest="unsorted" | 49 | mkdir -p ${ogWiki}/${base} |
| 63 | mkdir -p `dirname users/${file}` | 50 | 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" | 51 | 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 | 52 | echo "downloading ${ogURL}/${base}/${file}?cover=print" |
| 66 | dest="" | 53 | # 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. |
| 54 | curl --silent --no-progress-meter ${ogURL}/${base}/${file}?cover=print -o ${ogWiki}/${base}/${file}.HTM | ||
| 55 | # Attempt to separate user profiles from user content. Doesn't work when people turn their profiles into content. | ||
| 56 | dest="" | ||
| 57 | if [[ "${base}" == "Main" ]]; then | ||
| 58 | dest="unsorted" | ||
| 59 | if [ -L users/${file}_fos.md ]; then | ||
| 60 | dest='users' | ||
| 61 | fi | ||
| 62 | mkdir -p `dirname users/${file}` | ||
| 63 | sed -i -E ${ogWiki}/${base}/${file}.HTM -e "s%<a href=\"/System/UserForm\">UserForm</a>%%w users/${file}_fos.SED" | ||
| 64 | if [ -s users/${file}_fos.SED ]; then | ||
| 65 | dest="users" | ||
| 66 | fi | ||
| 67 | rm users/${file}_fos.SED >/dev/null 2>&1 | ||
| 68 | rm -d `dirname users/${file}` >/dev/null 2>&1 | ||
| 69 | fi | ||
| 70 | # "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. | ||
| 71 | # Skipping anything with "<a href="/Main/UnknownUser">UnknownUser</a></span></div>". | ||
| 72 | if [[ "${base}" == "Sandbox" ]]; then | ||
| 73 | dest="unsorted" | ||
| 74 | mkdir -p `dirname users/${file}` | ||
| 75 | sed -i -E ${ogWiki}/${base}/${file}.HTM -e "s%<a href=\"/Main/UnknownUser\">UnknownUser</a></span></div>%%w users/${file}_fos.SED" | ||
| 76 | if [ -s users/${file}_fos.SED ]; then | ||
| 77 | dest="" | ||
| 78 | fi | ||
| 79 | rm users/${file}_fos.SED >/dev/null 2>&1 | ||
| 80 | rm -d `dirname users/${file}` >/dev/null 2>&1 | ||
| 67 | fi | 81 | fi |
| 68 | rm users/${file}_fos.SED >/dev/null 2>&1 | ||
| 69 | rm -d `dirname users/${file}` >/dev/null 2>&1 | ||
| 70 | fi | ||
| 71 | 82 | ||
| 72 | if [[ "${dest}" != "" ]]; then | 83 | if [[ "${dest}" != "" ]]; then |
| 73 | mkdir -p `dirname ${dest}/${file}` | 84 | mkdir -p `dirname ${dest}/${file}` |
| 74 | realURL=${dest}/${file} | 85 | 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 | 86 | 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 | 87 | touch ${ogWiki}/${base}/${file}.md |
| 77 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_fos.md | 88 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_fos.md |
| 78 | ln -sfr ${ogWiki}/${base}/${file}.md.md ${dest}/${file}_fos.md.md | 89 | ln -sfr ${ogWiki}/${base}/${file}.md.md ${dest}/${file}_fos.md.md |
| 79 | rm ${ogWiki}/${base}/${file}.md | 90 | rm ${ogWiki}/${base}/${file}.md |
| 91 | fi | ||
| 80 | fi | 92 | fi |
| 81 | fi | 93 | fi |
| 82 | done | 94 | done |
| @@ -99,26 +111,38 @@ do | |||
| 99 | base=`echo "${line}" | cut -d '.' -f 1` | 111 | base=`echo "${line}" | cut -d '.' -f 1` |
| 100 | file=`echo "${line}" | cut -d '.' -f 2` | 112 | file=`echo "${line}" | cut -d '.' -f 2` |
| 101 | if [[ "${base}" != "Site" ]]; then | 113 | if [[ "${base}" != "Site" ]]; then |
| 102 | realURL=${ogWiki}/${base}/${file} | 114 | doit='false' |
| 103 | time=`date --rfc-3339=seconds -ur /opt/pmwiki/wiki.d/${base}.${file} | cut -d '+' -f 1` | 115 | if [ ! -s ${ogWiki}/${base}/${file}.HTM ]; then |
| 104 | mkdir -p ${ogWiki}/${base} | 116 | 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 | 117 | doit='true' |
| 106 | # echo "downloading ${ogURL}/?n=${base}.${file}?action=markdown" | 118 | 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 | 119 | echo "NEWER /opt/pmwiki/wiki.d/${base}.${file}" |
| 108 | echo "downloading ${ogURL}/?n=${base}.${file}?action=print" | 120 | 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 | 121 | 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. | 122 | doit='true' |
| 111 | if [[ "${base}" == "Profiles" ]]; then | 123 | fi |
| 112 | dest="unsorted" | 124 | if [[ ${doit} == "true" ]]; then |
| 113 | if [ -L users/${file}_pm.md ]; then | 125 | realURL=${ogWiki}/${base}/${file} |
| 114 | dest='users' | 126 | time=`date --rfc-3339=seconds -ur /opt/pmwiki/wiki.d/${base}.${file} | cut -d '+' -f 1` |
| 127 | mkdir -p ${ogWiki}/${base} | ||
| 128 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | ||
| 129 | # echo "downloading ${ogURL}/?n=${base}.${file}?action=markdown" | ||
| 130 | # curl --no-progress-meter ${ogURL}/?n=${base}.${file}?action=markdown -o ${ogWiki}/${base}/${file}.MARKDOWN | ||
| 131 | echo "downloading ${ogURL}/?n=${base}.${file}?action=print" | ||
| 132 | curl --no-progress-meter ${ogURL}/?n=${base}.${file}?action=print -o ${ogWiki}/${base}/${file}.HTM | ||
| 133 | # 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. | ||
| 134 | if [[ "${base}" == "Profiles" ]]; then | ||
| 135 | dest="unsorted" | ||
| 136 | if [ -L users/${file}_pm.md ]; then | ||
| 137 | dest='users' | ||
| 138 | fi | ||
| 139 | realURL=${dest}/${file} | ||
| 140 | echo -e "ogWiki=${ogWiki}\nogURL=${ogURL}\nrealURL=${realURL}_pm\nogBase=${base}\nogFile=${file}\ntimestamp=${time}\n" > ${ogWiki}/${base}/${file}.md.md | ||
| 141 | touch ${ogWiki}/${base}/${file}.md | ||
| 142 | ln -sfr ${ogWiki}/${base}/${file}.md ${dest}/${file}_pm.md | ||
| 143 | ln -sfr ${ogWiki}/${base}/${file}.md.md ${dest}/${file}_pm.md.md | ||
| 144 | rm ${ogWiki}/${base}/${file}.md | ||
| 115 | fi | 145 | 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 | 146 | fi |
| 123 | 147 | ||
| 124 | # TODO - groups are PmWiki/Onefang and PmWiki/Tiki | 148 | # TODO - groups are PmWiki/Onefang and PmWiki/Tiki |
