#!/bin/bash # Installs the voicemail transcription mailcmd. Run with sudo. set -euo pipefail SRC=/home/jp/asterisk-vm DEST=/opt/vm-transcribe echo "== creating $DEST" install -d -o asterisk -g asterisk -m 755 "$DEST" "$DEST/models" echo "== python venv + faster-whisper" if [ ! -x "$DEST/venv/bin/python3" ]; then python3 -m venv "$DEST/venv" "$DEST/venv/bin/pip" install -q --upgrade pip "$DEST/venv/bin/pip" install -q faster-whisper fi echo "== installing script" install -o root -g root -m 755 "$SRC/vm_mailcmd.py" "$DEST/vm_mailcmd.py" install -o root -g root -m 755 "$SRC/vm_telegram.py" "$DEST/vm_telegram.py" install -o root -g root -m 755 "$SRC/vm_tg_setup.py" "$DEST/vm_tg_setup.py" chown -R asterisk:asterisk "$DEST/models" echo "== telegram config (not overwritten if it already exists)" if [ ! -f "$DEST/telegram.conf" ]; then install -o root -g asterisk -m 640 "$SRC/telegram.conf" "$DEST/telegram.conf" echo " created $DEST/telegram.conf - add your bot token and chat IDs" else echo " kept existing $DEST/telegram.conf" fi echo "== log file" touch /var/log/asterisk/vm_mailcmd.log chown asterisk:asterisk /var/log/asterisk/vm_mailcmd.log chmod 640 /var/log/asterisk/vm_mailcmd.log echo "== pre-downloading the whisper model as the asterisk user" sudo -u asterisk "$DEST/venv/bin/python3" - <