aboutsummaryrefslogtreecommitdiff
path: root/libexec/app-set-version
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-01-27 15:00:27 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-01-27 15:00:27 +0100
commite1daac32c5b7ca0d902c16135d361aa5303f5124 (patch)
tree3ebe514ae823d23b26c96d8d2db9c6b97e191de4 /libexec/app-set-version
parent11c930f71db58201994265b71a8f76187f1dbda1 (diff)
downloadapp.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-xlibexec/app-set-version50
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