Clu
Clu
is the Gopherbot development robot that runs wherever I need him, and tracks with ongoing development of Gopherbot. This repository represents the bulk of Clu's custom configuration; the only other bits:
- clu-state - Clu's memories and other personal belongings; Clu's automated
backup
job updates this repository whenever his memories change - clu-private (private repository) - Clu's
private/environment
- an environment file, which should be mode0600
and closely guarded (see below for example contents)
Clu
's custom configuration will form the basis for new robot configuration, the contents of robot.skel. At times, Clu
's configuration may be ahead of master, when it represents a development target.
Directory Structure
This is the directory structure of a well-formed robot, created when I run ../gopherbot/fetch-robot.sh clu
:
clu/
- Top-level directory, not a git repogopherbot
- symlink to/opt/gopherbot/gopherbot
terminal.sh
- convenience script for runningclu
with the terminal connectorcustom/
- clone ofparsley42/clu-gopherbot
, custom configuration repositorystate/
- clone ofparsley42/clu-state
, where clu saves state, e.g. memoriesprivate/
- clone ofparsley42/clu-private
, a private repository containing onlyenvironment
Makefile
- a set of targets for running clu in a local container; see Running Cluenvironment
- a symlink toprivate/environment
or.env
if fetched from a.env
file; see Fetching Clu
The environment file is only:
GOPHER_ENCRYPTION_KEY=<redacted>
#GOPHER_CUSTOM_REPOSITORY=https://github.com/parsley42/clu-gopherbot.git
GOPHER_CUSTOM_REPOSITORY=git@github.com:parsley42/clu-gopherbot.git
DEPLOY_KEY=-----BEGIN=OPENSSH=PRIVATE=KEY-----:b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn:NhAAAAAwEAAQAAAYEA7nXaHD1uZ9cZbI/szT74uOUwDTlihejMKKGPRcTRXbnnFkdLlcg+:fIJ09q8oIt33xvUQmmupnK65dqasQfna0jQeTFiJSdiXOjtH1kFmwiN7VyzrGu3Y8Yk2/i:tJ3By5TqsuqkoRDPxDGE6RnVrYYK3XTiVGPTNskkXctsJ2Ip9/W1rP5MY8oACgh1B8R24+:bXLwU0XzWDlrcVM9/l78AcSUEo6277cbBEwetVO5rR6dZJw+k/9Kfgyv+J4OucEXRMjgyZ:k6gz1P+T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UBoYWt1aW4ubG9jYWxkb21haW4B:-----END=OPENSSH=PRIVATE=KEY-----:
NOTE: You can use 'tr' to create the above DEPLOY_KEY=...
, e.g.:
$ cat deploy_rsa | tr ' \n' '=:'
-----BEGIN=OPENSSH=PRIVATE=KEY-----:b3Bl...W4B:-----END=OPENSSH=PRIVATE=KEY-----:
Fetching Clu
The fetch-robot.sh
script will create the above directory structure. There are two ways I can run gopherbot/fetch-robot.sh
to fetch Clu:
.env
Fetching with If I create an empty directory for Clu and stick the above environment in a .env
file in that directory, I can just:
$ cd clu
$ /opt/gopherbot/fetch-robot.sh
... that will read the .env
and create the directory structure above. This will work for any well-formed robot.
Fetching during development
Because I do most of my development in a github.com/parsley42/gopherbot
fork, and Clu's repositories are also parented by github.com/parsley42
, I can fetch Clu with the developer shortcut mode of fetch-robot.sh
:
$ ./gopherbot/fetch-robot.sh clu
This requires not only that it be run from a forked Gopherbot repository, but that the development robot has a private repository (e.g. clu-private
) with it's environment file (containing the required GOPHER_ENCRYPTION_KEY
). It's definitely the fastest way for me to get up and going, though.
Running Clu
One of the main goals for Gopherbot version 2 was robot portability and first-class container support. Given the new feature set, there are several ways I can start Clu.
Worth noting here is how Gopherbot get's it's environment. The first and most obvious is from the environment exported from the parent process, as is the case when starting in a container. Second, on startup, Gopherbot first looks for private/environment
, then .env
, and loads the first one if finds, overwriting the current environment.
I can start that robot with TWO environment variables
(... for anybody who remembers the old "Name That Tune" game show)
Since Clu's primary configuration repository is publicly available, I can start in a directory with this .env
file:
GOPHER_ENCRYPTION_KEY=<redacted>
GOPHER_CUSTOM_REPOSITORY=https://github.com/parsley42/clu-gopherbot.git
Note that this is closer to how I would run Clu in a production container or vm, without using fetch-robot.sh
, though I would likely use a deploy key as shown above in production.
Method 1 Local Install
$ /opt/gopherbot/gopherbot
2020/01/06 11:53:02 Initialized logging ...
... (clone, restart, and restore brain) ...
2020/01/06 11:53:07 Info: Robot is initialized and running
After which you'll have a basic directory structure with GOPHER_CUSTOM_REPOSITORY
in custom/
, and GOPHER_STATE_REPOSITORY
(defined in custom/conf/gopherbot.yaml
) restored in to state/
.
Method 2 Run in container with Docker
$ docker run --env-file .env lnxjedi/gopherbot:latest
2020/01/06 11:53:02 Initialized logging ...
... (clone, restart, and restore brain) ...
2020/01/06 11:53:07 Info: Robot is initialized and running
This accomplishes the same as above, only custom/
and state/
are created in the container's /home/robot
directory.
fetch-robot
Using Most of the time when I'm doing development, I just use fetch-robot.sh
like so:
$ ./gopherbot/fetch-robot.sh clu
$ cd clu
$ ./gopherbot
2020/01/06 11:53:02 Initialized logging ...
... (normal startup, custom/ and state/ already present) ...
2020/01/06 11:53:07 Info: Robot is initialized and running
Since fetch-robot.sh
also copies the sample container Makefile
from gopherbot/resources/docker
, I can also use e.g. make prod
, make dev
and make debug
targets to start Clu