Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,19 @@ CloudMachine lives in the menu bar. Its window opens on a **Required Setup
Steps** card listing what is left to do on this Mac, in order, each with a
button — or, for the steps an app cannot do, a command to copy:

1. **Install rclone.** CloudMachine downloads its own copy; it signs in to
Google Drive and writes the configuration the machine gets a copy of.
1. **rclone** is downloaded automatically. At start and then every hour
CloudMachine checks its own copy; if rclone is missing or too old it
fetches it in the background (checked against the official SHA256 sums)
and the window shows the state. It signs in to Google Drive and writes
the configuration the machine gets a copy of. If the download fails (no
network, wrong checksum) the window shows the error and when the next
attempt is; there is no button and no retry faster than hourly.
2. **Connect Google Drive** — a command to run in Terminal. It opens Google's
sign-in in the browser and waits for your approval. Enter your own OAuth
credentials first (see [below](#your-own-google-oauth-credentials)).
3. **Install Lima** — `brew install lima`, to copy.
3. **Install Lima.** The cask installs it with Homebrew; if it is missing
(an app installed outside brew), the window says so and gives
`brew install lima` to copy — the app never runs Homebrew itself.
4. **Set up the machine** — creates and starts `cmsmb` (the first start
downloads Ubuntu and installs packages, several minutes), copies rclone's
configuration into it and sets its SMB password.
Expand Down
10 changes: 9 additions & 1 deletion mac-app/Sources/CloudMachineApp/Models/AppStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ struct BackupProgressInfo: Equatable {
@MainActor
final class AppStatus: ObservableObject {
@Published var dependencyState: DependencyState = .unknown
/// The automatic rclone install started when the app launches.
@Published var rcloneInstall: ToolInstallState = .idle
@Published var remoteConfigured: Bool = false
@Published var machine = MachineStatus()
/// The answer to "when was a BACKUP last made" - the only measure
Expand Down Expand Up @@ -298,7 +300,13 @@ final class AppStatus: ObservableObject {

/// A one-sentence answer to the question "is my data safe".
var headline: String {
if case .missing(let what, _) = dependencyState {
if case .missing(let what, let remedies) = dependencyState {
// Same rule as the setup card: anything but a failure is "installing".
if what == ["rclone"], !rcloneInstall.isFailure { return L10n.tr("Installing rclone") }
// Lima comes from Homebrew; the app never runs brew itself.
if what == ["Lima"], let remedy = remedies.first {
return L10n.tr("Lima is not installed - run in Terminal: %@", remedy)
}
return L10n.tr("Missing: %@", what.joined(separator: ", "))
}
if !remoteConfigured { return L10n.tr("Google Drive not connected") }
Expand Down
22 changes: 17 additions & 5 deletions mac-app/Sources/CloudMachineApp/Models/SetupPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import Foundation
/// already exists is worse than showing the step a few seconds late.
struct SetupStep: Equatable {
enum Action: Equatable {
case installRclone
case setUpMachine
case startMachine
case grantFullDiskAccess
Expand All @@ -35,6 +34,8 @@ struct SetupStep: Equatable {
/// What the card shows instead of `command`, when `command` holds a secret
/// (the SMB password): the Copy button still copies `command`.
var displayedCommand: String?
/// Something runs now: the card shows a spinner and no button.
var inProgress = false
}

enum SetupPlan {
Expand All @@ -53,6 +54,8 @@ enum SetupPlan {
/// `nil` while the machine has no address or no stored password.
var setDestinationCommand: String?
var maskedSetDestinationCommand: String?
/// The automatic rclone install the app starts on launch.
var rcloneInstall: ToolInstallState = .idle
}

/// `configure-remote`, with `--folder` only for a valid name - an invalid
Expand All @@ -68,10 +71,19 @@ enum SetupPlan {
static func steps(_ input: Inputs) -> [SetupStep] {
var steps: [SetupStep] = []
if !input.hasRclone {
steps.append(
SetupStep(
title: L10n.tr("Install rclone (signs in to Google Drive for the machine)"),
command: nil, action: .installRclone))
// No button: the app installs rclone itself, and retries hourly.
if case .failed(let message, let retryAt) = input.rcloneInstall {
steps.append(
SetupStep(
title: L10n.tr("rclone could not be installed: %@", message) + " "
+ L10n.tr("Next attempt: %@", retryAt.formatted(date: .omitted, time: .shortened)),
command: nil, action: nil))
} else {
steps.append(
SetupStep(
title: L10n.tr("Installing rclone - downloading and verifying it"),
command: nil, action: nil, inProgress: true))
}
}
// The Drive folder of this Mac is chosen here, before the machine is
// created: the machine takes its folder from it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ final class CloudMachineController: ObservableObject {
private var backupCycleCheckedAt: Date?
/// `AgentRepair.afterLaunch`, started once per process.
private var agentMaintenance: Task<Void, Never>?
/// Installs rclone by itself when the app starts and it is missing or too
/// old; the state shows in the window instead of a bare "missing".
private let rcloneAuto = RcloneAutoInstaller.live()
private var rcloneObserverSet = false
private var rcloneError = RcloneErrorSlot()
/// One failed read of the Time Machine preferences is not "no Full Disk Access".
private var preferencesReads = BackupHealth.ReadConfirmation()

Expand All @@ -46,12 +51,30 @@ final class CloudMachineController: ObservableObject {
if agentMaintenance == nil {
agentMaintenance = Task.detached { await AgentRepair.afterLaunch() }
}
if !rcloneObserverSet {
rcloneAuto.onChange = { [weak self] state in
guard let self else { return }
self.status.rcloneInstall = state
self.rcloneError.apply(state, to: &self.status.errorMessage)
// Only what depends on rclone; the regular cycle does the rest.
if state == .installed || state == .idle {
Task { await self.refreshDependencies() }
}
}
rcloneObserverSet = true
}
let maintenance = agentMaintenance
refreshTask?.cancel()
refreshTask = Task { [weak self] in
var cycles = 0
while !Task.isCancelled {
await self?.refreshAll()
// Cheap when not due: acts at start and then once an hour.
// Own task: a download must not stall the status refresh.
if let auto = self?.rcloneAuto {
if !CMTooling.hasManagedRclone { auto.checkNow() }
Task { await auto.tick() }
}
// An agent can stop being startable later too, so check every few
// minutes - never while the launch reload is still running (a failing
// bootstrap can take tens of seconds; the panel does not wait for it).
Expand Down Expand Up @@ -288,7 +311,8 @@ final class CloudMachineController: ObservableObject {
let password = VMSetup.storedPassword()
return SetupPlan.steps(
SetupPlan.Inputs(
hasRclone: CMTooling.hasManagedRclone, remoteConfigured: status.remoteConfigured,
hasRclone: CMTooling.hasManagedRclone && !rcloneAuto.replacementNeeded,
remoteConfigured: status.remoteConfigured,
hasLima: VMLayout.limactlPath != nil, machineExists: machineExists,
machineRunning: status.machine.isRunning, hasFullDiskAccess: status.hasFullDiskAccess,
agentsInstalled: status.agentsInstalled,
Expand All @@ -298,16 +322,11 @@ final class CloudMachineController: ObservableObject {
setDestinationCommand: address.flatMap { address in
password.map { VMSetup.destinationCommand(password: $0, address: address) }
},
maskedSetDestinationCommand: address.map { VMSetup.maskedDestinationCommand(address: $0) })
maskedSetDestinationCommand: address.map { VMSetup.maskedDestinationCommand(address: $0) },
rcloneInstall: status.rcloneInstall)
)
}

func installRclone() async {
await run(L10n.tr("Installing rclone"), log: "Installing rclone") {
await RcloneInstaller.install()
}
}

/// Connecting to Google Drive is done from the terminal, not from the GUI: OAuth opens
/// the browser and waits for approval, and we read the keys from the Keychain.
var connectDriveCommand: String { connectDriveCommand(folder: nil) }
Expand Down
6 changes: 4 additions & 2 deletions mac-app/Sources/CloudMachineApp/Views/DashboardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,6 @@ private struct DashboardContent: View {

private func setupActionTitle(_ action: SetupStep.Action) -> String {
switch action {
case .installRclone: return L10n.tr("Install rclone")
case .setUpMachine: return L10n.tr("Set up the machine")
case .startMachine: return L10n.tr("Start the machine")
case .grantFullDiskAccess: return L10n.tr("Open System Settings")
Expand All @@ -818,7 +817,6 @@ private struct DashboardContent: View {

private func perform(_ action: SetupStep.Action) async {
switch action {
case .installRclone: await controller.installRclone()
case .setUpMachine: await controller.setUpMachine()
case .startMachine: await controller.startMachine()
case .grantFullDiskAccess: controller.openFullDiskAccessSettings()
Expand Down Expand Up @@ -850,6 +848,10 @@ private struct DashboardContent: View {
.foregroundStyle(RenaCodeTheme.textMain)
}

if step.inProgress {
ProgressView().controlSize(.small)
}

if let action = step.action {
setupActionButton(action)
}
Expand Down
9 changes: 8 additions & 1 deletion mac-app/Sources/CloudMachineCore/L10nPolish+App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ extension L10nPolish {
"One folder per Mac. Set once - it cannot be changed after connecting.":
"Jeden folder na Maca. Ustawiany raz - po połączeniu nie da się go zmienić.",
"Use lowercase letters, digits and dashes.": "Użyj małych liter, cyfr i myślników.",
"Install rclone": "Zainstaluj rclone",
"Open System Settings": "Otwórz Ustawienia systemowe",
"Install agents": "Zainstaluj agentów",
// AppStatus
Expand Down Expand Up @@ -117,5 +116,13 @@ extension L10nPolish {
"Time Machine starts the next one on its own schedule.":
"Time Machine uruchomi kolejny według własnego harmonogramu.",
"Backup cycle": "Cykl kopii",
"Installing rclone - downloading and verifying it":
"Instaluję rclone - pobieranie i weryfikacja",
"rclone could not be installed: %@":
"Nie udało się zainstalować rclone: %@",
"Next attempt: %@":
"Następna próba: %@",
"Lima is not installed - run in Terminal: %@":
"Lima nie jest zainstalowana - uruchom w Terminalu: %@",
]
}
2 changes: 0 additions & 2 deletions mac-app/Sources/CloudMachineCore/L10nPolish+Machine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ extension L10nPolish {
"Generuje i instaluje agentów launchd (aplikacja, czujka kopii, start maszyny, strażnik maszyny).",
"Install Lima, which runs the CloudMachine machine: run this in Terminal":
"Zainstaluj Limę, która uruchamia maszynę CloudMachine: wykonaj to w Terminalu",
"Install rclone (signs in to Google Drive for the machine)":
"Zainstaluj rclone (loguje maszynę do Google Drive)",
"Install the background agents (machine start, buffer guard, backup watchdog)":
"Zainstaluj agentów w tle (start maszyny, strażnik bufora, czujka kopii)",
"Installs rclone through Homebrew - CloudMachine itself uses the one from install-rclone.":
Expand Down
2 changes: 0 additions & 2 deletions mac-app/Sources/CloudMachineCore/L10nPolish+System.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ extension L10nPolish {
"BRUDNE-DRZEWO",
"Cannot create the working directory: %@":
"Nie mogę utworzyć katalogu roboczego: %@",
"Could not read the rclone version number.":
"Nie udało się odczytać numeru wersji rclone.",
"Could not download %@.":
"Nie udało się pobrać %@.",
"No entry for %@ in SHA256SUMS.":
Expand Down
14 changes: 8 additions & 6 deletions mac-app/Sources/CloudMachineCore/L10nTranslations+ar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ extension L10nTranslations {
"مجلد واحد لكل Mac. يُضبط مرة واحدة - لا يمكن تغييره بعد الاتصال.",
"Use lowercase letters, digits and dashes.":
"استخدم أحرفًا لاتينية صغيرة وأرقامًا وشرطات.",
"Install rclone":
"تثبيت rclone",
"Open System Settings":
"فتح إعدادات النظام",
"Install agents":
Expand Down Expand Up @@ -367,8 +365,6 @@ extension L10nTranslations {
"ينشئ وكلاء launchd ويثبّتهم (التطبيق، مراقب النسخ الاحتياطي، تشغيل الجهاز الافتراضي، حارس الجهاز الافتراضي).",
"Install Lima, which runs the CloudMachine machine: run this in Terminal":
"ثبّت Lima التي تشغّل الجهاز الافتراضي لـ CloudMachine: شغّل هذا في الطرفية",
"Install rclone (signs in to Google Drive for the machine)":
"ثبّت rclone (يسجّل الدخول إلى Google Drive للجهاز الافتراضي)",
"Install the background agents (machine start, buffer guard, backup watchdog)":
"ثبّت وكلاء الخلفية (تشغيل الجهاز الافتراضي، حارس المخزن المؤقت، مراقب النسخ الاحتياطي)",
"Installs rclone through Homebrew - CloudMachine itself uses the one from install-rclone.":
Expand Down Expand Up @@ -607,8 +603,6 @@ extension L10nTranslations {
"DIRTY-TREE",
"Cannot create the working directory: %@":
"تعذّر إنشاء مجلد العمل: %@",
"Could not read the rclone version number.":
"تعذّرت قراءة رقم إصدار rclone.",
"Could not download %@.":
"تعذّر تنزيل %@.",
"No entry for %@ in SHA256SUMS.":
Expand Down Expand Up @@ -977,5 +971,13 @@ extension L10nTranslations {
"Samba من الـ Mac: %@",
"This Mac found no route to %@ (%@). Either the route to the machine is gone, or macOS Local Network privacy has not allowed CloudMachine - then allow it in System Settings > Privacy & Security > Local Network. Check: cloudmachine-agent vm-status":
"لم يجد هذا الـ Mac مسارًا إلى %@ (%@). إما أن المسار إلى الجهاز اختفى، أو أن خصوصية «الشبكة المحلية» في macOS لم تسمح لـ CloudMachine - عندها اسمح بذلك من إعدادات النظام > الخصوصية والأمن > الشبكة المحلية. تحقّق: cloudmachine-agent vm-status",
"Installing rclone - downloading and verifying it":
"جارٍ تثبيت rclone - تنزيله والتحقق منه",
"rclone could not be installed: %@":
"تعذّر تثبيت rclone: %@",
"Next attempt: %@":
"المحاولة التالية: %@",
"Lima is not installed - run in Terminal: %@":
"Lima غير مثبّتة - شغّل في Terminal: %@",
]
}
14 changes: 8 additions & 6 deletions mac-app/Sources/CloudMachineCore/L10nTranslations+da.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ extension L10nTranslations {
"Én mappe pr. Mac. Angives én gang - kan ikke ændres efter tilslutning.",
"Use lowercase letters, digits and dashes.":
"Brug små bogstaver, cifre og bindestreger.",
"Install rclone":
"Installer rclone",
"Open System Settings":
"Åbn Systemindstillinger",
"Install agents":
Expand Down Expand Up @@ -367,8 +365,6 @@ extension L10nTranslations {
"Opretter og installerer launchd-agenterne (appen, backup-vagthunden, maskinstart, maskinens vagt).",
"Install Lima, which runs the CloudMachine machine: run this in Terminal":
"Installer Lima, som kører CloudMachine-maskinen: kør dette i Terminal",
"Install rclone (signs in to Google Drive for the machine)":
"Installer rclone (logger maskinen ind på Google Drive)",
"Install the background agents (machine start, buffer guard, backup watchdog)":
"Installer baggrundsagenterne (maskinstart, buffervagt, backup-vagthund)",
"Installs rclone through Homebrew - CloudMachine itself uses the one from install-rclone.":
Expand Down Expand Up @@ -607,8 +603,6 @@ extension L10nTranslations {
"SNAVSET-TRÆ",
"Cannot create the working directory: %@":
"Kan ikke oprette arbejdsmappen: %@",
"Could not read the rclone version number.":
"Kunne ikke læse rclones versionsnummer.",
"Could not download %@.":
"Kunne ikke hente %@.",
"No entry for %@ in SHA256SUMS.":
Expand Down Expand Up @@ -977,5 +971,13 @@ extension L10nTranslations {
"Samba fra Mac: %@",
"This Mac found no route to %@ (%@). Either the route to the machine is gone, or macOS Local Network privacy has not allowed CloudMachine - then allow it in System Settings > Privacy & Security > Local Network. Check: cloudmachine-agent vm-status":
"Denne Mac fandt ingen rute til %@ (%@). Enten er ruten til maskinen væk, eller macOS' anonymitet for \"Lokalt netværk\" har ikke tilladt CloudMachine - tillad det så i Systemindstillinger > Anonymitet & sikkerhed > Lokalt netværk. Tjek: cloudmachine-agent vm-status",
"Installing rclone - downloading and verifying it":
"Installerer rclone - henter og kontrollerer det",
"rclone could not be installed: %@":
"rclone kunne ikke installeres: %@",
"Next attempt: %@":
"Næste forsøg: %@",
"Lima is not installed - run in Terminal: %@":
"Lima er ikke installeret - kør i Terminal: %@",
]
}
14 changes: 8 additions & 6 deletions mac-app/Sources/CloudMachineCore/L10nTranslations+de.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ extension L10nTranslations {
"Ein Ordner pro Mac. Wird einmal festgelegt und lässt sich nach dem Verbinden nicht mehr ändern.",
"Use lowercase letters, digits and dashes.":
"Nur Kleinbuchstaben, Ziffern und Bindestriche verwenden.",
"Install rclone":
"rclone installieren",
"Open System Settings":
"Systemeinstellungen öffnen",
"Install agents":
Expand Down Expand Up @@ -367,8 +365,6 @@ extension L10nTranslations {
"Erzeugt und installiert die launchd-Agents (App, Backup-Wächter, Maschinenstart, Maschinenwächter).",
"Install Lima, which runs the CloudMachine machine: run this in Terminal":
"Lima installieren, das die CloudMachine-Maschine ausführt: im Terminal ausführen",
"Install rclone (signs in to Google Drive for the machine)":
"rclone installieren (meldet die Maschine bei Google Drive an)",
"Install the background agents (machine start, buffer guard, backup watchdog)":
"Die Hintergrund-Agents installieren (Maschinenstart, Pufferwächter, Backup-Wächter)",
"Installs rclone through Homebrew - CloudMachine itself uses the one from install-rclone.":
Expand Down Expand Up @@ -607,8 +603,6 @@ extension L10nTranslations {
"UNSAUBERER-BAUM",
"Cannot create the working directory: %@":
"Das Arbeitsverzeichnis kann nicht angelegt werden: %@",
"Could not read the rclone version number.":
"Die Versionsnummer von rclone konnte nicht gelesen werden.",
"Could not download %@.":
"%@ konnte nicht geladen werden.",
"No entry for %@ in SHA256SUMS.":
Expand Down Expand Up @@ -977,5 +971,13 @@ extension L10nTranslations {
"Samba vom Mac: %@",
"This Mac found no route to %@ (%@). Either the route to the machine is gone, or macOS Local Network privacy has not allowed CloudMachine - then allow it in System Settings > Privacy & Security > Local Network. Check: cloudmachine-agent vm-status":
"Dieser Mac hat keine Route zu %@ gefunden (%@). Entweder ist die Route zur Maschine weg, oder der macOS-Datenschutz „Lokales Netzwerk“ hat CloudMachine nicht erlaubt – dann unter Systemeinstellungen > Datenschutz & Sicherheit > Lokales Netzwerk erlauben. Prüfen: cloudmachine-agent vm-status",
"Installing rclone - downloading and verifying it":
"rclone wird installiert – Download und Prüfung laufen",
"rclone could not be installed: %@":
"rclone konnte nicht installiert werden: %@",
"Next attempt: %@":
"Nächster Versuch: %@",
"Lima is not installed - run in Terminal: %@":
"Lima ist nicht installiert – im Terminal ausführen: %@",
]
}
Loading
Loading