Almost-minimal filesystem based blog.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
772 B

  1. #!/bin/sh
  2. entry="$1"
  3. property="$2"
  4. # Complain and exit if we weren't given a path and a property:
  5. if [ ! "$entry" ] || [ ! "$property" ]; then
  6. echo "Usage: wrt addprop <path> <property>"
  7. exit 64
  8. fi
  9. if [ ! -e "$entry" ]; then
  10. echo "$entry not found"
  11. exit 66
  12. fi
  13. # If the target is a plain file instead of a directory, make it into
  14. # a directory and move the content into $entry/index:
  15. if [ -f "$entry" ]; then
  16. # Get a safe temporary file:
  17. tempfile=`mktemp`
  18. echo "move $entry to $entry/index"
  19. mv "$entry" "$tempfile"
  20. mkdir "$entry"
  21. mv "$tempfile" "$entry/index"
  22. fi
  23. if [ -d "$entry" ]; then
  24. echo "touch $entry/$property.prop"
  25. touch "$entry/$property.prop"
  26. else
  27. echo "something broke - why isn't $entry a directory?"
  28. file "$entry"
  29. fi
  30. exit 0