blob: f8fd8af9caeec123d43458a224ccd1f5505a8476 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
gempost.sh
==========
gempost.sh is a simple bash script for "publishing" gemini posts.
usage
-----
To publish a singel file you can simply run:
./gempost.sh <target-file>
If you're using the index file mode you can optionally add a link description with:
./gempost.sh <target-file> <link-description>
It will based on your configuration:
1. upload the file to your server
2. modify an indexfile if configured
3. run any remote post processing (like update your rss feed!)
config
------
There is a "complete" sample config.sh file in the repository.
It will look for configs in:
1. GEMPOST_CONFIG_HOME
2. $XDG_CONFIG_HOME/gempost/config.sh
3. $HOME/.config/gempost/config.sh
Then it will simply source the files making the values available.
The available configurations are:
- GEMPOST_SSH_HOST
- the ssh host you wish to publish to - this is used as the entrypoint for both: scp and ssh
- scp $FILE $GEMPOST_SSH_HOST:$GEMPOST_REMOTE_PATH/$FILE_NAME
- ssh $GEMPOST_SSH_HOST "${GEMPOST_REMOTE_POST_PROCESS}"
- GEMPOST_REMOTE_PATH
- shown above - this will be where we publish the file to
- **NOTE** All paths get "realized" locally - so ~ or $HOME will be your LOCAL HOME FOLDER - use absolute paths to be safe!
- GEMPOST_REMOTE_POST_PROCESS
- This optional config is a remote ssh command
- GEMPOST_INDEX_ON
- 0 for disabled, 1 for enabled
- This enables the index update logic
- GEMPOST_REMOTE_INDEX_FILE
- The absolute path to the remote index file you wish to update
- GEMPOST_INDEX_LINK_PREFIX
- This will be the actual link prefix so "/gemlog" for example
- then we'll append ${GEMPOST_INDEX_LINK_PREFIX}/${FILE_NAME}
- GEMPOST_PREVIOUS_TITLE_FILE
- In order to properly prepend our link to the index file we need a target location we use the previous post as a target
The previous title file is stored in one of:
1. GEMPOST_PREVIOUS_TITLE_FILE
2. $XDG_DATA_HOME/gempost/previous-index-title.txt
3. $HOME/.local/share/gempost/previous-index-title.txt
After the index file is update it'll put the current file name into this file to be used as the next marker.
errors
------
There are a few errors that can occur (mostly around setups) - We don't trap remote process errors or scp/ssh errors - those will exit and usuall print out an error.
But we have a few error codes in the file:
# Invalid arguments - Missing file to post
ERR_MISSING_TARGET_FILE=2
# Supplied file is not found
ERR_TARGET_FILE_NOT_FOUND=3
# No configuration file in expected locations
ERR_CONFIG_FILE_NOT_FOUND=4
# GEMPOST_INDEX_ON enabled but the previous title file supplied is empty
ERR_PREV_TITLE_EMPTY=5
# GEMPOST_INDEX_ON enabled but no previous title file found in expected locations
ERR_PREV_TITLE_FILE_NOT_FOUND=6
An error will be written out for any of these, but if you're scripting around it these will be the error codes.
|