38 lines
1.1 KiB
Bash
Executable file
38 lines
1.1 KiB
Bash
Executable file
#!/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}"
|