Think Tank Workspaces

werc

Long awaited I wanted to use this for many years but too many other roadblocks in my life. I do have plans to revise this when I get a chance and clean things up. But my notes seemed valuable to me at the time.

This is for 9front instllation only

setup rc-httpd

touch /rc/bin/rc-httpd/select-handler
#!/bin/rc
PATH_INFO=$location
switch($SERVER_NAME) {
case 172.27.0.67
    FS_ROOT=/usr/glenda/www/yoda
    exec static-or-index
case*
    error 503
}

file permission.

Obviously this pertains to displaying webpage in glendas directory under yoda.

touch /usr/glenda/www/yoda/index.html
touch /sys/doc/www
chgrp sys /sys/doc/www
chmod +aw www
mv /rc/bin/service/!tcp80 /rc/bin/service/tcp80

If you are Glenda I guess the above will work But really you want to cp the service to the user that will run it cp /rc/bin/service/!tcp80 /usr/www/bin/service/tcp80 have that user run it as follows:

aux/listen -d /usr/www/bin/service tcp

This all seems faily simple. However we really want to create a new user for web related stuff and have werc as our framework.

My select-handler is as follows:

#!/bin/rc


if(~ $SERVER_NAME cirno){
    PATH_INFO=$location
    FS_ROOT=/usr/www/werc/sites/$SERVER_NAME
 	exec static-or-cgi /usr/www/werc/bin/werc.rc
}
if(~ $SERVER_NAME 172.27.0.67){
    PATH_INFO=$location
    FS_ROOT=/usr/www/werc/sites/$SERVER_NAME
    exec static-or-cgi /usr/www/werc/bin/werc.rc
}
if not
    error 503

I can connect to both sites via mothra

mothra http://172.27.0.67
mothra http://cirno

This is within virtual box and or qemu

I can also connect to it in Linux or Mac provided I have /etc/hosts cirno 172.27.0.67

The named routing is nice. If I pass an IP its automatically routed to correct location same with the name.

So as you can see above the user www manages this cirno using 'static-or-cgi'. So lets add a user.

auth/keyfs
echo newuser www >> /srv/cwfs.cmd or hjfs.cmd which ever you use
echo newuser upas +www >> /srv/cwfs.cmdf
auth/changeuser www
Password: not glend's password please pick a new one
auth/enable www

Now the new user is created lets log in.

I'm already connected to my plan9 cpu server via drawterm. So really I don't want to draw another window.

You can run rcpu

rcpu -u www

type in password

If you can then type /sys/lib/newuser to create a rio environment. After that is complete if you want to run rio that could be useful to prevent type rcpu a bunch of times for multiple terminals.

Next lets download werc

hg clone https://code.9front.org/hg/werc/

I think you can get this with git now.

It will take a bit to download depending on internet connection. But this is light weight. So really you just downloading a bunch of mecurial data along with werc.

The first thing you need to do is edit

/werc/etc/initrc:21 # line 21

Honestly I think this mostly pertained to configurations on another Nix based OS. For me the line is as follows.

path=(. ./bin ./bin/contrib /bin)

You still need the '.' for the current path but /usr/bin doesn't exist and neither does plan9port

lets setup the enviornment.

Plenty of documentation exists but basicly you are leveraging a bunch of .inc include files, .tmpl templates and all of that is magically driven by rc and awk scripts. All smartly writen ofcourse to make your world easy. Faster development and less code.

Here are the default sites

cpu% pwd
/usr/www/werc/sites
cpu% ls -l
--rw-r--r-- M 110 www www 0 Jan 17 13:38 CREATE-SITE-DIRECTORIES-HERE
d-rwxr-xr-x M 110 www www 0 Jan 17 13:38 default.cat-v.org
d-rwxr-xr-x M 110 www www 0 Jan 17 13:38 tst.cat-v.org
d-rwxr-xr-x M 110 www www 0 Jan 17 13:38 werc.cat-v.org

let's create new ones

mkdir /usr/www/werc/sites/172.27.0.67
mkdir /usr/www/werc/sites/cirno
touch /usr/www/werc/sites/172.27.0.67/index.md
touch /usr/www/werc/sites/cirno/index.md
echo 'hello from 172.27.0.0' > /usr/www/werc/sites/172.27.0.67/index.md
echo 'hello from cirno' > /usr/www/werc/sites/cirno/index.md

