Skip to main content

Documentation: Index

Various posts, probably originally published on my other site.

>> Recent Posts

Deploying Hugo site from Github

Just some quick notes on this - as everytime I setup a new server I forget some steps! Stick the Hugo executable somewhere on the server. Use the following PHP deploy script from here, published below in case it ever goes offline. /** * Automated deploy from GitHub * * https://developer.github.com/webhooks/ * Template from ServerPilot (https://serverpilot.io/community/articles/how-to-automatically-deploy-a-git-repo-from-bitbucket.html) * Hash validation from Craig Blanchette (http://isometriks.com/verify-github-webhooks-with-php) */ // Variables $secret = getenv('GH_DEPLOY_SECRET'); # Paul note: Best to set environment variable - avoid setting here. $repo_dir = '/home/example/git/examplerepo'; $web_root_dir = '/home/example/public_html'; $rendered_dir = '/public'; $hugo_path = '/usr/local/bin/hugo'; // Validate hook secret if ($secret !== NULL) { // Get signature $hub_signature = $_SERVER['HTTP_X_HUB_SIGNATURE']; // Make sure signature is provided if (!isset($hub_signature)) { file_put_contents('deploy.log', date('m/d/Y h:i:s a') . ' Error: HTTP header "X-Hub-Signature" is missing.' . "\n", FILE_APPEND); die('HTTP header "X-Hub-Signature" is missing.'); } elseif (!extension_loaded('hash')) { file_put_contents('deploy.log', date('m/d/Y h:i:s a') . ' Error: Missing "hash" extension to check the secret code validity.' . "\n", FILE_APPEND); die('Missing "hash" extension to check the secret code validity.'); } // Split signature into algorithm and hash list($algo, $hash) = explode('=', $hub_signature, 2); // Get payload $payload = file_get_contents('php://input'); // Calculate hash based on payload and the secret $payload_hash = hash_hmac($algo, $payload, $secret); // Check if hashes are equivalent if (!hash_equals($hash, $payload_hash)) { // Kill the script or do something else here. file_put_contents('deploy.log', date('m/d/Y h:i:s a') . ' Error: Bad Secret' . "\n", FILE_APPEND); die('Bad secret'); } }; // Parse data from GitHub hook payload $data = json_decode($_POST['payload']); $commit_message; if (empty($data->commits)){ // When merging and pushing to GitHub, the commits array will be empty. // In this case there is no way to know what branch was pushed to, so we will do an update. $commit_message .= 'true'; } else { foreach ($data->commits as $commit) { $commit_message .= $commit->message; } } if (!empty($commit_message)) { // Do a git checkout, run Hugo, and copy files to public directory exec('cd ' . $repo_dir . ' && git fetch --all && git reset --hard origin/master'); exec('cd ' . $repo_dir . ' && ' . $hugo_path); exec('cd ' . $repo_dir . ' && cp -r ' . $repo_dir . $rendered_dir . '/. ' . $web_root_dir); // Log the deployment file_put_contents('deploy.log', date('m/d/Y h:i:s a') . " Deployed branch: " . $branch . " Commit: " . $commit_message . "\n", FILE_APPEND); } Create webhook and secret in Github repository. Set GH_DEPLOY_SECRET as an environment variable for above script to use. Skip for public repo, else create SSH key if needed ssh-keygen -t ed25519 -C "githubemail@example.com" and import key into your account on Github. May need eval "$(ssh-agent -s)" and tell SSH to use the key ssh-add /path/to/key. Clone the repo to your web server by running in a suitable directory git clone git@github.com:you/repo.git don’t worry about username will authenticate with SSH key. CD into the repo directory make sure you can run git fetch --all. If this fails, may need to create personal access token in Github and specify it as part of the URL in .git/config inside the repo directory. May also need to run git config --global --add safe.directory /home/example/git/examplerepo. Check line 69 of deployment script and make sure origin/master is correct for your branch. Make sure PHP process has execute permissions on Hugo, and has read/write access to repo dir and the web server public_html directory, as once built into repodir/public it will need to be copied to public_html. Check permissions on the Hugo temp folder /tmp/hugo_cache/. If you can see this post, it worked! Might write this up as more of an organised general tutorial one day, in the meantime feel free to drop any comments below.

3 min read Read ->

>> All Posts

Showing 1 posts
~/posts/Web/Configuring the web/
Posted At Reading Time Title Tags
2023-01-14 3 min read Deploying Hugo site from Github
#github #hugo #web
10 posts per page · Page of 1

>> Recent Posts

Tailscale not updating on Ubuntu Server

While doing some routine patching this weekend, I noticied one of my Ubuntu servers was not properly updating Tailscale. This was one of two identical Ubuntu servers running Pihole to handle DNS. One was updating, one was not. Had a look in /etc/apt/sources.list.d/ the working one had the tailscale.list, the non-working install had tailscale.list.distUpgrade. Seemed simple to fix just run: cd /etc/apt/sources.list.d/ sudo mv tailscale.list.distUpgrade tailscale.list And then check for updates.

1 min read Read ->

Glances Web UI broken on Debian, Ubuntu, Mint etc

When upgrading some of my servers to Ubuntu 22.04 earlier this year I noticed the Web UI for Glances was broken, didn’t do much investigation at the time, assumed it was a dodgy update or known compatibility issue that would be sorted in time. But noticed the same issue on Linux Mint 22.1 today, almost four months later. According to epsilon77 this is because: Hello! I am maintainer of glances in Debian, for Debian policy, the packages should not include prebult files, for this reason, we had to remove those js files from debian package. and this change does WEB-UI useless.

1 min read Read ->

Installing Pixelfed with Docker Compose

Just my quick notes on installing Pixelfed using Docker Compose, long term I’d like to write this up into a proper guide. Important things to note - Pixelfed as of the moment doesn’t have an official Docker image, normally you’d pull it from Github and build it yourself. However since version 0.11.5 I’ve started using an existing image maintained by Murazaki. Web proxy Assuming you’re running Nginx on the web host you’ll need to setup a proxy by adding something like this to your .conf file:

3 min read Read ->

>> All Posts

Showing 4 posts
~/posts/
Posted At Reading Time Title Tags
2026-10-10 1 min read Tailscale not updating on Ubuntu Server
#linux #open source #servers #tailscale
2023-05-13 1 min read Glances Web UI broken on Debian, Ubuntu, Mint etc
#linux #open source #servers
2023-04-23 3 min read Installing Pixelfed with Docker Compose
#activitypub #fediverse #pixelfed #social media #web
2023-01-14 3 min read Deploying Hugo site from Github
#github #hugo #web
10 posts per page · Page of 1