Tuesday, December 21, 2010

sysupd.sh

System update script. Syncs pacman databases, optionally lists available updates, upgrades, prompts for abs sync, and updates mlocate database. Flags to download the updates without installing, list available updates, no-confirm, and force sync.

#!/bin/bash

# make sure the script is being run as root
/usr/local/bin/chkroot && [[ $? = 0 ]] || exit 1

# define script variables
dlonly=
fsync=
noconf=
list=0

# get optoins
args=`getopt dlny $*`

set -- $args
for i; do
    case "$1" in
        -d) dlonly="-w"                        ; shift ;;
        -l) list=1                                ; shift ;;
        -n) noconf="--noconfirm"    ; shift ;;
        -y)    fsync="-y"                        ; shift ;;
        --) shift                                    ; break ;;
    esac
done

pacman -Sy $fsync
[[ "$?" = "0" ]] || exit 1

if [[ "$list" = "1" ]]; then
    pacman -Qu --dbpath /var/lib/pacman
    exit 0
fi

pacman -Su $dlonly $noconf
echo "Sync ABS? [Y/n]"
read sync_abs
if [[ "$sync_abs" != {"N","n"} ]]; then
    abs
fi

echo; echo "updating mlocate database"
updatedb

exit 0

Tuesday, December 14, 2010

tarpac

Pacman cache archiving. Right now it just gzips everything in the /var/cache/pacman/pkg directory, then cleans the pacman cache. The only problem is that the --clean flag keeps the most current package tarballs, which have also been archived, so there's a going to be redundancy in the archives. I need to write in a way to ignore the most recent of the tarballs, just haven't figured that out yet.

#!/bin/bash
# create a dated archive of the pacman cache

chkroot && [[ $? = 0 ]] || exit 1

cd /var/cache/
tar pczf /home/jason/pacmancache-`date +%F`.tar.gz pacman/pkg
[[ $? = 0 ]] || echo "archive failed"; exit 1

echo "clearing old cache..."
pacman -S --clean
exit 0

Tuesday, December 7, 2010

syncscripts

Here's my script to manage systemwide scripts. The scripts and their destination files are held in the syncscripts.lst file. Scripts can be added. The script has be run from the folder where are all of the other scripts are developed. It checks the if the destination file exists, and copies it if it doesn't. If it does exist, it compares the md5sum of script with that of the destination file; if they differ, it copies the script to the destination file. The remove function has not yet been written.

#!/bin/bash

# pre-defined script variables
silent=1
verbose=1
addscript=1
remscript=1
scriptlist=syncscripts.lst

# display script usage
disphelp() {
    echo "Usage: $(basename $0) [OPTION] [SCRIPT]"
    echo
    echo "OPTIONS:"
    echo " -s          silent"
    echo " -v          verbose"
    echo " -a SCRIPT      add script"
    echo " -r SCRIPT      remove script"
    echo " -h         display this message"
}

###########################################################
args=`getopt svar $*`

set -- $args
for i; do
    case "$1" in
        -s) silent=0        ; shift    ;;
        -v) verbose=0     ; shift ;;
        -a) addscript=0 ; shift ;;
        -r) remscript=0 ; shift ;;
        -h) disphelp        ; exit 0 ;;
        --) shift                ; break ;;
    esac
done

# check for existence of syncscripts.lst, create an empty one if
#+one does not already exist
if [[ ! -f $scriptlist ]]; then
    [[ $silent = 1 ]] && echo "syncscripts.lst not found, creating a blank file"
    touch $scriptlist
fi

# add script to scriptlist
if [[ $addscript = 0 ]]; then
    # check to make sure script exists, the add script and destination
    #+to file.
    if [[ -f $1 ]]; then
        [[ $silent = 1 ]] && echo "$1 $2" >> $scriptlist
        exit 0
    fi
    [[ $silent = 1 ]] && echo "failed to add $1, no such file"
    exit 1
fi

# remove script from scriptlist
if [[ $remscript = 0 ]]; then
    [[ $silent = 1 ]] && echo "the remove function has not yet been written, nothing was removed"
    exit 0
fi

# step through lines of syncscripts.lst, every two lines contain an
#+entry the first line is the script, the second the path to move it to
while read line; do
    script=`echo $line | awk '{print $1}'`
    dest=`echo $line | awk '{print $2}'`

    # if destination path does not exist, copy without checking md5sums
    if [[ -z $dest ]]; then
        [[ $silent = 1 ]] && echo "$dest does not exist, copying $script to $dest"
        cp $script $dest
        continue
    fi
    # get the md5sum of the script and its destination, if no
    #+changes have been made, it doesn't need to be copied.
    scriptsum=`md5sum $script | awk '{print $1}'`
    destsum=`md5sum $dest | awk '{print $1}'`
    if [[ $scriptsum != $destsum ]]; then
        [[ $silent = 1 ]] && echo "detected changes in $script, copying to $dest"
        cp $script $dest
    fi
done <$scriptlist


exit 0

Wednesday, November 24, 2010

Scripts

Since some of my scripts should be used system wide (i.e. multiple users, the system itself, etc.), I'll be writing a script that will move all of the pertinent scripts to their system directories if they've been changed. This way, other users wont need access to my home directory to run certain scripts, like the wireless connection tool.

Tuesday, November 23, 2010

Slackware 13.1

Installed Slackware on my server today. Still working on configuring. Wrote a script to step through and vim every file within a given directory, which I'll be posting soon. Then it's on to learning the package build and installation process.

Wednesday, November 10, 2010

[update]gmail python script

The problem reminded me of my python script, which retrieves to number of unread e-mails in my mailbox. They also had some syntax errors. So, in ~/.conkyrc I changed the 'exec python gmailscript' to 'exec python2 gmailscript' and it worked out just fine.

[bug]chocolate-doom package build

A bug in the build for the chocolate-doom AUR package was brought to my attention recently:
  1. ./docgen -m manpage.template ../src > chocolate-doom.6
  2.   File "./docgen", line 392
  3.     print line.rstrip()
  4.              ^
  5. SyntaxError: invalid syntax
  6. make[2]: *** [chocolate-doom.6] Error 1
  7. make[2]: Leaving directory `/home/arin/Downloads/chocolate-doom/src/chocolate-doom-1.4.0/man'
  8. make[1]: *** [all-recursive] Error 1
  9. make[1]: Leaving directory `/home/arin/Downloads/chocolate-doom/src/chocolate-doom-1.4.0'
  10. make: *** [all] Error 2

