Phillip Pearson - web + electronics notes

tech notes and web hackery from a new zealander who was vaguely useful on the web back in 2002 (see: python community server, the blogging ecosystem, the new zealand coffee review, the internet topic exchange).

2006-10-24

If you've held back from files in a PA update and broken something, here's how to selectively move to Subversion and fix it up

One dangerous option I included in the PA updater is the one to update all files that don't have conflicts, but leave everything else in place. This usually breaks your system :)

If you've used this option and ended up with a broken install, here's how to fix it. The example below uses the previously-broken idubb.com install.

(1) First, cd into your PA root dir. Then check out a copy of the latest code from Subversion and move the .svn directories into your install:

cd ~/public_html
svn checkout http://update.peopleaggregator.org/svn/release/pa pa_svn_latest
cd pa_svn_latest
for f in `find . -name .svn`; do mv $f ../; done

(2) Now go into MySQL (using the host/login/password/db in local_config.php)

mysql -u peopleaggregator -p peopleaggregator
(enter password)
select * from svn_objects where is_active=1 and held_revision is not null;

You'll get something like this:

+---------------------------------------------------------+------+----------------------------------+----------+-----------+---------------+
| path                                                    | kind | hash                             | revision | is_active | held_revision |
+---------------------------------------------------------+------+----------------------------------+----------+-----------+---------------+
| api/Invitation/Invitation.php                           | file | f4f0c8a7dac5950db1ce091231437a02 |        9 |         1 |            16 |
| web/Themes/Alpha/images/pa-logo.gif                     | file | 33d3095ec596ab354a5321ec47afdecc |        9 |         1 |            16 |
| web/homepage.php                                        | file | a6f3ac29057f7b09c3250289fc4b140f |        9 |         1 |            16 |
| web/BlockModules/InvitationModule/public_inner_html.tpl | file | 16bfeaf22dd8f82db34904fe094984a9 |       13 |         1 |            16 |
| web/Themes/Alpha/header_all.tpl                         | file | 21174ca7c74cc5b3996680f6b10f27ae |       13 |         1 |            16 |
| web/Themes/Alpha/footer.tpl                             | file | d253a24268ac6654c5765f1b9181f334 |       13 |         1 |            16 |
| config.inc                                              | file | e2454115a72ca2e298f1df2a2e896768 |       16 |         1 |            16 |
+---------------------------------------------------------+------+----------------------------------+----------+-----------+---------------+
7 rows in set (0.05 sec)

(3) Now you've got to update each of these files in turn. For each file, you've got to make a copy of what's on your system, then check out the appropriate version from Subversion, then move your file back in, and update to the latest version.

for f in api/Invitation/Invitation.php web/Themes/Alpha/images/pa-logo.gif web/homepage.php web/BlockModules/InvitationModule/public_inner_html.tpl web/Themes/Alpha/header_all.tpl web/Themes/Alpha/footer.tpl config.inc; do mv $f _asdf; svn update -r16 $f; mv _asdf $f; svn update $f; done

You'll see something like this:

Restored 'api/Invitation/Invitation.php'
U    api/Invitation/Invitation.php
Updated to revision 16.
G    api/Invitation/Invitation.php
Updated to revision 22.
Restored 'web/Themes/Alpha/images/pa-logo.gif'
U    web/Themes/Alpha/images/pa-logo.gif
Updated to revision 16.
C    web/Themes/Alpha/images/pa-logo.gif
Updated to revision 22.
Restored 'web/homepage.php'
U    web/homepage.php
Updated to revision 16.
C    web/homepage.php
Updated to revision 22.
Restored 'web/BlockModules/InvitationModule/public_inner_html.tpl'
U    web/BlockModules/InvitationModule/public_inner_html.tpl
Updated to revision 16.
C    web/BlockModules/InvitationModule/public_inner_html.tpl
Updated to revision 22.
A    web/Themes/Alpha/header_all.tpl
Updated to revision 16.
D    web/Themes/Alpha/header_all.tpl
Updated to revision 22.
Restored 'web/Themes/Alpha/footer.tpl'
U    web/Themes/Alpha/footer.tpl
Updated to revision 16.
C    web/Themes/Alpha/footer.tpl
Updated to revision 22.

If everything in there is A, U, G, or D, you're fine. If you see any Cs (C = conflict), your site is probably now even more broken than before. Not to worry, you now have enough clues to finish off the job :)

(4) Open each conflicting (C) file and look for text like this:

<<<<<<< .mine
        $invite_title = "Invite Colleagues and Friends to iDubb.com:";
