[Server-devel] XS on XO Setup as Contingency for Main Power Outage

Anna aschoolf at gmail.com
Wed Dec 15 19:09:55 EST 2010


Sorry this is so long, but I thought I'd post this in case someone else
needed something similar.  Also, any suggestions to make this more efficient
are more than welcome.

How I set up an "emergency use" XS on an XO-1

Since I run a public XS on a big old Dell in my house, I needed a solid
contingency plan should the power go out.  While I have my XS on a UPS, it's
small and cheap and only keeps it up about half an hour.  I do have a power
inverter that we hook up to a car battery, which keeps the DSL modem, and
thus our internet, up for many hours so we can use our netbooks.  Charging
an XO shouldn't add that much more drain.  So to keep my users happy and
chatting while I surf the web in the dark, I set up the XS on an XO-1.  This
will also be useful in the summer should my A/C unit go out when it's 100
degrees and I don't want my regular equipment to overheat.

I followed the instructions here to set up an 8 GB SD card:
http://wiki.laptop.org/go/XS-on-XO

It takes forever for the first boot, of course, while moodle initializes.
Log in as root, and set the root password.  Add a user for ssh.  It doesn't
have to be olpc.

adduser olpc
passwd olpc

Plug in a USB ethernet adapter.  The one I got at OLPC-SF works very well.
Run updates.

yum -y update

When that finishes, reboot.

I know you're supposed to do this right away after first boot and login, but
that gave me problems for some reason.  Anyway, now after I have the first
boot and updates over with, I set the domain.  Since I'm using the XSXO as a
backup for the XS, I set the domain to the XS's.

/etc/sysconfig/olpc-scripts/domain_config example.org

Enable password authentication in /etc/ssh/sshd_config and /etc/ssh/
sshd_config.in  You should be able to edit only sshd_config and then run
"make -f /etc/xs-config.make sshd_config" to do up sshd_config.in properly,
but never cooperates for me so I simply edit both files.

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no
#PasswordAuthentication no

Go ahead and reboot.  ssh in with your user and password.

****************
* Apache setup *
****************

Since this is an "emergency" XSXO, I'm not going to run Moodle.  I also need
a simple index page to let my users know what's going on.

Change the listen directives in /etc/httpd/conf/httpd-xs.conf to just this:

Listen 80

Stop Moodle from being the default homepage

mv /etc/httpd/conf.d/010-make-moodle-default.conf
/etc/httpd/conf.d/010-make-moodle-default.conf.bak

Set up an informative page in /var/www/html as index.html

<html>
<head><title>Emergency XSXO</title></head>
<body>
<br>
If you can see this, I'm running the XS on an XO</br>
<br>
It might be a power outage or I might be doing maintenance on the "big"
XS</br>
<br>
If you already have an ejabberd account on the usual XS, it's been migrated
over.</br>
<br>
<FONT COLOR="red">If you're just getting here and don't have an account,
here's the server info:</br>
<b></br>
<b>Server:  schoolserver.example.org</b></br>
<b>Port:  5223</b></FONT>
<br>
<a href="../cgi-bin/sysinfo.sh"><h3>Monitor System Stats</h3></a>
<br>
</body>
</html>

A cgi script is nice to see some XSXO system information, particularly how
the battery is doing.  Put this in /var/www/cgi-bin as sysinfo.sh and chmod
a+x sysinfo.sh

#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<html><head><title>XSXO System Information"
echo "</title></head><body>"

echo "<h1>General system information for XSXO on  $(hostname)</h1>"
echo ""

echo "<h1> Battery Status</h1>"
echo "<pre> $(cat /sys/class/power_supply/olpc-battery/capacity)%  $(cat
/sys/class/power_supply/olpc-battery/status)</pre>"

echo "<h1>Memory Info</h1>"
echo "<pre> $(free -m) </pre>"

echo "<h1>Disk Info:</h1>"
echo "<pre> $(df -h) </pre>"

echo "<br></br>"

echo "<h2>Information generated on $(date)</h2>"
echo "</body></html>"

echo "<br>"
echo "<a href="../index.html"><h3>Home Page<h3></a>"

