Remove prefix from global environment variables, prefixing them didn't make sense.

This commit is contained in:
Abdulmhsen B. A. A
2024-05-05 17:16:45 +03:00
parent f8443fb817
commit 4f1c783903
5 changed files with 60 additions and 35 deletions

25
FAQ.md
View File

@@ -49,7 +49,7 @@ $ docker exec -ti watchstate console system:tasks
### Container is crashing on startup? ### Container is crashing on startup?
This is likely due to misconfigured `user:` in `docker-compose.yaml`, the container is rootless as such it will crash if This is likely due to misconfigured `user:` in `compose.yaml`, the container is rootless as such it will crash if
the tool unable to access the data path. to check permissions simply do the following the tool unable to access the data path. to check permissions simply do the following
```bash ```bash
@@ -174,7 +174,7 @@ You have to repeat these steps for each user you want to migrate their data off
> [!IMPORTANT] > [!IMPORTANT]
> YOU MUST always start with fresh data for **EACH USER**, otherwise unexpected things might happen. > YOU MUST always start with fresh data for **EACH USER**, otherwise unexpected things might happen.
> Make sure to delete docker-compose.yaml `./data` directory. to start fresh > Make sure to delete compose.yaml `./data` directory. to start fresh
---- ----
@@ -286,7 +286,7 @@ $ mv /config/db/watchstate_v01-repaired.db /config/db/watchstate_v01.db
There are many ways to load the environment variables, However the recommended methods are: There are many ways to load the environment variables, However the recommended methods are:
* Via `docker-compose.yaml` file. * Via `compose.yaml` file.
* Via `/config/config/.env` file. This file normally does not exist you have to created manually. * Via `/config/config/.env` file. This file normally does not exist you have to created manually.
to see list of loaded environment variables run: to see list of loaded environment variables run:
@@ -328,14 +328,17 @@ $ docker exec -ti watchstate console system:tasks
#### Container specific environment variables. #### Container specific environment variables.
> [!IMPORTANT] > [!IMPORTANT]
> These environment variables relates to the container itself, and must be added via the `docker-compose.yaml` file. > These environment variables relates to the container itself, and must be added via the `compose.yaml` file.
| Key | Type | Description | Default | | Key | Type | Description | Default |
|------------------|---------|------------------------------------|----------| |----------------------|---------|------------------------------------|----------|
| WS_DISABLE_HTTP | integer | Disable included `HTTP Server`. | `0` | | DISABLE_HTTP | integer | Disable included `HTTP Server`. | `0` |
| WS_DISABLE_CRON | integer | Disable included `Task Scheduler`. | `0` | | DISABLE_CRON | integer | Disable included `Task Scheduler`. | `0` |
| WS_DISABLE_CACHE | integer | Disable included `Cache Server`. | `0` | | DISABLE_CACHE | integer | Disable included `Cache Server`. | `0` |
| HTTP_PORT | string | Change the `HTTP` listen port. | `"8080"` | | HTTP_PORT | string | Change the `HTTP` listen port. | `"8080"` |
| ~~WS_DISABLE_HTTP~~ | integer | Deprecated use `DISABLE_HTTP` | `0` |
| ~~WS_DISABLE_CRON~~ | integer | Deprecated use `DISABLE_CRON` | `0` |
| ~~WS_DISABLE_CACHE~~ | integer | Deprecated use `DISABLE_CACHE` | `0` |
--- ---
@@ -486,14 +489,14 @@ Those are some web hook limitations we discovered for the following media backen
As stated in webhook limitation section sometimes media backends don't make it easy to receive those events, as such, to As stated in webhook limitation section sometimes media backends don't make it easy to receive those events, as such, to
complement webhooks, you should enable import/export tasks by settings their respective environment variables in complement webhooks, you should enable import/export tasks by settings their respective environment variables in
your `docker-compose.yaml` file. For more information run help on `system:env` command as well as `system:tasks` your `compose.yaml` file. For more information run help on `system:env` command as well as `system:tasks`
command. command.
--- ---
### How to disable the included HTTP server and use external server? ### How to disable the included HTTP server and use external server?
Set this environment variable in your `docker-compose.yaml` file `WS_DISABLE_HTTP` with value of `1`. your external Set this environment variable in your `compose.yaml` file `WS_DISABLE_HTTP` with value of `1`. your external
server need to send correct fastcgi environment variables. Example caddy file server need to send correct fastcgi environment variables. Example caddy file
```caddyfile ```caddyfile
@@ -516,7 +519,7 @@ https://watchstate.example.org {
### How to disable the included cache server and use external cache server? ### How to disable the included cache server and use external cache server?
Set this environment variable in your `docker-compose.yaml` file `WS_DISABLE_CACHE` with value of `1`. Set this environment variable in your `compose.yaml` file `WS_DISABLE_CACHE` with value of `1`.
to use external redis server you need to alter the value of `WS_CACHE_URL` environment variable. the format for this to use external redis server you need to alter the value of `WS_CACHE_URL` environment variable. the format for this
variable is `redis://host:port?password=auth&db=db_num`, for example to use redis from another container you could use variable is `redis://host:port?password=auth&db=db_num`, for example to use redis from another container you could use
something like `redis://172.23.1.10:6379?password=my_secert_password&db=8`. We only support `redis` and API compatible something like `redis://172.23.1.10:6379?password=my_secert_password&db=8`. We only support `redis` and API compatible

