Showing posts with label Software. Show all posts
Showing posts with label Software. Show all posts

Tuesday, 31 January 2012

Manual patching a of FreeBSD Port

Sometime you want to modify only a little bit of the code for a port to add a new function. The method below shows how you can do this easily.

1) Go in to the port directory
2) Type make clean to remove any existing work directories
3) type make extract to uncompress the port
4) Type make patch to apply any patches that the port maintainer has included
5) Enter the directory where the problem source file is - usually work/portname-version/some subdir
6) Copy it to filename.c.orig (If the port maintainer has already patched filename.c, 'make patch' will already have created filename.c.orig) so you will need to move the current orig to a new name and then create you one.
7) Edit filename.c to include your changes
8) Diff the two files and put the resulting patch file in portdir/files

I.e., if filename.c is in work/foo-x.y/bar/ you should cd to
work/foo-x.y/ and then run

diff -u bar/filename.c.orig bar/filename.c > ../../files/patch-filename.c

10) Return to the portdir and type make clean
11) Type make extract and then make patch - if it works, you should be able to do the install - if it doesn't work, post the errors here
and we'll figure it out

Thursday, 11 August 2011

Installing Squid on FreeBSD

1) cd /usr/ports/www/squid
2) make install
3) <<Accept the defaults>>

     o You can find the configuration files for this package in the
       directory /usr/local/etc/squid.

     o The default cache directory is /var/squid/cache.
       The default log directory is /var/squid/logs.

       Note:
       You must initialize new cache directories before you can start
       squid.  Do this by running "squid -z" as 'root' or 'squid'.
       If your cache directories are already initialized (e.g. after an
       upgrade of squid) you do not need to initialize them again.

     o The default configuration will deny everyone but local networks
       as defined in RFC 1918 access to the proxy service.
       Edit the "http_access allow/deny" directives in
       /usr/local/etc/squid/squid.conf to suit your needs.

     To enable Squid, set squid_enable=yes in either
     /etc/rc.conf, /etc/rc.conf.local or /etc/rc.conf.d/squid
     Please see /usr/local/etc/rc.d/squid for further details.

     Note:
     If you just updated your Squid installation from 2.6 or earlier,
     make sure to check your Squid configuration against the 2.7 default
     configuration file /usr/local/etc/squid/squid.conf.default.

     Additionally, you should check your configuration by calling
     'squid -f /path/to/squid.conf -k parse' before starting Squid.
===> SECURITY REPORT:
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/sbin/squid

      This port has installed the following startup scripts which may cause
      these network services to be started at boot time.
/usr/local/etc/rc.d/squid

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.

      For more information, and contact details about the security
      status of this software, see the following webpage:

4) /usr/local/etc/rc.d/squid onestart (just for testing)
5)  Check which ports its listening on
sockstat |more
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS
squid    squid      66128 3  dgram  -> /var/run/log
squid    squid      66128 6  udp4   *:48072               *:*
squid    squid      66128 12 tcp4   *:3128                *:*
squid    squid      66128 13 udp4   *:3130                *:*
squid    squid      66126 3  dgram  -> /var/run/log
agarg    ssh-agent  47049 3  stream /tmp/ssh-NaHhONUHyq/agent.47048
agarg    sshd       47044 3  tcp4   10.48.0.238:22        10.202.70.142:65475
agarg    sshd       47044 4  stream -> ??
root     sshd       47041 3  tcp4   10.48.0.238:22        10.202.70.142:65475
root     sshd       47041 5  stream -> ??

Testing using Telnet

Direct Connection
telnet www.google.com.au 80
GET / HTTP/1.1

Squid Connection


telnet proxy.domain.tld 3128
GET http://www.google.com/ HTTP/1.1host:www.google.com<enter>
<enter>

Thursday, 21 July 2011

Outlook 2010 force selection of account before sending

Why did I have to find out about this? When accepting email invites the default sending account was set to my personal pop account (which has a non standard corporate name). As a result many of my colleagues were complaining who the hell is this bloke!

I've found two options to solve this:

1) force selection of outbound account

