diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-01-27 15:00:27 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-01-27 15:00:27 +0100 |
commit | e1daac32c5b7ca0d902c16135d361aa5303f5124 (patch) | |
tree | 3ebe514ae823d23b26c96d8d2db9c6b97e191de4 /libexec/app-set-version | |
parent | 11c930f71db58201994265b71a8f76187f1dbda1 (diff) | |
download | app.sh-e1daac32c5b7ca0d902c16135d361aa5303f5124.tar.gz app.sh-e1daac32c5b7ca0d902c16135d361aa5303f5124.tar.bz2 app.sh-e1daac32c5b7ca0d902c16135d361aa5303f5124.tar.xz app.sh-e1daac32c5b7ca0d902c16135d361aa5303f5124.zip |
o Creating an initial version of install-file.
Diffstat (limited to 'libexec/app-set-version')
-rwxr-xr-x | libexec/app-set-version | 50 |
1 files changed, 50 insertions, 0 deletions
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 |