#!/bin/rc -e # tcp80init: set up tcp80 namespace and log files # run as hostowner # example: # ; tcp80init /usr/web path/of/domain1 path/of/domain2 # domain1 and domain2 directories will appear as # /domain1 and /domain2 in tcp80's namespace # configure these in tcp80.c, compile, and copy the # resulting binary tcp80 to $bin rfork e log=/sys/log/tcp80 ns=/lib/namespace.tcp80 tmp=/tmp/tcp80init.$pid bin=/rc/bin/service/tcp80 if(~ $#* 0){ echo usage: tcp80init webroot '[hostroot...]' >[1=2] exit usage } root=`{cleanname -d `{pwd} $1} shift for(i) if(! test -d $i){ echo $i not a dir >[1=2] exit 'not a dir' } mkdir -p $root if(! test -e $log){ touch $log chmod +a $log chmod a+w $log } >$tmp { for(i){ i=`{cleanname -d `{pwd} $i} d=$root/`{basename $i} mkdir -p $d echo bind $i $d } for(i in /env/timezone $log){ mkdir -p $root^`{basename -d $i} touch $root^$i echo bind $i $root^$i } echo bind $root / } mv $tmp $ns >[1=2] { ls -l $log echo $root: du -a $root echo $ns: cat $ns if(test -e $bin) ls -l $bin if not echo $bin does not exist }