View File

@@ -1,5 +1,14 @@
# Old Updates # Old Updates
### 2024-04-30 - [BREAKING CHANGE]
We are going to retire the old webhooks endpoint, please refer to the [FAQ](FAQ.md#how-to-add-webhooks) to know how to
update
to the new API endpoint. We are going to include `WebUI` for alpha testing after two weeks from today `2024-05-15`.
Which most likely means the old webhooks
endpoint will be removed. We will try to preserve the old endpoint for a while, but it's not guaranteed we will be able
to.
### 2024-03-08 ### 2024-03-08
This update include breaking changes to how we process commands, we have streamlined the command interface to accept This update include breaking changes to how we process commands, we have streamlined the command interface to accept

View File

@@ -9,20 +9,17 @@ out of the box, this tool support `Jellyfin`, `Plex` and `Emby` media servers.
## updates ## updates
### 2024-05-05
We are deprecating the use of the following environment variables `WS_DISABLE_HTTP`, `WS_DISABLE_CRON`, `WS_DISABLE_CACHE`,
and replacing them with `DISABLE_CACHE`, `DISABLE_CRON`, `DISABLE_HTTP`. The old environment variables will be removed in the future versions.
It doesn't make sense to mark them as `WS_` since they are global and do not relate to the tool itself. And they must be set from the `compose.yaml` file itself.
### 2024-05-04 ### 2024-05-04
The new webhook endpoint no longer requires a key, and it's now open to public you just need to specify the backend The new webhook endpoint no longer requires a key, and it's now open to public you just need to specify the backend
name. name.
### 2024-04-30 - [BREAKING CHANGE]
We are going to retire the old webhooks endpoint, please refer to the [FAQ](FAQ.md#how-to-add-webhooks) to know how to
update
to the new API endpoint. We are going to include `WebUI` for alpha testing after two weeks from today `2024-05-15`.
Which most likely means the old webhooks
endpoint will be removed. We will try to preserve the old endpoint for a while, but it's not guaranteed we will be able
to.
Refer to [NEWS](NEWS.md) for old updates. Refer to [NEWS](NEWS.md) for old updates.
# Features # Features
@@ -40,7 +37,7 @@ Refer to [NEWS](NEWS.md) for old updates.
# Install # Install
create your `docker-compose.yaml` with the following content: create your `compose.yaml` with the following content:
```yaml ```yaml
services: services:
@@ -60,7 +57,7 @@ services:
- ./data:/config:rw # mount current directory to container /config directory. - ./data:/config:rw # mount current directory to container /config directory.
``` ```
Create directory called `data` next to the `docker-compose.yaml` file. After creating your docker compose file, start Create directory called `data` next to the `compose.yaml` file. After creating your docker compose file, start
the container. the container.
```bash ```bash
@@ -82,7 +79,7 @@ $ mkdir -p ./data && docker-compose pull && docker-compose up -d
> terminal `chown -R 99:100 /mnt/user/appdata/watchstate`. > terminal `chown -R 99:100 /mnt/user/appdata/watchstate`.
> [!NOTE] > [!NOTE]
> To use this container with `podman` set `docker-compose.yaml` `user` to `0:0`. it will appear to be working as root > To use this container with `podman` set `compose.yaml` `user` to `0:0`. it will appear to be working as root
> inside the container, but it will be mapped to the user in which the command was run under. > inside the container, but it will be mapped to the user in which the command was run under.
# Adding backend # Adding backend
@@ -132,7 +129,7 @@ $ docker exec -ti watchstate console state:import -v -s home_plex -s home_jellyf
> [!NOTE] > [!NOTE]
> Now that you have imported your current play state enable the import task by adding the following environment > Now that you have imported your current play state enable the import task by adding the following environment
> variables to > variables to
> your `docker-compose.yaml` file `WS_CRON_IMPORT=1`. By default, we have it disabled. for more environment variables > your `compose.yaml` file `WS_CRON_IMPORT=1`. By default, we have it disabled. for more environment variables
> please > please
> refer to [Environment variables list](FAQ.md#environment-variables). > refer to [Environment variables list](FAQ.md#environment-variables).
@@ -172,7 +169,7 @@ $ docker exec -ti watchstate console state:export -v -s home_plex -s home_jellyf
> [!NOTE] > [!NOTE]
> Now that you have exported your current play state, enable the export task by adding the following environment > Now that you have exported your current play state, enable the export task by adding the following environment
> variables to > variables to
> your `docker-compose.yaml` file `WS_CRON_EXPORT=1`. By default, we have it disabled. for more environment variables > your `compose.yaml` file `WS_CRON_EXPORT=1`. By default, we have it disabled. for more environment variables
> please > please
> refer to [Environment variables list](FAQ.md#environment-variables). > refer to [Environment variables list](FAQ.md#environment-variables).

View File

@@ -4,9 +4,9 @@ set -e
DATA_PATH="${WS_DATA_PATH:-/config}" DATA_PATH="${WS_DATA_PATH:-/config}"
ENV_FILE="${DATA_PATH}/config/.env" ENV_FILE="${DATA_PATH}/config/.env"
WS_UMASK="${WS_UMASK:-0000}" W_UMASK="${UMASK:-0000}"
umask "${WS_UMASK}" umask "${W_UMASK}"
echo_err() { cat <<< "$@" 1>&2; } echo_err() { cat <<< "$@" 1>&2; }
@@ -15,11 +15,11 @@ if [ ! -w "${DATA_PATH}" ]; then
CH_GRP=$(stat -c "%g" "${DATA_PATH}") CH_GRP=$(stat -c "%g" "${DATA_PATH}")
echo_err "ERROR: Unable to write to [${DATA_PATH}] data directory. Current user id [${UID}] while directory owner is [${CH_USER}]" echo_err "ERROR: Unable to write to [${DATA_PATH}] data directory. Current user id [${UID}] while directory owner is [${CH_USER}]"
echo_err "[Running under docker]" echo_err "[Running under docker]"
echo_err "change docker-compose.yaml user: to user:\"${CH_USER}:${CH_GRP}\"" echo_err "change compose.yaml user: to user:\"${CH_USER}:${CH_GRP}\""
echo_err "Run the following command to change the directory ownership" echo_err "Run the following command to change the directory ownership"
echo_err "chown -R \"${CH_USER}:${CH_GRP}\" ./data" echo_err "chown -R \"${CH_USER}:${CH_GRP}\" ./data"
echo_err "[Running under podman]" echo_err "[Running under podman]"
echo_err "change docker-compose.yaml user: to user:\"0:0\"" echo_err "change compose.yaml user: to user:\"0:0\""
exit 1 exit 1
fi fi
@@ -39,22 +39,38 @@ else
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] INFO: No environment file present at [${ENV_FILE}]." echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] INFO: No environment file present at [${ENV_FILE}]."
fi fi
DISABLE_HTTP=${DISABLE_HTTP:-0}
DISABLE_CRON=${DISABLE_CRON:-0}
DISABLE_CACHE=${DISABLE_CACHE:-0}
WS_DISABLE_HTTP=${WS_DISABLE_HTTP:-0} WS_DISABLE_HTTP=${WS_DISABLE_HTTP:-0}
WS_DISABLE_CRON=${WS_DISABLE_CRON:-0} WS_DISABLE_CRON=${WS_DISABLE_CRON:-0}
WS_DISABLE_CACHE=${WS_DISABLE_CACHE:-0} WS_DISABLE_CACHE=${WS_DISABLE_CACHE:-0}
if [ 0 != "${WS_DISABLE_HTTP}" ] || [ 0 != "${WS_DISABLE_CRON}" ] || [ 0 != "${WS_DISABLE_CACHE}" ]; then
echo_err ""
echo_err "---------------------------------------------------------------------------------------------"
echo_err "-----------------------------------[ DEPRECATION NOTICE ]------------------------------------"
echo_err "---------------------------------------------------------------------------------------------"
echo_err "The use of the following variables is deprecated and will be removed in future releases."
echo_err "WS_DISABLE_HTTP, WS_DISABLE_CRON, WS_DISABLE_CACHE."
echo_err "Please use the DISABLE_HTTP, DISABLE_CRON, DISABLE_CACHE variables instead."
echo_err "---------------------------------------------------------------------------------------------"
echo_err ""
fi
set -u set -u
# Generate Config structure. # Generate Config structure.
# #
WS_CACHE_NULL=1 /opt/bin/console -v >/dev/null WS_CACHE_NULL=1 /opt/bin/console -v >/dev/null
if [ 0 = "${WS_DISABLE_CACHE}" ]; then if [ 0 = "${DISABLE_CACHE}" ] && [ 0 = "${WS_DISABLE_CACHE}" ]; then
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Starting Cache Server." echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Starting Cache Server."
redis-server "/opt/config/redis.conf" redis-server "/opt/config/redis.conf"
fi fi
if [ 0 = "${WS_DISABLE_HTTP}" ]; then if [ 0 = "${DISABLE_HTTP}" ] && [ 0 = "${WS_DISABLE_HTTP}" ]; then
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Starting HTTP Server." echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Starting HTTP Server."
_CADDY_UUID_FILE="${XDG_DATA_HOME}/caddy/instance.uuid" _CADDY_UUID_FILE="${XDG_DATA_HOME}/caddy/instance.uuid"
if [ ! -f "${_CADDY_UUID_FILE}" ]; then if [ ! -f "${_CADDY_UUID_FILE}" ]; then
@@ -78,7 +94,7 @@ echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Ensuring state table has correct indexes.
/opt/bin/console system:apikey -q /opt/bin/console system:apikey -q
if [ 0 = "${WS_DISABLE_CRON}" ]; then if [ 0 = "${DISABLE_CRON}" ] && [ 0 = "${WS_DISABLE_CRON}" ]; then
if [ -f "/tmp/job-runner.pid" ]; then if [ -f "/tmp/job-runner.pid" ]; then
echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Found pre-existing tasks scheduler pid file. Removing it." echo "[$(date +"%Y-%m-%dT%H:%M:%S%z")] Found pre-existing tasks scheduler pid file. Removing it."
rm -f "/tmp/job-runner.pid" rm -f "/tmp/job-runner.pid"

View File

@@ -69,7 +69,7 @@ final class EnvCommand extends Command
<question>(1) Via Docker compose file</> <question>(1) Via Docker compose file</>
You can load environment variables via [<comment>docker-compose.yaml</comment>] file by adding them under the [<comment>environment</comment>] key. You can load environment variables via [<comment>compose.yaml</comment>] file by adding them under the [<comment>environment</comment>] key.
For example, to enable import task, do the following: For example, to enable import task, do the following:
------------------------------- -------------------------------