The sites are still not ready yet. Lets get the templates working. All of these templates are in other site example directories so you could possibly just copy and paste or zip and unzip into the right directories.

First site: 172.27.0.67

mkdir /usr/www/werc/sites/172.27.0.67/_werc
touch /usr/www/werc/sites/172.27.0.67/_werc/config

Let's edit the file

acme /usr/www/werc/sites/172.27.0.67/_werc/config
masterSite=blah.com
siteTitle='Blah'
siteSubTitle='Silly sub title'
conf_enable_comments
conf_enable_wiki

don't forget to add a new line after

'conf_enable_wiki'

Second site: cirno

Cirno config

lets do the same to the other site

mkdir /usr/www/werc/sites/cirno/_werc
touch /usr/www/werc/sites/cirno/_werc/config

Let's edit the file

acme /usr/www/werc/sites/cirno/_werc/config
masterSite=thinktank.com
siteTitle='Think Tank'
siteSubTitle='Explore Cool things'
conf_enable_comments
conf_enable_wiki

don't forget to add a new line after

'conf_enable_wiki'

The sites are still not ready. We need to add the include files. Yes you can visit them and the default templates will be utilized but we want to customize the templates

mkdir /usr/www/werc/sites/172.27.0.67/_werc/lib
touch /usr/www/werc/sites/172.27.0.67/_werc/lib/footer.inc
touch /usr/www/werc/sites/172.27.0.67/_werc/lib/top_bar.inc
acme /usr/www/werc/sites/172.27.0.67/_werc/lib/footer.inc
<br class="doNotDisplay doNotPrint" />
<div style="margin-right: auto;"><a href="http://werc.cat-v.org">Powered by werc</a></div>
<div><form action="/_search/" method="POST"><input type="text" id="searchtext" name="q"> <input type="submit" value="Search"></form></div>
acme /usr/www/werc/sites/172.27.0.67/_werc/lib/top_bar.inc
<div class="left">
  <a href="http://quotes.cat-v.org">quotes</a> |
  <a href="http://harmful.cat-v.org">harmful</a> |
  <a href="http://9p.cat-v.org/">9P</a> |
  <a href="http://cat-v.org">cat-v.org</a>
</div>
<div class="right">
  <span class="doNotDisplay">Related sites:</span>
  | <a href="http://cat-v.org/update_log">site updates</a>
  | <a href="/sitemap">site map</a> |
</div>

other site

mkdir /usr/www/werc/sites/cirno/_werc/lib
touch /usr/www/werc/sites/cirno/_werc/lib/footer.inc
touch /usr/www/werc/sites/cirno/_werc/lib/top_bar.inc
acme /usr/www/werc/sites/cirno/_werc/lib/footer.inc
<br class="doNotDisplay doNotPrint" />
<div style="margin-right: auto;"><a href="http://werc.cat-v.org">Powered by werc</a></div>
<div><form action="/_search/" method="POST"><input type="text" id="searchtext" name="q"> <input type="submit" value="Search"></form></div>
acme /usr/www/werc/sites/cirno/_werc/lib/top_bar.inc
<div class="left">
  <a href="http://quotes.cat-v.org">quotes</a> |
  <a href="http://doc.cat-v.org">docs</a> |
  <a href="http://repo.cat-v.org">repo</a> |
  <a href="http://go-lang.cat-v.org">golang</a> |
  <a href="http://sam.cat-v.org">sam</a> |
  <a href="http://man.cat-v.org">man</a> |
  <a href="http://acme.cat-v.org">acme</a> |
  <a href="http://glenda.cat-v.org">Glenda</a> |
  <a href="http://ninetimes.cat-v.org">9times</a> |
  <a href="http://harmful.cat-v.org">harmful</a> |
  <a href="http://9p.cat-v.org/">9P</a> |
  <a href="http://cat-v.org">cat-v.org</a>
</div>
<div class="right">
  <span class="doNotDisplay">Related sites:</span>
  | <a href="http://cat-v.org/update_log">site updates</a>
  | <a href="/sitemap">site map</a> |
</div>

Both sites should be up and running

but with differnt headers

Lets add users and get comments running.

lets do the same to the other site:

bin/aux/addwuser.rc william mysecretpass admin

We also need to add

conf_enable_app 

to

sites/cirno_werc/config

So you need to log in in order to add a comment. When I log in I still get an error writing data.

