mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-03 07:40:52 +02:00
Merge pull request #2361 from alexbelgium/codex/automatically-download-and-refresh-extensions
Auto-download Chromium extensions for karakeep
This commit is contained in:
@@ -57,6 +57,7 @@ RUN \
|
|||||||
ttf-freefont \
|
ttf-freefont \
|
||||||
font-noto-emoji \
|
font-noto-emoji \
|
||||||
font-wqy-zenhei \
|
font-wqy-zenhei \
|
||||||
|
unzip \
|
||||||
&& mkdir -p /usr/src/chrome \
|
&& mkdir -p /usr/src/chrome \
|
||||||
&& adduser -D chrome \
|
&& adduser -D chrome \
|
||||||
&& chown -R chrome:chrome /usr/src/chrome
|
&& chown -R chrome:chrome /usr/src/chrome
|
||||||
@@ -109,6 +110,23 @@ RUN chmod 777 /.bashio-standalone.sh
|
|||||||
|
|
||||||
RUN sed -i "s|/usr/bin/env|/usr/bin/with-contenv|g" /etc/cont-init.d/*
|
RUN sed -i "s|/usr/bin/env|/usr/bin/with-contenv|g" /etc/cont-init.d/*
|
||||||
|
|
||||||
|
RUN set -e; \
|
||||||
|
extensions_dir="/usr/src/chrome/extensions"; \
|
||||||
|
mkdir -p "${extensions_dir}"; \
|
||||||
|
for entry in \
|
||||||
|
"i-dont-care-about-cookies:fllaojicojecljbmefodhfapmkghcbnh" \
|
||||||
|
"ublock-origin:cjpalhdlnbpafiamejdnhcphjbkeiagm"; do \
|
||||||
|
name="${entry%%:*}"; \
|
||||||
|
ext_id="${entry##*:}"; \
|
||||||
|
curl -fsSL "https://clients2.google.com/service/update2/crx?response=redirect&prodversion=120.0&acceptformat=crx2,crx3&x=id%3D${ext_id}%26installsource%3Dondemand%26uc" \
|
||||||
|
-o "/tmp/${name}.crx"; \
|
||||||
|
rm -rf "${extensions_dir:?}/${name}"; \
|
||||||
|
mkdir -p "${extensions_dir}/${name}"; \
|
||||||
|
unzip -q "/tmp/${name}.crx" -d "${extensions_dir}/${name}"; \
|
||||||
|
rm "/tmp/${name}.crx"; \
|
||||||
|
done; \
|
||||||
|
chown -R chrome:chrome "${extensions_dir}"
|
||||||
|
|
||||||
############
|
############
|
||||||
# 5 Labels #
|
# 5 Labels #
|
||||||
############
|
############
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ Webui can be found at `<your-ip>:3000`.
|
|||||||
| `CRAWLER_VIDEO_DOWNLOAD_MAX_SIZE` | int | | Max video size (MB). |
|
| `CRAWLER_VIDEO_DOWNLOAD_MAX_SIZE` | int | | Max video size (MB). |
|
||||||
| `CRAWLER_VIDEO_DOWNLOAD_TIMEOUT_SEC` | int | | Video download timeout. |
|
| `CRAWLER_VIDEO_DOWNLOAD_TIMEOUT_SEC` | int | | Video download timeout. |
|
||||||
| `CRAWLER_ENABLE_ADBLOCKER` | bool | `true` | Enable ad blocking in the crawler. |
|
| `CRAWLER_ENABLE_ADBLOCKER` | bool | `true` | Enable ad blocking in the crawler. |
|
||||||
| `CHROME_EXTENSIONS_DIR` | str | `/share/karakeep/extensions` | Host-mounted extensions directory for headless Chromium. |
|
| `CHROME_EXTENSIONS_DIR` | str | `/usr/src/chrome/extensions` | Extensions directory for headless Chromium. |
|
||||||
| `MEILI_MASTER_KEY` | password | | Meilisearch master key (auto-generated if left blank). |
|
| `MEILI_MASTER_KEY` | password | | Meilisearch master key (auto-generated if left blank). |
|
||||||
| `MEILI_ADDR` | str | | Meilisearch URL. |
|
| `MEILI_ADDR` | str | | Meilisearch URL. |
|
||||||
| `BROWSER_WEB_URL` | str | | Chromium remote debugging URL. |
|
| `BROWSER_WEB_URL` | str | | Chromium remote debugging URL. |
|
||||||
@@ -72,15 +72,9 @@ Webui can be found at `<your-ip>:3000`.
|
|||||||
|
|
||||||
### Extensions for headless Chromium
|
### Extensions for headless Chromium
|
||||||
|
|
||||||
This add-on loads extensions in headless Chromium with the `--headless=new` flag. To use the included defaults:
|
This add-on loads extensions in headless Chromium with the `--headless=new` flag. The defaults are downloaded automatically during the image build and refreshed each time the add-on starts into `/usr/src/chrome/extensions` (non-persistent).
|
||||||
|
|
||||||
1. Create these folders on the host (via the `/share` mount):
|
You can override the base folder with the `CHROME_EXTENSIONS_DIR` option to point to a host-mounted directory if you prefer to manage extensions manually. Any missing extension folder is skipped at runtime.
|
||||||
- `/share/karakeep/extensions/i-dont-care-about-cookies`
|
|
||||||
- `/share/karakeep/extensions/ublock-origin`
|
|
||||||
2. Unzip each extension into its corresponding folder.
|
|
||||||
3. Restart the add-on.
|
|
||||||
|
|
||||||
You can override the base folder with the `CHROME_EXTENSIONS_DIR` option. Any missing extension folder is skipped at runtime.
|
|
||||||
|
|
||||||
### Custom Scripts and Environment Variables
|
### Custom Scripts and Environment Variables
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ arch:
|
|||||||
description: bookmark-everything app with a touch of AI for the data hoarders out there
|
description: bookmark-everything app with a touch of AI for the data hoarders out there
|
||||||
environment:
|
environment:
|
||||||
BROWSER_WEB_URL: http://127.0.0.1:9222
|
BROWSER_WEB_URL: http://127.0.0.1:9222
|
||||||
CHROME_EXTENSIONS_DIR: /share/karakeep/extensions
|
CHROME_EXTENSIONS_DIR: /usr/src/chrome/extensions
|
||||||
DATA_DIR: /data
|
DATA_DIR: /data
|
||||||
DISABLE_NEW_RELEASE_CHECK: "true"
|
DISABLE_NEW_RELEASE_CHECK: "true"
|
||||||
MEILI_ADDR: http://127.0.0.1:7700
|
MEILI_ADDR: http://127.0.0.1:7700
|
||||||
@@ -19,7 +19,7 @@ map:
|
|||||||
name: Karakeep
|
name: Karakeep
|
||||||
options:
|
options:
|
||||||
env_vars: []
|
env_vars: []
|
||||||
CHROME_EXTENSIONS_DIR: /share/karakeep/extensions
|
CHROME_EXTENSIONS_DIR: /usr/src/chrome/extensions
|
||||||
CRAWLER_DOWNLOAD_BANNER_IMAGE: true
|
CRAWLER_DOWNLOAD_BANNER_IMAGE: true
|
||||||
CRAWLER_ENABLE_ADBLOCKER: true
|
CRAWLER_ENABLE_ADBLOCKER: true
|
||||||
CRAWLER_FULL_PAGE_ARCHIVE: false
|
CRAWLER_FULL_PAGE_ARCHIVE: false
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ bashio::log.info "Creating folders"
|
|||||||
mkdir -p \
|
mkdir -p \
|
||||||
/data/cache \
|
/data/cache \
|
||||||
/data/chrome \
|
/data/chrome \
|
||||||
/share/karakeep/extensions \
|
/config/meili \
|
||||||
/config/meili
|
/usr/src/chrome/extensions
|
||||||
|
|
||||||
if id chrome &>/dev/null; then
|
if id chrome &>/dev/null; then
|
||||||
chown -R chrome:chrome /data/cache /data/chrome
|
chown -R chrome:chrome /data/cache /data/chrome /usr/src/chrome/extensions
|
||||||
fi
|
fi
|
||||||
|
|||||||
30
karakeep/rootfs/etc/cont-init.d/92-chrome-extensions.sh
Executable file
30
karakeep/rootfs/etc/cont-init.d/92-chrome-extensions.sh
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/command/with-contenv bashio
|
||||||
|
# shellcheck shell=bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
EXTENSIONS_DIR="${CHROME_EXTENSIONS_DIR:-/usr/src/chrome/extensions}"
|
||||||
|
|
||||||
|
bashio::log.info "Refreshing Chromium extensions in ${EXTENSIONS_DIR}"
|
||||||
|
|
||||||
|
mkdir -p "${EXTENSIONS_DIR}"
|
||||||
|
|
||||||
|
download_extension() {
|
||||||
|
local name="$1"
|
||||||
|
local extension_id="$2"
|
||||||
|
local crx_path
|
||||||
|
|
||||||
|
crx_path="$(mktemp)"
|
||||||
|
curl -fsSL "https://clients2.google.com/service/update2/crx?response=redirect&prodversion=120.0&acceptformat=crx2,crx3&x=id%3D${extension_id}%26installsource%3Dondemand%26uc" \
|
||||||
|
-o "${crx_path}"
|
||||||
|
rm -rf "${EXTENSIONS_DIR:?}/${name}"
|
||||||
|
mkdir -p "${EXTENSIONS_DIR}/${name}"
|
||||||
|
unzip -q "${crx_path}" -d "${EXTENSIONS_DIR}/${name}"
|
||||||
|
rm -f "${crx_path}"
|
||||||
|
}
|
||||||
|
|
||||||
|
download_extension "i-dont-care-about-cookies" "fllaojicojecljbmefodhfapmkghcbnh"
|
||||||
|
download_extension "ublock-origin" "cjpalhdlnbpafiamejdnhcphjbkeiagm"
|
||||||
|
|
||||||
|
if id chrome &>/dev/null; then
|
||||||
|
chown -R chrome:chrome "${EXTENSIONS_DIR}"
|
||||||
|
fi
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
EXTENSIONS_DIR="${CHROME_EXTENSIONS_DIR:-/share/karakeep/extensions}"
|
EXTENSIONS_DIR="${CHROME_EXTENSIONS_DIR:-/usr/src/chrome/extensions}"
|
||||||
|
|
||||||
extensions=()
|
extensions=()
|
||||||
for extension in "${EXTENSIONS_DIR}/i-dont-care-about-cookies" "${EXTENSIONS_DIR}/ublock-origin"; do
|
for extension in "${EXTENSIONS_DIR}/i-dont-care-about-cookies" "${EXTENSIONS_DIR}/ublock-origin"; do
|
||||||
|
|||||||
Reference in New Issue
Block a user