This web log is meant to be both technical and personal, generally detailing my exploits and adventures as well as providing notes and ideas.
- Bert JW Regeer (畢傑龍)

20 pound turkey, 20 pounds of mashed taters and 11 guys!

Thanksgiving was great, I went over to a friends house and he cooked us an awesome dinner.

20 pound turkey for 6 hours in the oven
20 pounds of mashed potatoes, which is insane
6 pound pork grilled on teh BBQ.

The food was great. I have never had soo much turkey in a day. I must say though that it was awesome being there with everyone.

We were all in and out of conscinceness after around 8. Then at 2 in the morning we all got up to head out to the local Best Buy to go stand in line. At first it was to get the Xbox 360's that they were supposedly selling for $100, but we learned while waiting in line that that was all a hoax. The real reason I came then, was to get myself a nice 22" Westinghouse widescreen LCD screen for $200. This thing has more inputs than a whore. It can do 1080i, and thus has Composite inputs, DVI input, VGA input, and standard video input, and S-Video input. It also has two 2.5 W speakers built in. It does 1680 x 1050 Widescreen over DVI, which is an awesome resolution. It is VERY awesome to use for watching movies, and is absolutely handy when it comes to needing screen space to do programming, since I can now use my laptop screen as a backup and leave Safari open on that with notes or other information.

Widescreen for the win!

Very cool presentation: BSD is dying

I just found this from another blog I read FreeBSDGirl, it is an interesting presentation done by someone at BSDCan and later off course at other cons as well, including the nycbsdcon.

It talks about how BSD currently stands, and why it is dying. Fun to watch, especially since his presentation style is awesome. Watch BSD is dying on Google Video

Final version of My Lesbian Love

Imagine you are back in high school. You are sitting in your English class. It is silent reading time. You carefully take a sip of your cup of coffee. You put your book down and stare out the window at the gym class that comes running by. You wonder if you have to do any running for gym today as well, or if your teacher is nicer. You think of your girlfriend and wonder how bored she is currently in French. You pick your book up again, and start reading just as your teacher looks up to see if everyone is still reading. You take a quick peek at the clock, only 10 minutes left to go! You take out your Palm V and add a note to yourself about picking up another book by this author. You take a look down at the floor where your backpack is sitting and you make a quick mental note to clean it out.

The bell rings, and you jump up. You are not in school anymore, you are at home, and the bell you hear is the front door. You get up out of bed wondering what time it is. You go down stairs, without getting the question answered, as it the power is off. You yawn as you open the door, and take a look at the guy standing there pulling the door bell. It is FedEx. They are delivering the hardware you ordered online only two days ago. Just as you are starting to take the package apart the power comes back online, causing all the devices in the house to start flashing 12:00. With a sigh you take a look at your watch that is lying on the kitchen table, 17:35, you make a mental note not to sleep all day again. After all the devices are reset you take a look at the mess on the kitchen table. Motherboard, hard drives, memory, everything all scattered over the place. You take a look at the other box FedEx dropped off, you assume it contains the new computer case. You look at the box and notice that it has been kicked around by FedEx, like always. Your parents are not going to be home for a while, so you decide to call up your girlfriend Melissa. Your heart skips a beat at the excitement of having her around to help you out. She picks up the phone and you say "Hey, just got my stuff from FedEx, want to come drop by and give me a hand?"
Her reply is quick, "Sure, I'll give you a hand in more than one way", she giggles at the sexual connotation. You get back to unpacking. You are just finished unpacking everything when the door bell rings again. Your girlfriend has shown up. You go to open the front door for her. Without even saying a word she walks over to you, and gives you a big kiss, she then walks over to the table. You follow her. As she is about to say something, you reach into your pocket and pull out what she was going to ask about. You hand them to her, and let her more feminine hands take care of the case for you. You take a quick look over all the parts scattered all over the place, and start cleaning up all the foam, and cardboard. It looks like none of the hardware was destroyed in-transit even-though the packaging it came in was for all other intents and purposes destroyed.

The rig is complete, you and your girlfriend completed a task normally done in a few hours within 45 minutes. The big question you have is, does it boot up? You walk up stairs back to your room to grab the spare LCD monitor you have sitting around. You also grab a monitor and the FreeBSD install CD. You think to yourself, a server should not be run on anything else. You head back downstairs, and find that Melissa has already found an extra power outlet in your kitchen. You hand over the keyboard and the CD, and plug in the power to the computer and the LCD. You then plug it into the onboard video card. You hit the power button ....

