Remember Remember

lunes, 15 de junio de 2009

Screen -X

I found here a nice use of screen I didn't know about:

screen -X stuff

You can send a sequence of chars to any screen!,

example

screen -S 9962.pts-0.ursa -p 4 -X stuff 'ls^M'


Side note: I knew the ESC * and the ESC ESC meaning on bash, but I didn't know the ESC . That's useful!.

martes, 2 de junio de 2009

Reinstalling...

As I mentioned before, I almost broke my system :P. Even though the system is running well, this (and vacation time) suggested me to reinstall my laptop using debootstrap, lets see how does it go.

lvcreate VolumeGroup -L 5G -n root
/sbin/mkfs.ext3 /dev/VolumeGroup/root
mount /dev/VolumeGroup/root /mnt/
debootstrap --arch=i386 jaunty /mnt

wow, that was easy! ~350Mb (including the packages) and includes many usefull packages.

The system is installed, now we need to make it bootable:

cp /etc/apt/sources.list /mnt/etc/apt
edit edit edit
cp /etc/fstab /mnt/fstab
edit edit edit
mount -o bind /dev/ /mnt/dev/
mount -o bind /proc/ /mnt/proc/
chroot /mnt
apt-get update
apt-get install linux-image-2.6.28-11-generic lvm2 wpagui


Finally I edited the grub conf (menu.lst) and now I am gonna reboot the machine.


A couple of errors, both it booted. I forgot to copy the microcode (firmware) of my wireless card, but once I copied it and configured the wpa, I could connect to my wireless network.

Now

aptitude install firefox-3.5 openbox vim-full mc xserver-xorg-core x11-xserver-utils xinit

and startx :)

Home server ct'ed

The package debootstrap looks interesting

Home server

So I got bored of thinking on serving from my home laptop. Let's do it:

I don't want to think too much, so I am gonna install the webserver in a chrooted slack

lvcreate VolumeGroup -L 1G -n JailRoot

From a previous post, I know that a good base for a chrooted Slack are the following packages
attr
coreutils
grep
pkgtools
aaa_base
bash
etc
gzip
tar
acl
bin
glibc
libtermcap

then



a="attr
coreutils
grep
pkgtools
aaa_base
bash
etc
gzip
tar
acl
bin
glibc
libtermcap"

wget http://slackware.cs.utah.edu/pub/slackware/slackware-12.2/FILELIST.TXT

for j in $(for i in $a; do grep "/$i-" FILELIST.TXT ; done | gawk -F ' [.]/' '/tgz$/{print $2}'); do wget http://slackware.cs.utah.edu/pub/slackware/slackware-12.2/$j; done


Now we can go and check slashdot for a while :.

Yes, there are some spurious packages, with a quick glance, we can do
rm bash-completion-20060301-noarch-1.tgz


As we are not necessarily inside a Slack to begin with, we will have to install the packages the good-ol' way:

mkreiserfs /dev/VolumeGroup/JailRoot
mount /dev/VolumeGroup/JailRoot /mnt/
mv *tgz /mnt
cd /mnt


NOTE, from now use a non super user account (I used root and almost crashed my system :) rm -Rf anyone?)

tar xf pkgtools-12.1.0-noarch-7.tgz
sbin/installpkg -root /mnt *tgz



now, back in business with root
chroot /mnt/

and we are in!

By now we have a ~250Mb bareboned installation of slack (I know, it can be done better, but this times disk space is not a big deal), now we can install the moin wiki:
wget http://slackware.mirrors.tds.net/pub/slackware/slackware-12.2/slackware/d/python-2.5.2-i486-4.tgz
cd opt
wget http://static.moinmo.in/files/moin-1.8.3.tar.gz
tar xf moin-1.8.3.tar.gz


try to run, and...

Traceback (most recent call last):
File "wikiserver.py", line 38, in
MoinScript().run()
File "/opt/moin-1.8.3/MoinMoin/script/__init__.py", line 138, in run
self.mainloop()
File "/opt/moin-1.8.3/MoinMoin/script/__init__.py", line 240, in mainloop
from MoinMoin import wikiutil
File "/opt/moin-1.8.3/MoinMoin/wikiutil.py", line 25, in
from MoinMoin.support.python_compatibility import rsplit
File "/opt/moin-1.8.3/MoinMoin/support/python_compatibility.py", line 90, in
import sha
File "/usr/lib/python2.5/sha.py", line 6, in
from hashlib import sha1 as sha
File "/usr/lib/python2.5/hashlib.py", line 133, in
md5 = __get_builtin_constructor('md5')
File "/usr/lib/python2.5/hashlib.py", line 60, in __get_builtin_constructor
import _md5
ImportError: No module named _md5


a quick google points to openssl, then
wget http://slackware.cs.utah.edu/pub/slackware/slackware-12.2/slackware/a/openssl-solibs-0.9.8i-i486-1.tgz
installpkg openssl-solibs-0.9.8i-i486-1.tgz


now another try and

2009-06-02 20:08:02,283 INFO MoinMoin.log:126 using logging configuration read from "/opt/moin-1.8.3/wikiserverlogging.conf"
2009-06-02 20:08:02,530 INFO MoinMoin.server.server_standalone:72 ThreadPoolServer serving on 127.0.0.1:8080
Traceback (most recent call last):
File "wikiserver.py", line 38, in
MoinScript().run()
File "/opt/moin-1.8.3/MoinMoin/script/__init__.py", line 138, in run
self.mainloop()
File "/opt/moin-1.8.3/MoinMoin/script/__init__.py", line 255, in mainloop
plugin_class(args[2:], self.options).run() # all starts again there
File "/opt/moin-1.8.3/MoinMoin/script/__init__.py", line 138, in run
self.mainloop()
File "/opt/moin-1.8.3/MoinMoin/script/server/standalone.py", line 131, in mainloop
run(Config)
File "/opt/moin-1.8.3/MoinMoin/server/server_standalone.py", line 636, in run
switchUID(config.uid, config.gid)
File "/opt/moin-1.8.3/MoinMoin/server/__init__.py", line 31, in switchUID
raise RuntimeError('will not run as root!')
RuntimeError: will not run as root!


Ok, this looks easier to fix.
Two options here: create users in the jail or use users from the machine. I am lazy (and I think it can be safer [citation needed :P], lets face it, I am lazy), therefore I am gonna create users inside:

wget http://slackware.cs.utah.edu/pub/slackware/slackware-12.2/slackware/a/shadow-4.0.3-i486-15.tgz
adduser user
su - user
python wikiserver.py


And PRESTO!, it is working now.