My Blog

Simple Bash Script to use OS X 10.4 as a firewall

There was an unused Apple desktop machine running OS X 10.4 sitting around, so I decided to use it as a storage for our company's firewall log. The current log is then rotated and saved in /private/var/log/archived. Here's the script:

#!/bin/bash
echo Stopping Syslog...
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist
sleep 1

echo ""
printf %s "Rotating log files:"
cd /var/log
for i in edmonton.log; do
    if [ -f "${i}" ]; then
        printf %s " ${i}"
        if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
        if [ -f "${i}.6${gzext}" ]; then mv -f "${i}.6${gzext}" "${i}.7${gzext}"; fi
        if [ -f "${i}.5${gzext}" ]; then mv -f "${i}.5${gzext}" "${i}.6${gzext}"; fi
        if [ -f "${i}.4${gzext}" ]; then mv -f "${i}.4${gzext}" "${i}.5${gzext}"; fi
        if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
        if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
        if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
        if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
        if [ -f "${i}" ]; then
              touch "${i}.$$" && chmod 640 "${i}.$$" && chown root:admin "${i}.$$"
              mv -f "${i}" "${i}.0" && mv "${i}.$$" "${i}" && if [ -x /usr/bin/gzip ]; then
                gzip -9 "${i}.0"; fi
        fi
    fi
done
if [ -f /var/run/syslog.pid ]; then kill -HUP $(cat /var/run/syslog.pid | head -1); fi
echo ""

cp -f /var/log/edmonton.log.1.gz /var/log/archived/edmonton_log-`/bin/date +%Y-%m-%d`.gz

sudo rm -f /var/log/edmonton.log
sudo touch /var/log/edmonton.log
sudo chgrp -v admin /var/log/edmonton.log
sudo chmod -v go+w /var/log/edmonton.log


for i in toronto.log; do
    if [ -f "${i}" ]; then
        printf %s " ${i}"
        if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
        if [ -f "${i}.6${gzext}" ]; then mv -f "${i}.6${gzext}" "${i}.7${gzext}"; fi
        if [ -f "${i}.5${gzext}" ]; then mv -f "${i}.5${gzext}" "${i}.6${gzext}"; fi
        if [ -f "${i}.4${gzext}" ]; then mv -f "${i}.4${gzext}" "${i}.5${gzext}"; fi
        if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
        if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
        if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
        if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
        if [ -f "${i}" ]; then
              touch "${i}.$$" && chmod 640 "${i}.$$" && chown root:admin "${i}.$$"
              mv -f "${i}" "${i}.0" && mv "${i}.$$" "${i}" && if [ -x /usr/bin/gzip ]; then
                gzip -9 "${i}.0"; fi
        fi
    fi
done
if [ -f /var/run/syslog.pid ]; then kill -HUP $(cat /var/run/syslog.pid | head -1); fi
echo ""

cp -f /var/log/toronto.log.1.gz /var/log/archived/toronto_log-`/bin/date +%Y-%m-%d`.gz

sudo rm -f /var/log/toronto.log
sudo touch /var/log/toronto.log
sudo chgrp -v admin /var/log/toronto.log
sudo chmod -v go+w /var/log/toronto.log

for i in montreal.log; do
    if [ -f "${i}" ]; then
        printf %s " ${i}"
        if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
        if [ -f "${i}.6${gzext}" ]; then mv -f "${i}.6${gzext}" "${i}.7${gzext}"; fi
        if [ -f "${i}.5${gzext}" ]; then mv -f "${i}.5${gzext}" "${i}.6${gzext}"; fi
        if [ -f "${i}.4${gzext}" ]; then mv -f "${i}.4${gzext}" "${i}.5${gzext}"; fi
        if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
        if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
        if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
        if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
        if [ -f "${i}" ]; then
              touch "${i}.$$" && chmod 640 "${i}.$$" && chown root:admin "${i}.$$"
              mv -f "${i}" "${i}.0" && mv "${i}.$$" "${i}" && if [ -x /usr/bin/gzip ]; then
                gzip -9 "${i}.0"; fi
        fi
    fi