=======
        $invite_title = "Invite friends and colleagues to join PeopleAggregator:";
>>>>>>> .r22

Now replace this whole lot with the correct version. (In this case it looks like the PA code had a grammar fix, but the same line had already been changed by the site operator to refer to iDubb.com, and Subversion isn't quite magical enough to merge this sort of thing.)

(5) Once you've done that for everything, run svn resolved to mark each file as up to date:

svn resolved web/Themes/Alpha/images/pa-logo.gif web/homepage.php web/BlockModules/InvitationModule/public_inner_html.tpl web/Themes/Alpha/footer.tpl

Your site should now be working, assuming you fixed all the conflicts properly!

In future, to update, go into your PA root directory, run svn update, then php web/update/run_scripts.php:

cd ~/public_html
svn update
php web/update/run_scripts.php

Update

An easier way to do this is probably to do step (2) first, then instead of steps (1) and (3), do this:

cd ~/public_html
svn checkout http://update.peopleaggregator.org/svn/release/pa pa_svn_latest
cd pa_svn_latest
svn update -r16 api/Invitation/Invitation.php web/Themes/Alpha/images/pa-logo.gif web/homepage.php web/BlockModules/InvitationModule/public_inner_html.tpl web/Themes/Alpha/header_all.tpl web/Themes/Alpha/footer.tpl config.inc
for f in `find . -name .svn`; do mv $f ../; done
svn update

Now move on to step (4) - look for conflicting files (marked C in the svn update output), fix them, and run svn resolved as above.

... more like this: []

PeopleAggregator on FreeBSD [IN PROGRESS]

We know of one FreeBSD PA install, so it's definitely possible. I don't have a FreeBSD VM though, so it's as good a time as any to install one.

I downloaded the 23MB bootonly ISO image and kicked off an install. It failed the first couple of times, until I realised that I had to select 'ftp (passive)' mode to get through the pair of NAT gateways (vmware, and my linux router) between the VM and the internet, and after that it started moving.

Oddly, I can get 600kB/sec downloading from ftp.freebsd.org to my server in the USA (and about 200kB/sec from there to my home in NZ), but only 14kB/sec if I try FTP directly from home to ftp.freebsd.org. So the network install is painfully slow; it's been running in the background for about half an hour and only downloaded 19MB.

Finally figured out that I can just open an ssh tunnel to a copy of squid running on my server, and download through that, getting 150-200 kB/sec. Once installed, here's what to do:

vi /etc/rc.conf

Add the line: sshd_enable="YES"

vi /etc/ssh/sshd_config

Uncomment the PermitRootLogin line and edit: PermitRootLogin yes

/etc/rc.d/sshd start
ifconfig

Now I can ssh to the IP address for lnc0 and log in as root.

pkg_add -r bash
/usr/local/bin/bash --login
export http_proxy=http://192.168.2.63:3129/
pkg_add -r emacs
pkg_add -r php5
emacs /etc/rc.conf

Add the line: apache_enable="YES"

emacs /usr/local/etc/apache/httpd.conf

Changed ServerName to minif2.

apachectl restart

An error occurred here - to debug, tail -f /var/log/httpd-error.log and run apachectl restart again. It turns out that it can't resolve minif2.localdomain, so I add that into /etc/hosts (add 'minif2 minif2.localdomain' to the end of the ::1 and 127.0.0.1 lines) and run apachectl restart again, and this time it works.

cd /usr/local/www/data
pkg_add -r subversion
svn checkout http://update.peopleaggregator.org/svn/release/pa

Now setting up Samba so I can resolve minif2 without having to edit the hosts file on my Windows box.

pkg_add -r samba
cd /usr/local/etc/rc.d
mv samba.sh.sample samba.sh
cd /usr/local/etc
cp smb.conf.default smb.conf
emacs smb.conf

Change workgroup to MYELIN.

/usr/local/etc/rc.d/samba.sh start

Now I can browse to http://minif2/pa from the host and get a setup icon to click on.

chmod a+w /usr/local/www/data-dist/pa/web/config Refresh to get huge list of errors. cd /usr/local/www/data/pa
chmod a+w log networks web/files web/cache web/sb-files
pkg_add -r pear-DB

Argh, looks like pear-DB depends on php4, so I'm probably going to have to install from ports rather than packages.

I'm getting tired of doing this; it's taking too long. I'm going to download ports in the background, and finish this off some other day. Now I remember why I was so happy when I could switch www.myelin.co.nz from a FreeBSD box to a Debian Linux one!

... more like this: []