Guest User

Untitled

a guest
Jun 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # DokuWiki helper script to fix the pages's last modified time stamp
  4. # to match the one recorded in the metadata.
  5. # This fixes pages shown as 'last modified by (external edit)', e.g. after
  6. # restoring the wiki from a backup without preserving the files' timestamp.
  7. #
  8. # Copyright (c) 2018 Damien Regad
  9. #
  10. # Revision history
  11. # 2018-06-19 Created
  12.  
  13. # ----------------------------------------------------------------------------
  14. # Change this to point to your dokuwiki's data directory
  15. DW_DATA=~/dokuwiki/data
  16.  
  17. # ----------------------------------------------------------------------------
  18.  
  19. DW_PAGES=$DW_DATA/pages
  20. DW_META=$DW_DATA/meta
  21.  
  22. # Process all pages in the wiki
  23. find $DW_PAGES -type f -printf "%P\t%T@\n" |
  24. while read file timestamp
  25. do
  26. # Remove file extension to get the page name with path
  27. page=${file%.*}
  28.  
  29. # Page's history file - skip if it does not exist
  30. history=$DW_META/$page.changes
  31. [[ -e $history ]] || continue
  32.  
  33. # Get the most recent timestamp in history file
  34. dw_time=$(tail -1 $history | cut -f1)
  35.  
  36. # Reset the timestamp if the file's is more recent
  37. if [[ ${timestamp%.*} -gt $dw_time ]]
  38. then
  39. echo $page "- updating timestamp" $(date -Is --date="@$timestamp") "->" $(date -Is --date="@$dw_time")
  40. touch --date="@$dw_time" $DW_PAGES/$file
  41. fi
  42. done
Add Comment
Please, Sign In to add comment