Archlinux recently swiched from Python2 to Python3 as the default python. It uses symlinks to point /usr/bin/python to the actual Pythonx package. While Python2 is still installed, the /usr/bin/python symlink now points to Python3. The docgen script was using the default python (now Python3). The opening line for the script read: '#! /usr/bin/env python'. So, I will look into this, but the syntax used, which threw the error, was probably deprecated (or there's a bug). The salution thus being to edit the file to use Python2. Thus, the line "sed 's/python/python2/' -i man/docgen" was added to the PKGBUILD. The Python2 package also had to be added to the list of dependencies.

Wednesday, November 3, 2010

recurperms

I wrote a script to remove the executable flags from all files within a directory but directories themsevles. It will also descend into sub-directories.

#!/bin/bash

# This script will chmod -x every file within a
# directory recursively, without removing the
# executable nature of the directories contained
# within.
################################################

do_recursion() {
    files=`ls`
    file=
    for i in $files; do
        file=$file$i
        if [[ ! -e $file ]]; then
            file=$file' '
            continue
        fi
        if [[ -d "$(pwd)/$file" ]]; then
            echo "descending into directory $(pwd)/$file"
            cd "$(pwd)/$file"
            do_recursion
        fi
        if [[ -d "$(pwd)/$file" ]]; then
            echo "ascending to directory $(pwd)/$file"
        else
            echo "chmodding $(pwd)/$file"
            chmod -x $file
        fi
        file=
    done
    cd ..
    return
}

do_recursion

exit 0

Tuesday, November 2, 2010

pacdown

Since I'm going to be running testing full-on, I'm going to need a script that can downgrade recently upgraded packages. I'll want to be able to pass the script a single package name that it can then downgrade, or tell it to downgrade all packages recently upgraded from testing. This may also lead to my package management script that will look at a blacklist file of packages that had to be downgraded, so that they won't be re-upgraded unless removed from the blacklist.

Testing Packages

Suprisingly, I haven't run into any conflicts until now. I guess some packages in testing require other packages in testing to be installed. Therefore, when using the testing repos, it is necessary to update the machine soley from the testing repo, rather than pick and choose packages to be tested. I will thus be scrapping the pactesting script and installing all packages from testing. I e-mailed the mailing list and it was advised that I do the aforementioned and simply use a script to revert to the stable package incase a testing package does not work propperly.

Monday, November 1, 2010

[bug]pactesting

When passing an option to pacman, i.e. pactesting -w package, pactesting will treat the option as a package while validating. While the script still works as it should, options and all, it's not correct. An update is in the works.

Friday, October 29, 2010

crond errors

While going through the cron log with my scanlogs script, I noticed that the only errors present are those that say 'unable to exectute /usr/sbin/sendmail/'. Sendmail is a script of some sort that sends a message (to the root user, I believe) with cronjob info. However, /usr/bin/sendmail doesn't exist. You can also sepcify this messaging script in the config file, /etc/conf.d/crond, with the -M switch. So, I made a blank script, cronmailer, and had cron call it instead of sendmail.

Thursday, October 28, 2010

[update]seressid

I think I've posted this script before. Simple script to search for a regexp within a near by broadcasting ESSID. Reports found networks or that nothing matched 'regexp'.

#!/bin/bash

chkroot && [[ $? = 0 ]] || exit 1

count=0
while [[ $count < 10 ]]; do
  iwlist wlan0 scan | grep $1
  [[ $? = 0 ]] && exit 0
    let count=$count+1
  sleep 2
done

echo "No ESSID's matching term '$1' found."

exit 1

Tuesday, October 26, 2010

[update]wircon

Fixes:
If the find_network function failed, the script would still try to connect to a network, which would cause an error because there was no network set to connect to.
An instance where main was called from a function which was called by main. Now it just returns to main rather than calling it again.
An edit to the restart function in the init script was also necessary. The delay between stopping and starting the script was changed from 1 second to 2.

Still to fix:
If the script is stopped before it enters the 'main' function, the signal wont be caught and the do_unset_network function wont be run.

#!/bin/sh

dhcpcdPID="/var/run/dhcpcd.pid"
networks=`cat /home/jason/devel/scripts/wircon/pref_networks.lst`
statfile="/home/jason/devel/scripts/wircon/status"
silent=1

# make sure the script is being run as root
# chkroot && [[ $? = 0 ]] || exit 1

echo "starting" > $statfile

##################################################################
# scan for essids located in pref_networks.lst
find_network() {
  for i in $networks; do
    iwlist wlan0 scan | grep $i &> /dev/null
    if [[ "$?" = "0" ]]; then
      local essid=$i
      break
    fi
  done

  case $essid in
    "SouthPacific")
            network="sp"
            ;;
    "SouthPacific_Extender")
            network="spx"
            ;;
    "Belkin_G_Wireless_C973D1")
            network="seans"
            ;;
        "NETGEAR-Go")
            network="seans2"s
            ;;
        "MadisonOaks")
            network="daniels"
            ;;
        *)
            network=
  esac
}

##################################################################
# if dhcpcd is running, stop it
do_dhcpcd_check() {
  if [[ -f $dhcpcdPID ]]; then
    if [[ $silent = "1" ]]; then
      dhcpcd -x
    else
      dhcpcd -x -q
    fi
  fi

}

##################################################################
# load wireless firmware
do_load_firmware() {
  [[ $silent = "1" ]] && echo "loading wireless firmware"
  ifconfig wlan0 up
}

##################################################################
# set essid and, if applicable, network key
do_set_network() {
  [[ $silent = "1" ]] && echo "setting network parameters"
  iwconfig wlan0 essid $ESSID
  if [[ $KEY != "" ]]; then
      iwconfig wlan0 key $KEY
  fi
}

##################################################################
# unset the network for graceful exit
do_unset_network() {
  do_dhcpcd_check
  ifconfig wlan0 down
}

##################################################################
# try for dhcp lease
do_dhcpcd() {
  if [[ $silent = "1" ]]; then
    dhcpcd
  else
    dhcpcd -q
  fi
}

##################################################################
# something that helps find a carrier
do_channel_auto() {
  [[ $silent = "1" ]] && echo "connecting to carrier"
  iwconfig wlan0 channel auto
}

##################################################################
# make sure it worked
check_connection() {
  ping -c 1 www.google.com &> /dev/null

  if [[ $? = "0" ]]; then
    return 0
  else
    return 1
  fi
}

##################################################################
# set the desired network
set_network_params() {
  case $network in
    "sp")
            ESSID="SouthPacific"
            KEY="6bcebdfbea3caf9f3cd36b31b8"
            ;;
    "spx")
            ESSID="SouthPacific_Extender"
            KEY="6bcebdfbea3caf9f3cd36b31b8"
            ;;
    "seans")
            ESSID="Belkin_G_Wireless_C973D1"
            KEY=
            ;;
        "seans2")
            ESSID="NETGEAR-Go"
            KEY=
            ;;
        "daniels")
            ESSID="MadisonOaks"
            KEY=
            ;;
    *)
            return 1
  esac

    return 0
}

##################################################################
# make sure we're still connected to the network
connection_monitor() {
  while [[ 1 = 1 ]]; do
    sleep 10
    check_connection
    if [[ $? = 1 ]]; then
      echo "disconnected" > $statfile
      return
    fi
    echo "connected" > $statfile
  done
}

##################################################################
# call all functions in proper order to establish connection
main() {
  trap 'echo "down" > $statfile; do_unset_network; exit;' INT
  trap 'echo "down" > $statfile; do_unset_network; exit;' TERM

    while [[ 1 = 1 ]]; do
        set_network_params
        [[ $? = 0 ]] && break
        echo "searching" > $statfile
        find_network
    done

  while [[ 1 = 1 ]]; do
    do_dhcpcd_check
    do_set_network
    sleep 2
    do_dhcpcd
    do_channel_auto
    check_connection
    if [[ $? = 0 ]]; then
      [[ $silent = "1" ]] && echo "connection established"
      connection_monitor
        else
            echo "disconnected" > $statfile
    fi
  done
}


