Pages

Friday 28 November 2014

Ubuntu - Update hostname from DHCP

This script is basically a mutation of the script found in drwindsor's post :
#!/bin/sh
# Filename:     /etc/dhcp/dhclient-exit-hooks.d/hostname
# Purpose:      Used by dhclient-script to set the hostname of the system
#               to match the DNS information for the host as provided by
#               DHCP.
#

if [ "$reason" != BOUND ] && [ "$reason" != RENEW ] \
   && [ "$reason" != REBIND ] && [ "$reason" != REBOOT ]
then
        return
fi

echo dhclient-exit-hooks.d/hostname: Dynamic IP address = $new_ip_address
hostname=$(host $new_ip_address | cut -d ' ' -f 5 | cut -d "." -f 1)
echo $hostname > /etc/hostname
hostname $hostname
echo dhclient-exit-hooks.d/hostname: Dynamic Hostname = $hostname

Git mirror without cloning

What I want to do is to set up a bare mirror git repository without fetching the changes. It should be a fast operation compared to:
git clone --mirror $REPOURL
Here are the steps that I did to achieve the same results as a full clone:
# Create and update with the clone command
git clone --mirror https://github.com/matelakat/vimide vimide-with-clone
cd vimide-with-clone/
git fetch
cd ..
And let's create the equivalent:
git init --bare vimide-manual
cd vimide-manual
git remote add --mirror origin https://github.com/matelakat/vimide
git fetch
git pack-refs --all --prune
cd ..
You can see that the two directories are the same:
diff -r vimide-with-clone/ vimide-manual/ && echo "ALL the same"
ALL the same