#!/bin/bash set -e # (C) copyright 2025 Chris Olson AC9KH, Joseph Counsil K0OG # Modded 2026 to prevent KDE system crashes via strict /opt path isolation. # Builds and installs JS8Call from source on a linux system. # Requires sudo access. Installs to /opt/lib/js8call and /opt/bin. # --- Variables --- red="\033[0;31m" clear_color="\033[0m" JS8_VERSION="master" # New Isolated Safe Paths JS8_INSTALL_PREFIX="/opt/lib/js8call" JS8_BIN_DIR="/opt/bin" JS8_QT_DIR="${JS8_INSTALL_PREFIX}/Qt" # Toxic Legacy Paths to detect and safely nuke TOXIC_SYSTEM_BIN="/usr/bin/JS8Call" TOXIC_SYSTEM_LIB="/usr/lib/js8call" TOXIC_LDCONFIG="/etc/ld.so.conf.d/js8call.conf" # Legacy local install paths — used to detect and remove old ~/.local installs LEGACY_BIN="$HOME/.local/bin/JS8Call" LEGACY_QT_DIR="$HOME/.local/lib/Qt" LEGACY_LIB_DIR="$HOME/.local/lib/js8lib" LEGACY_DESKTOP="$HOME/.local/share/applications/JS8Call.desktop" LEGACY_ICON="$HOME/.local/share/icons/icon_128.svg" # --- Functions --- divider() { echo "######################################################################" } error() { echo "Installation has exited with an error." exit 1 } clear # --- Must not run as root --- if [ "$(id -u)" -eq 0 ]; then divider echo -e "${red}You are logged in as root. You MUST be logged in as a normal user to run this script. It is recommended to add your username to the sudo group. We need to install system libraries that are required to build JS8Call. This must be done as a sudo user. This script will NOT RUN AS ROOT!${clear_color}" divider exit 1 fi # --- Detect distro --- if [ -f /etc/os-release ]; then . /etc/os-release DISTRO=$ID else echo "Cannot detect Linux distribution. Exiting." exit 1 fi # --- Check for .deb managed installation --- if dpkg -l js8call 2>/dev/null | grep -q "^ii"; then divider echo -e "${red}JS8Call is currently installed via the .deb package. Running this script will overwrite the package-managed installation and may cause conflicts with your package manager. It is strongly recommended to remove the .deb package first: sudo dpkg -r js8call This ensures a clean installation without package manager conflicts.${clear_color}" divider read -p "Remove the .deb package now and continue? Yes(y) / No(n): " REMOVE_DEB /dev/null << EOF [Paths] Prefix = ${JS8_QT_DIR} Plugins = plugins Libraries = lib EOF echo "Paths fixed. Compilation links will successfully target /opt." # --- Fetch JS8Call source --- clear echo "Fetching JS8Call source code..." divider if [ ! -d "$HOME/development/JS8Call-improved" ]; then cd "$HOME/development" git clone "https://github.com/JS8Call-improved/JS8Call-improved.git" cd "$HOME/development/JS8Call-improved" git checkout "${JS8_VERSION}" else echo "Source directory already exists — checking for updates..." cd "$HOME/development/JS8Call-improved" git fetch origin git checkout "${JS8_VERSION}" git pull origin "${JS8_VERSION}" fi sleep 2 # --- Build JS8Call --- cd "$HOME/development/JS8Call-improved" BRANCH=$(git branch --show-current) clear divider echo "JS8Call Build Details: Qt version : 6.12.0 with FFmpeg audio (requires PulseAudio or PipeWire) Branch : JS8Call-improved ${BRANCH} Distro : ${DISTRO} / ${JS8_ARCH}" divider read -p "Press Enter to continue" /dev/null << 'EOF' #!/bin/bash # Isolate environment strings explicitly for this binary tree process export OPT_RUN_PREFIX="/opt/lib/js8call" export LD_LIBRARY_PATH="$OPT_RUN_PREFIX/lib:$OPT_RUN_PREFIX/Qt/lib:$LD_LIBRARY_PATH" export QT_PLUGIN_PATH="$OPT_RUN_PREFIX/Qt/plugins" exec "$OPT_RUN_PREFIX/bin/js8call" "$@" EOF sudo chmod 755 "${JS8_BIN_DIR}/JS8Call" # ==================================================================== # NEW STAGE: CONSTRUCT THE HAM RADIO MENUS FOR KDE/FREEDESKTOP # ==================================================================== echo "Creating Ham Radio application menu category..." # 1. Define the formal 'Ham Radio' visual directory properties sudo mkdir -p /usr/share/desktop-directories sudo tee /usr/share/desktop-directories/HamRadio.directory > /dev/null << 'EOF' [Desktop Entry] Value=1.0 Type=Directory Name=Ham Radio Comment=Amateur Radio Applications Icon=js8call EOF # 2. Inject the custom category menu rule into the system-wide XDG layout # This forces KDE Plasma's application menu to map the 'HamRadio' category tag to a real visual section. sudo mkdir -p /etc/xdg/menus/applications-merged sudo tee /etc/xdg/menus/applications-merged/hamradio.menu > /dev/null << 'EOF' Applications Ham Radio HamRadio.directory HamRadio EOF # 3. Create Desktop entry pointing to the new Ham Radio category mapping sudo bash -c "cat > /usr/share/applications/JS8Call.desktop << EOF [Desktop Entry] Type=Application Name=JS8Call GenericName=Weak Signal Digital Communications Exec=${JS8_BIN_DIR}/JS8Call Icon=js8call Terminal=false Categories=HamRadio; EOF" # ==================================================================== # Install icon to standard hicolor theme location sudo mkdir -p /usr/share/icons/hicolor/scalable/apps sudo cp ../artwork/icon_128.svg /usr/share/icons/hicolor/scalable/apps/js8call.svg # Refresh desktop menu database if command -v update-desktop-database > /dev/null 2>&1; then sudo update-desktop-database /usr/share/applications fi # --- Cleanup prompt --- clear divider echo "DONE!" echo "Do you want to remove the JS8Call development directory? The program will run fine without it and you can re-fetch it with this script at any time." divider read -p "Remove JS8Call source tree? Yes(y) / No(n): " CLEANUP