Fast forward a few years, you are sitting in University and you have an awesome teacher named Ellen. She has just given you an assignment that involves writing in the second person, and you can't think of anything. Your mind wanders as she starts to give more instructions, and something about a free writing exercise. You wander a few years back and wonder where it went wrong with Melissa. Was it the fact that your mom walked in on you two in bed? Was it the fact that you are a lesbian? Maybe it was the distance that was generated between the two of you when your mom did not let you go out on Friday night anymore. Made you go to Church classes, and tried to make you like guys. You start thinking about how society is screwed up, and how it is wrong that society does not accept people that are not like them. You think you are going to write this second person essay on just that topic. You take out a pen and start jotting down ideas, unbeknownst to you, you are following the class. Your teacher Ellen has just told everyone to make a spider web of what they want their essay to be on, and how they should model it. You start having more questions than answers. It is 20 past the hour, class is over. That concludes all the classes you have for today and as you make your way towards the exit you notice a girl you remember from your Linux/UNIX class sitting in the corner playing some new game. As you walk over you ask yourself if you are really falling for her. She has beautiful green eyes, not unlike your own. However hers also have a tint of blue in them as well. You get more and more confused as you walk over to where she is sitting.

As you walk over to her, you start to get more scared. You start asking yourself questions like, how should I approach her. You feel insecure, and worst of all, you have no-one to fall back on yet. You have no-one to talk to about your feelings. Right before you get to her, you panic, you turn around and walk away. Away from the feelings of insecurity, away from someone you are falling in love with. You know you are falling in love, the butterflies, they are all signs. The cold sweats, the dreams. You want to be with her, you can't foster the courage to walk up to her and talk to her. You don't seem to have power over your legs as your body walks away while your brain and heart want to go back. You know you want to be with her, everything about her makes you complete. Her eyes, her body, the way she moves, the way she talks and smiles. You know Jennyfer would make you a complete human being, and happy again. You just don't have the power, you are afraid of failure.

That night as you are lying in bed, thinking of Jennyfer you wonder how to approach the problem. You ponder on it for a long time before finally falling asleep. You dream about being with Jennyfer again. Holding her hand, kissing her lips, hugging her, taking showers with her, sleeping with her. It seems like the dream never ends, but at 07:30 your alarm clock goes off, and wakes you up. You hit it, and it stops making the god-awful noise. You get out of bed, and head into the bathroom, you turn on the shower. After which you walk out of the bathroom to the kitchen. You grab some corn flakes and some milk. Following your daily ritual you take the milk and put it in the bowl, after which you let it sit there and walk back to the bathroom. By this time your shower is nice and warm and provides a soothing stream of water. You wash your hair, and shave. You get out of the shower, still naked you walk back into the kitchen, grab the bowl, the corn flakes and you poor them in. You start eating as you walk back to the bed room. Here you quickly throw on some clothes, put on some eye liner, and grab your purse and head out the door. You take care to lock the door, and run to the bus.

As you are on the bus it hits you. You are going to go back to your high school days and do what you did best. Write little notes. The ones you used to write about the teacher when they had their socks on backwards, or when you tried to get Melissa's attention to go out to lunch after school was over. You start thinking about how you could approach the situation. As you write the note you start thinking of how to get it to Jennyfer. The note you write is simple. In it you ask her if she wants to come out to dinner tonight. You see her in the computer lab when you walk in. Different location, yet she still seems like she is sitting alone in a corner. Her beauty shining like the ray's of the sun as it rises. As you walk by, you nonchalantly put the note down on the table and walk on. You have two classes to go before you might get a reply. You are hoping so desperately to get a reply. You sit through your two classes with anxiety wondering if Jennyfer will take you up on your offer, or if she will shoot you down. As you walk into your Linux/UNIX class you notice that at the stop you normally sit at, there is a note half hidden underneath the keyboard. You take it out and read it. All it says is "Who is asking?". Your heart drops as you fear that she thinks you are helping out some guy. You scribble on a note "Me", and hand it to her with a slightly trembling hand. The smile she gives you though gives you hope. At the end of class as you are exiting you feel a slight tap on your shoulder. You turn around and there is Jennyfer. She smiles and gives you the most reassuring nod, and then says "Yes, I do want to go out to dinner with you!"

