source: ValBot/Bash/drive_https_upgrade.sh@ 1176

Last change on this file since 1176 was 1169, checked in by iritscen, 3 years ago

ValBot: Reorganized files. Updated docs with more helpful information.

  • Property svn:executable set to *
File size: 1.3 KB
RevLine 
[1169]1#!/bin/bash
2
3IFS="
4"
5
6CORE="/path/to/Pywikibot/core"
7SUMMARY="changing link from http->https"
8RATE=6
9FIX_START=551
10FIX_END=650
11
12cd "$CORE"
13if [ ! -f "pwb.py" ]; then
14 echo "drive_https_upgrade.sh: Can't launch Pywikibot!"
15 exit
16fi
17
18echo "drive_https_upgrade.sh: Starting at fix $FIX_START..."
19
20FIX_CUR=0
21LAST_RUN=0
22for THE_LINE in `cat "/path/to/ValExtLinks report.txt"`; do
23 if [[ $THE_LINE =~ .*http-\>https.* ]]; then
24 let FIX_CUR+=1
25 if [ $FIX_CUR -lt $FIX_START ]; then
26 continue
27 fi
28 if [ $FIX_CUR -gt $FIX_END ]; then
29 echo "drive_https_upgrade.sh: Stopped after fix $FIX_END."
30 exit
31 fi
32
33 # Wait for rate limit to expire if we have run the Python script before in this session
34 if [ $LAST_RUN -gt 0 ]; then
35 CUR_TIME=$(date +%s)
36 WAIT_REMAINDER=$(($RATE - $CUR_TIME + $LAST_RUN))
37 if [ $WAIT_REMAINDER -gt 0 ]; then
38 echo "drive_https_upgrade.sh: Waiting $WAIT_REMAINDER second(s)."
39 sleep $WAIT_REMAINDER
40 fi
41 fi
42 ON_PAGE=${THE_LINE#*page \'}
43 ON_PAGE=${ON_PAGE%%\'*}
44 FROM_LINK=${THE_LINE#*URL \'}
45 FROM_LINK=${FROM_LINK%%\'*}
46 TO_LINK=${THE_LINE%\'*}
47 TO_LINK=${TO_LINK##*\'}
48 LAST_RUN=$(date +%s)
49 python pwb.py replace -page:"$ON_PAGE" "$FROM_LINK" "$TO_LINK" -summary:"$SUMMARY" -always
50 fi
51done
Note: See TracBrowser for help on using the repository browser.