Skip to content

Commit

Permalink
Update paperless #1078 #889
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbelgium committed Nov 21, 2023
1 parent 689e371 commit bc4c700
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 33 deletions.
6 changes: 1 addition & 5 deletions paperless_ngx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
WORK IN PROGRESS DON'T UPDATE (no data loss)

### 2.0.0b1-4 (20-11-2023)
### 2.0.0b1-5 (20-11-2023)
- Correct passing of addon options to addon
- Automatically changes config.yaml addon option to new location
- Restore local and smb disks scripts

## 2.0.0b1 (19-11-2023)
- Update to latest version from paperless-ngx/paperless-ngx
- MAJOR CHANGE : new HA config logic implemented. Files are now located in the addon config file, that can be accessed from the addon_configs folder from my filebrowser or cloudcommander addons. Migration of data, custom configs, and custom scripts should be automatic. Please be sure to update all your links however ! For more information, see here : https://developers.home-assistant.io/blog/2023/11/06/public-addon-config/
- Update to new official image
Expand Down
11 changes: 5 additions & 6 deletions paperless_ngx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

ARG BUILD_FROM
ARG BUILD_VERSION
ARG BUILD_UPSTREAM="2.0.0b1"
FROM ${BUILD_FROM}

##################
Expand Down Expand Up @@ -66,12 +65,12 @@ ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templat
RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh

# Add custom scripts
# RUN sed -i "2a source /ha_entrypoint.sh" /sbin/docker-entrypoint.sh && \
# sed -i 's=/./=source /=g' /ha_entrypoint.sh && \
# sed -i "s=env bash=env bashio=g" /sbin/docker-entrypoint.sh
RUN sed -i "2a source /ha_entrypoint.sh" /sbin/docker-entrypoint.sh && \
sed -i "s=/./=source /=g" /ha_entrypoint.sh && \
sed -i "s=env bash=env bashio=g" /sbin/docker-entrypoint.sh

ENTRYPOINT [ "/usr/bin/env" ]
CMD [ "/ha_entrypoint.sh" ]
#ENTRYPOINT [ "/usr/bin/env" ]
#CMD [ "/ha_entrypoint.sh" ]
#SHELL ["/bin/bash", "-o", "pipefail", "-c"]

############
Expand Down
1 change: 1 addition & 0 deletions paperless_ngx/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## ⚠ Open Issue : [🐛 [paperless_ngx] Updates are not recognised (opened 2023-07-03)](https://github.com/alexbelgium/hassio-addons/issues/889) by [@rafael298](https://github.com/rafael298)
# Home assistant add-on: Paperless NGX

