Skip to content

Commit

Permalink
fixed script to be more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
qbit committed Oct 22, 2011
1 parent 87d350d commit 3d67976
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 16 deletions.
36 changes: 36 additions & 0 deletions bin/wpacfg
@@ -0,0 +1,36 @@
#!/bin/ksh

DEBUG=1

eval . ~/lib/functions

# WIF=iwn0
WIF=$(ifconfig | grep -B 4 IEEE802 | grep ^[a-z] | awk -F\: '{print $1}')
IF=/sbin/ifconfig

echo -n "SSID: "
read SSID

echo -n "WPA-PSK: "
stty -echo
read -s KEY
stty echo
echo ""
#log "using ${KEY} on ${WIF}"

echo -n "Use dhclient (y/n)? "
read DH

sudo $IF $WIF up nwid $SSID wpa wpakey $KEY

if [ $? ]; then
log "'${WIF}' configured for '$SSID'"

if [[ $DH = "y" ]]; then
log "using dhclient on '${WIF}'."
sudo dhclient -q $WIF
fi

exit;
fi

25 changes: 25 additions & 0 deletions common/dot_kshrc
@@ -0,0 +1,25 @@
OS=$(uname)

alias vi="vim"

if [ $OS == "OpenBSD" ]; then
export PKG_PATH="ftp://ftp.openbsd.org/pub/OpenBSD/snapshots/packages/i386/"
if [ ! -f ~/.cvsrc ]; then
export CVSROOT="anoncvs@anoncvs1.usa.openbsd.org:/cvs"
fi
fi

PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games:$HOME/bin:$HOME/Development/go/bin:.
export PATH HOME TERM

if [ "$(id -u)" -eq 0 ] ; then
PS1='\u@\h[\[\e[01;$(($??31:39))m\]$?\[\e[0m]\]:\w\]# '
else
PS1='\u@\h[\[\e[01;$(($??31:39))m\]$?\[\e[0m]\]:\w\]$ '
fi

KEY_CHAIN=$(which keychain);
if [ -x $KEY_CHAIN ]; then
$KEY_CHAIN -q ~/.ssh/id_rsa
. ~/.keychain/$(hostname)-sh
fi
39 changes: 23 additions & 16 deletions install
Expand Up @@ -51,43 +51,50 @@ function srm {
fi
}

function link_dotfile {
name=$( echo $2 | sed -e 's/^dot_/\./' );
if [[ -e ~/$name ]] || [[ -L ~/$name ]]; then
function link_file {
if [[ -e $2 ]] || [[ -L $2 ]]; then
if [ $setup_flag = true ]; then
diff -q ~/$name $1/$2
diff -q $2 $1
if [ "$?" -ne "0" ]; then
vimdiff ~/$name $1/$2
vimdiff $2 $1
else
echo -n "$name already in place, but is the same. Remove and crate symlink? ( y/yes ) "
echo -n "$2 already in place, but is the same. Remove and crate symlink? ( y/yes ) "
read ANS
if [[ $ANS = "y" || $ANS = "yes" ]]; then
srm ~/$name
lnk $WD/$1/$2 ~/$name
srm $2
lnk $1 $2
else
echo "$ANS?"
exit
fi
fi
else
srm ~/$name
lnk $WD/$1/$2 ~/$name
srm $2
lnk $1 $2
fi
else
log "file does not exist"
lnk $WD/$HOST/$1 ~/$name
lnk $1 $2
fi
}

function dotify {
echo $( echo $1 | sed -e 's/^dot_/\./' );
}

if [ -d $HOST ]; then
for file in $( ls $HOST ); do
link_dotfile $HOST $file
link_file $WD/$HOST/$file ~/$( dotify $file )
done
else
for file in $( ls default ); do
link_dotfile 'default' $file
link_file $WD/default/$file ~/$( dotify $file )
done
fi

for file in $( ls common ); do
link_dotfile 'common' $file
link_file $WD/common/$file ~/$( dotify $file )
done

for file in $( ls bin ); do
link_file $WD/bin/$file ~/bin/$file
done

0 comments on commit 3d67976

Please sign in to comment.