Auth: success
umask: '/bin/umask' directory entry not found
mkdir: can't create sites/cirno/_werc/comments: 'sites/cirno/_werc/comments' access permission denied
ERROR XXX: Could not create comment:  mkdir 57899: error
cirno/ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15 - POST - md_handler sites/cirno/index.md - lib/default_master.tpl
Mon Jan 17 14:54:06 PST 2022 :: cirno :: POST / HTTP/1.1 :: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15 :: 200 :: http://cirno/
tee: cannot open /tmp/fltr_cache/8abfe6173693d0f2edb5404b78cd9aa804db02d6/57917: '/tmp/fltr_cache' does not exist
mv: can't stat /tmp/fltr_cache/8abfe6173693d0f2edb5404b78cd9aa804db02d6/57917: '/tmp/fltr_cache' does not exist
Auth: success
Mon Jan 17 14:54:07 PST 2022 :: cirno :: GET /pub/style/style.css HTTP/1.1 :: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15 :: 200 :: http://cirno/

Not really sure why I get this error. The user www should have full access to everything. However I suspect an issue with one of the files /bin/umask does not exist in plan9. So I did a grep to search for it I found it in two areas.

/usr/www/werc/apps/bridge/app.rc:88. I would comment it out

I also belive app.rc:91 is incorrect

I think app.rc:91 should be

mkdir -p $dir &&
Auth: success
sites/cirno/_werc/comments/1642460857/user: ./apps/bridge/app.rc:93: can't open: 'sites/cirno/_werc/comments' does not exist
Mon Jan 17 15:07:37 PST 2022 :: cirno :: POST / HTTP/1.1 :: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15 :: 200 :: http://cirno/

I still got another error. I guess you need to create the directory 'comments' in sites/cirno/werc/

so I had to manually run

mkdir -p comments while in sites/cirno/werc/ directory and then run

chmod 777 comments

Not exactly happy about that but it works.

Wiki is also another issue and required the following

mkdir -p sites/cirno/index.md_werc
chmod 777 index.md_werc
chmod 777 index.md

This is all silly until I figure out why this won't assume user correctly.


updates by running as user www I don't have to run chmod 777.

All I need to do is

mkdir -p comments
chmod +wx comments
mkdir -p sites/cirno/index.md_werc
chmod +wx index.md_werc
chmod +wx index.md

So I just learned more from list server

when you boot the system, $user is the hostowner, which refers to the owner of the kernel process. the hostowner ends up owning the disk file server process, as well, but the disk file server programs don't provide any automatic mechanism for violating disk file permissions without writing code or abusing the system's running processes with a special tool such as acid(1).

disk file permissions are completely separate from kernel process permissions, and are controlled by the disk file server process (cwfs or hjfs). by convention, plan 9 arranges for the kernel, auth, and disk file server to honor matching usernames, even though technically they're separate entities.

it looks like your system is running rc-httpd via a tcp80 script launched by the default listen(8) process, which ends up being owned by the special user none, rather than your chosen user www.

here's what i do for 9front.org:

first, move the /rc/bin/services/tcp80 script into /cfg/$sysname/service.www/

then add the following to /cfg/$sysname/cpustart:

auth/as www aux/listen -p 128 -t /cfg/$sysname/service.www

when you reboot, this will start a listener running as user www on the directory /cfg/$sysname/service.www/, and any listener script you put in there will in turn be run as user www.

sl


On my mac mini

mkdir /cfg/$sysname/service.www
mkdir /cfg/$sysname/cpustart
cp /rc/bin/services/!tcp80 /cfg/$sysname/service.www/tcp80
acme /cfg/$sysname/cpustart
auth/as www aux/listen -p 128 -t /cfg/$sysname/service.www

Don't forget to add a new line after auth/as statement above

I will revise this later. But I wanted to keep the notes anyways.

I think the big thing I have learned working with plan9 is efficiency. I have worked without a lot of webservers including python django and flask running gunicorn and nginx for media. Lazy work and tons of rewrites and changes etc...I'm honestly tired of creating a websites for others and the last thing I want to do is build that for myself.

This is where werc seems to shine.

Once I had all this working on my local plan9 machines it was easy to tar.tgz werc and /cfg and move to thinktankworkspaces.com.

After that it was trivial to copy over all the domains and start making changes.


To post a comment you need to login first.