9thport ruby, rails, sysadmin, os x, and other stuff

22Feb/100

Another day at the bus stop

Another day at the bust stop that got me to take a panorama of the weather. This time I saw lots of fog!

Filed under: Photos, Travel No Comments
22Feb/100

When starting Dreamweaver CS4 I get an error of microsoft visual c++ runtime library: runtime error

Today I got an error message of "microsoft visual c++ runtime library: runtime error ..." when attempting to run Adobe Dreamweaver CS4. This is horrible!! Here is a screen show showing what I got:

dreamweaver cs4 windows error

my dreamweaver cs4 windows error

My method for fixing this error on Windows XP was to do move the following directory into my Recycle Bin:

  • c:\Documents and Settings\[username]\Application Data\Adobe\Dreamweaver CS4

Note: The "Application Data" folder is hidden and you might need to do the following:

  1. Choose menu "Tools"
  2. Choose menu item "Folder Options"
  3. Choose tab "View"
  4. Enable "Show hidden files and folders"
  5. Click "OK"

After removing the directory, launching Dreamweaver worked! I was also surprised that I did not loose any of my site settings.

12Feb/100

bash script template to be used for parsing arguments to make your shell programming life easier

I found that all my bash scripts really bennifet with the following template because:

  1. it handles options with possible responses of needs
  2. debugging with a flag
  3. help description of the script

This template keeps proving to be enough to start my script building. There is really nothing more to say about this so here is my template:

#!/usr/bin/env bash

# created at: Wed Apr 04 10:03:41 PDT 2009
# updated at: Wed Apr 22 15:33:24 PDT 2009
# author: aaron addleman

# manage subversion with swatch and ftp log file. all actions will be sent to a file for throttling purposes to allow SVN to handle its own lock files
# BEGIN SCRIPT
usage()
{
cat << EOF
usage: $0 options
This script takes commands from a swatch and converts to svn commands for a directory under version control.
OPTIONS:
-h      Show this message
-a   Action needed (STOR, DELE, MKD, ENTRIES, SVNUPDATE)
-u      Username to use for commits
-f      File or directory being affected
-m      message to use
-x      Execute SVN commands from the $SVNACTIONS file
(when this option is used, all others are ignored)
-v      Verbose (boolean)
-t      Test (dont run any commands, but print them to the command line)
EOF
}

ACTION=
USER=
FILE=
MESSAGE=
VERBOSE=
TEST=
while getopts "h a:u:f:m:x:v:t" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
a)
ACTION=$OPTARG
;;
u)
USER=$OPTARG
;;
f)
FILE=$OPTARG
;;
m)
MESSAGE=$OPTARG
;;
v)
VERBOSE=1
;;
t)
TEST=1
;;
?)
usage
exit
;;
esac
done

4Feb/100

Installing Ubuntu now…

I really like the Ubuntu operating system and the team that is making it. I hope to make it my personal development computer once I find a nice laptop to run it on.

Installing Ubunto 9.10 on VMWare

Installing Ubunto 9.10 on VMWare

Full Screen Terminal Screen shot in Ubuntu while installing Ruby on Rails

Full Screen Terminal Screen shot in Ubuntu while installing Ruby on Rails

Filed under: Linux, Sysadmin No Comments
4Feb/100

RedHat Linux ACL report bash shell script

Finally the day has arrived where I had to make a script to build an report for the access control list attributes on all of the files on my web server. I decided to use bash because it was easy for me to do and for compatibility of future releases of RedHat. I would have much rather have done it in Python or Ruby, but ohwell. By no means is this script really complete. I have to admit that it needs better testing of the input arguments and the debugging messages are pretty bad. I wrote this script in under 1 hour. I will do better as time proceeds, but for now, it got the job done.

My script does the following:

  1. takes two arguments
    1. the path to start looking for directories
    2. the file name for the report
  2. builds a header with date and time of report
  3. finds the users and groups and counts the amount of times they appear in the report for a summary
  4. appends the full report of all the files with the ACL