##################################################################
# check scripts usage
if [[ $# > 0 ]]; then
  if [[ $1 = "-s" ]]; then
    silent=0
    shift
  fi
    do_load_firmware
    sleep 2
  if [[ ! -z $1 ]]; then
    network=$1
  else
    find_network
  fi
else
    do_load_firmware
    sleep 2
  find_network
fi

main

exit 2

Saturday, October 16, 2010

scanlogs-0.0.1-1

First draft of the log scanning script. Only searches through '.log' files, purposefully ommitting '.log.n' files created by logrotate. Special case search terms can be added in a case statement, as seen with the Xorg.0.log example. It then goes through each file, and if any instances of the search-term are found, it displays the name of the file in red and asks if it should be displayed, which is then piped through less (later it will only be piped through less if it's too long to fit on the screen). If no instances are found in the file, it prints the name of the file in blue and "clean" under it, then moves to the next file.

Note: right now the auth.log example doesn't work properly. I also plan to code in multiple search terms.

#!/bin/bash

chkroot && [[ $? = 0 ]] || exit 1

logpath='/var/log/'

alllogs=`ls $logpath | grep 'log$'`

clear

for i in $alllogs; do


    #special log cases
    case $i in
        "Xorg.0.log")
            search_term="(EE)"
        ;;
        "auth.log")
            search_term='authentication failure'
        ;;
        *)
            search_term="error"
    esac

    num_errors=`cat $logpath$i | grep -c "$search_term"`
    if [[ "$num_errors" -gt "0" ]]; then
        echo -e "\033[1;31m$i\033[0m"
        echo " :: found $num_errors instances of '$search_term', expand? [y/N]"
        read choice
        if [[ $choice = ['y','Y'] ]]; then
            cat $logpath$i | grep $search_term | less
        fi
    else
        echo -e "\033[1;34m$i\033[0m"
        echo " :: clean"
        echo
    fi
done

exit 0

Monday, October 11, 2010

[bug]Wircon

Turns out I messed something up in the coding. For some reason when re/started from the rc.d init script, some error messages are thrown. I'm guessing these messages are always there, it's just usually not visible because it's run as a startup script. I also might just try to write it in C, or maybe Python (the orriginal plan).

Thursday, October 7, 2010

[update]chkroot

Don't know why I didn't think to do this before...

#!/bin/bash

[[ $(id -u) = 0 ]] && exit 0
[[ $1 = "-q" ]] || echo 'error: this script must be run with root privileges'
exit 1

Wednesday, October 6, 2010

scanlogs

Working on a script to search through all of my current log files (those that haven't been pushed to a .log.n file by logrotate) for any anomolies. I'm mostly going to use this to search for error messages in log files, however, I might add some auth.log functionality to it. Suchas, any time a person tries to gain root access unsuccessfully.

Thursday, September 30, 2010

[AUR]chocolate-doom

I am the proud new maintainer of the chocolate-doom port. I updated the PKGBUILD and everything installed fine. I'll be mulling over the PKGBUILD script in the future to see what I can do to improve it.

Sunday, September 26, 2010

[update]chkroot

I rearranged the code to check for root then exit 0; if that fails, it checks for a quiet switch and echos an error message accordingly, then exit 1.

#!/bin/bash

if [[ $(id -u) = 0 ]]; then
    exit 0
fi

[[ $1 = "-q" ]] || echo 'error: this script must be run with root privileges'
exit 1

Friday, September 24, 2010

chkroot

Since I have so many scripts that require root privileges to run, I wrote a simple script to do the check, so all I have to do is add a line in each script to run the check, rather than writing out the same if statement in every script.

Here's the check_root.sh script that I wrote:
#!/bin/bash

if [[ $(id -u) != 0 ]]; then
    echo 'error: this script must be run with root privileges'
    exit 1
fi

exit 0

and here's how it's called within other scripts:
chkroot && [[ $? = 0 ]] || exit 1

[update]sysmon

I updated my sysmon script so that it actually works. I was having problems with the battery charge comparrison, I'm guess becuase of all the leading zeros. So, I put them in quotes and rather than using the actual greather-than, less-than ('>' '<') symbols, I used the '-gt/-lt' operators. Now, all is well in the system monitoring script.

#!/bin/zsh


# make sure user has root privileges
chkroot && [[ $? = 0 ]] || exit 1

log="/home/jason/devel/scripts/sysmon/sysmon.log"
ver=(0.0.3-1)

echo "" > $log

# define battery variables
charge_now='/sys/class/power_supply/BAT1/charge_now'
charge_full='/sys/class/power_supply/BAT1/charge_full'
charge_factor=20  # 5% battery power

# define temperature variables
max_temp=85
for i in {0..1}; do
  temp_path="/sys/class/hwmon/hwmon$i/device/temp1_input"
  [[ -f $temp_path ]] && break
done

# get full charge value
full="`cat $charge_full`"

# calculate the minimum charge based on the charge_factor
charge_min=$(($full/$charge_factor))

# just keep going
while [[ "1" = "1" ]]; do
  # get current charge
  charge="`cat $charge_now`"

  # system doesn't use hwmon1 or hwmon0 exclusively, so there's a need to differentiate
  temp="`cat $temp_path`"
  temp=$temp[1,2]

  #[[ $temp > $max_temp ]] || [[ $charge < $charge_min ]]

  if [[ "$temp" -gt "$max_temp" ]]; then
    echo `date` >> $log
    echo "Shutdown due to high temp: $temp C" >> $log
        shutdown -h now
  fi

  if [[ "$charge" -lt "$charge_min" ]]; then
    echo `date` >> $log
    echo "Shutdown due to low charge: $charge < $charge_min" >> $log
        shutdown -h now
  fi
  sleep 10
done

Wednesday, September 22, 2010

Daily Activities

Follow-up on the shadow file. It just stores username, password, and date information pertaining to the password. From what I've read on the mailing list, the last changed date would set to sometime in the future, the update fixed this. Thus, the new file isn't really that important, I'll probably just have to update the root and other user dates. Anyway, here's a page explaining the file.

pactesting [update]

Looks like the resync isn't needed. Pacman will only sync and download the active repos in the config file. It doesn't remove the synced tarballs from the /var/lib/pacman directory. So, here's my updated script.

#!/bin/sh

config='/etc/pacman-testing.conf'
packages=""

# make sure the script is being run as root
if [[ $(id -u) != 0 ]]; then
    echo "error: you must be root to run this script"
    exit 1
fi

# Sync pacman with testing repos
pacman -Sy --config $config

# make sure packages exist
echo "checking package name(s)..."
for i in $@; do
    pacman -Qi $i > /dev/null
    [[ "$?" = "1" ]] && echo "skipping..." && continue
    packages=$packages" $i"
done

if [[ $packages = "" ]]; then
    echo "error: no existing packages received, resyncing repos and exiting..."
    exit 1
fi

# upgrade packages
pacman -S --config $config $packages

exit 0

Tuesday, September 21, 2010

Daily Activities

Just did an update of filesystem (2010.07-1 -> 2010.09-1) and it installed a new shadow file, /etc/shadow.pacnew. There are some noticable differences from the current /etc/shadow file. I will thus have to read up on the shadow file to figure out what everything is meant for and then reconcile the two.

I also noticed that when using the testing script I wrote, when resyncing the main repos, they'll be up to date. So, I'm not too sure if it is necesarry to resync these, or if just using switching back to the main configuration file is enough.

Monday, September 20, 2010

pactesting -- script to install packages from the testing repos

Pretty simple script to install packages from the testing repos, the comments say it all. The pacman-testing.conf file is a copy of pacman.conf with only the [testing] and [community-testing] repos enabled.

#!/bin/sh

config='/etc/pacman-testing.conf'
packages=""

# make sure the script is being run as root
if [[ $(id -u) != 0 ]]; then
    echo "error: you must be root to run this script"
    exit 1
fi

# Sync pacman with testing repos
pacman -Sy --config $config

# make sure packages exist
echo "checking package name(s)..."
for i in $@; do
    pacman -Qi $i > /dev/null
    [[ "$?" = "1" ]] && echo "skipping..." && continue
    packages=$packages" $i"
done

if [[ $packages = "" ]]; then
    echo "error: no existing packages reveived, resyncing repos and exiting..."
    pacman -Sy
    exit 1
fi

# upgrade packages
pacman -S --config $config $packages

# resync with regular repos
pacman -Sy

exit 0

Friday, September 17, 2010

Daily Activities

Two things going on today, there are a couple vulnerabilities in the linux kerne, which can be found here. They have a proof of concept written in C, which works on the Archlinux kernel, an fix has been implemented, just waiting for it to hit the repos.

I'm also installing Arch on my thumbdrive, rather than just having the livecd on it, I can install other tools to it now. Anyhow, that's all.

Tuesday, September 14, 2010

Daily Activities

Completed reading and taking notes on chapter 2 of the Zsh user guide. Now I need to go back and do related configurations to my system.

Monday, September 13, 2010

Wircon-0.0.2-1

I changed around the wireless-connection script. I created a status file, where the script would echo its status to (connected, disconnected, or down). I use this status on my conky bar. If the status is connected or disconnected, the script is running; if it's down, the script isn't. I also wrote in some traps do echo the 'down' status before the script exits. The last change is that it no longer exits after five attempts to connect, it keeps trying. Anyway, here it is:

#!/bin/sh

dhcpcdPID="/var/run/dhcpcd.pid"
networks=`cat /home/jason/devel/scripts/wircon/pref_networks.lst`
statfile="/home/jason/devel/scripts/wircon/status"
silent=1

# make sure the script is being run as root
if [[ $(id -u) != "0" ]]; then
    echo "This script must be run as root"
    exit 1
fi

# scan for essids located in pref_networks.lst
find_network() {
  for i in $networks; do
    iwlist wlan0 scan | grep $i &> /dev/null
    if [[ "$?" = "0" ]]; then
      local essid=$i
      break
    fi
  done

  case $essid in
    "SouthPacific")
    network="sp"
    ;;
    "SouthPacific_Extender")
    network="spx"
    ;;
    "Belkin_G_Wireless_C973D1")
    network="seans"
  esac
}

