A year ago we explained how to use Kubuntu 8.10 from a USB device. Now, a year later, I was in the same situation, but with Kubuntu 9.10 instead. And since then we've made some steps.
Ubuntu itself brings an application to make a USB device boots Ubuntu. In the panel there is the application "K-> Applications -> System -> USB Startup Disk Creator" (o also with /usr/bin/usb-creator-kde command), which is very simple
I just found out, since debian lenny, and in Ubuntu/KUbuntu (I don't know if it was in 8.04, but it do is in 8.10), winexe application, of which we talked about and used, for instance, in our process killing scripts or remote shell scripts, comes with wmi-client package. That is, if you want to install it, you just should do:
apt-get install wmi-clientAnd done! I guess RedHat and Suse have this package too... can anyone confirm this?
Instructions: We download the file with the tools, we unzip them in some directory, and run kubuntu810.bat. We choose drive letter, we choose architecture, and done! We need to do nothing more. The script itself downloads the ISO file if you don't have it.
Keep in mind that you must choose a drive being the first physical partition on the device, and it must have a FAT filesystem bigger than 750MB...
I think it could not be easier!!
Why am I publishing this? And so short? Well, yesterday I was told something off...
"What a boring post, Kubuntu-USB post! Why don't you put commands and nothing more? Don't you see nobody will read it this way?"
Ok, ok, ok... You don't need to get mad at me :D ACK. Hands on work...
I've taken PenDriveLinux instructions, published for Ubuntu, USB Ubuntu 8.10 install from Windows, and I've adapted it for KUbuntu. I've added some little things, such as choosing 32 or 64 bits architecture, and allowing the use of a proxy for the ISO downloading part (apart from adding a "-f" to syslinux command, because I was getting "Not a removable drive" error).
Update 5/11
PenDriveLinux has done it, with this article, so I no longer have the exclusive :P
Canonical has just released the new Ubuntu and Kubuntu 8.10. Like every new version, I like to see what's new (above all because upgrades tnd to break things apart from time to time). And this time I liked to see what's new even more, because Kubuntu 8.10 (intrepid ibex) changes KDE desktop version, and installs KDE 4.1 by default.
I've always thought that using a CD just for testing linux dist, and using it once, is wasting it. Everyone has an 1GB pendrive we've been given in some meeting, or we bought (even my father has one, I bought one for him, 8GB for 10€ the other day at MediaMarkt), and a device like that, with fast access and reusable, seems the best place where we can make our tests.
Installing Ubunto on a pendrive is very easy, there are lots of documentatios every were, for instance in PenDriveLinux, where they have an article for installing Ubuntu, with some scripts doing it all. I haven't found the same for Kubuntu, but you just need a few modifications.
First of all we need an USB device, that can be a hard drive, a pen drive, a mobile phone... anything.
We will use the first physical partition of the device. That is, if we have just logical partitions, we must remove them and create at least one physical partition. This is that way because logical partitions have values of 5 and up (the 4 first values al reserved for physical partitions), and we need it to be the first, the one with value 1. If we have just one partition, then nothing to worry about, go ahead!
We will also need this partition to have a FAT filesystem, either FAT16 or FAT32, big enough to fit the KUbuntu CD (750MB).
Once we have the device, with the first partition prepared, we need to download KUbuntu 8.10 ISO. When we're done downloading, we should access to the ISO filesystem. We can achieve that in windows by using 7zip for instance, and with a simple mount in linux:
mkdir /tmp/live-cd
mount -t iso9660 -o loop kubuntu-8.10-desktop-amd64.iso /tmp/live-cdNow we should copy to the root of the unit some directories: "casper dists install pics pool preseed .disk", also "isolinux" directory content and "md5sum.txt README.diskdefines install/mt86plus" files. From linux console, that would be:
cp -r casper dists install pics pool preseed .disk isolinux/* md5sum.txt README.diskdefines install/mt86plus /tmp/live-cddefault persist
label persist
menu label ^Run KUbuntu Persistently saving changes back to USB
kernel /casper/vmlinuz
append file=/preseed/kubuntu.seed boot=casper persistent initrd=/casper/initrd.gz quiet splash --
label live
menu label ^Try KUbuntu without saving any changes to USB
kernel /casper/vmlinuz
append file=/preseed/kubuntu.seed boot=casper initrd=/casper/initrd.gz quiet splash --
label live-install
menu label ^Install KUbuntu
kernel /casper/vmlinuz
append file=/preseed/kubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.gz quiet splash --
label check
menu label ^Check CD for defects
kernel /casper/vmlinuz
append boot=casper integrity-check initrd=/casper/initrd.gz quiet splash --
label memtest
menu label Test ^memory
kernel /install/mt86plus
label hd
menu label ^Boot from first hard disk
localboot 0x80Finally we need to make this drive bootable. For this we need syslinux tool, which we can find at kernel.org website in all versions (windows and linux, but a simple apt-get install syslinux will do the trick). Once we got it, we run:
syslinux -maf UNITAnd that's it. We just need to check the computer will boot from USB devices, and done!
As it's this easy (maybe more easy than it's to explain it), maybe I'll do some scripts for installing from windows and linux... but this will be other day!
Following the path we were on former posts , if we have seed with psexec, noe it's very easy to make new tools. Three examples:
winshell.sh
With this tool we get a shell in windows servers. It doesn't use psexec because it haven't, cmd.exe is in system path.
#!/bin/bash
[ $# -ne 1 ] && echo "Error, I need one argument" && echo "Use: $0 server" && exit 1
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
. $PROGPATH/winvars.sh
winexe //$1 "cmd" $PSCREDENTIALSwininfo.sh
With this tool we can get some server information. Physical RAM, SO version, uptime, number of processos, frequency of them, and video card driver. This last detail doesn't seems important at all, but it's very useful, because it can tell you wether if a server is physical or virtual. If video driver is something like "ATI Technologies Inc. 3D RAGE IIC PCI", then it's a physical machine. If video driver is something like"VMware SVGA II", then it's a virtual machine.
#!/bin/bash
[ $# -ne 1 ] && echo "Error, I need one and only one argument" && exit 1
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
$PROGPATH/winpsexec.sh $1 pstools\\psinfowinkill.sh
As its name clearly stands, it's a process killing tool (we can previously know the PID useing winps.sh).
#!/bin/bash
[ $# -ne 2 ] && echo "Error, I need two arguments" && echo "Use: $0 server pid" && exit 1
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
$PROGPATH/winpsexec.sh $1 "pstools\\pskill $2"If we want to check the event log of a windows server from our linux console (without having to connect through terminal server, allowing us to grep the results, etc, etc, etc), here we have the tool!
We use psloglist with this parameters:
-d 1 so it shows just last day of logs (we don't want to be flooded with logs)
-f we so just warning and errors will be shown (usually, only those are interesting)
$2 this is the second parameter. If we wnat to see just "application" or "system" logs (usually the only interesting) you just type it there.
#!/bin/bash
[ $# -lt 1 ] && echo "Error, I need at least one argument" && echo "Use: $0 server [system|security|application]" && exit 1
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
$PROGPATH/winpsexec.sh $1 "pstools\\psloglist -d 1 -f we $2"Let's be honest. Nagios has lots of good things. But it also have bad ones: it stores data in non-indexed text files, executes a compiled CGI, configuration files are unconfortable when adding and removing new machines (mainly removing them)... and mainly: it's ugly. Maybe ugly is not the word... it's austere, simple, not attractive.
I don't give a damn (and I'm pretty sure I'm not the only one), because it's a tool, and it does its work. I'm not here to enjoy watching it, but to warn me when things go wrong, and to explain me why are they going wrong. But in this world, the ones who take decisions and buy things, they frequently look at the appearance, sometimes beyond functionality. Then if you are trying to convince someone to use nagios, you'll have more chances if it was pretty.
Here is where nagios nuvola style comes, to give nagios another look, very different, and to make it nicer (in the full article you'll find two screenshots so you can compare). It's made by the same people that made nagiosql, and although it has a nagiosexchange page, the downloadable file there is corrupt (one css is bad, status.css, and it looks very different). I took it from this website, and you can download it here, too.
Installing it couldn't be easier. You just copy files inside "html" directory inside your nagios. In a debian, for instance, it's as easy as:
wget http://tomas.cat/blog/sites/default/files/nagios-nuvola-1.0.3.tar_.gz
mkdir nuvola
cd nuvola
tar zxvf ../nagios-nuvola-1.0.3.tar_.gz
cp -a html/* /usr/share/nagios3/htdocs/
cp -a html/stylesheets/* /etc/nagios3/stylesheets/.And that's it, you got your look-improved nagios!
Next mission was making scripts to execute pstools remotely. I started make one for each tool, but I found out there was a lot of shared code, so I decided to create an generic script, psexec.sh (honoring pstools), receiving the server and the tool, with its parameters. After that, we should only create a wrapper for every command to make our life easier.
The script must check if file credentials are valid, and asking for others if they aren't. Once authenticated, it must check if there's pstools installed or not, and copy them if not.
In the full story you can see the code of psexec.sh and an example wrapper, winps.sh. Keep in mind that they need some files, winvars.sh and cp_pstools.sh in order to work properly, as we saw in the previous post.
Following the path we were... What if we want to use pstools in 50 servers? As an idea, we can creat a shared unit, and make all servers to execute pstools there. But if we have some in some networks, some in some other networks (including DMZ), in a domain or not... Couln't be an easy way to copy them?
With this purpose I've made this little script, doing exactly that: copying pstools to the server we want. First of all it mounts a cifs unit (with smbmount), then copy the files and then umount it.
I've made it to be called from other scripts. For instance, if we make a "winps", we can make it to check if pstools are installed first, and to copy them if they aren't.
In the full article you can see the code an download the file.
You are trying to connect via remote desktop (terminal server) to the server, but you find out there's too much people already connected. You get the damn message:
What can I do? Is easy. As we already have our brand new tool winexe, we can make a little script to make our lives easier:
#!/bin/bash
[ $# -lt 1 ] && echo "Error: Missing argument" && echo "Use: $0 server [disc #session]" && exit
[ ! -z "$2" ] && [ $2 != disc ] && echo "Error: Can't understand second argument" && echo "Use: $0 server [disc #session]" && exit
[ "$2" == "disc" ] && echo "Disconnecting session $3 from server $1..." && winexe //$1 "logoff $3" -A secretfile && exit
echo "Listing server $1 sessions:"
winexe //$1 "query session" -A secretfileFile "secretfile" is optional, just in case you don't want to type user and pass. Contents are:
domain=YOURDOMAIN
username=user
password=passThat's an poorly error-controlled script, but it allows you to watch who is connected:
user@server:~/$ ts.sh server2
Listing server server2 sessions:
SESSIONNAME USERNAME ID STATE TYPE DEVICE
> user1 0 Disc rdpwd
rdp-tcp 65536 Listen rdpwd
Administrator 3 Disc rdpwd
user2 1 Disc rdpwd
console 5 Conn wdcon
user@server:~/$In this server you can't login, there are too much users. We can see everybody is "disconnected", so there is no one working. We choose the user we like the least, and we kick him out:
user@server:~/$ ts.sh server2 disc 1
Disconnecting session 1 from server server2...
user@server:~/$ ts.sh server2
Listing server server2 sessions:
SESSIONNAME USERNAME ID STATE TYPE DEVICE
> user1 0 Disc rdpwd
rdp-tcp 65536 Listen rdpwd
Administrator 3 Disc rdpwd
console 5 Conn wdconEt voilà, we just get a free session to connect to admin this server.
Obviously, is way better if everybody logs off when they end working. But if you have to share your servers with absentminded admins, you must take care of yourself...