Since the XSXO will be exposed to the internet, I create robots.txt in
/var/www/html to try and keep the spiders away.

User-agent: *
Disallow: /

Restart httpd and test the changes.

******************
* Ejabberd Setup *
******************

Sometimes my users use XOs, but most of the time they like other clients,
like finch, pidgin, adium, etc.  It's useful to be able to reset passwords
or delete accounts via the web interface.  It's also useful for the admin
user to be able to create a persistent chat room.  To do that, I login as
the admin user with psi, create a room named "chat" and then configure it to
be persistent.

As I did with ssh, I go ahead and edit both /etc/ejabberd/ejabberd-xs.cfg
and /etc/ejabberd/ejabberd-xs.cfg.in as I've never quite gotten 'make -f
/etc/xs-config.make' to behave.

To allow admin login, uncomment this line.

{acl, admin, {user, "admin", "schoolserver.example.org"}}.

To allow web access, uncomment these lines.

  {5280, ejabberd_http, [
                         inet6,
             http_poll,
             web_admin
            ]}

To allow the admin user to configure persistent chat rooms, add  _admin to
the the lines below like so.

  {mod_muc,      [
          {host, "conference. at HOST@"},
          {access, muc},
          {access_create, muc},
          {access_persistent, muc_admin},
          {access_admin, muc_admin}

Restart the ejabberd service.

I don't need to create the admin login on the XSXO as I've already done that
on the XS with these two commands:

ejabberdctl register admin schoolserver.example.org <password>
ejabberdctl set-password admin schoolserver.example.org <password>

Migrate the ejabberd database from the XS to the XSXO.  This takes care of
the admin login as well as any persistent chat rooms you've already set up.
It should go without saying that you need to keep this up to date.  You can
restore the ejabberd backup on the XSXO as many times as you want and it'll
just overwrite the old database.

On the XS, create the backup file:

ejabberdctl backup /tmp/jabber.bak

Copy the backup file over to /tmp on the XSXO.  Change permissions:

chown ejabberd:ejabberd /tmp/jabber.bak

Restore the backup to the XSXO:

ejabberdctl restore /tmp/jabber.bak

Check to make sure it took.  Run this on both the XS and XSXO and the counts
should match:

ejabberdctl stats registeredusers

The address for the web admin interface will be:
http://schoolserver.example.org:5280/admin

Login:  admin at schoolserver.example.org
Password:  the previously set password

**********************
* Speed up boot time *
**********************

I got the XSXO to boot in about 53 seconds.  When you're scrambling around
in the dark, you don't want to wait forever for a login prompt.

If you're not using these services, turn them off with chkconfig --level 345
<service> off

hddtemp
dhcpd
moodle
pgsql-xs
xsactivation
idmgr
xs-rysncd

Use chkconfig --list to see which services are set to run on which runlevel.

To further speed up boot, go into /etc/sysconfig/network-scripts and move
the devices you're not going to use into a backup directory.  You can always
put them back later.

cd /etc/sysconfig/network-scripts
mkdir bak
mv ifcfg-eth1 bak
mv ifcfg-lanbond* bak
mv ifcfg-msh* bak
mv ifcfg-wmesh* bak

*******************
* Save some power *
*******************

Turning off the backlight will reduce power consumption a bit, especially
important if you've only got a car battery to charge it with.

Turn off the backlight:
echo 0 > /sys/class/backlight/dcon-bl/brightness

Turn the backlight back on:
echo 15 > /sys/class/backlight/dcon-bl/brightness

******************
* Switching over *
******************

So the power just went out.  I hook the inverter up to a car battery and
plug my DSL modem into it.  While the connection comes back up, I safely
shut down the regular XS and turn off the UPS to stop that infernal
beeping.  Power on the XSXO and get an IP from the router.  Log into the
router's web interface and put the XSXO into the DMZ.  Renew the IP on the
XSXO.

ifdown eth0
ifup eth0

Everyone who was logged into jabber on the XS will automagically move over
to the XSXO.


Anna Schoolfield
Birmingham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.laptop.org/pipermail/server-devel/attachments/20101215/74a89087/attachment.htm 


More information about the Server-devel mailing list