diff --git a/.gitignore b/.gitignore index 0501d09..fb88d34 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ fly.toml +fly.toml.old diff --git a/Dockerfile b/Dockerfile index ced2542..99e6bc1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,10 @@ FROM ghcr.io/mollyim/mollysocket:latest ENV MOLLY_WEBSERVER=false \ + MOLLY_VAPID_KEY_FILE=vapid.key \ RUST_LOG=info -CMD [ "server" ] +COPY assets/*.sh /usr/local/bin/ + +ENTRYPOINT [ "/usr/local/bin/docker-entrypoint.sh" ] +CMD [ "/usr/local/bin/mollysocket", "server" ] diff --git a/Makefile b/Makefile index 6faa638..993b7cc 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,36 @@ launch: fly.toml - flyctl launch --copy-config --no-public-ips --yes + @flyctl launch --copy-config --no-public-ips --yes .PHONY: launch deploy: - flyctl deploy + @flyctl deploy .PHONY: deploy ssh: - flyctl ssh console + @flyctl ssh console .PHONY: ssh +qr: + @# if your terminal background is dark: + @flyctl ssh console --command "qr.sh" +.PHONY: qr + +qr-invert: + @# if your terminal background is light: + @flyctl ssh console --command "mollysocket qr airgapped" +.PHONY: qr-invert + +restart: + @flyctl scale count 0 --process-group worker --yes + @flyctl scale count 1 --process-group worker --yes +.PHONY: restart + status: - flyctl status + @flyctl status .PHONY: status logs: - flyctl logs --no-tail + @flyctl logs --no-tail .PHONY: logs release: @@ -23,4 +38,4 @@ release: .PHONY: release fly.toml: - cp fly.template.toml fly.toml + @cp fly.template.toml fly.toml diff --git a/README.md b/README.md index 7b53168..a8a82e7 100644 --- a/README.md +++ b/README.md @@ -3,18 +3,6 @@ Get Signal push notifications without Google Play Services, and without killing your phone's battery. A secure, free, low-maintenance solution using [Fly.io](https://fly.io). ---- - -**IMPORTANT UPDATE 2024-12-04:** Good news! Unified push has been merged into the main Molly -app, and the old "unified push" flavor of the app is now deprecated. There also seem to be some -usability improvements around getting it set up. That said, I don't have time to look into them -now, so these instructions are now old. In the next few days I'll get around to bringing them -up-to-date. - -See [this issue](https://github.com/pcrockett/mollysocket-fly/issues/15) for more details. - ---- - **Table of Contents:** * [What we're building and why](doc/WHAT_WHY.md) diff --git a/assets/docker-entrypoint.sh b/assets/docker-entrypoint.sh new file mode 100755 index 0000000..f4e8928 --- /dev/null +++ b/assets/docker-entrypoint.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +gen_vapid_key() { + echo "Generating VAPID key..." + mollysocket vapid gen > "${MOLLY_VAPID_KEY_FILE}" +} + +main() { + test -f "${MOLLY_VAPID_KEY_FILE}" || gen_vapid_key + "${@}" +} + +main "${@}" diff --git a/assets/qr.sh b/assets/qr.sh new file mode 100755 index 0000000..e7264ec --- /dev/null +++ b/assets/qr.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +RESET='\033[0m' +BLACK_FOREGROUND='\033[47m' +WHITE_BACKGROUND='\033[0;30m' + +main() { + echo -e " +${WHITE_BACKGROUND}${BLACK_FOREGROUND} +$(mollysocket qr airgapped) +${RESET} +" +} + +main diff --git a/doc/HOWTO.md b/doc/HOWTO.md index 2ca5018..9bbb7c3 100644 --- a/doc/HOWTO.md +++ b/doc/HOWTO.md @@ -53,8 +53,8 @@ mobile data connections. ### Install Molly on your Android phone -[Install the UnifiedPush flavor of Molly](https://github.com/mollyim/mollyim-android-unifiedpush?tab=readme-ov-file#download) -on your phone and [migrate your Signal account](https://github.com/mollyim/mollyim-android/wiki/Migrating-From-Signal) +[Install Molly](https://github.com/mollyim/mollyim-android?tab=readme-ov-file#download) on your +phone and [migrate your Signal account](https://github.com/mollyim/mollyim-android/wiki/Migrating-From-Signal) (if necessary). Also disable battery optimizations for the Molly app. And once again don't worry; Molly won't eat @@ -65,10 +65,13 @@ your battery like the Signal app. Once Molly is all set up and running, go into notification settings in Molly and scroll down to the bottom. -1. Select UnifiedPush as the delivery method. -2. Click on the new UnifiedPush option that appears. -3. Turn on "air gapped" mode. -4. Click on "Server parameters" to copy a command to the clipboard. +1. Find _Delivery service_ and click on it. +2. Select _UnifiedPush_. This will bring up a message about scanning a QR code. +3. Come back to the git repository you cloned. Run `make qr`. This should show you a QR code. +4. On your phone, click _Scan QR code_. Allow the app to use your camera, and scan the code. _If + your terminal background is light (what kind of monster are you? 😉) and you have trouble + scanning the QR code, try running `make qr-invert` instead._ +5. Click on "Server parameters" to copy a command to the clipboard. Send that command to your computer where you're working somehow (for example via Signal's "Note to self" feature and the Signal Desktop app). @@ -78,7 +81,7 @@ self" feature and the Signal Desktop app). Come back to the git repository you cloned. Run ```bash -flyctl ssh console +make ssh ``` This will open an interactive terminal on your server. Then run @@ -92,7 +95,7 @@ Almost done! Run `exit` to exit the SSH session and come back to your local mach ### Restart the server -Run `flyctl deploy`. This will restart the MollySocket server, which will cause MollySocket to begin +Run `make restart`. This will restart the MollySocket server, which will cause MollySocket to begin monitoring the Signal service for notifications. If everything is working, there's just one thing left to do: diff --git a/doc/MIGRATION.md b/doc/MIGRATION.md new file mode 100644 index 0000000..2c01790 --- /dev/null +++ b/doc/MIGRATION.md @@ -0,0 +1,55 @@ +## Legacy Molly-UP to Molly-FOSS migration notes + +Good news! This UnifiedPush "flavor" of Molly [is no longer required](https://github.com/mollyim/mollyim-android-unifiedpush/releases/tag/v7.23.1-1.up1). +UnifiedPush support has been merged into the main Molly-FOSS app. + +**There will be no more updates for the legacy app.** To keep receiving updates, you'll need to +migrate to the main Molly-FOSS app. + +Additionally, a new version of [MollySocket](https://github.com/mollyim/mollysocket) has been +released with a slightly different workflow for getting set up. I recommend that you: + +1. [Create a new instance of MollySocket](#create-a-new-instance-of-mollysocket) +2. [Migrate your Android app from the legacy version to Molly-FOSS](#migrating-to-molly-foss) +3. [Restore MollySocket push notifications](#restore-mollysocket-push-notifications) +3. [Destroy the old instance of MollySocket](#destroy-the-old-instance-of-mollysocket) + +### Create a new instance of MollySocket + +Open this repository in a terminal and run: + +```bash +mv fly.toml fly.toml.old +make launch +``` + +Congratulations, you should now have a second instance of MollySocket running in a new Fly app. + +### Migrating to Molly-FOSS + +1. [Install Molly-FOSS on your phone](https://molly.im/download/fdroid/). _Don't uninstall the old + Molly-UP app yet._ +2. In the old Molly app, go to Chat settings and scroll down to the bottom to _Chat backups_. Click + that and generate a new backup. Remember the file path where you saved the backup. +3. Now go to Android's app settings page and _Disable_ the old Molly app. Don't uninstall it yet, + just in case. You can uninstall it later when you're all finished and everything is working. +4. Open up the new Molly-FOSS app. As you go through the welcome screens, you'll see an option to + restore from a backup. Do that. + +When the new app is running correctly, you'll need to Restore push notifications. + +### Restore MollySocket push notifications + +Go through the steps in the instructions starting at +[step 5: Setup the Molly app for push notifications](HOWTO.md#setup-the-molly-app-for-push-notifications). + +_Recommended: Let it run for a while to make sure you continue receiving push notifications._ + +### Destroy the old instance of MollySocket + +1. [Login to fly.io](https://fly.io/app/sign-in) +2. Click on the old MollySocket app +3. Go to Settings +4. Click _Delete app_. + +Now is also probably a good time to fully uninstall the old Molly-UP app from your phone. diff --git a/doc/WHAT_WHY.md b/doc/WHAT_WHY.md index 91ad69a..9cf539e 100644 --- a/doc/WHAT_WHY.md +++ b/doc/WHAT_WHY.md @@ -9,10 +9,10 @@ alive at all times. For some reason, Signal isn't good at doing that efficiently burn through 50% of your battery in a single day. Fortunately, there's [Molly](https://molly.im/), a Signal fork that is mostly marketed as "A -hardened version of Signal." However the killer feature in my opinion is not the extra security, but -rather [UnifiedPush](https://unifiedpush.org/) support. UnifiedPush is what allows an app to receive -proper push notifications without Google Play Services and _also_ without absolutely destroying your -battery life. +hardened version of Signal." However the killer feature in my opinion is not the extra security, +but rather [UnifiedPush](https://unifiedpush.org/) support. UnifiedPush is what allows an app to +receive proper push notifications without Google Play Services and _also_ without absolutely +destroying your battery life. Here's an oversimplified, mostly wrong diagram that lays out how the whole system should work: @@ -44,11 +44,11 @@ to wake up Molly, which then handles actually downloading and displaying the not If you think the above diagram looks like a lot of moving parts that could break, it's good to keep in mind that this is generally how Google sets up a stock Android device (instead of `ntfy.sh` you -have Google Play services, etc.). The only _really_ different piece about this setup is MollySocket. +have Google Play services, etc.). The only _really_ different piece about this setup is +MollySocket. This repository shows how to get a low-maintenance, free, [MollySocket](https://github.com/mollyim/mollysocket) instance running in "Air Gap mode" on [Fly.io](https://fly.io/). It handles the hardest part of the -diagram above, making it much easier to get the [UnifiedPush flavor of Molly](https://github.com/mollyim/mollyim-android-unifiedpush) -working properly. +diagram above, making it much easier to get UnifiedPush for Molly working properly. Next: [Getting Molly with UnifiedPush working](HOWTO.md) diff --git a/fly.template.toml b/fly.template.toml index 0d9c121..2a0483c 100644 --- a/fly.template.toml +++ b/fly.template.toml @@ -6,7 +6,7 @@ primary_region = "arn" dockerfile = "Dockerfile" [processes] - worker = "server" + worker = "mollysocket server" [[mounts]] source = "mollysocket_data"