if [ "$WIKI_PASSWORD" != "" ]; then
if [ -e $WIKI_PAGE ]; then
WIKI_PAGE=${WIKI_PAGE%%.*}
cookie=/tmp/cookie
if [ -e $cookie ]; then rm $cookie; fi
# Logging on to wiki
curl -q -c $cookie \
$WIKI_PROTOCOL://$WIKI_USER:$WIKI_PASSWORD@$WIKI_DOMAIN/$WIKI_LOGIN_PATH
form_token=`grep form_token $cookie | awk '{ print $7 }'`
echo -n $form_token > /tmp/token
# Find latest version of wikipage
curl -b $cookie -q -o /tmp/wikipage \
$WIKI_PROTOCOL://$WIKI_DOMAIN/$WIKI_PATH/$WIKI_PAGE?action=edit
wiki_version=`grep hidden /tmp/wikipage | grep version | awk -F'"' '{print $6}'`
# Uploading wiki
curl -q -b $cookie -F "text=<$WIKI_PAGE.wiki" \
-F "action=edit" -F "__FORM_TOKEN=</tmp/token" \
-F "version=$wiki_version" \
$WIKI_PROTOCOL://$WIKI_DOMAIN/$WIKI_PATH/$WIKI_PAGE
else
echo "WIKI_PAGE[$WIKI_PAGE] does not exist"
exit
fi
else
echo "WIKI_PASSWORD[$WIKI_PASSWORD] must be specified"
exit
fi
leave a comment