# if dhcpcd is running, stop it
do_dhcpcd_check() {
  if [[ -f $dhcpcdPID ]]; then
    if [[ $silent = "1" ]]; then
      dhcpcd -x
    else
      dhcpcd -x -q
    fi
  fi

}

# load wireless firmware
do_load_firmware() {
  [[ $silent = "1" ]] && echo "loading wireless firmware"
  ifconfig wlan0 up
}

# set essid and, if applicable, network key
do_set_network() {
  [[ $silent = "1" ]] && echo "setting network parameters"
  iwconfig wlan0 essid $ESSID
  if [[ $KEY != "" ]]; then
      iwconfig wlan0 key $KEY
  fi
}

# unset the network for graceful exit
do_unset_network() {
  do_dhcpcd_check
  ifconfig wlan0 down
}

# try for dhcp lease
do_dhcpcd() {
  if [[ $silent = "1" ]]; then
    dhcpcd
  else
    dhcpcd -q
  fi
}

# something that helps find a carrier
do_channel_auto() {
  [[ $silent = "1" ]] && echo "connecting to carrier"
  iwconfig wlan0 channel auto
}

# make sure it worked
check_connection() {
  ping -c 1 www.google.com &> /dev/null

  if [[ $? = "0" ]]; then
    return 0
  else
    return 1
  fi
}

# set the desired network
set_network() {
  case $network in
    "sp")
    ESSID="SouthPacific"
    KEY="6bcebdfbea3caf9f3cd36b31b8"
    ;;
    "spx")
    ESSID="SouthPacific_Extender"
    KEY="6bcebdfbea3caf9f3cd36b31b8"
    ;;
    "seans")
    ESSID="Belkin_G_Wireless_C973D1"
    KEY=
    ;;
    *)
    [[ $silent = "1" ]] && echo "$1 is not a recognized essid"
  esac
}

connection_monitor() {
  while [[ 1 = 1 ]]; do
    sleep 10
    check_connection
    if [[ $? = 1 ]]; then
      echo "disconnected" > $statfile
      main
    fi
    echo "connected" > $statfile
  done
}

# call all functions in proper order to establish connection
main() {
  trap 'echo "down" > $statfile; do_unset_network; exit;' INT
  trap 'echo "down" > $statfile; do_unset_network; exit;' TERM

  while [[ 1 = 1 ]]; do
    do_dhcpcd_check
    do_load_firmware
    do_set_network
    sleep 2
    do_dhcpcd
    do_channel_auto
    check_connection
    if [[ $? = 0 ]]; then
      [[ $silent = "1" ]] && echo "connection established"
      connection_monitor
    fi
  done
}

# check scripts usage
if [[ $# > 0 ]]; then
  if [[ $1 = "-s" ]]; then
    silent=0
    shift
  fi
  if [[ ! -z $1 ]]; then
    network=$1
  else
    do_load_firmware
    find_network
  fi
else
  do_load_firmware
  find_network
fi

set_network

main

exit 2

Testing VMs

I created two Archlinux virtual machines, one for i686 and one for x86_64. I have the testing repos enabled on both so I can test the packages. While I can't signoff on packages, I can report bugs in the signoff threads. Apparently this is something that not many people do, so it's a start.

Friday, September 10, 2010

Daily Activities

I remembered this morning that I had done an lsorphans, by mistake actually, and it yielded several results. So, I did an rmorphans. One of the packages removed was HAL. It appears that nothing on my system relies on HAL anylonger. However, VMware does. So, I had to reinstall HAL with the --asexplicit switch, so that it wouldn't appear in an orphan listing anymore.

Thursday, September 9, 2010

wircon-0.0.1-1 -- a wireless detection/connection script for broadcom 43** wireless cards

I wrote this because none of the available programs seem to handle the Broadcom 43** wireless cards very well. The script has a couple of options. It can be sent a pre-determined network nickname to connect to, or it can read from a list of "preferred networks" and connect to whichever it finds first. It also contains a silent (-s) switch, which removes all output. The network nickname is what's passed to the script when called, so with wircon home, once the script reached the "set_network" function, it would set the ESSID corresponding to 'home'. This way one doesn't have to type out 'FooBar_G_Serial_0834DS90' everytime they want to connect to that network. However, the preferred networks file 'pref_networks.lst' should contain the actual network ESSID.
The script has been completely modularized, so it's run as a series of functions. It's also meant to be backgrounded as it will switch to a function which loops infinitely, checking the internet connection with each iteration; if none is found, it calls the main connection cycle again and repeats. If it is unable to connect after 5 tries, it exits completely with an errorcode of 1.

#!/bin/sh

dhcpcdPID="/var/run/dhcpcd.pid"
networks=`cat /home/jason/devel/scripts/wircon/pref_networks.lst`

# make sure the script is being run as root
if [[ $(id -u) != "0" ]]; then
    echo "This script must be run as root"
    exit 1
fi

# scan for essids located in pref_networks.lst
find_network() {
  for i in $networks; do
    iwlist wlan0 scan | grep $i &> /dev/null
    if [[ "$?" = "0" ]]; then
      local essid=$i
      break
    fi
  done

  case $essid in
    "[Network_ESSID1")
    network="NE1"
    ;;
    "[Network_ESSID2")
    network="NE2"
    ;;
    "Network_ESSID3")
    network="NE3"
  esac
}

