#!/bin/bash # MyLogin.world: connects this openmediavault to your dashboard, then installs openmediavault-mylogin 1.0.0 and runs `mylogin-omv setup`. # Run the command your dashboard shows: --code is valid 24 hours, --address is where you open openmediavault. set -euo pipefail usage() { echo "Usage: bash <(wget -qO- https://mylogin.world.compas.cs.stonybrook.edu/install/omv) --code --address
. Copy the command from your dashboard." >&2; exit 1; } code= address= while [ $# -gt 0 ]; do [ $# -ge 2 ] || usage case $1 in --code) code=$2 ;; --address) address=$2 ;; *) usage ;; esac shift 2 done [ -n "$code" ] && [ -n "$address" ] || usage [ "$(id -u)" = 0 ] || { echo "Run this as root (sudo -i) on openmediavault." >&2; exit 1; } [ -x /usr/sbin/omv-rpc ] || { echo "This is not openmediavault." >&2; exit 1; } dpkg --compare-versions "$(dpkg-query -W -f '${Version}' openmediavault)" ge 8.5.1 || { echo "This needs openmediavault 8.5.1 or later: update it first." >&2; exit 1; } arch=$(dpkg --print-architecture) case $arch in amd64) file=openmediavault-mylogin_1.0.0_amd64.deb sum=2b96bc0fd4fe91891b0b0668a46eb743b61aa6aeee54d6526f41e60aff7b0f65 ;; arm64) file=openmediavault-mylogin_1.0.0_arm64.deb sum=0064dddb64a1355caa43bb44b4d38a5bbf7fa407dc7dcba57d8a4e839874b57f ;; armhf) file=openmediavault-mylogin_1.0.0_armhf.deb sum=074048c32cdd80a1dca7114daff064c810953b08a3d04c8667eea805de5acec0 ;; *) echo "Unsupported architecture: $arch" >&2; exit 1 ;; esac # wget, not curl: openmediavault ships wget. With --content-on-error the error body is printed; the exit status says whether it worked ok=1 body=$(jq -n --arg code "$code" --arg address "$address" --arg hostname "$(hostname)" '{$code, $address, $hostname}' | wget -qO- --content-on-error --header='content-type: application/json' --post-file=/dev/stdin https://mylogin.world.compas.cs.stonybrook.edu/install/omv) || ok=0 field() { printf %s "$body" | jq -r "try (.$1 | strings) catch empty" 2>/dev/null || true; } [ "$ok" = 1 ] || { msg=$(field error.message); echo "${msg:-Could not reach https://mylogin.world.compas.cs.stonybrook.edu. Try again.}" >&2; exit 1; } slug=$(field slug) relay=$(field relay) app_url=$(field appUrl) admin=$(field admin) dir=$(mktemp -d); trap 'rm -rf "$dir"' EXIT; chmod 755 "$dir" wget -qO "$dir/$file" https://mylogin.world.compas.cs.stonybrook.edu/downloads/omv/"$file" echo "$sum $dir/$file" | sha256sum -c --quiet - || { echo "Checksum mismatch; nothing installed." >&2; exit 1; } chmod 644 "$dir/$file" apt-get install -y "$dir/$file" mylogin-omv setup --slug "$slug" --relay "$relay" --app-url "$app_url" --admin "$admin"