From e1daac32c5b7ca0d902c16135d361aa5303f5124 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 27 Jan 2013 15:00:27 +0100 Subject: o Creating an initial version of install-file. --- libexec/app-set-version | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 libexec/app-set-version (limited to 'libexec/app-set-version') diff --git a/libexec/app-set-version b/libexec/app-set-version new file mode 100755 index 0000000..75d44a8 --- /dev/null +++ b/libexec/app-set-version @@ -0,0 +1,50 @@ +#!/bin/bash + +set -e +set -u + +APPSH_HOME=$(cd $(dirname "$0")/.. && pwd) + +. $APPSH_HOME/lib/common +# HEADER END + +version= + +while getopts "v:" opt +do + case $opt in + v) + version=$OPTARG + shift 2 + OPTIND=1 + ;; + esac +done + +if [[ -z $version || $# != 0 ]] +then + usage +fi + +if [[ ! -d versions/$version ]] +then + fatal "Invalid version: not a directory: versions/$version" +fi + +if [[ -e current && ! -s current ]] +then + fatal "'current' is not a symlink" +fi + +if [[ -e current ]] +then + prev=`ls -l current` + prev=${prev/#* -> versions} + prev=${prev:1} + prev=${prev/%?root} + echo "Changing current symlink from $prev to $version" + ln -f -s versions/$version/root current +else + echo "Creating current symlink for version $version" + ln -s versions/$version/root current +fi -- cgit v1.2.3