Toorcon

So Friday at around 1600 hours, someone in the Hardware lab up in room 422 at UAT goes "We are all going down to San Diego for Toorcon, want to join?". I am down for almost anything. We get together a total of 11 people at 22:00 at night, get in 3 cars, and start the 5 hour drive down to San Diego. We drop by the local Fry's Foods and buy food (11 people walking in at once is scary looking, especially all geeks :P). Once we are stocked up, we get on the road. Armed with nothing more than a few laptops, some clothes, deodorant, soap and tons of tech gear and a map-quest printout of directions, we are off.

We get to San Diego at around 0400 hours in the morning, and we look around for a Hotel. We head over to a local Days Inn, and WifiWarrior[1] the oldest of the group, our schools student government vice-president lets us get the rooms at a discounted rate for $109[2] per night, 2 hotel rooms, for $260 total. THAT WAS DIRT CHEAP. So we get some sleep, and head over to the convention center. We pay admission $120, and get these cool Lan Yard's with Pac Man's attached to them as our passes to the convention. We sit in on the Saturday morning talks and then head over to the CTF [3] and sign up for 11 college students to compete under the team name UAT. We set up, and start trying to hack the servers, not knowing what we are doing we just basically DDoS the shit out of the servers, and the other teams are starting to get pissed about the fact that they are not able to get any real work done since we are slowing the network down too much. Tough shit. We never get into a single computer, but we do end up knowing what services the machines are running so we can decide a plan of attack the next day.

That night we go out to dinner for Thai food (real good food as well, Lotus Thai in San Diego on 9th and Market), and we get to spend the evening with Captain Crunch (Wikipedia him). He is one of the coolest guys ever. He has some awesome plans to stop much of the spam email many of us are trying to deal with lately. The amount of fun 11 people can have is awesome. 11 people that share the same interests and or passions just got together and had tons of fun.

During the con, I met several key security people, that keep our networks safe. People like Dan Kaminsky. That guy got up on stage hung-over/drunk and gave his entire presentation, and it seemed to make sense, some parts were just way over my head, but it left me with some great ideas for future projects and or research I would like to do. Captain Crunch was awesome in his own way. His ideas and thoughts were great, but sometimes he just seemed to be unable to tell people just exactly what he was thinking.

The second day we got back, and we finally got into one of the servers through a Samba exploit, getting us our first 30 points on the leader-board! Then I out of my sheer "Let's secure this now" mindset removed all the services that could be exploited, and hard rebooted the box. Thing is, we had re-set the root password to "sorry" to thwart the other people, and thus the people running this CTF could not get in, to fix whatever services I had closed, since after all, others should have a fair chance of getting in as well. In the end we had 60 points. Which was two servers hacked, and rooted! We, as in almost all 11 of us, learned more in just two days than what we could learn from some of the classes at UAT. The creators of the contest talked with us afterwards giving us tips of what we should strengthen up on, and what we should look into, that way when we come back next year, or DefCon we can show up strong.

The car ride back was about as eventful as the event there. In our car we had great talks about American politics, and other software/hardware. What we learned, what we needed to learn, and other really useful information. This was one of the best weekends I have had so far here at UAT, and I can't really say I have had a bad weekend here. Just the entire attitude that 11 people could get together last minute, with about 10 minutes of preparation and jump into 3 cars, drive all the way down to San Diego (California), and everything was perfect, was just really cool. The entire rush of "Let's go to San Diego!".

I bought two books, and a T-Shirt. Total money I spent: $320. Time to earn that money back! People still owe me some money, so I am getting some of that money back, but it is gone from my bank account, so it really does not exist in my books anymore!

To learn more about Toorcon, visit their website http://toorcon.org/. To learn more about UAT visit the website http://uat.edu/

[1] This name was given to him by lostboy when he pulled out a 3 - 5 ft 18 Dbi gain Marina antenna and his 15 Dbi Directional wifi antenna and held them up like he was a knight, with a shield and a sword!

[2] Normal price: $129 per night, plus $20 per person extra. Social engineering for the win!

[3] Capture the flag. Computers are set up with operating systems running known services that can be exploited, the point of the game is to steal as many of these systems that are running, and capture those that others have taken. The OS's can range from Linux to FreeBSD, to Solaris, to Mac OS X, to Solaris. This game is normally only entered into when one has the skill-set, but at smaller cons like this one, even with no skill-set, one may jump in and just attempt it, and learn from the experience.

