Using OpenDNS on Your Fon Router

12 08 2008

There is large interest in OpenDNS, and I happen to be a fan of it myself.  Sadly, Fon routers, when connected directly to a modem and using DHCP, use the ISP's DNS servers and don't allow you to override those settings.  Fortunately, there is a loophole in older Fon firmware that allows you to enable a BusyBox shell (so you can connect to it via SSH).  This is actually a security hole and shouldn't be a good thing at all, but hey, I'm kind of glad it exists.  Anyways, let's get started.

Enable SSH access to your Fon router by following these instructions.  Be sure to enable permanent SSH access, as it'll be very useful later.  When your Fonera updates to newer firmware that doesn't allow code injections, SSH will still be enabled.  Be sure to leave your network cable unplugged until after you enable SSH permanently or you might form some gray hairs.


Now, in a shell, let's create a startup script that overrides the ISP's DNS settings after the network is initialized.  Type the following:

vi /etc/init.d/S45opendns


Now, in the vi window, paste this (press i to insert text):

echo "nameserver 208.67.222.222" > /etc/resolv.conf
echo "nameserver 208.67.220.220" >> /etc/resolv.conf

This will "blank" /etc/resolv.conf and load it with the OpenDNS settings.  Save and exit vi (press the esc key then type :x).

Now, to make the file executable type:

chmod +x /etc/init.d/S45opendns

You're all done!  OpenDNS settings will be persistent across reboots.  You can activate the settings now without having to reboot by simply running your new script:

/etc/init.d/S45opendns

If DHCP renewals cause your new nameserver settings to be overwritten to the ISP's, you can create a cron job that runs every few minutes (you can pick a time based on your ISP's DHCP lease time):

Type crontab -e in the terminal window.  When vi opens, insert the following line at the end:

15 * * * * /etc/init.d/S45opendns

This will run your new script every 15 minutes, so there will never be more than a 15-minute period where you will not be using OpenDNS.

That should be all you need to get you going. If you're using more advanced features of OpenDNS, you can use DNS-O-Matic on your Fon to keep OpenDNS informed of IP changes. Comment below with your experiences.


Downloading files from BitRoad.net without installing plugins

11 06 2008

BitRoad.net is a decent file hosting services that promises that they "don't have speed limits,
the size and a storage time of files
". This might sound suspicious, but I've been using them and their sister sites for well over a year now, and am pretty satisfied, especially with the speed of their servers. The main drawback: they require you to download a plugin before downloading that's detected as malware.


When downloading via IE, the software they want you to install is called "ADSTechnology" and "FireBit" when using Firefox. I have actually installed ADSTechnology before and it seemed harmless, but the malware warnings from my AV were discouraging enough that I removed it. Also, the software doesn't appear to have any impact on downloading at all.


Now to the good stuff: how to bypass the plugin. I'll give the Firefox case since it subsumes the IE case (plus Firefox is better anyways ;-) ).

  1. Install the User Agent Switcher addon for Firefox and restart the browser
  2. Go to Tools -> User Agent Switcher -> Internet Explorer 7 (Windows Vista)
  3. Browse to the file in BitRoad.net that you want to download. You'll be shown a small box mentioning ADSTechnology.
  4. Right-click and view the page source
  5. Ctrl+F in the source code window and search for "check_install"
    1. You'll see something that looks like this:
    onsubmit="check_install('http://b7.bitroad.net/download5/3f0605518729_k0adf32ybm046/filename.ext')">
  6. Copy the URL in the single quotes and enter it in the address bar. The download should now begin.


In IE, just follow steps 3 onwards.


Taking control of your DNS

15 03 2008

Many webmasters, especially those who run their own servers, rely on
free DNS providers extensively to help ensure site uptime. There are
many out there, with widely varying numbers of pros and cons. For
example, afraid.org seems to provide a great number of configuration
options and features, but adding mass records can still be daunting.
This is true with just about all other free DNS services, as they
typically allow you to add one record at a time. I accidentally
stumbled upon a free host that didn't sound free at all, DollarDNS,
that offers more than I ever expected in a free DNS host. They offer
the typical set of features that most DNS hosts offer, but with one
very important feature: full control of your zone files.

Domains are
added via a web interface, and a sample zone file (from a template that
you can configure) is created. From there, you can use their web
interface to add records, or just dive into the zone editor. The zone
editor is recommended for those who have a bit of experience with DNS
servers as errors can be easily made, but that method is extremely
efficient. For example, if you want to create dozens of CNAMES that
point to www.domain.tld, copying and pasting one line multiple times is
much easier than going to through the web interface dozens of times.


