Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # DokuWiki helper script to fix the pages's last modified time stamp
- # to match the one recorded in the metadata.
- # This fixes pages shown as 'last modified by (external edit)', e.g. after
- # restoring the wiki from a backup without preserving the files' timestamp.
- #
- # Copyright (c) 2018 Damien Regad
- #
- # Revision history
- # 2018-06-19 Created
- # ----------------------------------------------------------------------------
- # Change this to point to your dokuwiki's data directory
- DW_DATA=~/dokuwiki/data
- # ----------------------------------------------------------------------------
- DW_PAGES=$DW_DATA/pages
- DW_META=$DW_DATA/meta
- # Process all pages in the wiki
- find $DW_PAGES -type f -printf "%P\t%T@\n" |
- while read file timestamp
- do
- # Remove file extension to get the page name with path
- page=${file%.*}
- # Page's history file - skip if it does not exist
- history=$DW_META/$page.changes
- [[ -e $history ]] || continue
- # Get the most recent timestamp in history file
- dw_time=$(tail -1 $history | cut -f1)
- # Reset the timestamp if the file's is more recent
- if [[ ${timestamp%.*} -gt $dw_time ]]
- then
- echo $page "- updating timestamp" $(date -Is --date="@$timestamp") "->" $(date -Is --date="@$dw_time")
- touch --date="@$dw_time" $DW_PAGES/$file
- fi
- done
Add Comment
Please, Sign In to add comment