This post is stolen from here and i've copied the contents below incase the original disapears.

While we're on the subject of controlling Outlook behavior through policies, I'll mention another registry key that some users might find useful.

In last week's EMO I mentioned a problem some users are having with Outlook's new 'default' account behavior when multiple accounts are delivered to different data files. Outlook uses the email address assigned to the data file you are currently working in as the default for new mail. This is creating problems for IMAP users who have POP3 accounts delivered to the default pst (which is required for IMAP accounts) when they want the IMAP account used as the default for sending. Someone wrote a macro that always uses the default account. Or you can add or edit a registry key to force the user to select an account every time they send a new message. (Replies and Forwards always use the account the message arrived on.)

This will also work for people who multiple accounts and frequently accidently send using the wrong account.

HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\14.0\outlook\options
Value Name: ForceAccountSelection
Value type: REG_DWORD: 1 for force, 0 to disable.

Then restart outlook to pickup the changes

2) Change account settings

The second option that worked for me was to change the name, email address field and outbound email server. The inbound was left set to the account I really wanted to download from.

The downside of this is you now cannot send any email from this inbound account. However in my case this is a good thing!

Tuesday, 19 July 2011

Find large files on a Unix box

Here is a command you can use to find large files. You will need to be running this a root user

find / -size +50M -printf "%s - %p\n" | sort -r

Setting up SSH Agent on Freebsd

The inspiration is from here and the man page for ssh-agent.

Assuming you are using csh/tcsh
1) Add the following to .cshrc -- eval `ssh-agent -c`
2) Then everytime you log in run ssh-add to load up your private key
3) when you ssh to the remote machine use "ssh -A" to forward your authentication details over


An alternative is to use ssh-ident from here. All you have to do is modify your .bashrc (or .cshrc or .zshrc) to have:

alias ssh='/path/to/ssh-ident'

Tuesday, 21 June 2011

APE/CUE to Flac

1) Download Foobar 2000 and start the installation. One of the option during the install is to do a portable install to the desktop!
2) Download Monkey's Audio Decoder 2.1.5 and copy this into the component folder of foobar
3) Download the FLAC codec and use 7Zip to open the installer executable as an archive. Drag and drop the flac.exe to the Foobar portable install folder.
4) now edit the .cue file and check if the string has the correct ending:

FILE "Goodbye Yellow Brick Road.ape" WAVE

Most of the time this says wav. So edit and change it to .ape and save it

5) drag and drop the cue file into foobar 2000
6) select all the track and right click on convert

Friday, 3 June 2011

Installing FreeBSD 9 in VMWare

Install FreeBSD 9

Create a new VM machine with
  • 1 CPU
  • 512M DRAM
  • 50 G Disk with can be allocate as we go along

