#!/bin/bash set -e set -u export APPSH_HOME=$(cd $(dirname "$0")/.. && pwd) . $APPSH_HOME/lib/common # HEADER END usage_text() { echo "usage: $usage_app -v -f [-C ] [-c ]" } version= file= prepend_config= append_config= while getopts "v:f:C:c:" opt do case $opt in v) version=$OPTARG shift 2 OPTIND=1 ;; f) file=$OPTARG shift 2 OPTIND=1 ;; C) prepend_config=$OPTARG shift 2 OPTIND=1 ;; c) append_config=$OPTARG shift 2 OPTIND=1 ;; esac done if [[ -z $version || -z $file || $# != 0 ]] then usage fi re="[.a-zA-Z0-9]" if [[ ! $version =~ $re ]] then fatal "Invalid version: $version" fi if [ -d versions/$version ] then echo "Version $version is already unpacked" else mkdir -p versions/$version.tmp echo "Unpacking..." unzip -q -d versions/$version.tmp $file if [ ! -d versions/$version.tmp/root ] then echo "Invalid zip file, did not contain a 'root' directory." >&2 rm -rf versions/$version.tmp exit 1 fi mv versions/$version.tmp versions/$version fi if [ -n "$prepend_config" ] then debug "Prepending config from $prepend_config" app-conf import "$prepend_config" fi if [ -r versions/$version/app.config ] then debug "Importing config from package" app-conf import versions/$version/app.config fi if [ -n "$append_config" ] then debug "Appending config from $append_config" app-conf import "$append_config" fi app-run-hook -v "$version" -h pre-install app-set-version -v "$version" app-run-hook -v "$version" -h post-install