Ubuntu multiple loopback interfaces

So today I was playing around with this crap named Ubuntu and I could not figure out why my extra loopback interfaces I added to /etc/network/interfaces would not show up after restarting networking with /etc/init.d/networking restart. The reason for that is that it excludes all loopback interfaces.

auto lo
iface lo inet loopback
auto lo:0
iface lo:0 inet static
address 127.0.0.2
netmask 255.0.0.0

Then use the function "ifup" to restart all the networking stuff. ifup -a. You are not set, check with ifconfig.

My Lesbian Love

Imagine you are back in high school. You are sitting in your English class. It is silent reading time. You carefully take a sip of your cup of coffee. You put your book down and stare out the window at the gym class that comes running by. You wonder if you have to do any running for gym today as well, or if your teacher is nicer. You think of your girlfriend and wonder how bored she is currently in French. You pick your book up again, and start reading just as your teacher looks up to see if everyone is still reading. You take a quick peek at the clock, only 10 minutes left to go! You take out your Palm V and add a note to yourself about picking up another book by this author. You take a look down at the floor where your backpack is sitting and you make a quick mental note to clean it out sometime and wash it.

The bell rings, and you jump up. You are not in school anymore, you are at home, and the bell is the front door. You get up out of bed wondering what time it is, and wander down stairs without getting the question answered as it seems the power is off. You yawn as you open the door, and take a look at the guy standing there pulling the door bell. It is Fedex. They are delivering the stuff you ordered online only two days ago. Just as you are starting to take the package apart the power comes back online, causing all the devices in the house to start flashing 12:00. With a sigh you take a look at your watch that was sitting on the kitchen table, 17:35, you make a mental note not to sleep all day again. After all the devices are reset you take a look at the mess on the kitchen table. Motherboard, hard drives, memory, everything all scattered over the place. You find the other box Fedex has also delivered, you assume it contains the new computer case. You look at the box and notice that it has been kicked around by Fedex, once again. Your parents are not going to be home for a while, so you decide to call up your girlfriend Melissa. Your heart skips a beat at the excitement of having her around to help you out. She picks up the phone and you say "Hey, just got my stuff from Fedex, want to come drop by and give me a hand?"
Her reply is quick, "Sure, I'll give you a hand in more than one way", she giggles at the sexual connotation. you get back to unpacking. After all the components are laid bare on the table your girlfriend shows up, she rings the door bell and you let her in. Without even saying a word she walks over to you, and gives you a big kiss, she then walks over to the table. You follow her. As she is about to say something, you reach into your pocket and pull out what she was going to ask about. You hand them to her, and let her more feminine hands take care of the case for you. You look over the parts scattered all over the table, in the mean time she slowly one by one takes the screws out of the case, which seems to have survived the travel from Newegg in New Jersey to Arizona without any troubles, even-though the packaging it came in was for all other intents and purposes destroyed.

The rig is complete, you and your girlfriend completed a task normally done in a few hours within 45 minutes. The big question you have is, does it boot up? You walk up stairs back to your room to grab the spare LCD monitor you have sitting around. You also grab a monitor and the FreeBSD install CD. You think to yourself, a server should not be run on anything else. You head back downstairs, and find that Melissa has already found an extra power outlet in your kitchen. You hand over the keyboard and the CD, and plug in the power to the computer and the LCD. You then plug it into the onboard video card. You hit the power button ....

Fast forward a few years, you are sitting in University and you have an awesome teacher named Ellen. She has just given you an assignment that involves writing in the second person, and you can't think of anything. Your mind wanders as she starts to give more instructions, and something about a free writing exercise. You wander a few years back and wonder where it went wrong with Melissa. Was it the fact that your mom walked in on you two in bed? Was it the fact that you are a lesbian? Maybe it was the distance that was generated between the two of you when your mom did not let you go out on Friday night anymore. Made you go to Church classes, and tried to make you like guys. You start thinking about how society is screwed up, and how it is wrong that society does not accept people that are not like them. You think you are going to write this second person essay on just that topic. You take out a pen and start jotting down ideas, unbeknownst to you, you are following the class. Your teacher Ellen has just told everyone to make a spider web of what they want their essay to be on, and how they want it modelled. You start having more questions than answers. It is 20 past the hour, class is over. That concludes all the classes you have for today and as you make your way towards the exit you notice a girl you remember from your Linux/UNIX class sitting in the corner playing some new game. As you walk over you ask yourself if you are really falling for her. She has beautiful green eyes, not unlike your own. However hers have a tint of blue in them as well. You get more and more confused as you walk over to where she is sitting.