Download the a FreeBSD Boot ISO and boot off this image. Then select the following

  • Standard Install (others don't fully install unless you pick all the options manually)
  • All distributions
  • Yes to the mouse
  • No packages (will build them from the ports)
  • Use the full disk for FreeBSD
  • Accept all the default mount sizes and options

CVSUP

cd /usr/ports/net/cvsup (or /usr/ports/net/cvsup-without-gui)
make install

Put the following into a text file (to get updates to 8.0 and all src, ports,docs)

*default host=cvsup.au.FreeBSD.org
#*default host=cvsup.FreeBSD.org
*default base=/usr
*default prefix=/usr
*default release=cvs tag=RELENG_9
*default delete use-rel-suffix
*default compress
src-all
ports-all tag=.
doc-all tag=.
cvsroot-all
Update the sources using

cvsup -g cvsupfile.txt

Building your own kernel (64bit)

Follow this: http://www.freebsd.org/doc/handbook/kernelconfig-building.html

Alternatively, from /usr/src/Makefile (my current favored method)

#  0.  cp /usr/src/sys/amd64/conf/GENERIC /usr/src/sys/amd64/conf/ZZZ
# 0a. vi /usr/src/sys/amd64/conf/ZZZ
Find this line
ident               GENERIC
Replace “GENERIC” with the name you want to use (ie your hostname)
ident               ZZZ

#  1.  `cd /usr/src'       (or to the directory containing your source tree).
#  2.  `make buildworld'
#  3.  `make buildkernel KERNCONF=YOUR_KERNEL_HERE'     (default is GENERIC).
#  4.  `make installkernel KERNCONF=YOUR_KERNEL_HERE'   (default is GENERIC).
#       [steps 3. & 4. can be combined by using the "kernel" target]
#  5.  `reboot'        (in single user mode: boot -s from the loader prompt or select the singer user mode option).
# 5a. 'mount -a -t ufs' (mount all partitions as RW)
#  6.  `mergemaster -p' (Check only the most critical files and ask what needs to be done. Read /usr/sys/UPDATING for what changes may have happened)
#  7.  `make installworld'
#  8.  `make delete-old'       (I don't delete the old.... you may want to)
#  9.  `mergemaster'            (you may wish to use -i, along with -U or -F. This does all the rest of the configs. I tend to use -Ui rather than -F).
# 10.  `reboot'
# 11.  `make delete-old-libs' (in case no 3rd party program uses them anymore) (I don't delete the old.... you may want to)



Installing X11



The -DBATCH command makes the build accept all default options (ie no need to watch)

cd /usr/ports/x11/xorg
make -DBATCH install clean

Add the following to rc.conf to make keyboard/mouse work under xdm

#Starting with version 7.4, Xorg can use HAL to autodetect keyboards and mice. The sysutils/hal and devel/dbus ports are installed as dependencies of x11/xorg, but must be enabled by the following entries in the /etc/rc.conf file:

hald_enable="YES"
dbus_enable="YES"


Installing XDM

cd /usr/ports/x11/xdm
make -DBATCH install

edit /etc/ttys
and change the following from

ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure

to

ttyv8 "/usr/local/bin/xdm -nodaemon" xterm on secure


You can also confirgure XDM to allow remote connections via XDMCP:

edit /usr/local/lib/X11/xdm/xdm-config
and comment OUT the following line: DisplayManager.requestPort: 0

edit /usr/local/lib/X11/xdm/Xaccess
and add the following lines
* #any host can get a login window
LISTEN 10.210.10.24

NOTE the LISTEN * command doesn't work


Install Open-vm-tools


cd /usr/ports/emulators/open-vm-tools
make -DBATCH install

add the following to RC.conf


#vmware open-vm-tools
vmware_guest_vmblock_enable="YES"
vmware_guest_vmhgfs_enable="YES"
vmware_guest_vmmemctl_enable="YES"
vmware_guest_vmxnet_enable="YES"
vmware_guestd_enable="YES"

reboot and ensure vmware-guest process is running, otherwise start it up

Install VM-tools


1) Install Compat6x

cd /usr/ports/misc/compat6x
make -DBATCH install

2)

If necessary, mount the VMware Tools virtual CD-ROM image by entering a command similar to the following:
mount /cdrom
Change to a working directory (for example, /tmp):
cd /tmp
tar zxpf /cdrom/vmware-freebsd-tools.tar.gz
umount /cdrom
Run the VMware Tools installer:
cd vmware-tools-distrib
./vmware-install.pl

[[Accept all defaults]]


Renewing a DHCP lease using FreeBSD


ifconfig
In this case the active interface is sis0, so here is the command to run.
/sbin/dhclient sis0

Now occasionally that may not work as quickly as you might like. If you want to force it, you can restart the networking components by hand.

# /etc/netstart

Technically /etc/netstart has been obseleted by /etc/rc.network, although both seem to work just fine.



LocateDB


/usr/libexec/locate.updatedb

or in the crontab

0 * * * * /usr/libexec/locate.updatedb

NTPd


Add the following to /etc/rc.conf

#this adds the -g option to the default flags which are located in /etc/defaults/rc.conf
#-g option removes sanity checking. IE regardless of how different the machine time is from the
#polled time change the machine time to match.
#VMs tend to run out of sync as they are a simulated environment
ntpd_flags="${ntpd_flags} -g"
ntpd_enable="YES"