zk_html/diary/2019-01-09-sparkleup.html

67 lines
4.3 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html>
<head>
<title>Zk | 2019-01-09-sparkleup</title>
<link rel="stylesheet" type="text/css" href="/style.css" />
<meta name="viewport" content="width=device-width" />
<meta charset="utf-8" />
</head>
<body>
<main>
<header>
<h1>Zk | 2019-01-09-sparkleup</h1>
</header>
<article class="content">
<hr />
<p>type: post
date: 2019-01-09
slug: sparkleup
title: Headless SparkleShare with sparkleup</p>
<hr />
<p><em>Update: this is now a <a href="https://github.com/makyo/sparkleup">project you can use</a>!</em></p>
<p>I found myself wanting a headless version of SparkleShare, and was stymied by <a href="https://github.com/hbons/SparkleShare/issues/1683">the lack thereof</a>. I wanted to keep some IRC and MUCK logs in a SparkleShare project, but I run my clients for those in a <code>tmux</code> session on a server. However, that server lives elsewhere, and has no X, so, alas, the usual SparkleShare clients were right out.</p>
<p>My solution was a combination of ones I've seen elsewhere, and I'm calling it sparkleup because...I dunno, it sounded fun. It looks like this:</p>
<div class="codehilite"><pre><span></span><code><span class="n">sparkleup</span><span class="o">/</span>
<span class="err">├──</span> <span class="n">projects</span><span class="o">/</span>
<span class="err"></span>   <span class="err">└──</span> <span class="n">logs</span><span class="o">*</span>
<span class="err">└──</span> <span class="n">ssh</span><span class="o">*</span>
</code></pre></div>
<p><code>logs.sh</code> is a simple script to be run by cron, but before I get to that, a minor diversion into git land.</p>
<p>My ssh key on the server requires a password --- as do all of mine --- which makes interacting with SparkleShare programatically difficult. After all, if I just do <code>dazzle link</code> with my normal key, then every time I try to commit to the project, I'll be asked for a password. I'm not scripting that.</p>
<p>The solution was to generate a new SSH key with no password and <code>dazzle link</code> that. However, since that key lives in <code>~/.ssh/sparkle</code>, git won't pick up on it by default, because SSH won't pick up on it by default. Add to that the fact that you can't select an SSH key for git to use and...bleh.</p>
<p>So the solution was two layered. First, I created a new <code>ssh</code> for git to use. <code>sparkleup/ssh</code> is a script to be passed to git with the <code>GIT_SSH</code> environment variable. It looks like:</p>
<div class="codehilite"><pre><span></span><code><span class="ch">#!/bin/bash</span>
ssh -i ~/.ssh/sparkle <span class="nv">$@</span>
</code></pre></div>
<p>That lets me write a job that will, without any interaction from me, commit and push to a SparkleShare project. That's one script per SparkleShare project I need to manage this way, each of which looks like:</p>
<div class="codehilite"><pre><span></span><code><span class="ch">#!/bin/bash</span>
<span class="nb">export</span> <span class="nv">GIT_SSH</span><span class="o">=</span>/home/makyo/sparkleup/ssh
<span class="nb">cd</span> /home/makyo/logs
<span class="nb">pwd</span>
git add .
git commit -am <span class="s2">&quot;update from sparkleup&quot;</span>
git push origin master
</code></pre></div>
<p>Then I add a crontab line to run that daily (or however frequently I need to update the project):</p>
<div class="codehilite"><pre><span></span><code><span class="o">#</span> <span class="n">m</span> <span class="n">h</span> <span class="n">dom</span> <span class="n">mon</span> <span class="n">dow</span> <span class="n">command</span>
<span class="mi">0</span> <span class="mi">5</span> <span class="o">*</span> <span class="o">*</span> <span class="o">*</span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">makyo</span><span class="o">/</span><span class="n">sparkleup</span><span class="o">/</span><span class="n">projects</span><span class="o">/</span><span class="n">logs</span>
</code></pre></div>
<p>It's not really the type of thing I can turn into a separate project, but maybe it helps someone out with similar problems!</p>
</article>
<footer>
<p>Page generated on 2020-04-24</p>
</footer>
</main>
</body>
</html>