sg-data-dirs.sh 940 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/ash
  2. ## 'sg-data' partition should be already mounted here
  3. _WWW='/www'
  4. ## check is /www in mounted
  5. ## for as long as 30 seconds
  6. n=0
  7. while ! mountpoint -q $_WWW; do [ $n -gt 30 ] && exit 1;
  8. sleep 1
  9. let n++
  10. done
  11. unset n
  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. )
  33. ## reload Lighttpd since it might have had open files in /www
  34. killall -HUP lighttpd
  35. exit 0