Also, since the zone editor is essentially a plain-text editor that
offers you full control, you can easily import and export zone files
from/to different locations. Afraid.org allows you to export your zone
file, so moving to DollarDNS just involves a simple copy-and-paste.
You can also use your own text editor or a script to generate your zone
file and paste it into DollarDNS when finished.

No minimum TTL maximum hostname limit appears to be mentioned
anywhere, so I doubt that there are any. You seemingly have infinite control over your zone.

I
currently use them for slave DNS and after a NOTIFY, DollarDNS requests
a transfer within a second or so. Compare that to any other service.

DollarDNS
offers two DNS servers, although only ns1.dollardns.net appears to be
authoritative (ns2.dollardns.net refuses queries immediately). Still,
assuming you have other DNS servers authoritative for your domain, that
isn't a major issue.

Dynamic DNS is also supported via a client
that they provide, although I have not tested it. Based on the quality
of the service overall, I expect the dynamic portion to work flawlessly
as well.

I recommend this service overall due to its feature set, quality, reliability, and the admin's modesty (the admin created a page comparing DollarDNS to others, and he admits on the homepage that domain registrations through his service aren't the cheapest around).

If you know of a free host that amazes you, leave a comment. I'd like to hear about it.



Creating a customized OpenVPN installer

19 01 2008


OpenVPN is an excellent product with seemingly infinite configuration options. After setting everything up to your tastes, though, you may find that your end users are a bit too "simple" to install OpenVPN and your custom config files successfully. I find that many users (well, where I work at least) are uncomfortable browsing to and placing files in C:\Program Files\OpenVPN. You can easily get around this by creating a self-extracting executable with a default output path of C:\Program Files\OpenVPN (use IZArc to make nice free SXEs). Although that gets the job done, the end user would still need to install OpenVPN, the run the SXE. Why not cut down the number of steps in half (or by one :p ), while at the same time adding your company's touch to the OpenVPN installer?

Recent documentation on this is not very widespread, but luckily still of good use. The main source of documentation on this can be found here, and is supplied by the creator of OpenVPN GUI. The documentation can be followed, but unfortunately the packages provided are a bit outdated. To get up-to-date (and to become Vista-compatible), we first download a copy of the current release candidate (2.1 RC4 at the time of writing). I actually had to get the Windows installer since I didn't want to bother compiling from source. Next, I downloaded the 2.1 beta 7 package from the OpenVPN GUI site. I installed the Windows installer by accepting all defaults, then extracted the install source (anywhere should work). Next, to get things up-to-date I replaced openvpn.exe and openvpn-gui.exe in the openvpn\bin folder of the extracted archive with that from my Windows installation (C:\Program Files\OpenVPN\bin).

To get our installer to work with Vista, we need to replace the blacklisted 0801 TAP driver with the newer 0901 TAP driver. This is not documented anywhere I could find, but doing this turned out to be easy and effective. Simply make replacements as we did above, but instead copy the contents of C:\Program Files\OpenVPN\driver to the openvpn\tap-win32\i386 folder of the extracted archive. You can safely remove the older 0801 files. To make this work, we now have to edit the openvpn-gui.nsi script in the extracted archive. In any text editor (Notepad++ worked great for me and offered syntax highlighting), open up openvpn-gui.nsi, look for !define TAP "tap0801", and replace that with !define TAP "tap0901". Your archive is now Vista-compatible.

There are many other changes that can be made in the Nullsoft installer script such as including your company name, custom icons, and most importantly your OpenVPN client config. You can look through the script to understand how it works and modify it accordingly. To include your custom config/cert files, browse in your text editor to Section "OpenVPN GUI" SecGUI. You will see a comment indicating where your custom config files go. To include multiple files in the install, simply add more File entries, like so:


CODE:
  # Include your custom config file(s) here.
  SetOutPath "$INSTDIR\config"
  File "${HOME}\config\client.ovpn"
  File "${HOME}\config\ca.crt"
  File "${HOME}\config\dh2048.pem"
  File "${HOME}\config\client.crt"
  File "${HOME}\config\client.key"

This will include client.ovpn, ca.crt, dh2048.pem, etc. to your custom installer, and will place them in the config folder upon installation.

To compile your masterpiece into an executable, you need to download and install The Nullsoft Scriptable Install System. Although a newer edition may work, I went with the original documentation's recommendation and installed the older v2.05. You can get this here. Once installed, you can simply right-click on the openvpn-gui.nsi script you modified and click on "Compile NSIS Script". A log of the compilation will show and an opportunity to test the installer will show if everything went well. You will also have an installable .exe waiting for you in the current directory waiting to be distributed to your clients.

