45 lines
1.4 KiB
Bash
Executable File
45 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
set -eu
|
|
|
|
PACKAGE_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
|
ORCHESTRATOR="$PACKAGE_DIR/orchestrator/hy2xs-orchestrator"
|
|
ORCHESTRATOR_INSTALL_PATH="/usr/local/lib/hy2xs/hy2xs-orchestrator"
|
|
ORCHESTRATOR_SYMLINK="/usr/local/bin/hy2xs-orchestrator"
|
|
RUNTIME_PACKAGE_DIR="/usr/local/lib/hy2xs/package"
|
|
|
|
log() {
|
|
printf '[hy2xs-install] %s\n' "$*"
|
|
}
|
|
|
|
fail() {
|
|
printf '[hy2xs-install] ERROR: %s\n' "$*" >&2
|
|
exit 1
|
|
}
|
|
|
|
if [ "$(id -u)" != "0" ]; then
|
|
fail "HY2XS install must run as root."
|
|
fi
|
|
|
|
if [ ! -x "$ORCHESTRATOR" ]; then
|
|
fail "Missing executable orchestrator artifact: $ORCHESTRATOR"
|
|
fi
|
|
|
|
install -d -m 0755 /usr/local/lib/hy2xs
|
|
install -m 0755 "$ORCHESTRATOR" "$ORCHESTRATOR_INSTALL_PATH"
|
|
ln -sf "$ORCHESTRATOR_INSTALL_PATH" "$ORCHESTRATOR_SYMLINK"
|
|
|
|
log "installing runtime package assets to: $RUNTIME_PACKAGE_DIR"
|
|
rm -rf "$RUNTIME_PACKAGE_DIR"
|
|
install -d -m 0755 "$RUNTIME_PACKAGE_DIR"
|
|
cp -a "$PACKAGE_DIR/config" "$RUNTIME_PACKAGE_DIR/"
|
|
cp -a "$PACKAGE_DIR/docs" "$RUNTIME_PACKAGE_DIR/"
|
|
cp -a "$PACKAGE_DIR/systemd" "$RUNTIME_PACKAGE_DIR/"
|
|
cp -a "$PACKAGE_DIR/templates" "$RUNTIME_PACKAGE_DIR/"
|
|
cp -a "$PACKAGE_DIR/metadata" "$RUNTIME_PACKAGE_DIR/"
|
|
cp -a "$PACKAGE_DIR/ui" "$RUNTIME_PACKAGE_DIR/"
|
|
cp -a "$PACKAGE_DIR/install.sh" "$RUNTIME_PACKAGE_DIR/"
|
|
|
|
log "package directory: $PACKAGE_DIR"
|
|
log "starting install-only orchestrator"
|
|
exec "$ORCHESTRATOR_INSTALL_PATH" install --package-dir "$RUNTIME_PACKAGE_DIR" "$@"
|