# fss-0002
# how to ssl: http://jackbaty.com/2005/12/27/lighttpd-and-ssl/

main:
  if [[ $(grep -m 1 -o '^t_web:[^:]*:' /etc/passwd) == "" ]] ; then adduser -l /bin/false -t target -g t_web -n web ; fi
  tkis_local_require turtle_version
  sed -i -e "s|usr/include|${TC}include|g" configure
  ./configure $CONF --with-ldap --with-attr --with-openssl --with-pcre --with-bzip2 --without-mysql --without-valgrind --with-ldap --sysconfdir=/home/targets/web/setting --with-linux-aio
  echo "#define HAVE_SQLITE3 1" >> config.h
  echo "#define HAVE_SQLITE3_H 1" >> config.h
  find -name Makefile -exec sed -i -e "s|^SQLITE_CFLAGS =|& $(pkg-config --cflags sqlite3)|g" '{}' ';'
  find -name Makefile -exec sed -i -e "s|^SQLITE_LIBS =|& $(pkg-config --libs sqlite3)|g" '{}' ';'
  make
  make install
  chmod oug-x /lib/mod_{access,accesslog,alias,auth,cgi,cml,compress,dirlisting,evasive,evhost,expire,fastcgi,flv_streaming,indexfile,magnet,proxy,redirect,rewrite,rrdtool,scgi,secdownload,setenv,simple_vhost,ssi,staticfile,status,trigger_b4_dl,usertrack,webdav,userdir,extforward}.la
  mv -v /lib/mod_{access,accesslog,alias,auth,cgi,cml,compress,dirlisting,evasive,evhost,expire,fastcgi,flv_streaming,indexfile,magnet,proxy,redirect,rewrite,rrdtool,scgi,secdownload,setenv,simple_vhost,ssi,staticfile,status,trigger_b4_dl,usertrack,webdav,userdir,extforward}.la ${TC}lib/
  mkdir -vp /home/websites/{fast-cgi,website}
  if [ ! -e /home/targets/web/settings/web.conf ] ; then cp -v ${PR}web.conf /home/targets/web/settings/ ; cp -v ${PR}index.html /home/websites/website/ ; fi
  cp -v ${PR}spawn-php.sh /bin/
  chgrp -R e_webserver /bin/spawn-php.sh /sbin/lighttpd /lib/mod_{access,accesslog,alias,auth,compress,dirlisting,evasive,evhost,flv_streaming,indexfile,proxy,redirect,rewrite,rrdtool,secdownload,setenv,simple_vhost,ssi,staticfile,status,trigger_b4_dl,userdir,usertrack,webdav,expire,cgi,cml,fastcgi,magnet,scgi,userdir,extforward}.so /sbin/lighttpd-angel
  if [[ -f /lib/mod_mysql_vhost.la ]] ; then chmod oug-x /lib/mod_mysql_vhost.la && mv -v /lib/mod_mysql_vhost.la ${TC}lib/ ; fi
  if [[ -f /lib/mod_mysql_vhost.so ]] ; then chgrp e_webserver /lib/mod_mysql_vhost.so ; fi
  if [[ -f /bin/spawn-fcgi ]] ; then chgrp e_webserver /bin/spawn-fcgi ; fi
  chgrp -R d_website /home/websites
  find /home/websites/ -type d -exec chmod g+s '{}' ';'
  sed -i -e "s|FILL_IN_VERSION_HERE|$turtle_version|" /home/websites/website/index.html
