Category Archives: Code Samples

All Code Samples go here.

Add IP to whitelist for Postini Mail Filtering 7

I could not find any way to see how you could add an IP address as a ‘white list’ for our Postini installation. Mails coming from our mailing list manager kept getting caught in the Postini spam interface (which is probably a whole other issue, which I will need to address later). To get Postini to white list an IP address, you need to go into the Batch editing mode and issue this command: addallowedip organization name,domain.com:10.0.0.0 Full Postini Batch Reference See page 30 for ‘addallowedip’ syntax and more information.

How To Turn Off Your Monitor Via Command Line in Ubuntu 24

As previously written on this blog, I have set up a display in our lobby at work to display the day’s current events and meetings using Ubuntu and a tiny PC. Since this is a display which is on all day, the screensaver and monitor blanking (and other Energy Star features) are all turned off. Under the auspice of wanting to save energy and also extending the life of a new monitor, someone suggested that we turn off the monitor at night using an electrical timer. A lightbulb went off in my head, that there must be a better way to do this via command line and then run it in the cron. It turns out the solution is very simple. The xset command is the X server preferences command. It has a simple command to turn off the monitor: 1$ xset dpms force off and to turn the monitor….

Installatron WordPress Upgrade Disables Plugins 3

I just found a quick tip on the Installatron forums. By default Installatron disables all WordPress plugins when doing an upgrade. This is due to the WordPress best practices for upgrading the version of their system. When you have a lot of WordPress installs to go through this is a big pain because it usually breaks the site. According to this post, you disable the disabling of the plugins by creating a file named .dont_disable_plugins in the directory that wordpress is installed to. Via command line it is as simple as this: 1touch /path/to/wordpress/.dont_disable_plugins Execute that command on the command line (or upload an empty file via FTP/SCP) and the plugins will remain enabled. There is also an option in the installatron settings to enable this file creation upon install. Note that if you have a plugin that is not compatible with a new version of WordPress, it may break….

Memory Allocation Problems on Xen Server & Fix 1

Recently I started seeing this error while provisioning Xen VPSes on a server with 8GB of RAM: 12[2009-03-23 15:51:40 xend.XendDomainInfo 3310] DEBUG (XendDomainInfo:1603) XendDomainInfo.destroy: domid=None [2009-03-23 15:51:40 xend 3310] ERROR (xmlrpclib2:184) (12, ‘Cannot allocate memory’) I checked the memory, and sure enough, all of the VPSes were using up the memory. More specifically, dom0 (the main server) had ‘ballooned’ and begun to take up 3GB of RAM, this is more than the system should need: 12[2009-03-22 18:03:08 xend.XendDomainInfo 3310] DEBUG (XendDomainInfo:1113) Setting memory target of domain Domain-0 (0) to 2903 MiB. [2009-03-22 18:03:09 xend 3310] DEBUG (balloon:127) Balloon: 537840 KiB free; need 537600; done. Basically when memory ballooning is set, the memory available to the main hypervisor will have a minimum value set and will balloon according to the current requirements. This setting is in the config file which for me is at /etc/xen/xend-config.sxp: 1234# Dom0 will balloon out when….

Apt-get Update GPG Key Errors and Fix 13

Running sudo apt-get upgrade, I started getting this error: 1Reading package lists… Done 1W: GPG error: http://ppa.launchpad.net intrepid Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY 313D312748A22A95 1W: You may want to run apt-get update to correct these problems Ah ha! But apt-get update is the command causing this problem. The solution is to import this key from the gpg servers; I don’t know why this isn’t done automatically, but here is it: 1sudo apt-key adv –recv-keys –keyserver keyserver.ubuntu.com 313D312748A22A95; gpg –export –armor 313D312748A22A95 | sudo apt-key add – Resulting in: 123456Executing: gpg –ignore-time-conflict –no-options –no-default-keyring –secret-keyring /etc/apt/secring.gpg –trustdb-name /etc/apt/trustdb.gpg –keyring /etc/apt/trusted.gpg –recv-keys –keyserver keyserver.ubuntu.com 313D312748A22A95 gpg: requesting key 48A22A95 from hkp server keyserver.ubuntu.com gpg: key 48A22A95: public key "Launchpad PPA for Filip Brcic" imported gpg: Total number processed: 1 gpg:              unchanged: 1 OK Congrats! sudo apt-get….

Convert Windows or DOS Encoded Files to Unix/Linux. (ANSI to UTF-8) Comments Off

Windows files and Unix files (Redhat, Ubuntu, etc) are encoded in different ways. Namely, the end of line that is a part of most files created in Windows is not compatible with Unix. You can usually see this because there is a ‘weird character’ at the end of each line. ‘cat’ does not show it, but ‘cat -e’ will show these characters: xx.xx.125.240 spc240.xx.xx^M$ xx.xx.125.241 spc241.xx.xx^M$ The ^M is a Windows ‘End of Line’ character. Fortunately there is an easy way to fix these for using them in a unix based system. Install ‘dos2unix’, and then run the file through them: dos2unix filename You can even run these on a bunch of files: [root@ns1 ~]# dos2unix RDNS-* dos2unix: converting file RDNS-xx.xx.81 to UNIX format … dos2unix: converting file RDNS-xx.xx.82 to UNIX format … dos2unix: converting file RDNS-xx.xx.85 to UNIX format … dos2unix: converting file RDNS-xx.xx.95 to UNIX format … dos2unix:….

Remote Desktop from Windows XP to Windows Server 2008 or Windows Vista 3

The Remote Desktop connection settings for Windows Server 2008, and I believe Windows Vista, includes 3 levels of service: Don’t allow connections to this computer Allow connections from computers running any version of Remote Desktop (less secure) Allow connections only from computers running Remote Desktop with Network Level Authentication (more secure) At first blush, you would probably choose the “more secure” option. Practically, this mainly means that it only allows connections from the latest Remote Desktop software in Windows Vista. It is probably another attempt by Microsoft to force consumers and businesses into upgrading to Windows Vista. But… I digress. When connecting with an older Terminal Services (TS) client in XP or even Vista, you will get this message: “Remote computer requires Network Level Authentication, which your computer doesn’t support” Not all is lost. There are two ways around this. The first and most obvious solution is to select the….