# if dhcpcd is running, stop it
do_dhcpcd_check() {
  if [[ -f $dhcpcdPID ]]; then
    if [[ $silent = "1" ]]; then
      dhcpcd -x
    else
      dhcpcd -x -q
    fi
  fi

}

# load wireless firmware
do_load_firmware() {
  [[ $silent = "1" ]] && echo "loading wireless firmware"
  ifconfig wlan0 up
}

# set essid and, if applicable, network key
do_set_network() {
  [[ $silent = "1" ]] && echo "setting network parameters"
  iwconfig wlan0 essid $ESSID
  if [[ $KEY != "" ]]; then
      iwconfig wlan0 key $KEY
  fi
}

# try for dhcp lease
do_dhcpcd() {
  if [[ $silent = "1" ]]; then
    dhcpcd
  else
    dhcpcd -q
  fi
}

# something that helps find a carrier
do_channel_auto() {
  [[ $silent = "1" ]] && echo "connecting to carrier"
  iwconfig wlan0 channel auto
}

# make sure it worked
check_connection() {
  ping -c 1 www.google.com &> /dev/null

  if [[ $? = "0" ]]; then
    return 0
  else
    return 1
  fi
}

# set the desired network
set_network() {
  case $network in
    "NE1")
    ESSID="[Network_ESSID1]"
    KEY="biglongkey"
    ;;
    "NE2")
    ESSID="[Network_ESSID2]"
    KEY="hopefullydifferentbiglongkey"
    ;;
    "NE3")
    ESSID="[Network_ESSID3]"
        # unsecure network
    KEY=
    ;;
    *)
    [[ $silent = "1" ]] && echo "$1 is not a recognized essid"
  esac
}

connection_monitor() {
  while [[ 1 = 1 ]]; do
    sleep 10
    check_connection
    if [[ $? = 1 ]]; then
      main
    fi
  done
}

main() {
  count=0
  while [[ $count < 5 ]]; do
    do_dhcpcd_check
    do_load_firmware
    do_set_network
    sleep 2
    do_dhcpcd
    do_channel_auto
    check_connection
    if [[ $? = 0 ]]; then
      [[ $silent = "1" ]] && echo "connection established"
      connection_monitor
    else
      let count=$count+1
    fi
  done
}

# check scripts usage
silent=1
if [[ $# > 0 ]]; then
  if [[ $1 = "-s" ]]; then
    silent=0
    shift
  fi
  if [[ ! -z $1 ]]; then
    network=$1
  else
    find_network
  fi
else
  find_network
fi

set_network

main

exit 1

Tuesday, September 7, 2010

[update]sysmon-0.0.2-3

I had to make a couple changes. I accidentally had the battery charge check against the full value, so any time I unplugged my laptop, it would shutdown. Also, while it appeared to work correctly, I forgot that the value of temp1_input was in thousands. Thus, a temperature of 53C would be 53000. So, I removed the zeros.

#!/bin/zsh

# define battery variables
charge_now='/sys/class/power_supply/BAT1/charge_now'
charge_full='/sys/class/power_supply/BAT1/charge_full'
charge_factor=20 # 5% battery power

# define temperature variables
max_temp=80
for i in {0..1}; do
temp_path="/sys/class/hwmon/hwmon$i/device/temp1_input"
[[ -f $temp_path ]] && break
done

# get full charge value
full="`cat $charge_full`"

# just keep going
while [[ "1" = "1" ]]; do
# get current charge
charge="`cat $charge_now`"

# calculate the minimum charge based on the charge_factor
charge_min=$(($full/$charge_factor))

# system doesn't use hwmon1 or hwmon0 exclusively, so there's a need to differentiate
temp="`cat $temp_path`"
temp=$temp[1,2]

[[ $temp > $max_temp ]] || [[ $charge < $charge_min ]] && `shutdown -h now` sleep 10 done

System Backup

I need to start backing up my system. I was just reading about a guy who lost everything on his machine to an unclean reboot. For the future, once I get my server going again, I would like to create a networked sync with it.

Monday, September 6, 2010

[complete]sysmon-0.0.2-2

Finished it all. I accidentally left an echo in the previous release. So, here's the completed script.

#!/bin/zsh

# define battery variables
charge_now='/sys/class/power_supply/BAT1/charge_now'
charge_full='/sys/class/power_supply/BAT1/charge_full'
charge_factor=20 # 5% battery power

# define temperature variables
max_temp=80
for i in {0..1}; do
temp_path="/sys/class/hwmon/hwmon$i/device/temp1_input"
[[ -f $temp_path ]] && break
done

# get full charge value
full="`cat $charge_full`"

# just keep going
while [[ "1" = "1" ]]; do
# get current charge
charge="`cat $charge_now`"

# calculate the minimum charge based on the charge_factor
charge_min=$(($full/$charge_factor))

# system doesn't use hwmon1 or hwmon0 exclusively, so there's a need to differentiate
temp="`cat $temp_path`"

[[ $temp > $max_temp ]] || [[ $charge < $full ]] && `shutdown -h now` sleep 10 done


And here's the init script that I wrote up for it.
#!/bin/sh

. /etc/rc.d/functions

PID="`pidof -x sysmond 2>/dev/null`"

case "$1" in
start)
stat_busy "Starting System Monitor"
/usr/bin/sysmond &
if [[ $? -gt 0 ]]; then
stat_fail
else
stat_done
fi
;;
stop)
stat_busy "Stopping System Monitor"
[[ ! -z $PID ]] && kill $PID
if [[ "$?" = "0" ]]; then
stat_done
else
stat_fail
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "ussage: $0 {start|stop|restart}"
esac
exit 0

[tested]sysmon-0.0.2-1

Here it is, all updated and tested. Turned out I had a couple mismatched variables, but the logic works like a charm. Next will be to implement it in an init script for the boot procedure.

#!/bin/zsh

# define battery variables
charge_now='/sys/class/power_supply/BAT1/charge_now'
charge_full='/sys/class/power_supply/BAT1/charge_full'
charge_factor=20 # 5% battery power

# define temperature variables
max_temp=80
for i in {0..1}; do
temp_path="/sys/class/hwmon/hwmon$i/device/temp1_input"
[[ -f $temp_path ]] && break
done

# get full charge value
full="`cat $charge_full`"

# just keep going
while [[ "1" = "1" ]]; do
# get current charge
charge="`cat $charge_now`"

# calculate the minimum charge based on the charge_factor
charge_min=$(($full/$charge_factor))
echo "min charge: $charge_min"

# system doesn't use hwmon1 or hwmon0 exclusively, so there's a need to differentiate
temp="`cat $temp_path`"

