This is a 'how to do something' sort of blog post, I might write about why later. The something is running a social network for my friends.
The starting point is probably run your own social, which covers a lot of the 'why' and some of the 'what'. Chances are if you are reading this post you already know about it, but if not it's a good read and probably a prerequisite for caring about the rest of this post.
In case it wasn't apparent from this website, I like running my own things. I decided that lockdown (metadata: it has been approximately 55 days since I had a face-to-face conversation with someone I know) would be a good opportunity to find new ways of interacting with my friends. Maybe that's getting too far into the why, though. I grabbed another VPS (total VPS count: 3) and decided to set up a mastodon server running the hometown fork.
The basic gist of running mastodon with hometown is to follow two sets of instructions:
This is basically comprehensive but I still messed it up the first time, so in this post I will walk through the steps with some inane recipe-tier flavour-text on the side. Also, the hometown migration doc warns that it's not for beginners, so maybe I can help pseudo-beginners? Semi-nerds like myself still deserve autonomous social networks.
Step 1: Procure a server
My existing VPSes are with Heficed, which I knew as Host1Plus. I originally got a VPS with them many years ago because I wanted to run a Tor exit out of an African country, and they had a data centre in Johannesburg and didn't seem to care about the Tor exit thing.
For reasons I price I opted for OVH this time. In case it's useful, my VPS has 8GB of RAM and 160 GB of storage, and is running Ubuntu 18.04 (this is the recommended OS from the Mastodon guide). I put it in a London data centre, maybe one day I can visit it.
Full disclosure: I initally only paid for one month of the VPS, then ignored 2 weeks worth of warning emails, and everything from I T E R A T I O N 1 got wiped. There was nothing I could do, in such an unprecedented time. In the current iteration I've paid for a year up front. This isn't immensely cheap (it cost about 200 pounds), but I'm one of the lucky ones right now because I have a job. Maybe if it takes off I'll ask for donations from the users.
Step 2: Install Mastodon version 2.9.3
This is where we approximately follow the mastodon installation instructions, but make sure to end up with version 2.9.3 installed. This is (at time of writing) necessary for the subsequent hometown migration*. update from 30 minutes after I wrote that: the hometown wiki looks a bit out of date, there are versions of hometown that are aligned with recent versions of Mastodon e.g. v3.1.2, but I don't want to rewrite this entire blog post so ???
This was the hardest part because you have to deviate slightly from the provided instructions. I'm assuming you're looking at them (time of writing: 7th May 2020) and basically following along, so I don't have to reproduce all the steps here. By the time that page is out of date, this one will be too.
Preparing the machine is all fine.
Installing from source is fine until it comes to installing Ruby. They recommend this:
> RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.6.6
> rbenv global 2.6.6
This version of Ruby is too new! I went for version 2.6.1. I don't remember how I figured out this version would work, a dream maybe?
Postgres installation instructions are all fine. Be careful if you already have the remnants of failed installations lying around (who would have that?!) with misleading table names. In a way, losing everything to the big VPS wipe was a gift.
Vigilance is once again required while checking out the Mastodon codebase. They tell you to do this:
git clone https://github.com/tootsuite/mastodon.git live && cd live
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
That second line is trying to check out the most recent version of Mastodon, and we're not here for that. I cheated by taking the commit hash for v2.9.3 from the Hometown instructions, which is gonna give us this instead:
git clone https://github.com/tootsuite/mastodon.git live && cd live
git checkout 06f906acace5770fc10f333a203b036c5b72c849
You can sanity-check this has produced the correct version with
git describe --tags
where it will dutifully give you v2.9.3
, probably.
The rest of the Mastodon instructions are basically as-is.
Before you do the interactive setup wizard
RAILS_ENV=production bundle exec rake mastodon:setup
you should probably do step 1.5, though.
Step 1.5: Get a domain and mail server
The Mastodon server running on the VPS needs some way of being known to the outside world, and domain names are a recent technology purporting to improve on the otherwise-flawless system of memorising ipv4 addresses.
I use Namecheap for my domains (including apeiroto.pe and my Mastodon server). The basic idea is you rent a domain from them, because they're internet landlords I guess. Once you own your domain you can update its A Record (for me this is in the domain management page) to include the IP address of your VPS.
I'm including 'get a mail server' in here because I did that with Namecheap as well. I briefly considered running my own mail server on the VPS, but I'm not at that level of running my own things. Not yet. During the mastodon setup wizard it will ask for various details of your mail server, which should be available from whatever provider you go with (e.g SMTP address, username and password and such). I'm like 30% sure the way I set this up has left it open to harvesting by spambots, so I'm not going to give any further advice in case the spambots find me.
The reason you are giving it an email address is so it can send things like Forgot Password? emails to your users.
Step 2.05: Finish step 2 and then check
Before proceeding, go to your new domain in the browser and check that:
- mastodon is working
- mastodon is version 2.9.3 (near the bottom of the page)
You could stop here and be content with your Mastodon server running a slightly out of date version of Mastodon. You could be happy.
Step 3: Migrate to hometown
Now we refer back to the hometown wiki page on migrating from mastodon mentioned before.
Because we ensured to install version 2.9.3 before, this should mostly Just Work. The only slightly odd thing for me was getting this error:
> git fetch --tags
> git merge v1.0.1+2.9.3
merge: v1.0.1+2.9.3 - not something we can merge
This might be some git config issue but changing to
git fetch --tags -all
and then merging as described fixed it.
Following the rest of instructions as they are should result in your Mastodon server now including a mention of hometown at the bottom, indicating that it works.
Step 4 (optional): Make local-only posting default
For me, the reason to use hometown was that sweet local-only posting, but it's still possible for users to post publicly. Following all the above steps, it ended up that public (or federated to be more specific) posting was the default. Having to toggle local-only on every tweet (I refuse to say toot because it sounds stupid as hell) was a pain and could easily result in accidental public posts. Thus began a saga of trying to figure out how to change this behaviour.
I don't know much Javascript and I know even less Ruby, so after some fruitless attempts to reverse-engineer the codebase I got some friends involved, who are faster at reverse-engineering and who did not repeatedly pause their progress with games of starcraft 2. Eventually (like, four hours later) Paddy realised that this is just an option you can set in a config file:
In case of link rot, this is the settings.yml
file in the config
subfolder of the repository. The config option is default_federation
, and you want it to be false
for local-only to be default. I'm looking forward to discovering what the other options do.
Step 5: Give back to community
... by using acquired wisdom to update their documentation (maybe)
While double-checking things for this post I realised that the hometown installation document seems to be out of date.
Remember how we painstakingly made sure we had v2.9.3 of Mastodon installed, so we could use hometown? It looks like there's already hometown v1.0.3 for mastodon v3.1.2 so that was actually unnecessary and we could have just installed whatever Mastodon version we wanted. Anyway I hope you enjoyed this blog post, I'm going to go mass queens before they get nerfed.