Encryption Programs Setup Script (PTE and Kleopatra)
====================================================

Installs or updates the latest available release of each of:

  PTE (Paranoia Text Encryption) for PC, by Paranoia Works
    How it's installed: Official Java program (pte.jar), unpacked from the
      PC download zip. Java is installed first if needed.
    Source: paranoiaworks.mobi
      (https://paranoiaworks.mobi/download/files/PTE-PC.zip)

  Kleopatra (GnuPG / OpenPGP certificate manager and encryption)
    How it's installed:
      Linux / Raspberry Pi: your distribution's 'kleopatra' apt package
      Windows: Gpg4win, which includes Kleopatra and GnuPG
    Source: Linux -- your distribution's repositories
      (project home page: https://apps.kde.org/kleopatra/);
      Windows -- gpg4win.org (https://files.gpg4win.org/)

For more information, see https://sitrepnet.com/

Files
-----

  install-encryption.sh    Linux and Raspberry Pi (bash)
  install-encryption.bat   Windows: double-click this. It runs the
                           PowerShell script below with the settings it
                           needs.
  install-encryption.ps1   Windows (PowerShell). Keep it in the same folder
                           as install-encryption.bat.
  INSTRUCTIONS.txt         Step-by-step guide for beginners

Supported systems
-----------------

- Debian-family Linux (Debian, Ubuntu, Linux Mint, Pop!_OS) and Raspberry
  Pi OS (32-bit and 64-bit). Packages are installed with apt-get. On other
  distros, PTE can still be installed with --skip-deps if Java 11+, unzip
  and curl are already there; install Kleopatra with your own package
  manager.
- Windows 10 and 11 (x64; ARM64 also works). Uses Windows PowerShell 5.1,
  which is built in.
- Both programs open windows, so a desktop is needed. Raspberry Pi OS
  "Lite" (no desktop) can't run them.

PTE's Linux part is based on the pte_install() routine in
gitlab.com/amrron/setup-scripts (https://gitlab.com/amrron/setup-scripts),
AmRRON-Setup-Script.sh, with the changes listed under "Differences from
the AmRRON script" below.

Usage
-----

Linux / Raspberry Pi:

  chmod +x install-encryption.sh
  ./install-encryption.sh [options]

  Run it as your normal user, not with sudo. It asks for your password
  itself.

Windows:

  Double-click install-encryption.bat, or from a Command Prompt:

  install-encryption.bat [options]

  Run it as your normal user. Windows shows a permission (UAC) prompt when
  Java or Gpg4win is being installed, since those install for all users.

The script will:

1. Show installed vs. latest versions for both programs.
2. With no --only given, ask which program (if either) to skip -- press
   Enter to install both.
3. Install Java for PTE if this computer doesn't have Java 11 or later.
4. Download and install whatever is missing or out of date.
5. Create menu / Start menu entries and desktop icons.

Options
~~~~~~~

The same options work on both Linux and Windows.

  --only=NAME[,NAME]  Only act on the named program(s): pte, kleopatra.
                      Skips the interactive selection prompt.
  --check-only        Show installed vs. latest versions, install nothing
  --force             Reinstall even if already at the latest version
  --skip-deps         Don't install PTE's dependencies (Java; on Linux also
                      unzip and curl)
  --no-desktop        Don't create menu entries or desktop icons
  --dir=DIR           Folder to install PTE into (default: ~/Security on
                      Linux, %USERPROFILE%\Security on Windows). PTE goes
                      in DIR/"Paranoia Text Encryption".
  --ui-scale=N        Make the PTE window bigger on high-resolution screens
                      (e.g. 1.5 or 2). Kept on later runs; --ui-scale=1
                      sets it back to normal.
  -h, --help          Show help

Where things end up
-------------------

Linux / Raspberry Pi:

  ~/Security/Paranoia Text Encryption/    PTE (pte.jar, libs/, License/)
      .install-encryption-release                date of the installed PTE release
  /usr/local/bin/pte                      the 'pte' command
  ~/.local/share/applications/pte.desktop PTE menu entry
  ~/.local/share/icons/pte.png            PTE icon, taken from inside pte.jar
  ~/Desktop/PTE.desktop                   PTE desktop icon
  /usr/bin/kleopatra                      Kleopatra (apt package; it adds
                                          its own menu entry)
  ~/Desktop/Kleopatra.desktop             Kleopatra desktop icon

Windows:

  %USERPROFILE%\Security\Paranoia Text Encryption\   PTE
      .install-encryption-release, pte.ico
  Start menu\Programs\PTE.lnk, Desktop\PTE.lnk        PTE shortcuts
  C:\Program Files\Eclipse Adoptium\jre-21...\        Java, if it was needed
  C:\Program Files (x86)\Gpg4win\ or
  C:\Program Files\Gpg4win\                           Gpg4win / Kleopatra
  Desktop\Kleopatra.lnk                               Kleopatra shortcut
                                                      (Gpg4win adds its own
                                                      Start menu entries)

Requirements
------------

PTE needs Java 11 or later (the current pte.jar is built for Java 11,
class file version 55).

- Linux: the script installs 'default-jre' with apt if the 'java' command
  is missing, older than 11, or a "headless" version that can't open
  windows. On every current Debian, Ubuntu and Raspberry Pi OS release,
  default-jre is Java 11 or newer.
- Windows: the script looks for Java 11+ on PATH, in JAVA_HOME and in the
  usual install folders (Eclipse Adoptium, Oracle, Microsoft, Zulu,
  Corretto, BellSoft). If none is found it installs the Eclipse Temurin 21
  JRE (from api.adoptium.net) with its Windows installer, set up to add
  Java to PATH, set JAVA_HOME and open .jar files.

Versions and updates
--------------------

PTE: Paranoia Works doesn't publish a version number for the PC build, so
the script uses the date the server reports for PTE-PC.zip (its
"Last-Modified" header) as the version, shown as "release of YYYY-MM-DD".
That date is saved in .install-encryption-release inside the program folder. If
the date on the server matches, the download is skipped.

The PTE download is checked before anything is changed: it must be a
valid zip containing "Paranoia Text Encryption/pte.jar". Updates unpack
over the top of the existing folder; the folder is never deleted first,
so settings PTE keeps there are kept.

Kleopatra on Linux: "latest" is the newest version your distribution
offers, which is usually behind KDE's newest release. Install runs
apt-get update first, then installs or upgrades the 'kleopatra' package.
With --check-only, the "latest" shown is from apt's last refresh.

Kleopatra on Windows: the version shown is the Gpg4win version (Kleopatra
comes inside Gpg4win). The latest is read from the list of files at
files.gpg4win.org. The installer is run silently (/S).

Download checks on Windows: the Java installer and the Gpg4win installer
must carry a valid Windows digital signature, and Gpg4win's must be from
g10 Code (the Gpg4win developers), or they aren't run. PTE isn't signed by
Paranoia Works, so on both systems it gets only the zip check above.

Raspberry Pi and other ARM machines
-----------------------------------

The PTE zip includes a native library (libs/libpwsr.so on Linux,
libs/pwsr.dll on Windows) that only runs on Intel/AMD (x86-64) PCs; PTE
uses it only to enlarge ("upscale") images in the steganography editor,
and if it can't load the library it just reports "Native super-resolution
not available". Encryption and decryption are pure Java and work normally
on the Pi. The script prints a note about this on non-x86-64 machines.

Kleopatra is a KDE program. On a Pi that doesn't already have KDE
libraries, the first install is a download of a few hundred MB.

Existing installs
-----------------

- A PTE installed by the AmRRON setup script uses the same folder
  (~/Security/Paranoia Text Encryption), so it's updated in place. The
  'pte' command that script created is replaced with this script's
  version.
- Any other /usr/local/bin/pte that this script didn't create is left
  alone. The script puts its launcher in the program folder instead
  (pte.sh) and points the menu entry and desktop icon at that.
- If you used --dir= the first time, use the same --dir= when updating.
- A Kleopatra or Gpg4win you installed yourself is simply updated.

Launching PTE
-------------

Linux: /usr/local/bin/pte

  #!/bin/bash
  # Launcher created by install-encryption.sh
  cd "<install folder>" || ...
  exec java [-Dsun.java2d.uiScale=N] -Djava.library.path="<install folder>/libs" \
       -jar "<install folder>/pte.jar" "$@"

Windows: the PTE shortcuts run javaw.exe with the same options, starting
in PTE's folder. They point at the Java found when the script ran; if you
later update or remove that Java and the shortcut stops working, run the
script again to repoint it. With --no-desktop no shortcut is made; open
pte.jar by double-clicking it instead.

Differences from the AmRRON script (PTE)
----------------------------------------

- Checks for Java 11 or later and for a Java that can open windows,
  instead of only checking that some 'java' command exists.
- Checks the download before changing an existing install.
- Skips the download when the release hasn't changed.
- Adds the native library path to the launcher.
- Adds a menu entry as well as the desktop icon, and uses PTE's own icon
  (res/icon_pte_128.png inside pte.jar) instead of a separate image file.
- Also runs on Windows, and also installs Kleopatra.

Uninstalling
------------

Linux / Raspberry Pi:

  sudo rm /usr/local/bin/pte
  rm ~/.local/share/applications/pte.desktop ~/Desktop/PTE.desktop
  rm ~/.local/share/icons/pte.png
  rm -r ~/Security/"Paranoia Text Encryption"
  sudo apt-get remove kleopatra      (then: sudo apt-get autoremove)
  rm ~/Desktop/Kleopatra.desktop

Java was installed as a normal apt package; remove it with apt if nothing
else needs it.

Windows: delete the PTE shortcuts (Start menu and desktop) and the
%USERPROFILE%\Security\Paranoia Text Encryption folder. Remove Gpg4win,
and Java (Eclipse Temurin JRE) if nothing else needs it, from Settings >
Apps.

Script version: 1.0.0 (2026-11-18)
For more information, see https://sitrepnet.com/