[[ $temp > $max_temp ]] || [[ $charge < $full ]] && `shutdown -h now` sleep 10 done

sysmon0.0.1-4 -- Monitor cpu temp and battery charge for unacceptable levels

I wrote this script with intent to background. If the battery charge gets below 5% or the cpu temperature climbs above 80C, the command to halt is issued.

#!/bin/zsh

# define battery variables
charge_now='/sys/class/power_supply/BAT1/charge_now'
charge_full='/sys/class/power_supply/BAT1/charge_full'
charge_factor=20 # 5% battery power

# define temperature variables
max_temp=80
for i in {0..1}; do
temp_path="/sys/class/hwmon/hwmon$i/device/temp1_input"
[[ -f $temp_path ]] && break
done

# get full charge value
full=`cat $charge_full`

# just keep going
while [[ "1" = "1" ]]; do
# get current charge
charge=`cat $charge_now`

# calculate the minimum charge based on the charge_factor
charge_min=$(($full/$charge_factor))

# system doesn't use hwmon1 or hwmon0 exclusively, so there's a need to differentiate
temp="`cat $temp_path`"
[[ "$?" = "0" ]] || continue

[[ $temp > 80 ]] || [[ $charge < $min_charge ]] && `shutdown -h now` sleep 10 done


This is a running version. I have not tested to see if it will execute properly once the conditions are met. Setting it to short term list, most likely tomorrow.

[solved]Virtual Machine Crashes on Start in VMware Player

Turns out I didn't have to reinstall vmplayer. I simply had to rebuild the modules. I figured it had something to do with the recent kernel upgrade, although I figured the kernel26-2.6.35.4-1 release had broken vmplayer. It does make sense, however, that the kernel modules needed to be rebuilt. Atleast, now I know to rebuild such packages upon kernel updates.

vmware-modconfig --console --install-all

New Post Methodology

Instead of just posting 'Daily Activities' every day, I'm going to place any issues within their own post. The title of the post will be a concise description of its contents i.e. foobar-0.0.1-1 crashes on start. This way problems and projects can be searched and followed more efficiently. There will also potentially be a 'Daily Activities' section. This will include the miscilaneous things that might not completely deserve their own topic.

Sunday, September 5, 2010

Daily Activities

03:10AM ::
Now next-morning. I forgot there was a pacman update today. Fixed the rankmirrors problem. There were also updates to sudo, vim, and chromium. All is well for now.

10:15PM ::
Wrote up a script to be backgrounded that will check the battery charge and cpu temp. and halt the system if either is out of an acceptable range. I still have test and impliment it.

VMware Player is not starting up the WinXP VM that I created, so I'll have to look into that. I'm guess that a recent update might of broken something and I'll have to re-install.

More later...

Friday, September 3, 2010

Daily Activities

5:00PM ::
I actually did this yesterday. I added a feature to my conky bar, it shows how many updates are available for my system. I put a script in cron.hourly which just runs `pacman -Sy` to update the local database. Then conky calls a script every 60 minutes that runs `pacman -Qu -b /var/lib/pacman` (/var/lib/pacman contains to local pacman databases), then returns the number of packages available.

I thought I read something about being able to put all of your small scripts into one fo the zsh files rather than creating a bunch of files. So, I'm looking into doing this as well.

I've also thought about implementing failsafes for my battery charge and cpu temperature. If they get too low and/or too high respectively, I'll have the computer shut itself down.

I also had another thought to do something last night, but completely forgot what it was. Hopefully I'll remember sometime soon. Until then, that's all for now.

Tuesday, August 31, 2010

Daily Activities

8:45AM ::
System Upgrade. Looks like a new kernel version is out 2.6.35.4-1, and a new release of udev. Downloading them now, see how it goes.

Saturday, August 28, 2010

Daily Activities

10:45 PM ::
I just installed VMplayer. I was never able to get VMware-Server working on my laptop and all I really need is something that can create and run virtual machines, which VMplayer can do. It's also free. I followed the instructions here. Under step 9, replace the /sbin/lsmod with /bin/lsmod in /etc/rc.d/vmware. Also in step 9, the script that it suggests downloading for kernel26-2.6.35 "and" VMware7.1.1, it's really "and/or", so it is necesary if you're installing VMplayer with kernel 2.6.35. Then run modconfig script. Also, note that VMware depends on the HAL daemon to be running. This caused me some frustration because I don't use HAL anymore now that it's been deprecated.

That's all for now.

Thursday, August 26, 2010

Daily Activities

System update
- got a new mirrorlist, hopefully it will help out. rankmirrors still isn't working, I guess it's not too high on the priority list. Maybe I'll take a look at the code or write my own script to handle mirror ranking.

Installed VLC, along with its million dependencies

Looks like Archlinux will be rolling out a multilib repo shortly. It will house all the things that depend on 32 bit libraries for 64 bit packages, like flash. Which means those things will no longer be in AUR, very exciting.

I've also been thinking about trying my hand in writing/maintaining some AUR packages. I need to do some reading on package builds and look for an orphaned package that might interest me/that I use.

Sunday, August 22, 2010

Daily Activities