As you walk over to her, you start to get more scared. You start asking yourself questions like, how should I approach her. You feel insecure, and worst of all, you have no-one to fall back on yet. No-one to talk to about your feelings. Right before you get to her, you panic, you turn around and walk away. Away from the feelings of insecurity, away from someone you are falling in love with. You know you are falling in love, the butterflies, they are all signs. The cold sweats, the dreams. You want to be with her, you can't foster the courage to walk up to her and talk to her. You don't seem to have power over your legs as your body walks away while your brain and heart want to go back. You know you want to be with her, everything about her makes you complete. Her eyes, her body, the way she moves, the way she talks and smiles. You know Jennyfer would make you a complete human being, and happy again. You just don't have the power, you are afraid of failure.

That night as you are lying in bed, thinking of Jennyfer you wonder how to approach the problem. You ponder on it for a long time before finally falling asleep. You dream about being with Jennyfer again. Holding her hand, kissing her lips, hugging her, taking showers with her, sleeping with her. It seems like the dream never ends, but at 07:30 your alarm clock goes off, and wakes you up. You hit it, and it stops making the god-awful noise. You get out of bed, and head into the bathroom, you turn on the shower, and head into the kitchen. You grab some corn flakes and some milk. Following your daily ritual you take the milk and put it in the bowl, after which you let it sit there and walk back to the bathroom. By this time your shower is nice and warm and provides a soothing stream of water. You wash your hair, and shave. You get out of the shower, still naked you walk back into the kitchen, grab the bowl, the corn flakes and you poor them in. You start eating as you walk back to the bed room. Here you quickly throw on some clothes, put on some eye liner, and grab your purse and head out the door. You take care to lock the door, and run to the bus.

As you are on the bus it hits you. You are going to go back to your high school days and do what you did best. Write little notes. The ones you used to write about the teacher when they had their socks on backwards, or when you tried to get Melissa's attention to go out to lunch after school was over. You start thinking about how you could approach the situation. As you write the note you start thinking of how to get it to Jennyfer. The note you write is simple. In it you ask her if she wants to come out to dinner tonight. You see her in the computer lab when you walk in. Different location, yet she still seems like she is sitting alone in a corner. Her beauty shining like the ray's of the sun as it rises. As you walk by, you nonchalantly put the note down on the table and walk on. You have two classes to go before you might get a reply. You are hoping so desperately to get a reply. You sit through your two classes with anxiety wondering if Jennyfer will take you up on your offer, or if she will shoot you down. As you walk into your Linux/UNIX class you notice that at the stop you normally sit at, there is a note half hidden underneath the keyboard. You take it out and read it. All it says is "Who is asking?". Your heart drops as you fear that she thinks you are helping out some guy. You scribble on a note "Me", and hand it to her with a slightly trembling hand. The smile she gives you though gives you hope. At the end of class as you are exiting you feel a slight tap on your shoulder. You turn around and there is Jennyfer. She smiles and gives you the most reassuring nod, and then says "Yes, I do want to go out to dinner with you!"

Book signing with Internet Legend Maddox

So Maddox was here in Tempe, AZ for a book signing (The Alphabet of Manliness, if you have not bought a copy yet you should right now!) at the borders on Mill Ave, which meant I headed over there with another friend of mine here from UAT. Maddox is an asshole! Seriously.

