Skip to content

Instantly share code, notes, and snippets.

@Thermionix
Last active January 27, 2016 23:20
Show Gist options
  • Save Thermionix/6590332 to your computer and use it in GitHub Desktop.
Save Thermionix/6590332 to your computer and use it in GitHub Desktop.
pfsense setup on alix board
#!/bin/bash
read -e -n1 -p "flash pfSense to CF card [y/N]: " OPTION
if [ "$OPTION" == "y" ]; then
imgfile=pfSense-2.1-RELEASE-1g-i386-nanobsd.img.gz
if [ ! -f $imgfile ]; then
read -e -n1 -p "download $imgfile [y/N]: " OPTION
if [ "$OPTION" == "y" ]; then
wget http://mirror.optus.net/pub/pfSense/downloads/$imgfile &&
wget http://mirror.optus.net/pub/pfSense/downloads/$imgfile.md5
fi
fi
if [ ! -f $imgfile ]; then
echo "# $imgfile not found, exiting"
exit
fi
remote_md5=`cat $imgfile.md5 | awk -F= '{print $2}' | awk '$1=$1'`
local_md5=`md5sum $imgfile | awk '{ print $1 }'`
if [ $remote_md5 != $local_md5 ]; then
echo "# remote md5: $remote_md5"
echo "# local md5: $local_md5"
echo "# unable to compare md5sums or md5sum mismatch, exiting"
exit
fi
read -e -n1 -p "write $imgfile to cf card [y/N]: " OPTION
if [ "$OPTION" == "y" ]; then
echo "## listing available disks"
sudo parted --list | egrep "^Disk /"
read -e -p "Set disk to install to: " -i "sd" DSK
#force umount if mounted?
echo "## writing $imgfile to $DSK"
imagesize=`gzip -l $imagefile|grep "$imagefile.gz"|tr -s ' ' ' '|sed 's/^ //'|cut -d ' ' -f 2`
#check pv installed
zcat $imgfile | sudo pv -s $imagesize | sudo dd of=/dev/$DSK bs=16k
echo "remove card and insert into alix board"
echo "continue when inserted"
read -p "Press [Enter] key to continue"
fi
fi
hash gtkterm &> /dev/null
if [ $? -eq 1 ]; then
read -e -n1 -p "gtkterm not found, install? [y/N]: " OPTION
if [ "$OPTION" == "y" ]; then
sudo apt-get install gtkterm
sudo usermod -a -G dialout `whoami`
fi
fi
if [ ! -d "/dev/serial" ]; then
echo "## no serial devices available, exiting"
exit
fi
echo "## recent dmesg entries relating to serial devices"
dmesg | grep tty
echo "## listing available serial devices"
ls -ogl /dev/serial/by-id/ | cut -d' ' -f7,8,9
read -e -p "Set serial port to use: " -i "ttyUSB0" ttyport
sudo chmod a+rw "/dev/$ttyport"
echo -e "\n## alix bios default baudrate 38400"
echo -e "## if not already set to 9400 connect with 38400 to change to 9400\n"
read -e -n1 -p "connect to alix with baudrate : 38400 [y/N]: " OPTION
if [ "$OPTION" == "y" ] ; then
gtkterm -p "/dev/$ttyport" -w Xon -s 38400 &
echo "# plugin power to alix"
echo "# s during memory check to access bios"
echo "# 9 to set baud to 9400"
echo "# C to check that CHS mode is selected"
echo "# q to quit"
read -p "Press [Enter] key to continue"
fi
read -e -n1 -p "connect to alix with baudrate : 9400 [Y/n]: " OPTION
if [ "$OPTION" == "y" ] || [ "$OPTION" == "" ]; then
gtkterm -p "/dev/$ttyport" -w Xon -s 9600 &
echo "# 1 to start configuration"
echo "# 1 to assign interfaces"
echo "# a for automatic"
echo "# 2 to assign ip"
echo "# 11 restart webConfigurator"
echo "connect in browser:"
echo "#http://<ipsetabove>/"
echo "#User: admin"
echo "#Password: pfsense"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment