💾 Archived View for moddedbear.xyz › logs › 2021-02-09-gemini-capsule-tips.gmi captured on 2023-03-20 at 18:00:54. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-11-30)
-=-=-=-=-=-=-
Just recently setup your own capsule? Here's some things I've found that are useful in maintaining and adding content to it.
This coupled with the next step will make connecting to your server and automating some tasks much easier. To create a basic alias, add the following to ~/.ssh/config (create the .ssh directory or config file if you need to):
1 │ Host [what you would like to name your alias] 2 │ Hostname [the IP address of your server] 3 │ User [the user you use to login]
If I named my alias "gemini-server", I could now connect to it by just typing "ssh gemini-server". Note that ssh aliases also work for tools like scp and rsync. Just type the name of your alias where you would normally type "user@address".
Using key-based instead of password-based authentication on your server is much more secure if your ssh port is open to the internet, and it's also much more convenient for you since authentication is handled automatically every time you try to connect (unless you protect your key with a passphrase).
DigitalOcean has a good guide on setting this up and most of it is still applicable if you're not using them for hosting.
DigitalOcean: How To Configure SSH Key-Based Authentication on a Linux Server
The simplest way to get work done on your capsule is to shell into the machine hosting your capsule and work directly on the server. For a lot of people this might be fine, but I find it a little cumbersome. Instead you can copy your capsule content to your local machine, work on it there, then upload your changes to the server when you're done. Yeah, I know this actually sounds like more steps but once you get it set up it's actually easier and you get a few great benefits from it.
Most importantly, you'll have a local backup of your capsule content. If/when the machine your capsule is hosted on decides to crap itself, restoring your capsule content will be as painless as possible. If you really care about your capsule content then you should implement a more robust backup solution, but keeping a local copy on your machine is a good first step.
Another benefit is that you can run a local gemini server to preview your capsule changes before making them live. This may not be valuable to everyone since I imagine most people are just adding a gemlog every now and then, but if you're doing something that you think could use a bit of testing before going public then this might be interesting to you.
Assuming your gemini content is kept in /home/user/gemini and you created an alias for your server called gemini-server, the following command will copy your gemini folder to your documents folder on your local machine.
scp -r gemini-server:/home/user/gemini/ ~/Documents/
Now you can make local changes to your capsule and then upload those changes using this command (courtesy of one of Hex DSL's videos on gemini).
rsync -aP ~/Documents/gemini/* gemini-server:~/gemini/
I'd recommend saving the above command to a script and putting it somewhere in your path to make it easily accessible. Or you can also create a shell alias for it.
A feed will allow visitors to subscribe to new posts from your capsule. I've already written a brief guide on how I got mine working, which I'll link below.
/logs/2021-02-08-setting-up-gemfeed.gmi
There might be times when you want to automate certain tasks on your server to run at specific times. For example, you might want to have your server periodically run gemfeed so your capsule's feed gets updated without you having to manually ssh into it to do it yourself.
Welcome to the world of cron jobs. Cron is a pretty powerful tool so I won't get too into it here. What you need to know is that a crontab, where you define cron jobs, follows this format:
[minute] [hour] [day] [month] [weekday] [command to run]
Assuming cron is already set up on your system (it probably is), you can run the command "crontab -e" to edit your crontab and add a cron job. You can also run "crontab -l" to list your current crontab. If I wanted to run gemfeed every half hour, I would add the following line to the bottom of my crontab.
0,30 * * * * /home/moddedbear/gemfeed.py -q -b gemini://moddedbear.xyz/logs -d /home/moddedbear/gemini/logs
If you're confused by the format, play around with crontab guru a bit and it'll quickly start to make sense.
---------------------------------------