mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-10 18:01:03 +01:00
Update
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
# ALEXBELGIUM'S DOCKERFILE #
|
||||
#============================#
|
||||
# _.------.
|
||||
# _.-` ('>.-`"1.57.1""-.
|
||||
# _.-` ('>.-`"""-.
|
||||
# '.--'` _'` _ .--.)
|
||||
# -' '-.-';` `
|
||||
# ' - _.' ``'--.
|
||||
# d '---` .-'"1.57.1"`
|
||||
# d '---` .-'""`
|
||||
# /`
|
||||
#=== Home Assistant Addon ===#
|
||||
|
||||
@@ -27,19 +27,19 @@ ENV S6_CMD_WAIT_FOR_SERVICES=1 \
|
||||
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
|
||||
S6_SERVICES_GRACETIME=0
|
||||
|
||||
USER root
|
||||
|
||||
# Global LSIO modifications
|
||||
ADD --chmod=744 "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_lsio.sh" "/ha_lsio.sh"
|
||||
ARG CONFIGLOCATION="/config/addons_config/immich"
|
||||
RUN if grep -qr "lsio" /etc; then /ha_lsio.sh "$CONFIGLOCATION"; fi && rm /ha_lsio.sh
|
||||
|
||||
USER root
|
||||
|
||||
# Install REDIS
|
||||
ENV DOCKER_MODS="imagegenius/mods:universal-redis"
|
||||
RUN \
|
||||
echo "Installing REDIS" \
|
||||
&& chmod 777 -R /docker-mods \
|
||||
&& /./docker-mods/* || ls / \
|
||||
&& chmod 777 -R /docker-mods \
|
||||
&& /./docker-mods/* || ls / \
|
||||
&& if [ !-f /defaults/redis.conf ]; then echo "Not installed" && exit 1; fi
|
||||
ENV DOCKER_MODS=""
|
||||
|
||||
@@ -57,8 +57,9 @@ ARG MODULES="00-banner.sh 01-custom_script.sh 00-global_var.sh 00-local_mounts.s
|
||||
ADD --chmod=744 "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_automodules.sh" "/ha_automodules.sh"
|
||||
RUN /ha_automodules.sh "$MODULES" && rm /ha_automodules.sh
|
||||
|
||||
|
||||
# Manual apps
|
||||
ENV PACKAGES="sudo redis-server yamllint pip libxml2-dev libxslt-dev libjpeg-dev zlib1g-dev build-essential"
|
||||
ENV PACKAGES="sudo yamllint pip postgresql-client"
|
||||
|
||||
# Automatic apps & bashio
|
||||
ADD --chmod=744 "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_autoapps.sh" "/ha_autoapps.sh"
|
||||
@@ -76,7 +77,6 @@ ADD --chmod=777 "https://raw.githubusercontent.com/alexbelgium/hassio-addons/mas
|
||||
ADD --chmod=777 "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" "/ha_entrypoint_modif.sh"
|
||||
RUN /ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh
|
||||
|
||||
#
|
||||
#ENTRYPOINT [ "/usr/bin/env" ]
|
||||
#CMD [ "/ha_entrypoint.sh" ]
|
||||
|
||||
|
||||
@@ -30,3 +30,5 @@ ln -sf "$DATA_LOCATION" /photos
|
||||
chown -R "$PUID":"$PGID" /photos
|
||||
|
||||
mkdir -p "$MACHINE_LEARNING_CACHE_FOLDER" "$TYPESENSE_DATA_DIR"
|
||||
chown -R "$PUID":"$PGID" "$MACHINE_LEARNING_CACHE_FOLDER"
|
||||
chown -R "$PUID":"$PGID" "$TYPESENSE_DATA_DIR"
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
#!/usr/bin/env bashio
|
||||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2155,SC2016
|
||||
|
||||
######################
|
||||
# Switch of database #
|
||||
######################
|
||||
|
||||
if [ -f /share/postgresql_immich.tar.gz ]; then
|
||||
bashio::log.warning "Your previous database was exported to /share/postgresql_immich.tar.gz"
|
||||
elif [ -d /data/postgresql ]; then
|
||||
bashio::log.warning "------------------------------------"
|
||||
bashio::log.warning "Internal postgres database detected, copying to /share/postgresql_immich.tar.gz"
|
||||
bashio::log.warning "------------------------------------"
|
||||
tar -zcvf /share/postgresql_immich.tar.gz /data/postgresql
|
||||
rm -r /data/postgresql
|
||||
fi
|
||||
|
||||
###################
|
||||
# Define database #
|
||||
###################
|
||||
|
||||
bashio::log.info "Defining database"
|
||||
bashio::log.info "-----------------"
|
||||
|
||||
bashio::log.info "Connecting to external postgresql"
|
||||
bashio::log.info ""
|
||||
|
||||
# Check if values exist
|
||||
if ! bashio::config.has_value 'DB_USERNAME' && \
|
||||
! bashio::config.has_value 'DB_HOSTNAME' && \
|
||||
! bashio::config.has_value 'DB_PASSWORD' && \
|
||||
! bashio::config.has_value 'DB_DATABASE_NAME' && \
|
||||
! bashio::config.has_value 'JWT_SECRET' && \
|
||||
! bashio::config.has_value 'DB_PORT'; then
|
||||
! bashio::exit.nok "Please make sure that the following options are set : DB_USERNAME, DB_HOSTNAME, DB_PASSWORD, DB_DATABASE_NAME, DB_PORT"
|
||||
fi
|
||||
|
||||
# Settings parameters
|
||||
export DB_USERNAME=$(bashio::config 'DB_USERNAME')
|
||||
export DB_HOSTNAME=$(bashio::config 'DB_HOSTNAME')
|
||||
export DB_PASSWORD=$(bashio::config 'DB_PASSWORD')
|
||||
export DB_DATABASE_NAME=$(bashio::config 'DB_DATABASE_NAME')
|
||||
export DB_PORT=$(bashio::config 'DB_PORT')
|
||||
export JWT_SECRET=$(bashio::config 'JWT_SECRET')
|
||||
|
||||
# Create database
|
||||
echo "CREATE ROLE root WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'securepassword';
|
||||
CREATE DATABASE immich; CREATE USER immich WITH ENCRYPTED PASSWORD 'immich';
|
||||
GRANT ALL PRIVILEGES ON DATABASE immich to immich;
|
||||
\q"> setup_postgres.sql
|
||||
chown postgres setup_postgres.sql
|
||||
# shellcheck disable=SC2024
|
||||
sudo -iu postgres psql < setup_postgres.sql
|
||||
rm setup_postgres.sql
|
||||
|
||||
# Export variables
|
||||
if [ -d /var/run/s6/container_environment ]; then
|
||||
printf "%s" "$DB_USERNAME" > /var/run/s6/container_environment/DB_USERNAME
|
||||
printf "%s" "$DB_PASSWORD" > /var/run/s6/container_environment/DB_PASSWORD
|
||||
printf "%s" "$DB_DATABASE_NAME" > /var/run/s6/container_environment/DB_DATABASE_NAME
|
||||
printf "%s" "$DB_PORT" > /var/run/s6/container_environment/DB_PORT
|
||||
printf "%s" "$DB_HOSTNAME" > /var/run/s6/container_environment/DB_HOSTNAME
|
||||
printf "%s" "$JWT_SECRET" > /var/run/s6/container_environment/JWT_SECRET
|
||||
fi
|
||||
|
||||
{
|
||||
printf "%s" "DB_USERNAME=\"$DB_USERNAME\""
|
||||
printf "%s" "DB_PASSWORD=\"$DB_PASSWORD\""
|
||||
printf "%s" "DB_DATABASE_NAME=\"$DB_DATABASE_NAME\""
|
||||
printf "%s" "DB_PORT=\"$DB_PORT\""
|
||||
printf "%s" "DB_HOSTNAME=\"$DB_HOSTNAME\""
|
||||
printf "%s" "JWT_SECRET=\"$JWT_SECRET\""
|
||||
} >> ~/.bashrc
|
||||
@@ -29,6 +29,20 @@ for KEYS in "${arr[@]}"; do
|
||||
export "${KEYS}=${VALUE//[\"\']/}"
|
||||
done
|
||||
|
||||
######################
|
||||
# Switch of database #
|
||||
######################
|
||||
|
||||
if [ -f /share/postgresql_immich.tar.gz ]; then
|
||||
bashio::log.warning "Your previous database was exported to /share/postgresql_immich.tar.gz"
|
||||
elif [ -d /data/postgresql ]; then
|
||||
bashio::log.warning "------------------------------------"
|
||||
bashio::log.warning "Internal postgres database detected, copying to /share/postgresql_immich.tar.gz"
|
||||
bashio::log.warning "------------------------------------"
|
||||
tar -zcvf /share/postgresql_immich.tar.gz /data/postgresql
|
||||
rm -r /data/postgresql
|
||||
fi
|
||||
|
||||
###################
|
||||
# Define database #
|
||||
###################
|
||||
@@ -36,71 +50,55 @@ done
|
||||
bashio::log.info "Defining database"
|
||||
bashio::log.info "-----------------"
|
||||
|
||||
case $(bashio::config 'database') in
|
||||
bashio::log.info "Connecting to external postgresql"
|
||||
bashio::log.info ""
|
||||
|
||||
"external_postgresql")
|
||||
# Check if values exist
|
||||
if ! bashio::config.has_value 'DB_USERNAME' && \
|
||||
! bashio::config.has_value 'DB_HOSTNAME' && \
|
||||
! bashio::config.has_value 'DB_PASSWORD' && \
|
||||
! bashio::config.has_value 'DB_DATABASE_NAME' && \
|
||||
! bashio::config.has_value 'JWT_SECRET' && \
|
||||
! bashio::config.has_value 'DB_PORT'; then
|
||||
! bashio::exit.nok "Please make sure that the following options are set : DB_USERNAME, DB_HOSTNAME, DB_PASSWORD, DB_DATABASE_NAME, DB_PORT"
|
||||
fi
|
||||
|
||||
bashio::log.info "Using external postgresql"
|
||||
bashio::log.info ""
|
||||
# Settings parameters
|
||||
export DB_USERNAME=$(bashio::config 'DB_USERNAME')
|
||||
export DB_HOSTNAME=$(bashio::config 'DB_HOSTNAME')
|
||||
export DB_PASSWORD=$(bashio::config 'DB_PASSWORD')
|
||||
export DB_DATABASE_NAME=$(bashio::config 'DB_DATABASE_NAME')
|
||||
export DB_PORT=$(bashio::config 'DB_PORT')
|
||||
export JWT_SECRET=$(bashio::config 'JWT_SECRET')
|
||||
|
||||
# Check if values exist
|
||||
if ! bashio::config.has_value 'DB_USERNAME' && \
|
||||
! bashio::config.has_value 'DB_HOSTNAME' && \
|
||||
! bashio::config.has_value 'DB_PASSWORD' && \
|
||||
! bashio::config.has_value 'DB_DATABASE_NAME' && \
|
||||
! bashio::config.has_value 'JWT_SECRET' && \
|
||||
! bashio::config.has_value 'DB_PORT'
|
||||
then
|
||||
! bashio::exit.nok "Please make sure that the following options are set : DB_USERNAME, DB_HOSTNAME, DB_PASSWORD, DB_DATABASE_NAME, DB_PORT"
|
||||
fi
|
||||
# Export variables
|
||||
if [ -d /var/run/s6/container_environment ]; then
|
||||
printf "%s" "$DB_USERNAME" > /var/run/s6/container_environment/DB_USERNAME
|
||||
printf "%s" "$DB_PASSWORD" > /var/run/s6/container_environment/DB_PASSWORD
|
||||
printf "%s" "$DB_DATABASE_NAME" > /var/run/s6/container_environment/DB_DATABASE_NAME
|
||||
printf "%s" "$DB_PORT" > /var/run/s6/container_environment/DB_PORT
|
||||
printf "%s" "$DB_HOSTNAME" > /var/run/s6/container_environment/DB_HOSTNAME
|
||||
printf "%s" "$JWT_SECRET" > /var/run/s6/container_environment/JWT_SECRET
|
||||
fi
|
||||
|
||||
# Settings parameters
|
||||
export DB_USERNAME=$(bashio::config 'DB_USERNAME')
|
||||
export DB_HOSTNAME=$(bashio::config 'DB_HOSTNAME')
|
||||
export DB_PASSWORD=$(bashio::config 'DB_PASSWORD')
|
||||
export DB_DATABASE_NAME=$(bashio::config 'DB_DATABASE_NAME')
|
||||
export DB_PORT=$(bashio::config 'DB_PORT')
|
||||
export JWT_SECRET=$(bashio::config 'JWT_SECRET')
|
||||
;;
|
||||
{
|
||||
printf "%s" "DB_USERNAME=\"$DB_USERNAME\""
|
||||
printf "%s" "DB_PASSWORD=\"$DB_PASSWORD\""
|
||||
printf "%s" "DB_DATABASE_NAME=\"$DB_DATABASE_NAME\""
|
||||
printf "%s" "DB_PORT=\"$DB_PORT\""
|
||||
printf "%s" "DB_HOSTNAME=\"$DB_HOSTNAME\""
|
||||
printf "%s" "JWT_SECRET=\"$JWT_SECRET\""
|
||||
} >> ~/.bashrc
|
||||
|
||||
**)
|
||||
###################
|
||||
# Create database #
|
||||
###################
|
||||
|
||||
bashio::log.info "Using internal postgresql"
|
||||
bashio::log.info ""
|
||||
# Create database if does not exist
|
||||
echo "CREATE ROLE root WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'securepassword';
|
||||
CREATE DATABASE immich; CREATE USER immich WITH ENCRYPTED PASSWORD 'immich'; GRANT ALL PRIVILEGES ON DATABASE immich to immich;
|
||||
\q"> setup_postgres.sql
|
||||
psql "postgres://$DB_USERNAME:$DB_PASSWORD@$DB_HOSTNAME:$DB_PORT" < setup_postgres.sql || true
|
||||
|
||||
# Settings files & permissions
|
||||
ln -s /usr/lib/postgresql/14/bin/postgres /usr/bin || true
|
||||
ln -s /usr/lib/postgresql/14/bin/psql /usr/psql || true
|
||||
mkdir -p /data/postgresql
|
||||
cp -rnf /var/lib/postgresql/14/main/* /data/postgresql/
|
||||
chown -R postgres /data/postgresql
|
||||
chmod -R 700 /data/postgresql
|
||||
|
||||
# Start postgresql
|
||||
/etc/init.d/postgresql start
|
||||
|
||||
# Create database
|
||||
echo "CREATE ROLE root WITH LOGIN SUPERUSER CREATEDB CREATEROLE PASSWORD 'securepassword';
|
||||
CREATE DATABASE immich; CREATE USER immich WITH ENCRYPTED PASSWORD 'immich';
|
||||
GRANT ALL PRIVILEGES ON DATABASE immich to immich;
|
||||
\q"> setup_postgres.sql
|
||||
chown postgres setup_postgres.sql
|
||||
# shellcheck disable=SC2024
|
||||
sudo -iu postgres psql < setup_postgres.sql
|
||||
rm setup_postgres.sql
|
||||
|
||||
# Settings parameters
|
||||
export DB_USERNAME=immich
|
||||
export DB_HOSTNAME=localhost
|
||||
export DB_PASSWORD=immich
|
||||
export DB_DATABASE_NAME=immich
|
||||
export DB_PORT=5432
|
||||
export JWT_SECRET=$(bashio::config 'JWT_SECRET')
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
##################
|
||||
# Starting redis #
|
||||
##################
|
||||
exec redis-server & bashio::log.info "Starting redis"
|
||||
# Clean
|
||||
rm setup_postgres.sql
|
||||
|
||||
BIN
immich/stats.png
BIN
immich/stats.png
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.5 KiB |
Reference in New Issue
Block a user