Haven't done much today. Finally got my old zsh configuration copied over to the fresh install. So, I'm using zsh now. I thus used it to set append ~/.bin to my $PATH. This was somewhat tricky, because the only files this can be set it are *zshrc and *zshenv, both of which are called everytime a new instance of zsh is called. Thus when appending to $PATH in the method of `PATH=$PATH:~/.bin`, '~/.bin' will be appended with every new zsh. To fix this zsh can look for the appending of an array to be unique with `typeset -U $var`. It also breaks $PATH into its own zsh-style array $path. So, in zsh you can also append to $PATH by doing the following: `path=( ~/.bin $path) which will append ~/.bin to the beginning of $PATH. Put it all together and:

typeset -U path
path=( ~/.bin $path)

Friday, August 20, 2010

Conky Configuration

# alignment top_left
background no
# border_width 1
border_inner_margin 0
border_outer_margin 0
# cpu_avg_samples 2
# default_color white
# default_outline_color white
# default_shade_color white
# draw_borders no
# draw_graph_borders yes
# draw_outline no
# draw_shades no
double_buffer yes
use_xft yes
xftfont Terminux:size=9
# gap_x 5
# gap_y 60
if_up_strictness address
# minimum_size 5 5
# net_avg_samples 2
# no_buffers yes
# out_to_console no
# out_to_stderr no
# extra_newline no
own_window yes
own_window_type dock
own_window_transparent yes
stippled_borders 0
update_interval 1.0
uppercase no
use_spacer left
# show_graph_scale no
# show_graph_range no
total_run_times 0

TEXT
${color #3955D3}${time %a %D %r} $color \
|| ${color #3955A3}Kernel:${color grey} $kernel $color \
|| ${color #3955A3}cpu:${color grey} ${freq_g}Ghz ${cpubar 4,50} ($cpu) | hog:$color ${top name 1}${offset -20}${top cpu 1}${color} \
|| ${color #3955A3}ram:${color grey} ${membar 4,50} | hog:$color ${top_mem name 1}${offset -20}${top_mem mem 1}${color} \
|| ${color #3955A3}swap usage:${color grey} $swapperc% $color \
|| ${color #3955A3}network:${color grey} ${upspeed wlan0} up, ${downspeed wlan0} down, ${totaldown wlan0} downloaded $color
${color #3955A3}cpu temp: ${color grey} ${execi 10 /home/jason/bin/conky-temp.sh}C $color \
|| ${color #3955A3}battery:$color ${color #1E36BD}${battery_bar 4,50 BAT1}$color \
|| ${color #3955A3}w/r:${color grey}$diskio_write $diskio_read $color \
|| ${color #3955A3}Gmail-L: ${color grey}${execi 30 python ~/bin/conky-gmaillinux.py} $color \
|| ${color #3955A3}Gmail-H: ${color grey}${execi 30 python ~/bin/conky-gmailhome.py} $color \
|| ${color #3955A3}boot: ${color grey}${fs_free /boot}/${fs_size /boot} $color \
${color #3955A3}root: ${color grey}${fs_free /}/${fs_size /} $color \
${color #3955A3}tmp: ${color grey}${fs_free /tmp}/${fs_size /tmp} $color \
${color #3955A3}usr: ${color grey}${fs_free /usr}/${fs_size /usr} $color \
${color #3955A3}var: ${color grey}${fs_free /var}/${fs_size /var} $color \
${color #3955A3}home: ${color grey}${fs_free /home}/${fs_size /home} $color \

Recent Activities

I have moved and now have a job, so things are slowing down in the Linux world. I'm leeching off of someone's wifi right now; until I get internet of my own, the server reformat will have to be put on hold.

I finished the majority of my i3 configuration. I have conky working amazingly with all of my system data. I'll post the rc files shortly.

Friday, August 13, 2010

Bah

Turns out I was mislead... in a way. I don't have the proprietary ATI driver, my "old" chipset is not longer supported by ATI. Thus, my S-video does not work.

Fresh Install

I did a fresh install of Archlinux64 on my laptop last night. Got rid of all the bloat that is KDE (if you can call it that). I'm now simply running i3. I'm still working on getting it all setup and configured the way I like, reading through the documentation and such. Reformatting achieved a couple other things for me: a new partitioning scheme, I got rid of HAL, and now I'm using Xorg sans xorg.conf in /etc/X11. My laptop also has an S-video output, so I've installed the proprietary ATI drivers, which I'll need to configure further.
Here's the new partion scheme:
File System  Size  Mount

sda1  ext3   23MB  /boot
sda2  ext4   1GB   /
sda3         Extended Partition
 sda5 ext4   2GB   /tmp
 sda6 ext4   3GB   /var
 sda7 ext4   6GB   /usr
 sda8 swap   512MB swap
sda4  ext4   80GB  /home

I also screwed up on my CentOS partitioning. I only gave the /usr partition 3GB and it's already full. I still need to find if my machine is ESXi compatable, if it is, I'm just going to install that. Otherwise, I guess it's another CentOS install. I think this time I'll get rid of Gnome and try i3 on it, since I much prefer a WM.

Wednesday, August 11, 2010

i3 configuration... thus far

this is my .Xdefaults, it's where all the terminal configuration goes
! urxvt

urxvt.title: Terminal
urxvt.background: #1A1A1A
urxvt.foreground: #999999
urxvt.cursorColor: #5E468C
urxvt.borderColor: #1A1A1A
urxvt.borderless: false
urxvt.internalBorder: 3
urxvt.externalBorder: 3
urxvt.scrollBar: false
!urxvt.font -misc-fixed-medium-r-*--12-*-*-*-*-*-iso10646-1
!urxvt.boldFont: -misc-fixed-medium-r-*--12-*-*-*-*-*-iso10646-1
urxvt.font: xft:terminus:pixelsize=10
urxct.boldFont: xft:terminus:bold:pixelsize=10

! transparency
*inheritPixmap: true
*tintColor: white
*shading: 40

! colors
!black
*color0: #333333
*color8: #3D3D3D
!red
*color1: #8C4665
*color9: #BF4D80
!green
*color2: #287373
*color10: #53A6A6
!yellow
*color3: #7C7C99
*color11: #9E9ECB
!blue
*color4: #395573
*color12: #477AB3
!magenta
*color5: #5E468C
*color13: #7E62B3
!cyan
*color6: #31548C
*color14: #6096BF
!white
*color7: #899CA1
*color15: #C0C0C0

This goes into the .xinitrc file
# set background and wallpaper
xsetroot -solid "#1A1A1A"
feh --bg-scale /path/to/image/.jpg

Daily Activities

Did some reading up on Python today. Downloaded the latest version of the Dive in Python book.

Also, decided to look into i3. Seems pretty cool, but there's not much documentation on how to configure anything outside of the basics. Still looking...

Update: Figured some things out. Will be posting my config files.

Tuesday, August 10, 2010

Daily Activities

8:12PM ::
I installed VMware server last night, it didn't work. I tried many things to get it to work including reconfiguring and reinstalling it. This isn't the first time it hasn't worked for me. So, I've installed VMware Workstation 7.0, the only catch is that it's only free for 30 days. Eh. As stated in the previous post, I think I'll look into ESXi.
I've also taken down a couple of the short term ToDo's. I'm going to scrap the http virtual server for now, since I'll be messing with ESXi sometime soon. I also wont be doing too much tweaking/configuring on the CentOS server, because it's going to get scrapped in favor of ESXi.

Update

Heard about this thing called VMware ESXi. It's its own OS for running virtual machines, seems pretty cool. I think I might give it a try on my server. I just need to do some more research to check compatability.

Sunday, August 8, 2010

Daily Activities

11:00PM ::
Per the last post, I've tackled the wireless problem. Now, I'm going to start working on a program to maintain the wireless connection.

I've also added some formatting to the blog. The bold seqments signify shell interaction, I've also coded up some code tags in the CSS to make it more legible.

Wireless Problem

5:06PM ::
I wrote a script to run at startup to connect to the wireless. However, the dhcpcd program outputs a no interfaces have a carrier message. Even when I don't run the script on startup, dhcpcd has to fail in this way before it can actually connect. There's also a kernel message eth0: link down. I'm not sure what's going on, but until I have this worked out, there's no use in writing a script if I'm always going to have to connect manually anyway. I've also tried this on kernel26-2.6.34.2-2 and 6.35.1-1. Now the plan is to see if there are any driver or dhcpcd updates.

10:24PM ::
Turns out there was a bug in dhcpcd-5.2.6 and 5.2.7 was just moved out of testing. So, I'm pretty sure that is what the main problem was. However, after upgrading, my script still didn't work, so I did some investigating. This was my previous sequence of events:


ifconfig wlan0 up # loads the firmware
iwconfig wlan0 essid $ESSID key $KEY
iwconfig wlan0 channel auto
sleep 2 (dhcpcd needed time for the other settings to take hold before being able to connect)
dhcpcd

With this I would get the following output from dhcpcd:


version 5.2.x starting
no interfaces have a carrier
forked to background...

Then in my kernel log after the previous three statements would be:


eth0 waiting for carrier
wlan0 wating for carrier


I found that after this point if I manually re-entered the line iwconfig wlan0 channel auto I would get a wlan0 carrier aquired and the ip would be set.

So I edited my script, put the iwconfig wlan0 channel auto after the dhcpcd, and all is well in the world again.

Friday, August 6, 2010

nVidia Driver Installation on CentOS 5.5

This was, to put it bluntly, a royal pain in the ass. As mentioned before, I have an older nVidia GeForceFX 5900 GPU. For some reason this card has never worked well with the open-source nVidia drivers. So, even though I know it's shameful, I opt for the proprietary drivers. While when I was running Archlinux on this machine I was never able to get the nouveau drivers to work at all, at least in CentOS, their vesa driver worked for a single monitor. The problem is that I have an S-video out on my card that I like to use to make an old 27" in. CRT-TV a second monitor, so I can watch Netflix. Well, the only driver that ever works with the S-video has been still been the nVidia.

Now, there are a couple different extra repos out there that carry nVidia packages. I tried the one from rpmforge and it didn't work. After much frustration, finally getting the nvidia-settings to at least open, but still not getting X to load the nvidia module, I gave up. I decided that I would forgo the distro-taylored rpm and try installing the driver straight from the nVidia.com download page.

After some research I found out that this was fairly simple, all you have to do is run [CODE] # sh NVIDIA...{the rest of the install pkg name}[/CODE] as root and follow the prompts. That's it. However, there's a catch. You need to have the make, gcc, and kernel-devel packages also installed. So, I installed them, ran the install again. Now it's telling me that my kernel-devel stuff doesn't match my kernel... wtf? I promptly run a [CODE] # uname -r [/CODE] and find out that I'm using a "xen" kernel. Whatever that is. So I do some searching, find that there is in fact a kernel-xen-devel package, and install it. Alright, let's go again. This time the nVidia installation kindly informs me that it does not support the xen kernel. Son-of-bitch. I do some more research, install this "plain" kernel, edit my /etc/sysconfig/kernel file, change my DEFAULTKERNEL=kernel (rather than kernel-xen), edit my grub.conf to default to kernel 0 ("plain"), reboot, run the install script again, and OMFG it worked! Ran the nvidia-xconfig script, started up the nvidia-settings program (have to start it from a shell as root), configured my nvidia stuff, rebooted, and YES! YES! IT... W.O.R.K.E.D! I CAN'T BELIEVE IT WORKED!

After hours of toiling, I've finally gotten the graphics driver working. This has always proved to be the most difficult part of an installation and now that I've figured it out, I'm ecstatic. Time to celebrate and come back tomorrow for some VMware fun.

CentOS 5.5 Installation

3:50PM ::
I already installed once. Started by formatting with G-Parted LiveCD with the boot partition as ext2 and the rest a ext4. I didn't install a desktop environment the first time around. Couldn't get X working on my own, so I'm reinstalling. Reformatted the partitions with the CentOS installation, apparently CentOS won't do ext4, so now all but the boot partition are ext3, boot is still ext2.
There's on confusing part of the installation, where you choose the package(s) you want to install [Desktop-Gnome; Desktop-KDE; Server; etc.]. To figure out what exactly the packages are, you need to select the package you want to check out, then select "Packages from CentOS Extras", then the "customize now" radio button, then next. You can see all the default programs to be installed and can choose from others, if you want to try or add a different layout you can go back.

Edit: After customizing my packages with the install, it errored out before really doing anything. This could have been because I changed the partitions to ext3 or because the custome package thing doesn't really work. So, I went back and reformatted with the GParted LiveCD to use ext4 filesystems again. Chose the Server - GUI and Virtualization packages, didn't customize them, figured I'd just do it later, and everything went off witout a hitch.

4:15 ::
It's kind of pain to find installation documentation. When doing a netinstall, the mirror and directory can be mirror.centos.org and centos/x.x/os/i386 respectively; where x.x is the version, in my case 5.5.

Daily Activities

12:19PM ::
Decided that the CheckGmail program wasn't worth it. I'll figure something else out.
Currently installing CentOS on my server. I plan on creating a couple VM's, the first will be the actual LAMP server. In the future I'll probably add VM's for an FTP server and mail server. I also like to install a minimal WinXP VM so that I can watch Netflix.

11:38PM ::
CentOS Installation and Configuration thus far:
  • Installed OS
  • Installed Z-Shell and configured zshrc files
  • Installed ntfs-3g (from rpmforge repo)
  • Installed and configured nVidia graphics driver (took a long time)
  • Installed Firefox
  • More to come...

Thursday, August 5, 2010

Daily Activities

2:27PM ::
Slow day. Heard about Z shell the other day, looked into some of the documentation. Claims it combines the best of bash, ksh, and tcsh and improves on some things. So, I've decided to give it a try. In the process of configuring it now. Here's the zsh Arch Wiki.

12:46AM ::
Update (technically it's next day). While zsh is nice, new, and shiny, I've determined that bash cannot be ruled out completely. While zsh might have some improved features, bash is still a more commonly used scripting language. However, I do like zsh as an interactive shell, and once I have it configured to my liking, it will no doubt outpace bash.

1:20AM ::
Came accross this script, after the user dumps the output of pacman -Ss to a file, the script parses the file and outputs a better formatted version of the data. Minor error toware the end, line 193 should read "if which zenity &> /dev/null..." so as to redirect error output as well as the which function's normal output.

Wednesday, August 4, 2010

Daily Activities

While upgrading to kernel26-2.6.35 is a solution to the b43 driver breakage. I tested a kernel26-2.6.34.2-2 release this morning which fixes the b43 breakage. Should hit the repos soon.

Installed CheckGmail - must be run with -no_cookies flag to properly authenticate
Update: Errors out when mail is recieved. Adding to list of things to do.

Installed nmap and iptables
Nmap scan shows all but ssh port closed, go Arch for default security.

Tuesday, August 3, 2010

Kernel Fix for Broadcom WLan Devices

Forgo the 6.34.2 kernel, go straight for 6.35 and the problem is fixed.

Kernel26-2.6.34.2-1 Upgrade Fails

This kernel upgrade has commonly failed with the following message:

error: failed to commit transaction (conflicting files)
kernel26: /lib/modules/2.6.34-ARCH/modules.devname exists in filesystem
kernel26: /lib/modules/2.6.34-ARCH/modules.softdep exists in filesystem

The fix is simple:
pacman -Sf kernel26 kernel26-headers
pacman -Su

Kernel26-2.6.34.2-1 Upgrade Breaks Broadcom b43 Driver

Turns out it's a kernel problem. Solution: downgrade kernel until a fix is released.

Updates gone awry

Today I ran a pacman -Syu, there was an update to kernel26-2.6.34.2-1 as well as the corresponding kernel headers. Upon reboot, connection to dhcpcd failed. I don't remember the exact error and it wasn't recorded. I reverted back to kernel26-2.6.34.1-1 and the corresponding headers and all was well again.

I didn't try a wired connection before reverting, I probably should have. I use wireless and that's what wouldn't connect. Here are the specs on my wireless card:
BCM4318 [AirForce One 54g] 802.11g Wireless LAN Controller
Vendor: Broadcom Corporation

I had to install my wireless drivers from the AUR, I'm guessing they're incompatable with the newest kernel release, so I'll wait until there's a new release to the AUR.

The Linux Journal

This blog is going to be a (hopefully) daily journal of my Linux activities. Currently I have two systems running Archlinux: an old P4 3.0GHz PC that I orriginally put together as a DVR, and an HP Pavillion dv8000 series laptop with an AMD Turion64 proc. The laptop will continue to contain Archlinux, while the PC will most likely turn into a CentOS server.

The main goal of this journal is to keep record of everything that I do that is Linux related. It will serve as a personal reference, however, anyone who might stumle upon it may find it useful.