#!/bin/bash set -e set -u APPSH_HOME=$(cd $(dirname "$0")/.. && pwd) . $APPSH_HOME/lib/common # HEADER END usage() { echo "usage: $0 -v -f " exit 1 } version= file= while getopts "v:f:" opt do case $opt in v) version=$OPTARG shift 2 OPTIND=1 ;; f) file=$OPTARG shift 2 OPTIND=1 ;; esac done if [[ -z $version || -z $file || $# != 0 ]] then usage fi if [ -d versions/$version ] then echo "Version $version is already installed" exit 1 fi mkdir -p versions/$version echo "Unpacking..." unzip -q -d versions/$version $file if [ ! -d versions/$version/root ] then echo "Invalid zip file, did not contain a ./root directory." >&2 exit 1 fi # TODO: This should go away if [ -d current/bin ] then ( cd $name/$instance/current find bin -type f | xargs chmod +x ) fi app-run-hook -v "$version" -h pre-install app-set-version -v "$version" app-run-hook -v "$version" -h post-install