221 lines
7.6 KiB
Bash
Executable File
221 lines
7.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Install script for Fenrir Screen Reader
|
|
set -e
|
|
|
|
# Check if running as root
|
|
if [[ $(whoami) != "root" ]]; then
|
|
echo "This script must be run as root"
|
|
exit 1
|
|
fi
|
|
|
|
# Check Python version
|
|
pythonVersion=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
|
|
requiredVersion="3.8"
|
|
if ! python3 -c "import sys; exit(0 if sys.version_info >= (3, 8) else 1)" 2>/dev/null; then
|
|
echo "Python ${requiredVersion} or higher is required. Current version: ${pythonVersion}"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Fenrir Screen Reader Installation"
|
|
echo "=================================="
|
|
read -rp "This will install the Fenrir screen reader. Press Ctrl+C to cancel, or Enter to continue."
|
|
|
|
# Check for pip3
|
|
if ! command -v pip3 &> /dev/null; then
|
|
echo "pip3 is required but not installed. Please install pip3 first."
|
|
exit 1
|
|
fi
|
|
|
|
# Function to check dependencies
|
|
checkDependencies() {
|
|
echo "Checking dependencies..."
|
|
if python3 check-dependencies.py; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Function to install dependencies with pip
|
|
installWithPip() {
|
|
echo "Installing Python dependencies with pip..."
|
|
pip3 install -r requirements.txt --break-system-packages
|
|
}
|
|
|
|
# Function to detect package manager and provide instructions
|
|
detectPackageManager() {
|
|
if command -v apt &> /dev/null; then
|
|
echo "apt"
|
|
elif command -v dnf &> /dev/null; then
|
|
echo "dnf"
|
|
elif command -v yum &> /dev/null; then
|
|
echo "yum"
|
|
elif command -v pacman &> /dev/null; then
|
|
echo "pacman"
|
|
elif command -v zypper &> /dev/null; then
|
|
echo "zypper"
|
|
else
|
|
echo "unknown"
|
|
fi
|
|
}
|
|
|
|
# Function to show package manager instructions
|
|
showPackageInstructions() {
|
|
local pm=$1
|
|
echo "Package manager installation instructions:"
|
|
case $pm in
|
|
"apt")
|
|
echo " sudo apt update"
|
|
echo " sudo apt install python3-evdev python3-daemonize python3-dbus python3-pyudev python3-pexpect"
|
|
echo " sudo apt install python3-pyte python3-setproctitle python3-enchant python3-xdg"
|
|
echo " sudo apt install speech-dispatcher espeak-ng sox alsa-utils"
|
|
;;
|
|
"dnf"|"yum")
|
|
echo " sudo $pm install python3-evdev python3-daemonize python3-dbus python3-pyudev python3-pexpect"
|
|
echo " sudo $pm install python3-pyte python3-setproctitle python3-enchant python3-pyxdg"
|
|
echo " sudo $pm install speech-dispatcher espeak-ng sox alsa-utils"
|
|
;;
|
|
"pacman")
|
|
echo " sudo pacman -S python-evdev python-daemonize python-dbus python-pyudev python-pexpect"
|
|
echo " sudo pacman -S python-pyte python-setproctitle python-pyenchant python-pyxdg"
|
|
echo " sudo pacman -S speech-dispatcher espeak-ng sox alsa-utils"
|
|
;;
|
|
"zypper")
|
|
echo " sudo zypper install python3-evdev python3-daemonize python3-dbus python3-pyudev python3-pexpect"
|
|
echo " sudo zypper install python3-pyte python3-setproctitle python3-enchant python3-pyxdg"
|
|
echo " sudo zypper install speech-dispatcher espeak-ng sox alsa-utils"
|
|
;;
|
|
*)
|
|
echo " Unknown package manager. Please install the dependencies manually."
|
|
echo " Required packages: evdev, daemonize, dbus-python, pyudev, pexpect, pyte, setproctitle"
|
|
echo " System packages: speech-dispatcher, espeak-ng, sox, alsa-utils"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# Initial dependency check
|
|
echo "Performing initial dependency check..."
|
|
if ! checkDependencies; then
|
|
echo ""
|
|
echo "Some dependencies are missing. You have two options:"
|
|
echo "1. Install using pip (not recommended uses --break-system-packages)"
|
|
echo "2. Install using your system package manager (recommended assuming I got the package names and package manager syntax right)"
|
|
echo ""
|
|
|
|
read -rp "Use pip to install Python dependencies? (y/N): " usePip
|
|
usePip="${usePip:0:1}"
|
|
|
|
if [[ "${usePip^}" == "Y" ]]; then
|
|
installWithPip
|
|
else
|
|
packageManager=$(detectPackageManager)
|
|
echo ""
|
|
showPackageInstructions "$packageManager"
|
|
echo ""
|
|
echo "Please install the packages above, then press Enter to continue..."
|
|
read -r
|
|
fi
|
|
|
|
# Check dependencies again
|
|
echo "Rechecking dependencies..."
|
|
if ! checkDependencies; then
|
|
echo "Some dependencies are still missing. Please install them manually."
|
|
echo "You can run 'python3 check-dependencies.py' to see which ones are missing."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo "All dependencies satisfied!"
|
|
|
|
# Install Fenrir application files
|
|
echo "Installing Fenrir application files..."
|
|
|
|
# Fenrir main application
|
|
install -m755 -d /opt/fenrirscreenreader
|
|
cp -af src/* /opt/fenrirscreenreader
|
|
|
|
ln -fs /opt/fenrirscreenreader/fenrir /usr/bin/fenrir
|
|
|
|
# tools
|
|
install -m755 -d /usr/share/fenrirscreenreader/tools
|
|
cp -af tools/* /usr/share/fenrirscreenreader/tools
|
|
|
|
# scripts
|
|
install -m755 -d /usr/share/fenrirscreenreader/scripts
|
|
cp -af "config/scripts/wlan__-__key_y.sh" /usr/share/fenrirscreenreader/scripts/
|
|
|
|
# keyboard
|
|
for i in "config/keyboard/"*.conf ; do
|
|
install -m644 -D "$i" "/etc/fenrirscreenreader/keyboard/${i##*/}"
|
|
done
|
|
|
|
# punctuation
|
|
install -m755 -d /etc/fenrirscreenreader/punctuation
|
|
cp -af config/punctuation/* /etc/fenrirscreenreader/punctuation
|
|
|
|
# sound
|
|
install -d /usr/share/sounds/fenrirscreenreader
|
|
cp -af config/sound/default /usr/share/sounds/fenrirscreenreader/default
|
|
cp -af config/sound/template /usr/share/sounds/fenrirscreenreader/template
|
|
|
|
# config
|
|
if [ -f "/etc/fenrirscreenreader/settings/settings.conf" ]; then
|
|
echo "Do you want to overwrite your current global settings? (y/n)"
|
|
read -r yn
|
|
yn="${yn:0:1}"
|
|
if [[ "${yn^}" == "Y" ]]; then
|
|
mv /etc/fenrirscreenreader/settings/settings.conf /etc/fenrirscreenreader/settings/settings.conf.bak
|
|
echo "Your old settings.conf has been backed up to settings.conf.bak."
|
|
install -m644 -D "config/settings/settings.conf" /etc/fenrirscreenreader/settings/settings.conf
|
|
else
|
|
install -m644 -D "config/settings/settings.conf" /etc/fenrirscreenreader/settings/settings.conf.current
|
|
fi
|
|
else
|
|
install -m644 -D "config/settings/settings.conf" /etc/fenrirscreenreader/settings/settings.conf
|
|
fi
|
|
|
|
# Install systemd service if systemd is available
|
|
if command -v systemctl &> /dev/null; then
|
|
echo "Installing systemd service..."
|
|
|
|
# Detect which service file to use
|
|
if [ -f "/etc/arch-release" ] || [ -f "/etc/manjaro-release" ]; then
|
|
serviceFile="autostart/systemd/Arch/fenrir.service"
|
|
else
|
|
serviceFile="autostart/systemd/Debian/fenrir.service"
|
|
fi
|
|
|
|
if [ -f "$serviceFile" ]; then
|
|
install -m644 "$serviceFile" /etc/systemd/system/fenrir.service
|
|
systemctl daemon-reload
|
|
echo "Systemd service installed. Enable with: sudo systemctl enable fenrir"
|
|
else
|
|
echo "Warning: Systemd service file not found: $serviceFile"
|
|
fi
|
|
else
|
|
echo "Warning: Systemd not detected. Manual service setup may be required."
|
|
fi
|
|
|
|
# Final message
|
|
cat << EOF
|
|
|
|
Installation complete!
|
|
=============================
|
|
Install path: /opt/fenrirscreenreader
|
|
Settings path: /etc/fenrirscreenreader
|
|
|
|
Next steps:
|
|
1. Test Fenrir: sudo fenrir
|
|
2. Enable autostart: sudo systemctl enable fenrir
|
|
3. Configure audio (run both as user and root):
|
|
- PulseAudio: /usr/share/fenrirscreenreader/tools/configure_pulse.sh
|
|
- PipeWire: /usr/share/fenrirscreenreader/tools/configure_pipewire.sh
|
|
|
|
For help:
|
|
- Documentation: https://git.stormux.org/storm/fenrir
|
|
- Configuration: sudo fenrir --help
|
|
- Dependency check: python3 check-dependencies.py
|
|
|
|
Fenrir installation successful!
|
|
EOF
|