Compare commits

..

No commits in common. "638fbedc0aa2f0ee87eeb28c6d0a7e3251d1d4a0" and "32cc001cf3b6567e1545ce96ad42c63607f47774" have entirely different histories.

4 changed files with 11 additions and 38 deletions

View file

@ -152,16 +152,15 @@ Example folder structure:
#### Configuration
Some decisions need to be made on the client side, and most of those will be expressed in the form of environment variables passed into the container:
| Variable | Example value (default)| Description |
| Variable | Example value | Description |
|:--- |:--- |:--- |
| `SYNC_PEER` | `deb01.lab.bowdre.net` | FQDN or IP of the `library-syncer` server to which the client will connect |
| `SYNC_PORT` | (`2222`)| SSH port for connecting to the server |
| `SYNC_SCHEDULE` | (`0 21 * * 5`) | `cron`-formatted schedule for when the client should initiate a sync (example syncs at 9PM on Friday night) |
| `SYNC_DELAY` | `true` (`false`) | if true, sleeps a random number of seconds before begining the sync |
| `SYNC_DELAY_MAX_SECONDS` | (`21600`) | maximum seconds to sleep (example will be delayed up to 6 hours) |
| `SYNC_PORT` | `2222` | SSH port for connecting to the server |
| `SYNC_SCHEDULE` | `0 21 * * 5` | `cron`-formatted schedule for when the client should initiate a sync (example syncs at 9PM on Friday night) |
| `SYNC_DELAY` | `true` | if true, sleeps a random number of seconds before begining the sync |
| `SYNC_DELAY_MAX_SECONDS` | `21600` | maximum seconds to sleep (example will be delayed up to 6 hours) |
| `TLS_NAME` | `library.bowdre.net` | if set, the FQDN used for the client's web server; if not set, the library will be served strictly over HTTP |
| `TLS_CUSTOM_CERT` | `true` (`false`) | if `true`, the web server will expect to find a custom certificate *and private key* in the `./data/certs` volume |
| `LIBRARY_NAME` | (`Library`) | this name will show up in the generated Content Library JSON, but not anywhere else |
| `TLS_CUSTOM_CERT` | `true` | if `true`, the web server will expect to find a custom certificate *and private key* in the `./data/certs` volume |
Introducing a random sync delay might be useful if you have a bunch of remote sites and don't want them to attempt to sync all at once, but you're too lazy to manually customize the schedule for each one of them (no judgment!).
@ -184,7 +183,6 @@ services:
- SYNC_DELAY_MAX_SECONDS=21600
- TLS_NAME=library.lab.bowdre.net
- TLS_CUSTOM_CERT=true
- LIBRARY_NAME=Library
ports:
- "80:80/tcp"
- "443:443/tcp"
@ -260,27 +258,3 @@ The startup tasks are complete once you see the messaging about starting `cron`.
[...]
0 21 * * 5 /syncer/sync.sh delay > /proc/self/fd/1 2>/proc/self/fd/2
```
Open a web browser to `http(s)://[TLS_NAME or IP]/lib.json` and you can see the top-level library item:
```json
{
"vcspVersion": "2",
"version": "1",
"contentVersion": "1",
"name": "Library",
"id": "urn:uuid:aa465152-4ed2-44f5-8fb0-4fac5e03016a",
"created": "2022-08-07T20:14Z",
"capabilities": {
"transferIn": [
"httpGet"
],
"transferOut": [
"httpGet"
]
},
"itemsHref": "items.json"
}
```
### Subscribed library
The final piece of this puzzle to create a content library inside of vSphere subscribed to the client library that was just created.

View file

@ -7,9 +7,9 @@ echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Performing initial sync..."
/syncer/sync.sh > /proc/self/fd/1 2>/proc/self/fd/2
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Creating cron job..."
if [ "$SYNC_DELAY" == "true" ]; then
echo "${SYNC_SCHEDULE:-0 21 * * 5} /syncer/sync.sh delay > /proc/self/fd/1 2>/proc/self/fd/2" >> $CRONTAB_FILE
echo "$SYNC_SCHEDULE /syncer/sync.sh delay > /proc/self/fd/1 2>/proc/self/fd/2" >> $CRONTAB_FILE
else
echo "${SYNC_SCHEDULE:-0 21 * * 5} /syncer/sync.sh > /proc/self/fd/1 2>/proc/self/fd/2" >> $CRONTAB_FILE
echo "$SYNC_SCHEDULE /syncer/sync.sh > /proc/self/fd/1 2>/proc/self/fd/2" >> $CRONTAB_FILE
fi
chmod 0644 $CRONTAB_FILE

View file

@ -5,15 +5,15 @@ set -e
# insert optional random delay
if [ x$1 == x"delay" ]; then
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Waiting for random delay..."
sleep $(( RANDOM % ${SYNC_DELAY_MAX_SECONDS:-21600} + 1 ))
sleep $(( RANDOM % SYNC_DELAY_MAX_SECONDS + 1 ))
fi
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Sync sync starts NOW!"
# sync
/usr/bin/rsync -e "ssh -l syncer -p ${SYNC_PORT:-2222} -i /syncer/.ssh/id_syncer -o StrictHostKeyChecking=no" -av --exclude '*.json' $SYNC_PEER:/ /syncer/library
/usr/bin/rsync -e "ssh -l syncer -p $SYNC_PORT -i /syncer/.ssh/id_syncer -o StrictHostKeyChecking=no" -av --exclude '*.json' $SYNC_PEER:/ /syncer/library
# generate content library manifest
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Generating content library manifest..."
/usr/bin/python3 /syncer/update_library_manifests.py -n "${LIBRARY_NAME:-Library}" -p /syncer/library/
/usr/bin/python3 /syncer/update_library_manifests.py -n 'Library' -p /syncer/library/
echo -e "[$(date +"%Y/%m/%d-%H:%M:%S")] Sync tasks complete!"

View file

@ -13,7 +13,6 @@ services:
- SYNC_DELAY_MAX_SECONDS=21600
- TLS_NAME=library.lab.bowdre.net
- TLS_CUSTOM_CERT=true
- LIBRARY_NAME=Library
ports:
- "80:80/tcp"
- "443:443/tcp"