If you ran into errors, look through the logs to try to identify what's going on. Otherwise, you can simply just make some changes to the archive I already hacked up:
http://www.ameir.net/blog/uploads/openvpn_install_source-2.1rc4-gui-1.0.3.zip

If you're just interested in creating a custom OpenVPN installer for Windows and don't particularly care to dabble in Nullsoft install scripts or are just lazy, download the archive above and make whatever changes you may need. The hacks described above are implemented in this package.

NOTES:

In Vista, if you're using routing (tun mode), the end user must run OpenVPN by running as an administrator. This is because the routing table must be modified to tell your computer how to get to your company network. Otherwise, the client may appear to be connected (he/she actually is), but attempts to access the company network will fail, as packets are instead trying to go through the default route (usually your ISP). Using tap mode eliminates this requirement as clients are given IPs in the company's subnet range, therefore eliminating the need to do routing.

If using certificate authentication, then each of your users will need unique files in their config directory. I don't know of a way to automate this, unless you generate the client certificates on the fly and have a program initiate a compile of openvpn-gui.nsi with the new certificates included. In my install of OpenVPN, users are authenticated via Active Directory, so we don't have to distribute any user-specific files.  You may very well just have to use self-extracting archives or train your users how to work with zip files!


Installing Camelia OCaml IDE on Ubuntu Gutsy Gibbon

03 11 2007

[will be filled in later; put up for immediate use]

CODE:
sudo apt-get update
sudo apt-get install g++
sudo apt-get install qt3-dev-tools


tar xvfz camelia-1.1.tar.gz
cd src
sudo ./config
sudo make
sudo make install


sudo nano console/console.h

look for the following block of code and insert the last line:

class OProcess;
#include "ocamlprocess.h"
#include "debugprocess.h"
#include "olineedit.h"
#include "color.h"
#include "debugger/debug.h"
class Debugger;
class OCamlProcess; // insert this line here

You'll get an error regarding the tips if you don't complete this step:
sudo chmod -R 755 /usr/local/lib/camelia/tips/

Finally, run Camelia:
/usr/local/bin/camelia
You can also simply type "camelia" at the command line, so long as /usr/local/bin/ is in your $PATH; it should be on a default Ubuntu install.


Free mail relay servers

13 09 2007

For many people, using an external mail server for outbound mail is more than critical. There are many reasons for this, some of which are:

  • bypassing dynamic IP blacklists by using a non-blacklisted mail server
  • sending mail from an alternative mail server on an alternative SMTP port (useful if your ISP blocks port 25, and the external server supports alternative ports)
  • hardcoding an SMTP server into a web-based application (like a forum or CMS) when a mail server is otherwise unavailable

