#!/bin/bash # Notes # Run this as: # $ wget -O - http://delx.net.au/files/setup.txt | bash # or # $ curl http://delx.net.au/files/setup.txt | bash # or # $ curl http://delx.net.au/files/setup.txt | R=http://host/repo bash # Some blank lines echo -ne "\n\n\n" HGDOTFILES="http://delx.net.au/hg/hgdotfiles-generic" if [ -n "${R}" ]; then HGDOTFILES="${R}" fi echo "Using repository: ${HGDOTFILES}" sleep 3 # Check for mercurial install if ! hg &> /dev/null; then echo "You must install Mercurial..." if fink &> /dev/null; then echo "Using fink..." fink install mercurial-py26 elif apt-get &> /dev/null; then echo "Using apt-get..." sudo apt-get install mercurial elif yum &> /dev/null; then echo "Using yum..." sudo yum install mercurial fi if ! hg &> /dev/null; then echo "You're on your own. Exiting..." exit 1 fi fi # Safety checks cd DOTDIR=".hgdotfiles-"$(hostname | cut -d '.' -f 1) if ! mkdir oldsettings; then exit 1 fi if [ -e "${DOTDIR}" ]; then echo "Error, ${DOTDIR} already exists." exit 1 fi # Install and backup hg clone "${HGDOTFILES}" "${DOTDIR}" for i in $(ls -A "${DOTDIR}" | grep -v '^\.hg\(ignore\)\?$' | grep -v README); do echo "${i}" if [ -e "${i}" -o -L "${i}" ]; then mv "${i}" oldsettings/ fi ln -s "${DOTDIR}/${i}" ./ done