done
if [ -f /var/run/syslog.pid ]; then kill -HUP $(cat /var/run/syslog.pid | head -1); fi
echo ""

cp -f /var/log/montreal.log.1.gz /var/log/archived/montreal_log-`/bin/date +%Y-%m-%d`.gz

sudo rm -f /var/log/montreal.log
sudo touch /var/log/montreal.log
sudo chgrp -v admin /var/log/montreal.log
sudo chmod -v go+w /var/log/montreal.log


sudo launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist

Then, I also added the following to /etc/syslog.conf

local4.*                        /var/log/montreal.log
local6.*                        /var/log/edmonton.log
local0.*                        /var/log/toronto.log

That's it!

Read More

I'm Back!

I'm back! It has been a while since I updated this blog, so I'm going to continue writing whatever comes to mind. I've submitted my resignation from the company that I currently work for. It's sad to leave a great company with great people to work with, but I have an upcoming project that has already been paid for in advance. I'm going to continue as a freelance web developer and also develop babygekko's CMS. We'll see where things will develop from here.

Read More

Exchange OAB 500 internal error

I've got a strange problem with the Exchange 2010 in my company - OAB 500 internal error as you can see in the log below. Outlook 2007 and 2010 both hang during "Sending and Receiving" and downloading the offline address book.

2010-06-14 14:59:18 192.168.111.13 GET  /OAB/90eba0b1-d8bd-46a6-8b29-42b101621094/oab.xml - 443 -  192.168.111.118 Microsoft+BITS/6.7 500 0 64 0
2010-06-14 14:59:20  192.168.111.13 GET /OAB/90eba0b1-d8bd-46a6-8b29-42b101621094/oab.xml -  443 - 192.168.111.187 Microsoft+BITS/6.7 500 0 64 0
2010-06-14  14:59:21 192.168.111.13 GET  /OAB/90eba0b1-d8bd-46a6-8b29-42b101621094/oab.xml - 443 - 192.168.60.121  Microsoft+BITS/6.7 500 0 64 140
2010-06-14 14:59:26 192.168.111.13  GET /OAB/90eba0b1-d8bd-46a6-8b29-42b101621094/oab.xml - 443 -  192.168.111.144 Microsoft+BITS/6.7 500 0 64 0
2010-06-14 14:59:26  192.168.111.13 GET /OAB/90eba0b1-d8bd-46a6-8b29-42b101621094/oab.xml -  443 - 192.168.111.187 Microsoft+BITS/6.7 500 0 64 15
2010-06-14  14:59:34 192.168.111.13 GET  /OAB/90eba0b1-d8bd-46a6-8b29-42b101621094/oab.xml - 443 - 192.168.60.121  Microsoft+BITS/6.7 500 0 64 124
2010-06-14 14:59:34 192.168.111.13  GET /OAB/90eba0b1-d8bd-46a6-8b29-42b101621094/oab.xml - 443 -  192.168.77.116 Microsoft+BITS/6.7 500 0 64 421
2010-06-14 14:59:34  192.168.111.13 GET /OAB/90eba0b1-d8bd-46a6-8b29-42b101621094/oab.xml -  443 - 192.168.111.168 Microsoft+BITS/6.7 500 0 64 0
2010-06-14  14:59:34 192.168.111.13 GET  /OAB/90eba0b1-d8bd-46a6-8b29-42b101621094/oab.xml - 443 - 192.168.111.74  Microsoft+BITS/6.7 500 0 64 78

Solution:

Set-OabVirtualDirectory -Identity "EXCHANGESERVERNAMEOAB (Default Web Site)" -internalurl http://yourlocalexchange2010.yourdomain.local -RequireSSL:$false

Read More

Fake antivirus disabling Taskmgr.exe

