Sunday, September 25, 2011

Falling from the cloud

So, for a few reasons, I've decided to try to take more of my identity back inhouse.  I'd outsourced some of my world to Blogger, Github, Facebook and domains hosted by GoDaddy, but, I figured I'd try to pull everything back home.

First up, I need to host my never-updated page back on my own server.  The most logical thing would be to run the Apache that have been integrated into Fedora 15, but, I want to run serveez, which is a GNU webserver that I've worked on a bit.

My network is very simple.  It looks like this:

I didn't have to do anything special to get the DSL Modem to allow traffic to my webserver.

The Router was more complicated.  I want anything trying to connect on port 80 to be forwarded on to the server.  So I used a browser to log into the control panel of the Linksys router.  Under a tab called "applications and gaming" and a section called "single port forwarding" I set the HTTP port 80 to be sent to the internal IP 192.168.1.99.

So why that IP xxx.xxx.xxx.99?  Well that router has its own DHCP server that the laptop and my server have been using when they connect to the router.  And that DHCP starts assigning numbers beginning with 192.168.1.100.  So usually my various computers are assigned IPs between 100 and 103 depending on which one is booted first.  But I need the HTTP traffic to be always forwarded to the server, so I'm going to have to give the server a static IP.

The server is running Fedora 15, so everything is hidden from the user and it is impossible to change anything without intensive google-fu.  But to change the network, run the command nm-connection-editor.  There I edited my wired IPv4 connection to "manual" mode instead of DHCP mode, entered the static IP, netmask, etc.  I found the address for the nameserver from the router's control panel.

Then, I had to figure out how to disable the firewall on port 80.  The magic command there was system-config-firewall-tui.  That brought up a firewall wizard.  Under the 'customize' section, I was allowed to disable the firewall for www port 80.

I used dyn.com's free service to make a temporary domain for my server.  Basically, you just create an account, choose a temporary hostname (something like blahblahblah.dyndns-home.com), have dyn's website tell you what your public IP is, and then connect that IP to your temporary hostname.

Then I kicked off the webserver, and was able to see my hello world web page.  Sweet.

But we're still not done.  Two more things have to happen.  The webserver needs to come up automatically when the computer boots, and a script needs to be in place to poll your public IP and inform Dyn whenever it changes.  When you have a DSL connection, you public IP probably changes every day as well as each time you reboot.

To get the webserver to boot on startup, you need to add it to the startup scripts.  Unfortunately Fedora has moved to the overly complicated and opaque systemd.  So to do that, I'd first have to get systemd to kick off serveez.

I created a file named serveez.service and saved it into /usr/local/share/systemd/system

[Unit]
Description=Serveez HTTP Daemon

[Service]
Type=forking
ExecStart=/usr/local/bin/serveez --daemon --cfg-file=/usr/local/etc/serveez-mg/serveez.cfg
PIDFile=/usr/local/var/serveez-mg/serveez.pid

[Install]
WantedBy=multi-user.target
From here, I ran the commands


systemctl enable serveez.service
systemctl start serveez.service

That should be enough to get it kicked off.  I verified that it was working using systemctl status serveez.service


The next chore was to get ddclient to run.  ddclient is a program that checks the IP address of the computer, and if it has changed, it notifies dyn.com, the provider of my dynamic IP hostname.  It wasn't included by default in my distro, so I installed it with yum.  The installed package included a script that gets put into /etc/rc.d, but, it didn't work for me.

I made a simple configuration file and put in into /etc/ddclient.conf


syslog=yes
mail=root
cache=/tmp/ddclient.cache
pid=/var/run/ddclient.pid
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
protocol=dyndns2
login=XXXXXXX
password=XXXXXXX
XXXXXX.dyndns-home.com

Obviously your DynDNS login, password, and the hostname at the bottom line would change for your setup.

And to have this kick off automatically, I had to make yet another systemd service file: ddclient.service

[Unit]
Description=ddclient dyndns.com dynamic ip updater

[Service]
Type=forking
ExecStart=/usr/sbin/ddclient -daemon 900
PIDFile=/usr/local/var/ddclient.pid

[Install]
WantedBy=multi-user.target

Pfft. And that basically got Serveez up and running on my box. But, enough stupidity for one Sunday.

Wednesday, May 25, 2011

Fedora 15 and Gnome 3

For the past few months, I've given up any real hacking.  I've weaned myself off of the antidepressants I was taking, and then I found that to retain my sanity I really needed to up the amount of exercise, sunshine, and fresh air I was getting to keep my emotions up.  So I've become quite the exercise fanatic of late: not because I like it, but, because it is necessary.

So, I have not touched any of my software projects for a couple of months.

But, after having read all of the horrible things said about Gnome 3, I wanted to experience the horror myself.  So I wiped the Dell PowerEdge T100 server and put Fedora 15 on it.

Installation was painless, but, it let me know that I didn't have the graphics power to run Gnome 3 in regular mode, so it runs in 'fallback' mode.  Fallback mode is quite nice, but, there are many oddities.

The default wallpaper is some blue stripes, which I did not find very soothing.  Right-clicking on the desktop does nothing, so, to change the wallpaper in fallback mode, you have to select Applications > System Tools > System Setting, select "Background" from the "Personal" section of the dialog, and then choose something else.

My workflow has always been based on leaving my currently active files and folders on the desktop.  My habit is to have my current projects on the desktop and inactive projects are stored in Documents.  Gnome 3's fallback mode does not allow files on the desktop, but, you can enable that feature.  Install and run the gnome-tweak-tool.  In its 'File Manager' section, set "Have file manager handle the desktop" to "On".  I found that trick here.

The next aggravation I found was that if you select a file in a File Manager window and then press the key, nothing happens.  You can right-click and select "Move to Trash".  But, I'd prefer that the key delete a file.  I eventually came across Gnome bug 647048 that says that this was intentional, and that now Ctrl+ is used to move a file to the trash.  I find changes like this to be the most worrisome, because I bounce between multiple operating systems as part of my job.  Certain actions are so fundamental as to be muscle memory and are uniform across my platforms.

I pulled a USB drive without unmounting.  That didn't go well.

Anyway, I don't really use Gnome for anything other than as a window and file manager, so I probably am not really get too deeply into this.