## some checks specific to SuperGlue

## where SuperGlue storage is mounted 
_SG=/www/htdocs

## mount if needed
mountpoint -q $_SG || block mount $_SG

## if /www is mounted
mountpoint -q $_SG && (

  ## if not writable chown with httpd
  [ $(stat $_SG -c %U) != 'httpd' ] && chown -R httpd $_SG
  [ $(stat $_SG -c %a) -lt '755' ] && chmod -R u+rwX $_SG

  ## check if index.html is present
  [ -e $_SG/index.html ] || (
    cp /www/lib/resources/index.html $_SG
    chown httpd $_SG/index.html
    )

  ## check symlinking
  for i in devTools resources templates; do
    [ -L $_SG/$i ] || ln -s /www/lib/$i $_SG/$i
  done

  ## if /www/tmp does not exist
  [ -d /www/tmp ] || (
    mkdir /www/tmp && chown httpd /www/tmp
    )
  )
)

exit 0