Today, one of the Windows XP machines in the network got compromised by a fake antivirus. I was able to get rid of this malware, which hid itself under C:Documents and SettingsAll UsersApplication DataMicrosoft, however I wasn't able to run taskmgr.exe. I googled for solutions on how to enable taskmgr.exe, some said that it was in the Group Policy. However, I couldn't find the entry.

Apparently, this fake antivirus also created a whole bunch of registry entries under [HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Image File Execution Options].

Extra debugger entry for Taskmgr.exe

To fix it, first delete the whole key and then merge the registry entry in this zipped file. Please note that this has only been tested with Windows XP 32-bit. Windows Vista and Windows 7 users, please don't use the registry file to fix your system.

Read More

Setting up Samsung 2443 monitor - 1920x1200 (60Hz) on Ubuntu 10.

OK so I just installed Ubuntu 10.04 with ATI's fglrx proprietary driver on my HP 6930p with Samsung 2443BW 24" monitor but the screen resolution got stuck at 1280x1024. Here's how I made it to work in its native resolution.

You can either use root or just add sudo before each command.

root@ubuntugekko:/# xrandr --newmode "1920x1200_60" 193.16 1920 2048 2256 2592 1200 1201 1204 1242 -HSync +Vsync

If you tested it and it works, then create a file in your home directory called .xprofile with the following in it:

prana@ubuntugekko:~$ cat .xprofile

xrandr --newmode "1920x1200_60.00" 193.16 1920 2048 2256 2592 1200 1201 1204 1242 -HSync +Vsync
xrandr --addmode CRT1 "1920x1200_60.00"
xrandr --output default --mode "1920x1200_60.00"

Done

Read More

Migrated this blog to Babygekko from Wordpress

Yippeee!!! I've finally migrated my blog to Babygekko (my own content management system) from Wordpress! This version is not available for download yet as I'm still testing it on this site.

Update ** - Ooops - apparently this server is still using PHP 5.2 .. commenting won't work since I have codes that use get_called_class() and I've tried the substitute and it doesn't work ...

Update ** OK finally removed the code..

Read More

Scrolling the screen in Assembly language back in the old 386 da

Mov CX,Scx
Mov DX,Sdx
Add DX,Y
Add CX,X
Mov Scx,CX
Mov Sdx,DX
Mov AX,04F07H
XOr BX,BX
Int 10H

I was just looking at my old files .. Mwahahahhahah .. calling interrupt 10 .. poof. Whatever I wrote 12 years ago doesn't work in my Intel Core 2 Duo anymore.  It was 386, then 486 .. now it's Core-Quad or whatever.

Read More

mirC 50% off coupon

Well worth it for this useful little proggie - only $10.00

http://www.mirc.com/register.php?coupon=MIRC-SWV0-MNKL

Read More

YUI javascript date picker – Gekko Date Picker

I've been trying to find a good date picker based on YUI for my web projects but haven't found any that meets the simplistic requirement - without having to attach it to events and whatnot. So I decided to made one for myself based on this: http://www.javascriptkit.com/script/script2/dyndateselector.shtml

gekkodatepicker

Read More

Merry Christmas!

Wishing everyone a happy & safe holiday!

Read More

Latest

DirectAdmin - error when compiling Exim 4.98 on Oracle Linux 8

17.Apr.2025
I was trying to upgrade Exim to 4.98 from 4.97 (with a standard "da build exim" command), and someh...

VirtualBox error NS_ERROR_INVALID_ARG (0X80070057) when adding an existing virtual machine

1.Oct.2024
If you've ever encountered the following error when adding an existing VM to your host:   ...

Tik Tok algorithm is interesting

17.Apr.2024
I don't know how Tik Tok does it and honestly I don't know how its algorithm works. It can't be alg...

How to upgrade Gitlab safely with zero downtime

30.Mar.2024
GitLab is a complex piece of software. If you are planning on upgrading your self-hosted GitLab mac...

How to reduce Proxmox VE guest machine backup size

30.Mar.2024
To reduce a guest machine before you perform a backup, first set the discard flag on the guest mach...