Relaying allows you to send email through an external mail server, but the email looks as if it's coming from your own domain. For example, I can send an email from anything@ameir.net to anythingelse@gmail.com via an intermediate host without the Gmail user knowing about the intermediary (unless he/she looks at the headers). This doesn't sound like a big deal at all, but if you lie under one of the bulleted conditions above, then you may find it hard to communicate with the rest of the web. Most mail servers only allow you to send mail from the email address you own from them (e.g. sending mail through AOL's mail servers requires you to send the mail FROM your address).

Because I was on a dynamic IP and because Comcast mysteriously blocked port 25, I found that I needed a way to have emails from my server get to me. My backups were no longer being sent via email, my blog wasn't notifying me of any actions, and I figured it would be cool to finally send an email without a DNSBL rejecting me solely because of my IP address.

Luckily, here are some solutions:

ulmb.com (ports 25, 587)

This service actually provides you with a webhosting account of 5GB. I tried using them as a webhost once, but gave up after I ran into some restrictions. Still, they support email and relaying (although relaying isn't advertised), which is of great use. They do not pester you about DNS pointing to them or anything of the sort either.

mail.ikojomail.com (ports 25, 26)

This is an email service that offers a 5GB quota with IMAP, POP, and all the bells and whistles. Unfortunately, its webmail interface needs a little working on (it doesn't synchronize with the actual IMAP data), but as a pure IMAP email service it works very well. As an SMTP relay it works even better.

UPDATE: This domain recently expired, leaving the service inoperable. If you can find the IP for the domain when it was up, you might be in luck.

mail.inboxnow.com (ports 25, 26)

This service is the same as Ikojomail, but with a different name. The webmail interface works just like Ikojomail's (not well). For IMAP and SMTP, the service is fast and works great.

mail.icmail.net (ports 25, 587)

This service has been around for a couple of years and is pretty reliable. They offer POP/IMAP/SMTP, and their SMTP servers allow you to send from another sender. The only thing I don't like about it is that it complains sometimes when you send emails shortly after each other/have multiple connections to the SMTP server.

smtp.webalta.com (port 25)

This is a web search company from Russia that offers email accounts. The signup and webmail interfaces are in Russian, but you can get by based on the icons and the locations of the text fields if you don't know Russian (I sure don't). The service is pretty fast, and, as you expected, allows you to send emails from another sender. Seems pretty reliable.

mail.kakle.com (ports 25, 465)

This service provides 5GB webmail with full IMAP/POP capabilities. It's actually a pretty good service (when it works), and uses Squirrelmail as the webmail frontend. Message filters are done by Squirrelmail so it's not entirely server side (because you have to login and load Squirrelmail for filtering to occur). Sometimes incoming email has problems (it either works great or not at all), but as an outgoing SMTP server it works superbly. Note that port 465 is typically SMTP over SSL, but Kakle uses it as standard SMTP.

If you own a mail server but do not know how to set up relaying, there is nothing to worry about. There is documentation online for everything.

Below I show how I setup mail relaying on my Postfix server (I'll use Inboxnow for this; change the hostname to whatever server you wish to try). Before you begin, make sure you have the postfix-tls package installed. On a Debian-based distro like Ubuntu, you can install it simply with:

CODE:
apt-get update && apt-get -y install postfix-tls

Now here comes the good stuff. You must paste the following commands as root for relaying to work (copy and paste the below into a plain-text editor such as Notepad or Gedit, modify the relevant info, and paste into a terminal as root):

CODE:
postconf -e 'relayhost = mail.inboxnow.com:26'
postconf -e 'smtp_sasl_auth_enable = yes'
postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd'
postconf -e 'smtp_sasl_security_options ='
# I disabled tls because Postfix complained about a self-signed certificate.
postconf -e 'smtp_use_tls = no'
echo "mail.inboxnow.com:26   USERNAME@inboxnow.com:PASSWORD" > /etc/postfix/sasl_passwd
chown root:root /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
/etc/init.d/postfix restart

You can see from above that I disabled TLS. This is generally not a good idea if TLS is available, but I encountered issues with Inboxnow's SSL certificate because it was self-signed. I disabled TLS in the meantime, and will keep my eyes peeled for a workaround. If you find any ways to get TLS working with a self-signed certificate, please let me know in the comments below. You should now be able to send emails via the relay. As a quick test, you can send yourself a test email and look at the headers to see the trajectory the email took. If you have mutt installed, you can easily do this by typing (as any user):

CODE:
echo "body" | mutt -s "test message" EMAIL@ADDRESS.TLD 


Site removed from Google due to FreeDNS

19 08 2007

My site has disappeared from Google's listings, and I initially blamed the cause on my site going down for a long period of time a while back. After finally getting back online, I decided to start using Google Sitemaps. After trying to add my site, though, I ran into a problem; Google claimed my site was inaccessible! I could browse the site fine so I figured it was a temporary problem on Google's end. After trying multiple times over a course of a month or so, I decided to investigate. What I found was a bit surprising: freedns.afraid.org (my dynamic DNS provider) blocks all requests from Google! I couldn't believe it!

A bit pissed, I emailed Joshua Anderson (the maintainer of FreeDNS) about it. He asked for my domain name and stated that Google can now access my site. He didn't respond to the portion of my email asking why Google is blocked in the first place.

Well, Google is now able to download my sitemap, but I will have to wait a LOOONG time before I show up in Google again. It took me a while the first time, and I'm basically starting again as if I'm reborn.

I also enlisted in a secondary DNS service, EditDNS.net, just in case there are some other surprises in afraid.org's services. Hopefully if any queries to afraid.org's servers fail, EditDNS will come through successfully.


Isn't blocking Google such a bad idea? I wonder what the reasoning behind it is. I don't see freedns.afraid.org having any trouble getting listed by Google.

UPDATE: FreeDNS has updated their FAQ to address the Google issue. Here's an excerpt:

QUOTE:

The official policy is this:



1) At around 4AM PST each night, the previous 24 hours worth of domain
additions are made visible to Google. (subdomain edits and updates are
instant).



2) No subdomains created via the shared domain system are visible to
Google. You must own the domain its self that you are creating a
subdomain off of to have it visible to Google by default.


Where voicemail meets today's technology

16 08 2007

For the past few years that I've had a cell phone, I've been known to be very bad at checking my voicemails. It's so clumsy, and if not checked soon enough, they pile and pile. If someone calls and there is a voicemail that you just must listen to, you have to go through ALL previous voicemails first. This is the same way voicemail was checked years ago, and I think it's time for a change. I'm glad others agree with me.

There are now services that can take over as your voicemail service. When you miss someone's call, the caller is redirected to your new voicemail service instead of your service provider's.


For a while, I was using Privatephone.com. PrivatePhone gives you your own local phone number that is intended for use as a personal number that you give out for spam-style offers online, or to people you meet randomly that ask for your number while you really don't want to give it out. I found a useful link at Howard Forums that details how to enable call forwarding on T-Mobile (my provider) phones, and I went ahead and gave it a shot. Months later, I was satisfied with my decision.


With PrivatePhone, I was able to check my voicemails through my phone like before, through email, or through a web-based email-like interface. I had .wav of each voicemail emailed to me, so I was notified immediately by Thunderbird as soon as an email arrived. In addition, PrivatePhone sent me a text message telling me a voicemail was left, with the caller's number. The text message only showed the caller's number (along with a short PrivatePhone message), even if the caller was in my PrivatePhone addressbook.

I then stumbled upon YouMail. YouMail did everything PrivatePhone failed to do. It not only is a third-party voicemail service, but it also has excellent features such as custom voicemail greetings for each caller, text messages with the caller's number, name (if the caller is not in your contact list, it shows the caller ID name), and length of the voicemail. In addition, the emailed copies of the voicemails were sent in .mp3 as opposed to the .wav of PrivatePhone; I had bad luck with VLC and .wav files for some reason. The only drawbacks to YouMail are that you don't get your own private number (everyone uses the same voicemail number; your voicemail is handled based on the number that forwards the call to them), and that you can't currently set caller groups. It would be nice to have friends, family, work, etc., be greeted with different voicemail messages, but not have to individually set the message for each individual caller. Still, this service to me far exceeds what PrivatePhone could offer me, and I am still using it today.

If you have multiple phones or need a number you can comfortably give out to near-strangers, you might want to try GrandCentral. If a caller dials your GrandCentral number, GrandCentral can have multiple phones ring at the same time. Think of this as phone redundancy when you have service problems with your phone(s). GrandCentral used to offer ringback tones (where callers are greeted by music or whatever you decide to upload), but since being bought by Google, that feature has disappeared (for copyright reasons I'm sure). Still, there is a library of ringback tones you can choose, but none of them are anything special. I suggest you give this a shot, I'm sure you'll like it ;-)

UPDATE: YouMail has recently made tons of changes to the site, and it appears to be getting better every week.  I strongly advise you check it out.  Whenever I think of a possible improvement, I end up seeing it implemented shortly after.  I'm quite impressed with the service.  Let me know what you think about it in the comments.

UPDATE:  Privatephone.com will be ending their service on December 31, 2007.  FreeDigits was the closest replacement I could find to Privatephone, but they now no longer offer dedicated phone numbers; they instead make you use a "short code" which is the same as an extension.  My guess is that they didn't want to pay for more phone numbers.  If you're still interested in that service, they offer it through a sister site, ringtonumber.com.


Backup Email Solutions

03 08 2007

I recently ran into a problem with my server setup where I would have incredibly long and random moments of downtime. The downtime wasn't the server's fault, but moreso due issues at the colocation site (i.e. my friend's house ;-) ). During this time period, of course, I was unable to send, receive, or retrieve any emails. Because I'm so dependent on email, and because the downtime was becoming excessive, I had to find some way to get around this. After doing some searching, I came up with these possibilities:

  1. backup MX service that tries to deliver your mail to your main mail server periodically; once your server is back up, the mail will be delivered to your usual inbox. If you only expect minor downtimes this solution is a good safeguard to ensure that you'll never lose any emails, but for those of you with shaky configurations (or if you have a long-term project to complete that requires downtime), this may be inideal because your emails will not be accessible until your mail server is back up and running.
  2. backup MX service that forwards all of your email to another address; you will be able to read these emails immediately (even while your mail server is down), but the messages will not appear in your mail server's inbox once it comes back up. This is nice for those who need immediate access to their emails, and cannot afford to wait until the server is back up (knowing that in many cases bringing the server back up is a time-consuming task). You unfortunately cannot access your existing email with this method, but then again, you can't do so with any method so long as the server's down. You also have to be aware that your mail server is down so you'll know to check your other email address. Hopefully an error message from your mail client is enough.
  3. outsourced email; an external provider completely handles all aspects of your domain's email; your MX records will point to the provider's servers, as will your email client. All spam control, filtering, mail rules, etc., will be handled at the host's end. Your mail server is essentially unnecessary with this solution. You certainly have much less control over your emails and cannot perform low-level tasks such as messing with your mboxes/Maildir, but you do have the relief of not worrying about your mail server's status.

You can see that each of these methods have their pros and cons, and I cannot tell you which method works best for your situation. I can, though, explain my situation and explain what works best for me.


My situation: I have excessive, spontaneous, and oftentimes lengthy downtimes due to various reasons (ISP issues, people tampering with my server >:-[ , etc.). Because I'm in school and often expect important emails, I have to make sure that I can access incoming emails at any time.

My solution: I first started off using a backup MX service that forwarded all of my emails to my Gmail account. This was useful since I already had a copy of all of my emails forwarded there (I had procmail send a copy to two other email accounts for archiving/backup purposes, while keeping a copy on my mail server). This method worked and worked well. Because I had my previous emails already in my Gmail account, all new emails arrived smoothly and I couldn't tell (from a Gmail perspective) that my mail server ever went down without looking at the message headers to see what mail server accepted and forwarded the email. I recommend this solution for those who archive their emails like I did by forwarding copies to other accounts, and for those who are comfortable with that backup email address. Gmail is able to respond with another From: address, so your replies will look like they're coming from you@yourdomain.com.

I eventually ditched this method just because I am in love with IMAP and missed the convenience of it. I never looked back at POP after using IMAP, which makes me want to yell at Google for only supporting POP. Anyways, my solution turned out to be one that allows for me to use IMAP, and still have access to all my emails when my server is down. I never thought I'd do it, but I did; I outsourced!  I ended up pointing my MX records over to AOL's servers (yes, I never thought I'd go with them either) and from then on checked my emails through Thundbird.  AOL offers IMAP(S), POP(S), and SMTP, so they really do have the basics for me.  They don't have many basic features such as mail rules or mail forwarding (which I'm praying for), but luckily I never was reliant on these.  There are many other providers that offer domain email hosting for free, but usually only the paid accounts are given POP/IMAP access, which is why I outsourced in the first place.

If you know anything about me, you know that I don't like paying for anything.  I've therefore compiled a list of free backup MX services and domain email hosts.

Secondary MX - tries to deliver to main mail server

  • rollernet.us
  • editdns.net

Secondary MX - forwards to another email address

  • zoneedit.net
  • ulmb.com
  • most webhosting accounts

Domain email hosting

  • AOL
  • Google Apps
  • Bluetie
  • Gawab


Server back online

03 07 2007

Okay, I think I've learned my lesson. I've tried a few "unlimited" webhosting offers from eBay and typically start off happy, but after a few months, sometimes only a few weeks, I run into problems. ameir.net was down for a while--and thus received no updates--because the webhost suddenly deleted my account without warning and did not respond to any of my messages. They "accidentally" did so a few times before and recreated my account after some yelling, but the most recent time just didn't work out. It took me so long to bring the site back online because I was wary of getting another super-cheap host, I didn't know of any trustworthy, reliable, and ad-free free webhosts, and I was also very busy with school. Anyways, I resorted to hosting my own server for now, so hopefully that will take care of the plethora of problems I've encountered. I'll try to update the site regularly. Keep checking the site for updates.


Useful eBay Tools

14 01 2007

Sniping services:
Gixen Snipe Tool
eStEaL
JustSnipe
Auction Stealer


My Favorite Filesharing Services

18 11 2006

A good filehost is important for use in many different applications.  It can help you to share large files with friends and colleagues, and can really be useful in more life-saving applications, such as backups.  I use these services to accomplish both, although I do admit I rely on them heavily in parallel with my backup scripts; I get a nightly backup of each of my MySQL databases to multiple email accounts, as well as to FTP.  I know it's super-redundant to happen this way, but I learned my lesson from the past.  Plus, this level of redundancy is pretty nice.  Here is a list of some of the file hosts that I use, and will update the table later with more details.

NameFilesize LimitDownload SpeedUpload SpeedComments
www.oxyshare.com700Mb??Used to be my favorite file host until things started going wrong.
www.up-file.com2GB???
www.mediafire.com100MB???
www.gigasize.com????
www.mihd.net1GB???
www.files-upload.com1GB???


MySQL Backup to FTP and Email Shell Script for Cron v2.1

23 09 2006

I updated the script just a tad bit. Using the magic of sed, this version of the script makes a backup of each database individually when you choose to backup all of your databases. The previous version dumped all of the databases into a single file. When you run this script and have it emailed to you, you'll end up with multiple attachments, each attachment being a single database name. Why did I do this? Well, I myself needed to restore a database and I had all the databases in a single file. I ended up searching throughout the file to find where surrounding databases started or stopped and copied the info in between. It wasn't very fun, especially since the databases weren't very small. This script gets around that headache completely. If you still prefer to have all of your DB data dumped into a single file, search for "MySQL Backup to FTP and Email Shell Script for Cron v2". Both scripts are exactly the same besides this feature.


CODE:
#! /bin/bash

# Ameir Abdeldayem
# http://www.ameir.net
# You are free to modify and distribute this code,
# so long as you keep my name and URL in it.

# your MySQL server's name
SERVER=ameir.net

# directory to backup to
BACKDIR=~/backups

# date format that is appended to filename
DATE=`date +'%m-%d-%Y'`

#----------------------MySQL Settings--------------------#

# your MySQL server's location (IP address is best)
HOST=localhost

# MySQL username
USER=username

# MySQL password
PASS=password

# List all of the MySQL databases that you want to backup in here, 
# each separated by a space
DBS="db1 db2"

# set to 'y' if you want to backup all your databases. this will override
# the database selection above.
DUMPALL=y


#----------------------Mail Settings--------------------#

# set to 'y' if you'd like to be emailed the backup (requires mutt)
MAIL=y

# email addresses to send backups to, separated by a space
EMAILS="1@gmail.com 2@inbox.com 3@goowy.com"

SUBJECT="MySQL backup on $SERVER ($DATE)"

#----------------------FTP Settings--------------------#

# set "FTP=y" if you want to enable FTP backups
FTP=n

# FTP server settings; should be self-explanatory
FTPHOST="ftp.server.com"
FTPUSER="username"
FTPPASS="pass"

# directory to backup to. if it doesn't exist, file will be uploaded to 
# first logged-in directory
FTPDIR="backups"

#-------------------Deletion Settings-------------------#

# delete old files?
DELETE=y

# how many days of backups do you want to keep?
DAYS=3

#----------------------End of Settings------------------#

# check of the backup directory exists
# if not, create it
if  [ -e $BACKDIR ]
then
echo Backups directory already exists
else
mkdir $BACKDIR
fi

if  [ $DUMPALL = "y" ]
then
echo "Creating list of all your databases..."

mysql -h $HOST --user=$USER --password=$PASS -e "show databases;" > dbs_on_$SERVER.txt

# redefine list of databases to be backed up
DBS=`sed -e ':a;N;$!ba;s/\n/ /g' -e 's/Database //g' dbs_on_$SERVER.txt`
fi

echo "Backing up MySQL databases..."
for database in $DBS
do
mysqldump -h $HOST --user=$USER --password=$PASS $database > \
$BACKDIR/$SERVER-mysqlbackup-$database-$DATE.sql
gzip -f -9 $BACKDIR/$SERVER-mysqlbackup-$database-$DATE.sql
done

# if you have the mail program 'mutt' installed on
# your server, this script will have mutt attach the backup
# and send it to the email addresses in $EMAILS

if  [ $MAIL = "y" ]
then
BODY="Your backup is ready! Find more useful scripts and info at http://www.ameir.net"
ATTACH=`for file in $BACKDIR/*$DATE.sql.gz; do echo -n "-a ${file} ";  done`

echo "$BODY" | mutt -s "$SUBJECT" $ATTACH $EMAILS
        
echo -e "Your backup has been emailed to you! \n"
fi

if  [ $FTP = "y" ]
then
echo "Initiating FTP connection..."
cd $BACKDIR
ATTACH=`for file in *$DATE.sql.gz; do echo -n -e "put ${file}\n"; done`

ftp -nv <<EOF
open $FTPHOST
user $FTPUSER $FTPPASS
cd $FTPDIR
$ATTACH
quit
EOF
echo -e  "FTP transfer complete! \n"
fi

if  [ $DELETE = "y" ]
then
find $BACKDIR -name "*.sql.gz" -mtime $DAYS -exec rm {} \;

if  [ $DAYS = "1" ]
then
echo "Yesterday's backup has been deleted."
else
echo "The backup from $DAYS days ago has been deleted."
fi
fi

echo Your backup is complete!

Download backupmysql-2.sh


LDAP Authentication PAM/NSS Using Debian or Ubuntu Bash Script v2

02 09 2006
Okay, so the old script wasn't that great (well I don't think so), mainly because of how I dealt with nsswitch.conf. I had the old script download it from the internet. Sure, it worked for me when I made the script, but that method can lead to many problems, especially when servers go down (which did happen). With the help of God I discovered sed. It's like find/replace, but even better. It has features dripping out of places I'd rather not see. Well anyways, the script is below. I also added a function to see if you were root or not. When I ran the old script on DreamLinux as root, it made new files in the pam.d directory, but they were all empty! The new method hit the spot right. Let me know if it works for you or not ;-)

CODE:
#! /bin/bash

# This script will install an LDAP authentication client for 
# Debian-based systems.  It relies on apt-get for package
# installation.  If you are using Ubuntu or Mepis, make sure
# you have the 'universe" repository enabled.  The packages we
# need are in there.
#
# Suppose the script's filename is ldapconf.sh
# If you are running it as a sudo user, type:
# chmod +x filename && sudo ./ldapconf.sh
#
# If you are root, run it as:
# chmod +x filename && ./ldapconf.sh
#
# Feel free to modify and distribute this file freely, so long
# as you leave the author's name and URL intact.
#
# Â© Ameir Abdeldayem
# http://www.ameir.net
# Last modified: September 1, 2006
#---------------------------------------------------------------#


DATE=`date +'%m-%d-%Y-%T'`

# check if root, else run as sudo user
function root
{
if [ $(whoami) = "root" ]
then
  echo -n
else
  echo -n "sudo "
fi
}

$(root) apt-get install libpam-ldap libnss-ldap ldap-utils nscd

echo "Backing up and modifying files in pam.d/ ..."
$(root) mv /etc/pam.d/common-account /etc/pam.d/common-account.$DATE.bak
$(root) echo account sufficient      pam_ldap.so >> /etc/pam.d/common-account
$(root) echo account required        pam_unix.so try_first_pass >> /etc/pam.d/common-account

$(root) mv /etc/pam.d/common-auth /etc/pam.d/common-auth.$DATE.bak
$(root) echo auth    sufficient      pam_ldap.so >> /etc/pam.d/common-auth
$(root) echo auth    required        pam_unix.so try_first_pass >> /etc/pam.d/common-auth

$(root) mv /etc/pam.d/common-password /etc/pam.d/common-password.$DATE.bak
$(root) echo password        sufficient      pam_ldap.so >> /etc/pam.d/common-password
$(root) echo password      required   pam_unix.so nullok obscure min=4 max=8 md5 \
try_first_pass >> /etc/pam.d/common-password

# changes in common-session shouldn't be needed, but if so uncomment and (re)run
# $(root) mv /etc/pam.d/common-session /etc/pam.d/common-session.$DATE.bak
# $(root) echo session       sufficient      pam_ldap.so >> /etc/pam.d/common-session
# $(root) echo session       required        pam_unix.so >> /etc/pam.d/common-session

$(root) cp /etc/nsswitch.conf /etc/nsswitch.conf.$DATE.bak
$(root) cp /etc/nsswitch.conf /etc/nsswitch.conf.bak

echo "Editing your nsswitch.conf file..."
$(root) sed -e 's/compat/ldap files/g' /etc/nsswitch.conf.bak > /etc/nsswitch.conf

echo -e "Finished installing packages and modifying configuration files! \n"

echo -e "NOTES:\nYou may need to restart your computer before changes take effect."
echo "You can restart your computer by typing '$(root)reboot' in this very same window."
echo "If you are trying to login as a user that is local AND in LDAP and are getting\
 permission errors, type (write this down) '$(root)nscd --invalidate=passwd' in a terminal."


Download ldapconf.sh


Backup Scripts- README

20 08 2006
If you are using any of the backup scripts on my site, it is useful to know a few things to get them up and running, and to keep existing things on your server sane.

These scripts can be used together; they are friendly to each other and do not mess with one another. It is completely safe (and recommended) to have the same backup directory for all of the scripts.

How to use the scripts:

You can copy the code directly from the site and paste into a plain text editor. Make sure the editor saves files as plain text; i.e. it does no word processing. Save the file and upload it to your server (unless you're working on the server so you won't have to transfer anything), preferably in the root of your home directory (not a big deal, though). It is a good idea to save each of the scripts with similar names like backupmysql.sh, backupldap.sh, etc.

File permissions:
Once the file is on the server, make it executable. If you have ssh or other command-line access, type chmod +x [filename]. If you are using FTP, CHMOD the scripts to make them executable.

Testing the script:
If you have ssh, you can test the script by going to the script's directory and typing ./backupmysql.sh (or whatever the filename is). If the script works with no problems, you can now move forward and create a cron job.

Creating a cron job:
If you are using cPanel, the 'simple' cron creation method is simple enough to run without explanation. Just type the full script's path in the field and select the desired timings.

If you are using the 'advanced' method in cPanel or are entering the cron job using ssh, entering something like 0 0 * ~/backupmysql.sh should do the trick (will run the script every midnight). To edit your cron jobs in ssh, type crontab -e, which will open an editor with your current cron jobs listed. Update that file and save.

If you get the error bad interpreter: No such file or directory, then you probably saved the file in Windows and transferred it over to the server. Windows, Linux, and Macs save files differently, so the shell script can't run unless it is Linux-ready. cPanel is pretty good with this. If you have access to cPanel, all you have to do is open the script in the filemanager and click 'save'. cPanel will save the file in the correct format. If you don't have cPanel access, you can open the file in a text editor in ssh and save it.

[to be finished]