testsAndMisc/linux_configuration/scripts/single_use/install_joplin.sh
Krzysztof kuhy Rudnicki dadd33f82d
Some checks are pending
Pre-commit checks / pre-commit (push) Waiting to run
Python tests / test (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Split install_joplin.sh and establish the shell-split pattern
299 -> 103, with the --with-server half in lib/joplin_server.sh. First
of the 84 linux_configuration files, done slowly to settle the pattern.

Three things bash -n and shellcheck do not catch, all found here:

- SCRIPT_DIR from "$0" breaks when the entry script is itself sourced.
  Use "${BASH_SOURCE[0]}"; keep readlink -f for the one symlinked script.
- A lib needs a shebang AND +x: without the shebang shellcheck raises
  SC2148, with it the shebang-executable hook fails. Match common.sh.
- Only a stubbed run proves the source line resolves. Copy entry+lib to
  a mktemp -d, sed `main` into a declare -F probe, run that. No
  installer step executes.

Also enumerates which scripts escape the repo: three copied out by
install_pacman_hooks.sh, one symlink, everything else generated. All
recorded in docs/shell-split-recipes.md.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-16 18:33:59 +02:00

104 lines
3.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Install Joplin - free, open-source, self-hostable note-taking app.
# Available on Linux (desktop), Android, iOS, Windows, macOS.
# Supports Markdown, end-to-end encryption, and self-hosted sync.
#
# This script:
# 1. Installs Joplin desktop app (AUR)
# 2. Optionally sets up Joplin Server via Docker for self-hosted sync
#
# Usage: ./install_joplin.sh [--with-server]
#
# Android app: https://play.google.com/store/apps/details?id=net.cozic.joplin
# or via F-Droid
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
info() { echo -e "${GREEN}[INFO]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
WITH_SERVER=false
JOPLIN_SERVER_PORT=22300
JOPLIN_DATA_DIR="$HOME/.joplin-server"
DUCKDNS_DOMAIN=""
DUCKDNS_TOKEN=""
for arg in "$@"; do
case "$arg" in
--with-server) WITH_SERVER=true ;;
--help | -h)
echo "Usage: $0 [--with-server]"
echo ""
echo "Options:"
echo " --with-server Also set up Joplin Server via Docker"
echo " --help, -h Show this help message"
exit 0
;;
*)
error "Unknown argument: $arg"
exit 1
;;
esac
done
# ── Check prerequisites ─────────────────────────────────────────────
command -v pacman >/dev/null 2>&1 || {
error "pacman not found. This script is for Arch Linux."
exit 1
}
# ── Install Joplin Desktop ──────────────────────────────────────────
install_joplin_desktop() {
if [[ -f "$HOME/.joplin/Joplin.AppImage" ]]; then
info "Joplin desktop is already installed at $HOME/.joplin/Joplin.AppImage"
return
fi
info "Installing Joplin desktop app via official installer (AppImage)..."
# Official Joplin install script downloads the latest AppImage
wget -O - https://raw.githubusercontent.com/laurent22/joplin/dev/Joplin_install_and_update.sh | bash
info "Joplin desktop installed at ~/.joplin/Joplin.AppImage"
info "Launch with: ~/.joplin/Joplin.AppImage (or 'joplin-desktop' from menu)"
}
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
# shellcheck source=lib/joplin_server.sh
source "$SCRIPT_DIR/lib/joplin_server.sh"
# ── Main ─────────────────────────────────────────────────────────────
main() {
echo "╔══════════════════════════════════════════════╗"
echo "║ Joplin Installation Script ║"
echo "║ Free & Open Source Note-Taking App ║"
echo "║ https://joplinapp.org ║"
echo "╚══════════════════════════════════════════════╝"
echo ""
install_joplin_desktop
if [[ "$WITH_SERVER" == true ]]; then
setup_joplin_server
else
echo ""
info "Tip: Run with --with-server to also set up Joplin Server"
info "for self-hosted sync across devices (desktop + Android)."
fi
echo ""
info "Android app available at:"
info " Google Play: https://play.google.com/store/apps/details?id=net.cozic.joplin"
info " F-Droid: https://f-droid.org/packages/net.cozic.joplin/"
echo ""
info "Done!"
}
main