Skip to content

Commit

Permalink
molly migration (#17)
Browse files Browse the repository at this point in the history
Resolves #15

Two big upstream changes:

* Molly merged unified push into the main app! No more "UP flavored
app."
* Mollysocket introduced VAPID support with a new QR code workflow.

This adjusts docs and adds some scripts to adapt to these changes.
Thanks @p1gp1g for your help.

---------

Co-authored-by: sim <[email protected]>
  • Loading branch information
pcrockett and p1gp1g authored Dec 7, 2024
1 parent a1a148b commit 5da3e43
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
fly.toml
fly.toml.old
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
27 changes: 21 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
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:
@gh release create --generate-notes --draft
.PHONY: release

fly.toml:
cp fly.template.toml fly.toml
@cp fly.template.toml fly.toml
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions assets/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "${@}"
16 changes: 16 additions & 0 deletions assets/qr.sh
Original file line number Diff line number Diff line change
@@ -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
19 changes: 11 additions & 8 deletions doc/HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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).
Expand All @@ -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
Expand All @@ -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:
Expand Down
55 changes: 55 additions & 0 deletions doc/MIGRATION.md
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 7 additions & 7 deletions doc/WHAT_WHY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion fly.template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ primary_region = "arn"
dockerfile = "Dockerfile"

[processes]
worker = "server"
worker = "mollysocket server"

[[mounts]]
source = "mollysocket_data"
Expand Down

0 comments on commit 5da3e43

Please sign in to comment.