[![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium)
Expand Down
8 changes: 4 additions & 4 deletions paperless_ngx/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"amd64"
],
"codenotary": "[email protected]",
"description": "Scan, index and archive all your physical documents",
"description": "scan, index and archive all your physical documents",
"devices": [
"/dev/dri",
"/dev/dri/card0",
Expand Down Expand Up @@ -76,7 +76,7 @@
"media:rw",
"ssl"
],
"name": "Paperless ngx",
"name": "Paperless NGX",
"options": {
"CONFIG_LOCATION": "/config/config.yaml",
"OCRLANG": "ENG FRA GER",
Expand Down Expand Up @@ -125,7 +125,7 @@
],
"slug": "paperless_ng",
"udev": true,
"url": "https://github.com/alexbelgium/hassio-addons/tree/master/paperless_ngx",
"version": "2.0.0b1-4",
"url": "https://github.com/alexbelgium/hassio-addons",
"version": "2.0.0b1-5",
"webui": "http://[HOST]:[PORT:8000]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ if [ -d "/homeassistant/addons_config/$slug" ]; then
echo "Migrating /homeassistant/addons_config/$slug"
mv /homeassistant/addons_config/"$slug"/media /config/ || true
mv /homeassistant/addons_config/"$slug"/consume /config/ || true
mv /homeassistant/addons_config/"$slug"/config.yaml /config/ || true
mkdir -p /config/data
mv /homeassistant/addons_config/"$slug"/* /config/data/ || true
rm -r /homeassistant/addons_config/"$slug"
Expand Down
27 changes: 10 additions & 17 deletions paperless_ngx/rootfs/etc/cont-init.d/99-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

bashio::log.info "Defining variables"

# Define variables
export PAPERLESS_ADMIN_PASSWORD="admin"
export PAPERLESS_ADMIN_USER="admin"
if bashio::config.has_value "PUID"; then export USERMAP_UID="$(bashio::config "PUID")"; fi
if bashio::config.has_value "PGID"; then export USERMAP_GID="$(bashio::config "PGID")"; fi
if bashio::config.has_value "TZ"; then export PAPERLESS_TIME_ZONE="$(bashio::config "TZ")"; fi
Expand All @@ -17,20 +20,14 @@ if bashio::config.has_value "OCRLANG"; then
export PAPERLESS_OCR_LANGUAGES="${PAPERLESS_OCR_LANGUAGES,,}"
fi
if bashio::config.has_value "PAPERLESS_OCR_MODE"; then export PAPERLESS_OCR_MODE="$(bashio::config "PAPERLESS_OCR_MODE")"; fi

export PAPERLESS_ADMIN_PASSWORD="admin"
export PAPERLESS_ADMIN_USER="admin"
export PAPERLESS_ALLOWED_HOSTS="\"*\""

chown -R paperless:paperless /config

if bashio::config.has_value "PAPERLESS_DATA_DIR"; then export PAPERLESS_DATA_DIR="$(bashio::config "PAPERLESS_DATA_DIR")"; else export PAPERLESS_DATA_DIR="/config/data"; fi
if bashio::config.has_value "PAPERLESS_MEDIA_ROOT"; then export PAPERLESS_MEDIA_ROOT="$(bashio::config "PAPERLESS_MEDIA_ROOT")"; else export PAPERLESS_MEDIA_ROOT="/config/media"; fi
if bashio::config.has_value "PAPERLESS_CONSUMPTION_DIR"; then export PAPERLESS_CONSUMPTION_DIR="$(bashio::config "PAPERLESS_CONSUMPTION_DIR")"; else export PAPERLESS_CONSUMPTION_DIR="/config/consume"; fi
if bashio::config.has_value "PAPERLESS_EXPORT_DIR"; then export PAPERLESS_EXPORT_DIR="$(bashio::config "PAPERLESS_EXPORT_DIR")"; else export PAPERLESS_EXPORT_DIR="/config/export"; fi

# Create folder and permissions if needed
chown -R paperless:paperless /config
for variable in "$PAPERLESS_DATA_DIR" "$PAPERLESS_MEDIA_ROOT" "$PAPERLESS_CONSUMPTION_DIR" "$PAPERLESS_EXPORT_DIR"; do
# Create folder and permissions if needed
mkdir -p "$variable"
chmod -R 755 "$variable"
chown -R paperless:paperless "$variable"
Expand Down Expand Up @@ -81,16 +78,14 @@ esac
set +u

# For all relevant variables
for variable in PAPERLESS_DATA_DIR PAPERLESS_MEDIA_ROOT PAPERLESS_CONSUMPTION_DIR PAPERLESS_EXPORT_DIR USERMAP_UID USERMAP_GID PAPERLESS_TIME_ZONE PAPERLESS_URL PAPERLESS_OCR_LANGUAGES PAPERLESS_OCR_MODE PAPERLESS_ADMIN_PASSWORD PAPERLESS_ADMIN_USER PAPERLESS_ALLOWED_HOSTS PAPERLESS_DATA_DIR PAPERLESS_MEDIA_ROOT PAPERLESS_CONSUMPTION_DIR PAPERLESS_DBENGINE PAPERLESS_DBHOST PAPERLESS_DBPORT PAPERLESS_DBNAME PAPERLESS_DBUSER PAPERLESS_DBPASS; do
for variable in PAPERLESS_DATA_DIR PAPERLESS_MEDIA_ROOT PAPERLESS_CONSUMPTION_DIR PAPERLESS_EXPORT_DIR USERMAP_UID USERMAP_GID PAPERLESS_TIME_ZONE PAPERLESS_URL PAPERLESS_OCR_LANGUAGES PAPERLESS_OCR_MODE PAPERLESS_ADMIN_PASSWORD PAPERLESS_ADMIN_USER PAPERLESS_DBENGINE PAPERLESS_DBHOST PAPERLESS_DBPORT PAPERLESS_DBNAME PAPERLESS_DBUSER PAPERLESS_DBPASS; do

# Skip if not defined
if [ -n \$$variable ]; then continue; fi

# Variable content
variablecontent="$(eval echo "\$$variable")"
# Skip if variable content empty
if [ ${#variablecontent} -le 2 ]; then
continue
else
bashio::log.blue "$variable=\"$variablecontent\""
fi
bashio::log.blue "$variable=\"$variablecontent\""

# Export
export "$variable=$variablecontent"
Expand Down Expand Up @@ -119,5 +114,3 @@ exec nginx & bashio::log.info "Starting nginx"
# Starting app #
###############
bashio::log.info "Initial username and password are admin. Please change in the administration panel of the webUI after login."

/./usr/local/bin/paperless_cmd.sh /sbin/docker-entrypoint.sh

0 comments on commit bc4c700

Please sign in to comment.