voice-dictation/scripts/install_macos_app.sh
2026-10-19 14:30:58 +03:00

38 lines
1.1 KiB
Bash
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# Устанавливает собранный bundle в /Applications с recoverable backup.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
SOURCE_APP="${1:-${PROJECT_DIR}/dist/Voice Dictation.app}"
DEST_APP="/Applications/Voice Dictation.app"
if [[ ! -d "${SOURCE_APP}" ]]; then
echo "[ОШИБКА] Не найдена сборка: ${SOURCE_APP}"
exit 1
fi
pkill -TERM -x VoiceDictation 2>/dev/null || true
for _attempt in 1 2 3 4 5; do
if ! pgrep -x VoiceDictation >/dev/null 2>&1; then
break
fi
sleep 1
done
if pgrep -x VoiceDictation >/dev/null 2>&1; then
pkill -KILL -x VoiceDictation
sleep 1
fi
if [[ -d "${DEST_APP}" ]]; then
BACKUP_APP="${HOME}/.Trash/Voice Dictation before $(date +%Y%m%d-%H%M%S).app"
mv "${DEST_APP}" "${BACKUP_APP}"
echo "Резервная копия: ${BACKUP_APP}"
fi
/usr/bin/ditto "${SOURCE_APP}" "${DEST_APP}"
codesign --verify --deep --strict "${DEST_APP}"
/usr/bin/open "${DEST_APP}"
echo "Установлено: ${DEST_APP}"