99-sg-dirs 824 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/ash
  2. set -o xtrace
  3. ## USB drive should be already mounted here
  4. _WWW="/www"
  5. n=0
  6. while ! mountpoint -q $_WWW; do [ $n -gt 30 ] && exit 1;
  7. sleep 1
  8. let n++
  9. done
  10. unset n
  11. ## if /www is mounted, then..
  12. _HTDOCS="$_WWW/htdocs"
  13. ## make ./htdocs if there is none
  14. [ -e $_HTDOCS ] || mkdir $_HTDOCS
  15. ## if not writable chown with httpd
  16. [ $(stat $_HTDOCS -c %U) == 'httpd' ] || chown -R httpd $_HTDOCS
  17. [ ! $(stat $_HTDOCS -c %a) -lt '755' ] || chmod -R u+rwX $_HTDOCS
  18. ## check if index.html is present
  19. [ -e $_HTDOCS/index.html ] || (
  20. cp /opt/lib/resources/demo.html $_HTDOCS/default.html
  21. chown httpd $_HTDOCS/default.html
  22. )
  23. ## check for log directory
  24. [ -e $_WWW/log ] || (
  25. mkdir $_WWW/log
  26. chown httpd $_WWW/log
  27. )
  28. ## check for tmp directory
  29. [ -e $_WWW/tmp ] || (
  30. mkdir $_WWW/tmp
  31. chown httpd $_WWW/tmp
  32. )