He was one of the coolest people I have ever met. I got my book signed, and he said "Manly handshake" in mine. My handshake is a strong grip (just like his), and two very small pumps, quick and subtle. I off course got a picture with me and him, but since it was taken on my Phone, the image quality is shit, and because of the lighting, it tried to expose it too long and it caused it to be moved. :-(, but at least it is a picture with the man, the myth and the legend!

Me and Maddox

I will take some pictures of the signing he did in the book, and post those online soon as well.

FastCGI quick and dirty

In this quick and dirty guide for FreeBSD I will assume you have already compiled and installed PHP5 with fcgi mode enabled, which can be checked by running:

/usr/local/bin/php-cgi --version

I will also assume you have installed mod_fastcgi from www/mod_fastcgi in the ports.

Create the fast cgi ipc temp dir, make sure you place this somewhere it will keep existing:

cd /var/tmp
mkdir -p /var/tmp/fcgi-ipc/dynamic
chmod -R 0777 /var/tmp/fcgi-ipc

Let's create the directory where we are going to place our PHP wrapper, this config is for server wide using the same FastCGI PHP config. This is on purpose, since it will allow server wide PHP usage. If you want you could then split it up into virtualhosts if one required a standalone php running for that.

mkdir /usr/local/www/fastcgi-bin/
chmod 755 /usr/local/www/fastcgi-bin/

Next up we create the very simple wrapper

cat << EOF > /usr/local/www/fastcgi-bin/php5.fcgi
#!/bin/sh
# To use your own php.ini, comment the next line and uncomment the following one
#PHPRC="/usr/local/etc"
export PHPRC
PHP_FCGI_CHILDREN=8
export PHP_FCGI_CHILDREN
exec /usr/local/bin/php-cgi
EOF

Set PHP_FCGI_CHILDREN to whatever value you want, that is how many processes it will use. I suggest the standard which is 8, if you make it more, you use more ram, you make it less Apache will have to wait if all of the PHP processes are in use.

Next up, make it executable:

chmod +x /usr/local/www/fastcgi-bin/php5.fcgi

Last but not least, edit httpd.conf and make sure to add a comment in front of the mod_php5 line, and uncomment the mod_fastcgi line. Then add this to the end of your Apache config:

<IfModule mod_fastcgi.c>
    FastCgiIpcDir /var/tmp/fcgi-ipc/
    FastCgiConfig  -pass-header HTTP_AUTHORIZATION

    AddHandler  fastcgi-script              .fcgi .fcg .fpl

    Action      application/x-httpd-php5    /fastcgi-bin/php5.fcgi
    AddType     application/x-httpd-php5    .php .php5
</IfModule>

ScriptAlias /fastcgi-bin/ "/usr/local/www/fastcgi-bin/"
<Location /fastcgi-bin/>
    Options ExecCGI
    SetHandler fastcgi-script
    Order allow,deny
    Allow from all
</Location> 

That's it. Restart apache and watch as the first time you access a PHP script FastCGI will spawn several of them, and they start serving requests. Load usage may seem higher, that is because unlike Apache the standalone running PHP's handle the jobs as they come in with whatever one is first, Apache will try to put as much work in one of it's preforked modules. As the PHP processes come and go through FastCGI the memory usage will go up and down. Mine has an average of about 300 MB, which is very good compared to the 800 MB Apache with mod_php would rack up.

Backup Script

I was working one some backup scripts and I decided I might as well generalise almost all of it (I am sorry about the hard coded paths) so almost anyone can come grab it and use it on their servers. The shell script is pretty self explanatory and I am not very good at documenting code, so the script source itself is your best bet as to why I did something some way. This script is in production use on several servers I administrate, I hope someone can use it as well.

Documentation on how to use it:

New backup script which will mount a /backup, then use rsync to copy files from /usr/home to /backup/yyyy-mm-dd. After it is done, it will remove the oldest backup, 14 days ago. All paths are hardcoded.

If a file .exclude is in a users homedir, it is looked at, and is used to exclude certain directories or files from the rsync. For example:

in /usr/home/xistence/.exclude

public_html/iso

No trailing slash, this will cause the folder /usr/home/xistence/public_html/iso to not be backed up. This might be for various reasons, but for this example it is because backing up GB sized files should not be something that is done, only because it takes ages and wastes valuable space.

Thing to keep in mind is, if you want to backup a 40 GB HD, with 22 GB used, to keep even a 3 day backup of that would require 3 * 22 GB, or 66 GB of available space on the backup drive. It is therefore in ones best interest to exclude very large files, and back them up in a different method since they are most likely not going to change much across revisions.

This script should be set to cron every 30 minutes, as rsync will do one full backup when the day changes, and then from there on do incremental backups.

Maybe removing the --delete option might help with customers that delete files and expect them to still be in the backup for that day, this way however if a file is removed it will still exist in the backup until it is deleted after 14 days.

#!/usr/local/bin/bash

# This file REQUIRES bash, and can not be run under /bin/sh!

###
 # Copyright 2006 Bert JW Regeer. All rights  reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
 # are met:
 # 1. Redistributions of source code must retain the above copyright
 #    notice, this list of conditions and the following disclaimer.
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
 #
 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
 # The views and conclusions contained in the software and  documentation are
 # those of the authors and should not be  interpreted as representing official
 # policies, either expressed  or implied, of bsdPanel project.
 #
###

for HOMEDIR in `/usr/bin/find /usr/home -type d -maxdepth 1 | grep -v '^.$'`; do
	if [ -f $HOMEDIR/.exclude ]; then
		echo "Exclude found for $HOMEDIR"
		while read line; do
			if [ "${line:0:1}" != "/" ]; then
				# They are missing a full path, we will be nice and add it
				TMPLINE="$HOMEDIR/$line"
				line=$TMPLINE
			fi
			echo "	Excluding $line"
			echo $line >> /tmp/exclude.$$
		done < $HOMEDIR/.exclude
	fi
done

mount | grep /backup

if [ $? -ne 0 ]; then
	/sbin/mount /backup
	if [ $? -ne 0 ]; then
		logger -s -p user.err -t backup "Backup drive could not be mounted! Bailing!"
		/sbin/umount -f /backup
		exit 1
	fi
fi

BACKUPDIR="/backup/`date "+%Y-%m-%d"`"
OLDDIR="/backup/`date -v-14d "+%Y-%m-%d"`"

if [ ! -d $BACKUPDIR ]; then
	mkdir $BACKUPDIR
fi

if [ $? -ne 0 ]; then
	logger -s -p user.err -t backup "Could not create backup folder $BACKUPDIR. Bailing!"
	/sbin/umount -f /backup
	exit 1
fi

# We got this far, now we have to run rsync. Rsync is very verbose on purpose

/usr/local/bin/rsync -av --relative --delete /usr/home/ $BACKUPDIR --exclude-from=/tmp/exclude.$$

if [ $? -ne 0 ]; then
	logger -s -p user.err -t backup "rsync failed. Do not trust backup ($BACKUPDIR)"
	/sbin/umount /backup
	exit 1
fi

echo "Backup complete! Deleting oldest backup (14 days ago)"

if [ -d $OLDDIR ]; then
	rm -rf $OLDDIR
fi

/sbin/umount /backup
/bin/rm -f /tmp/exclude.$$

logger -s -p user.notice -t backup "Backup complete at $BACKUPDIR."

Latest version can always be found in my SVN version control for bsdPanel.

If you do use it, send me an email at xistence [at] gee mail dot com.

Ninja Remote

Recently I recieved one of the really cool items at ThinkGeek, a Ninja Remote. What this device does is allow control of pretty much any TV that is out there on the market, all in a very small size. Hold the mute button until the TV mutes, let go of the button and you have full control. Volume, Channels, and even the input. And best off all, it contains a off button to turn off the TV.

So, I was heading down to Fry's electronics to pick up an employment application, and I figured they would have a ton of TV's to play with. I walk up to the first one, a Mitsubishi, and took control. First I changed the channel to a cooking channel and turned up the volume really loud. Next I walked over to a row of TV's, all of them JVC. I waited until the TV muted, and once again I was in control. I took a step back, and hit the power button. Every TV just went off. I quickly turned them all back on, and walked on to where I saw an employee trying to sell a Sharp TV. Doing the same trick I had just done, I turned off 3 rows of TV's, about 24 total. I almost die of laughter as the guy looks dumbfounded. *Poof* and all the TV's were off. Out of nowhere I see some guy come with a voltmeter and he starts plugging it into the power outlets only to conclude that there is still power. (In this mean time I am walking around and have turned off yet another set of TV's) They are unplugging TV's and plugging them back in. Never touching the power button. As if I were an innocent bystander I walk over, hit the power button on one TV and on my remote and have them watch in astonishment as ALL the TV's turn back on. They thank me and I am on my way!

That little device is so much fun. It is awesomely small so most people won't even notice what is up, and thus the surprise of having the TV go off is awesome. One couple was looking at a REALLY sweet Samsung LCD TV and I turned it off. The guy had the remote in his hand but had not pressed any buttons, and he quickly hung the remote back on the TV in the holder and quickly walked off as if to say "T'was not my fault".

Yeah, great fun. Now I need to fill in that application and hopefully get employed :D

Syndicate content