Ideas for the next version:

  1. Prompting of cleaning up world writable files
  2. Storing ACL for each file into a database for tracking history
  3. Do you have any ideas? If so, please let me know and maybe I will add them to the next version.

    And now, here is the script:

    (for anyone who wishes to gen_acl_report.sh)

    #!/bin/bash

    # purpose: create ACL report on 1 level depth directories and output to text file report
    # usage: ./gen_acl_report.sh start_path report
    # the above command will generate a file called "report_20100203_YYYYMMDD_HHMMSS.txt"

    # created by: aaron
    # created at: 20100203

    # debug flag
    DEBUG="on"

    # debug function
    function DEBUG()
    {
    [ "$DEBUG" == "on" ] && $@ || :
    }

    # set path to find files
    STARTPATH="$1"

    # set report output
    REPORT="$2_`date +%Y%m_%H%M%S`.txt"

    # set temp report file
    ACLFILELIST=/tmp/acl_file_list.txt

    DEBUG echo "REPORT is = $REPORT"
    DEBUG echo "ACLFILELIST is = $ACLFILELIST"
    DEBUG echo "STARTPATH is = $STARTPATH"

    # build acl list
    function reportHeader
    {
    DEBUG echo "...inside function reportHeader"
    echo "ACL REPORT" >> $REPORT
    echo "Started on `date`" >> $REPORT
    echo "===================================" >> $REPORT
    DEBUG echo "...end of function reportHeader"
    }

    function getACL
    {
    DEBUG echo "...inside function getACL"
    # find all files excluding .svn
    #find $STARTPATH -path '*.svn' -prune -o -type f -exec getfacl {} \; > $ACLFILELIST
    # find all top level directories
    DEBUG echo "executing find $1"
    find $STARTPATH -maxdepth 1 -path '*\.svn' -prune -o -type d -exec getfacl {} \; > $ACLFILELIST
    DEBUG echo "...end of function getACL"
    }

    function groupsSummary
    {
    DEBUG echo "...inside function groupsSummary"
    echo "===================================" >> $REPORT
    echo "Group Summary:" >> $REPORT
    echo " " >> $REPORT
    cat $ACLFILELIST | grep "^group:[a-zA-Z]" | sort | uniq -c >> $REPORT
    echo " " >> $REPORT
    echo "Default Group Summary:" >> $REPORT
    echo " " >> $REPORT
    cat $ACLFILELIST | grep "^default:group:[a-zA-Z]" | sort | uniq -c >> $REPORT
    echo " " >> $REPORT
    echo "Users for each group:" >> $REPORT
    for a in `cat $ACLFILELIST | grep "^group:[a-zA-Z]" | sort | awk -F: '{print $2}' | uniq`
    do
    echo $a >> $REPORT
    for g in `cat /etc/group | grep $a`
    do
    echo $g | awk -F: '{print "\t"$4}' >> $REPORT
    done
    done
    echo " " >> $REPORT
    echo " " >> $REPORT
    echo "Users for each default group:" >> $REPORT
    for a in `cat $ACLFILELIST | grep "^default:group:[a-zA-Z]" | sort | awk -F: '{print $3}' | uniq`
    do
    echo $a >> $REPORT
    for g in `cat /etc/group | grep $a`
    do
    echo $g | awk -F: '{print "\t"$4}' >> $REPORT
    done
    done
    echo "===================================" >> $REPORT
    DEBUG echo "...end of function groupsSummary"
    }

    function usersSummary
    {
    DEBUG echo "...inside function usersSummary"
    echo "===================================" >> $REPORT
    echo "User Summary:" >> $REPORT
    echo " " >> $REPORT
    cat $ACLFILELIST | grep "^user:" | sort | uniq -c >> $REPORT
    echo " " >> $REPORT
    echo "Default User Summary:" >> $REPORT
    echo " " >> $REPORT
    cat $ACLFILELIST | grep "^default:user:" | sort | uniq -c >> $REPORT
    echo " " >> $REPORT
    echo "===================================" >> $REPORT
    DEBUG echo "...end of function usersSummary"
    }

    function maskSummary
    {
    DEBUG echo "...inside function maskSummary"
    echo "===================================" >> $REPORT
    echo "Mask Summary:" >> $REPORT
    echo " " >> $REPORT
    cat $ACLFILELIST | grep "^mask:" | sort | uniq -c >> $REPORT
    echo " " >> $REPORT
    echo "Default Mask Summary:" >> $REPORT
    echo " " >> $REPORT
    cat $ACLFILELIST | grep "^default:mask:" | sort | uniq -c >> $REPORT
    echo " " >> $REPORT
    echo "===================================" >> $REPORT
    DEBUG echo "...end of function maskSummary"
    }

    function findGroups
    {
    DEBUG echo "...finding list of groups"
    cat $ACLFILELIST | grep group:
    }

    function otherSummary
    {
    DEBUG echo "...inside function otherSummary"
    echo "===================================" >> $REPORT
    echo "Other Summary:" >> $REPORT
    echo " " >> $REPORT
    cat $ACLFILELIST | grep "^other:" | sort | uniq -c >> $REPORT
    echo " " >> $REPORT
    echo "Default Other Summary:" >> $REPORT
    echo " " >> $REPORT
    cat $ACLFILELIST | grep "^default:other:" | sort | uniq -c >> $REPORT
    echo " " >> $REPORT
    echo "===================================" >> $REPORT
    DEBUG echo "...end of function otherSummary"
    }

    function listofFiles
    {
    DEBUG echo "...list of files"
    echo "===================================" >> $REPORT
    echo "List of files" >> $REPORT
    cat $ACLFILELIST | grep "# file: " >> $REPORT
    echo "===================================" >> $REPORT
    DEBUG echo "...end of list of files"
    }

    function appendACL
    {
    DEBUG echo "...appending acl contents"
    echo "===================================" >> $REPORT
    echo "ACL list of files" >> $REPORT
    cat $ACLFILELIST >> $REPORT
    echo "===================================" >> $REPORT
    DEBUG echo "...end of acl contents appending"
    }

    function removeACL
    {
    DEBUG echo "...removing temp files for ACL"
    rm $ACLFILELIST
    DEBUG echo "...removing temp files for ACL done"
    }

    reportHeader
    getACL
    groupsSummary
    usersSummary
    maskSummary
    otherSummary
    listofFiles
    appendACL
    findGroups

    removeACL

    Filed under: Sysadmin No Comments