#!/bin/sh net session > /dev/null 2>&1 || { echo Not elevated. exit 1 } # Cygwin upgrade helper script. # Usage: # # install-cygwin.sh [ ports ] # # If you intend to use it for new installs, you will need minimal bootstrap # including POSIX shell interpreter and wget utility. # # You will have to edit the script to provide mirror URL of your choice. # # The script assumes existing installation of the same architecture as # the host operating system. # If you want to install 32-bit Cygwin on 64-bit host, override # $ARCH with value other than "x86_64". # F.e. # # ARCH=x86 ./install-cygwin.sh # Mirror URL - don't include trailing slash! MIRROR="${MIRROR:-http://ftp-stud.hs-esslingen.de/pub/Mirrors/sources.redhat.com/cygwin}" # System architecture. ARCH="${ARCH:-$(uname -m)}" # Localization is fine... as long as you don't show it to other people. export LANG=C if [ "$ARCH" != "x86_64" ]; then ARCH=x86 fi # Crude test for other Cygwin processes running. if [ "$1" != "--force" ]; then TTY=$(tty) test $(ps -al | grep -vE "\<${TTY##/dev/}\>" | wc -l) -gt 1 && { echo There\'s likely other processes running from Cygwin environment. echo Please stop them or use --force to suppress this test. exit 1 } else shift fi wget -N "http://cygwin.com/setup-${ARCH}.exe" if [ "$1" = "ports" ]; then KEYS="-K http://cygwinports.org/ports.gpg -s ""${MIRROR%%/}ports/" shift fi ./setup-${ARCH}.exe -O -s "${MIRROR%%/}/" $KEYS $* & sleep 2 taskkill /IM "sh.exe" /F