fix: auto-fix linting issues

This commit is contained in:
alexbelgium
2025-06-10 10:06:17 +00:00
committed by github-actions[bot]
parent e5adbd266f
commit f728166b14
197 changed files with 5747 additions and 5714 deletions

View File

@@ -8,7 +8,7 @@ set -e
echo "Cleaning files"
for var in /data/config/nginx /data/config/crontabs /data/config/logs; do
if [ -d "$var" ]; then rm -r "$var"; fi
if [ -d "$var" ]; then rm -r "$var"; fi
done
########################
@@ -22,10 +22,10 @@ rootuser='root'
printf "Creating possible missing Directories\n"
for folder in "$ocpath"/data "$ocpath"/assets "$ocpath"/updater "$ocpath"/apps "$ocpath"/assets "$ocpath"/config "$ocpath"/data "$ocpath"/themes /data/config/nextcloud/config /data/config/nextcloud/data /ssl/nextcloud/keys; do
if [ ! -d "$folder" ]; then
echo "... $folder"
mkdir -p "$folder" || true
fi
if [ ! -d "$folder" ]; then
echo "... $folder"
mkdir -p "$folder" || true
fi
done
printf "chmod Files and Directories. This could take some time, please wait...\n"
@@ -39,17 +39,17 @@ find "${ocpath}"/ -type d -exec chmod 0750 {} \;
printf "chown Directories. This could take some time, please wait...\n"
chown -R ${rootuser}:${htgroup} "${ocpath}"/
for folder in "${ocpath}"/apps/ "${ocpath}"/assets/ "${ocpath}"/config/ "${ocpath}"/data/ "${ocpath}"/themes/ /ssl/nextcloud/keys; do
chown -R ${htuser}:${htgroup} "$folder" || true
chown -R ${htuser}:${htgroup} "$folder" || true
done
printf "chmod/chown .htaccess\n"
if [ -f "${ocpath}"/.htaccess ]; then
chmod 0644 "${ocpath}"/.htaccess
chown "${rootuser}":"${htgroup}" "${ocpath}"/.htaccess
chmod 0644 "${ocpath}"/.htaccess
chown "${rootuser}":"${htgroup}" "${ocpath}"/.htaccess
fi
if [ -f "${ocpath}"/data/.htaccess ]; then
chmod 0644 "${ocpath}"/data/.htaccess
chown "${rootuser}":"${htgroup}" "${ocpath}"/data/.htaccess
chmod 0644 "${ocpath}"/data/.htaccess
chown "${rootuser}":"${htgroup}" "${ocpath}"/data/.htaccess
fi

View File

@@ -3,12 +3,12 @@
# Migrate files for new config location
slug="nextcloud-ocr"
if [ -f "/homeassistant/addons_config/$slug/config.yaml" ] && [ ! -f "/homeassistant/addons_config/$slug/migrated" ]; then
bashio::log.warning "Migrating config.yaml"
mv "/homeassistant/addons_config/$slug"/* /config/ || true
echo "Migrated to internal config folder accessible at /addon_configs/xxx-$slug" > "/homeassistant/addons_config/$slug/migrated"
bashio::log.warning "Migrating config.yaml"
mv "/homeassistant/addons_config/$slug"/* /config/ || true
echo "Migrated to internal config folder accessible at /addon_configs/xxx-$slug" >"/homeassistant/addons_config/$slug/migrated"
fi
if [ -f "/homeassistant/addons_autoscripts/$slug.sh" ]; then
bashio::log.warning "Migrating autoscript"
mv /homeassistant/addons_autoscripts/$slug.sh /config/ || true
bashio::log.warning "Migrating autoscript"
mv /homeassistant/addons_autoscripts/$slug.sh /config/ || true
fi

View File

@@ -3,11 +3,11 @@
set -e
if bashio::config.has_value "PUID" && bashio::config.has_value "PGID"; then
PUID="$(bashio::config "PUID")"
PGID="$(bashio::config "PGID")"
bashio::log.green "Setting user to $PUID:$PGID"
id -u abc &>/dev/null || usermod -o -u "$PUID" abc || true
id -g abc &>/dev/null || groupmod -o -g "$PGID" abc || true
PUID="$(bashio::config "PUID")"
PGID="$(bashio::config "PGID")"
bashio::log.green "Setting user to $PUID:$PGID"
id -u abc &>/dev/null || usermod -o -u "$PUID" abc || true
id -g abc &>/dev/null || groupmod -o -g "$PGID" abc || true
fi
echo "Updating permissions..."
@@ -18,44 +18,44 @@ chown -R "$PUID:$PGID" "/data/config"
# Check current version
if [ -f /data/config/www/nextcloud/config/config.php ]; then
datadirectory="$(sed -n "s|.*datadirectory.*' => '*\(.*[^ ]\) *',.*|\1|p" /data/config/www/nextcloud/config/config.php)"
echo "... data directory detected : $datadirectory"
datadirectory="$(sed -n "s|.*datadirectory.*' => '*\(.*[^ ]\) *',.*|\1|p" /data/config/www/nextcloud/config/config.php)"
echo "... data directory detected : $datadirectory"
else
datadirectory=/config/data
echo "Nextcloud is not installed yet, the default data directory is : $datadirectory. You can change it during nextcloud installation."
mkdir -p /config/data
chmod 777 /config/data
mkdir -p /share/nextcloud
chmod 777 /share/nextcloud
datadirectory=/config/data
echo "Nextcloud is not installed yet, the default data directory is : $datadirectory. You can change it during nextcloud installation."
mkdir -p /config/data
chmod 777 /config/data
mkdir -p /share/nextcloud
chmod 777 /share/nextcloud
fi
# Is the directory valid
if [[ "$datadirectory" == *"/mnt/"* ]] && [ ! -f "$datadirectory"/index.html ]; then
bashio::log.fatal "Data directory does not seem to be valid. Is your drive connected? Stopping to avoid corrupting the data directory."
bashio::addon.stop
bashio::log.fatal "Data directory does not seem to be valid. Is your drive connected? Stopping to avoid corrupting the data directory."
bashio::addon.stop
fi
# Remove nginx conf if existing
if [ -f /data/config/nginx/site-confs/default.conf ]; then
rm /data/config/nginx/site-confs/default.conf
# Avoid cannot enable app
sed -i "s|front_controller_active true|front_controller_active false|g" /defaults/nginx/site-confs/default.conf.sample
rm /data/config/nginx/site-confs/default.conf
# Avoid cannot enable app
sed -i "s|front_controller_active true|front_controller_active false|g" /defaults/nginx/site-confs/default.conf.sample
fi
# Set permissions
mkdir -p "$datadirectory"
if bashio::config.true "skip_permissions_check"; then
bashio::log.yellow "--------------------------------------------"
bashio::log.yellow "Permissions check skipped : \"skip_permissions_check\" is true"
bashio::log.yellow "--------------------------------------------"
bashio::log.yellow "--------------------------------------------"
bashio::log.yellow "Permissions check skipped : \"skip_permissions_check\" is true"
bashio::log.yellow "--------------------------------------------"
elif [[ "$PUID" = "0" ]] && [[ "$PGID" = "0" ]]; then
bashio::log.yellow "--------------------------------------------"
bashio::log.yellow "Permissions check skipped : \"PUID and PGID are 0\" is true"
bashio::log.yellow "--------------------------------------------"
bashio::log.yellow "--------------------------------------------"
bashio::log.yellow "Permissions check skipped : \"PUID and PGID are 0\" is true"
bashio::log.yellow "--------------------------------------------"
else
bashio::log.yellow "... setting permissions, this might take a long time. If it takes too long at each boot, you could instead activate skip_permissions_check in the addon options"
chmod 755 -R "$datadirectory" || true
chown -R "$PUID:$PGID" "$datadirectory" || true
bashio::log.yellow "... setting permissions, this might take a long time. If it takes too long at each boot, you could instead activate skip_permissions_check in the addon options"
chmod 755 -R "$datadirectory" || true
chown -R "$PUID:$PGID" "$datadirectory" || true
fi
mkdir -p /scripts

View File

@@ -12,12 +12,12 @@ if [ ! -f /app/www/public/occ ]; then cp /etc/cont-init.d/"$(basename "${BASH_SO
echo "Setting logs"
for var in /data/config/log/nginx/error.log /data/config/log/nginx/access.log /data/config/log/php/error.log; do
# Make sure directory exists
mkdir -p "$(dirname "$var")"
# Clean files
if [ -f "$var" ]; then rm -r "$var"; fi
# Create symlink
ln -sf /proc/1/fd/1 "$var"
# Make sure directory exists
mkdir -p "$(dirname "$var")"
# Clean files
if [ -f "$var" ]; then rm -r "$var"; fi
# Create symlink
ln -sf /proc/1/fd/1 "$var"
done
################
@@ -32,39 +32,39 @@ if [ -f /notinstalled ]; then exit 0; fi
# Check current version
if [ -f /data/config/www/nextcloud/config/config.php ]; then
CURRENTVERSION="$(sed -n "s|.*version.*' => '*\(.*[^ ]\) *',.*|\1|p" /data/config/www/nextcloud/config/config.php)"
CURRENTVERSION="$(sed -n "s|.*version.*' => '*\(.*[^ ]\) *',.*|\1|p" /data/config/www/nextcloud/config/config.php)"
else
CURRENTVERSION="Not found"
CURRENTVERSION="Not found"
fi
echo " "
# If not installed, or files not available
if [[ $($LAUNCHER -V 2>&1) == *"not installed"* ]] || [ ! -f /data/config/www/nextcloud/config/config.php ]; then
bashio::log.green "--------------------------------------------------------------------------------------------------------------"
bashio::log.yellow "Nextcloud not installed, please wait for addon startup, login Webui, install Nextcloud, then restart the addon"
bashio::log.green "--------------------------------------------------------------------------------------------------------------"
bashio::log.green " "
touch /notinstalled
exit 0
# Is there missing files
bashio::log.green "--------------------------------------------------------------------------------------------------------------"
bashio::log.yellow "Nextcloud not installed, please wait for addon startup, login Webui, install Nextcloud, then restart the addon"
bashio::log.green "--------------------------------------------------------------------------------------------------------------"
bashio::log.green " "
touch /notinstalled
exit 0
# Is there missing files
elif [[ $($LAUNCHER -V 2>&1) =~ ^"Nextcloud "[0-9].* ]]; then
# Log
bashio::log.green "----------------------------------------"
bashio::log.green " Nextcloud $CURRENTVERSION is installed "
bashio::log.green "----------------------------------------"
# Tentative to downgrade
# Log
bashio::log.green "----------------------------------------"
bashio::log.green " Nextcloud $CURRENTVERSION is installed "
bashio::log.green "----------------------------------------"
# Tentative to downgrade
else
bashio::log.red "-------------------------------------------------"
bashio::log.red " Unknown error detected, auto-repair will launch "
bashio::log.red "-------------------------------------------------"
bashio::log.red "Error message:"
bashio::log.red "$($LAUNCHER -V 2>&1)"
bashio::log.red "------------------------------------------------------------------"
sudo -u abc -s /bin/bash -c "php /app/www/public/occ maintenance:repair" || true
sudo -u abc -s /bin/bash -c "php /app/www/public/occ maintenance:repair-share-owner" || true
sudo -u abc -s /bin/bash -c "php /app/www/public/occ app:update --all" || true
sudo -u abc -s /bin/bash -c "php /app/www/public/occ upgrade" || true
bashio::log.red "-------------------------------------------------"
bashio::log.red " Unknown error detected, auto-repair will launch "
bashio::log.red "-------------------------------------------------"
bashio::log.red "Error message:"
bashio::log.red "$($LAUNCHER -V 2>&1)"
bashio::log.red "------------------------------------------------------------------"
sudo -u abc -s /bin/bash -c "php /app/www/public/occ maintenance:repair" || true
sudo -u abc -s /bin/bash -c "php /app/www/public/occ maintenance:repair-share-owner" || true
sudo -u abc -s /bin/bash -c "php /app/www/public/occ app:update --all" || true
sudo -u abc -s /bin/bash -c "php /app/www/public/occ upgrade" || true
fi
echo " "
@@ -75,10 +75,10 @@ echo " "
# Updater apps code
if ! bashio::config.true "disable_updates"; then
bashio::log.green "... checking for app updates"
sudo -u abc -s /bin/bash -c "php /app/www/public/occ app:update --all" || true
bashio::log.green "... checking for app updates"
sudo -u abc -s /bin/bash -c "php /app/www/public/occ app:update --all" || true
else
bashio::log.yellow "... disable_updates set, apps need to be updated manually"
bashio::log.yellow "... disable_updates set, apps need to be updated manually"
fi
###########################
@@ -101,8 +101,8 @@ echo "... Remove CODE if installed as not compatible"
################
if bashio::config.has_value "default_phone_region"; then
echo "... Define default_phone_region"
sudo -u abc php /app/www/public/occ config:system:set default_phone_region --value="$(bashio::config "default_phone_region")"
echo "... Define default_phone_region"
sudo -u abc php /app/www/public/occ config:system:set default_phone_region --value="$(bashio::config "default_phone_region")"
fi
######################
@@ -111,10 +111,10 @@ fi
echo "... Disabling check_data_directory_permissions"
for files in /defaults/config.php /data/config/www/nextcloud/config/config.php; do
if [ -f "$files" ]; then
sed -i "/check_data_directory_permissions/d" "$files"
sed -i "/datadirectory/a\ \ 'check_data_directory_permissions' => false," "$files"
fi
if [ -f "$files" ]; then
sed -i "/check_data_directory_permissions/d" "$files"
sed -i "/datadirectory/a\ \ 'check_data_directory_permissions' => false," "$files"
fi
done
timeout 10 sudo -u abc php /app/www/public/occ config:system:set check_data_directory_permissions --value=false --type=bool || echo "Please install nextcloud first"
@@ -123,12 +123,12 @@ timeout 10 sudo -u abc php /app/www/public/occ config:system:set check_data_dire
##################
for variable in env_memory_limit env_upload_max_filesize env_post_max_size; do
if bashio::config.has_value "$variable"; then
variable="${variable#env_}"
sed -i "/$variable/c $variable = $(bashio::config "env_$variable")" /etc/php*/conf.d/nextcloud.ini
sed -i "/$variable/c $variable = $(bashio::config "env_$variable")" /etc/php*/php.ini
bashio::log.blue "$variable set to $(bashio::config "env_$variable")"
fi
if bashio::config.has_value "$variable"; then
variable="${variable#env_}"
sed -i "/$variable/c $variable = $(bashio::config "env_$variable")" /etc/php*/conf.d/nextcloud.ini
sed -i "/$variable/c $variable = $(bashio::config "env_$variable")" /etc/php*/php.ini
bashio::log.blue "$variable set to $(bashio::config "env_$variable")"
fi
done
#####################
@@ -136,19 +136,19 @@ done
#####################
if bashio::config.true "enable_thumbnails"; then
echo "... enabling thumbnails"
# Add variables
sudo -u abc php /app/www/public/occ config:system:set preview_ffmpeg_path --value='/usr/bin/ffmpeg'
sudo -u abc php /app/www/public/occ config:system:set enable_previews --value=true
i=0
for element in AVI BMP Font GIF HEIC Image JPEG Krita MarkDown MKV Movie MP3 MP4 OpenDocument PDF PNG SVG TIFF TXT XBitmap; do # Comma separated values
sudo -u abc php /app/www/public/occ config:system:set enabledPreviewProviders "$i" --value="OC\\Preview\\${element}" >/dev/null
i=$((i + 1))
done
echo "... enabling thumbnails"
# Add variables
sudo -u abc php /app/www/public/occ config:system:set preview_ffmpeg_path --value='/usr/bin/ffmpeg'
sudo -u abc php /app/www/public/occ config:system:set enable_previews --value=true
i=0
for element in AVI BMP Font GIF HEIC Image JPEG Krita MarkDown MKV Movie MP3 MP4 OpenDocument PDF PNG SVG TIFF TXT XBitmap; do # Comma separated values
sudo -u abc php /app/www/public/occ config:system:set enabledPreviewProviders "$i" --value="OC\\Preview\\${element}" >/dev/null
i=$((i + 1))
done
else
# Remove variables
echo "... disabling thumbnails"
sudo -u abc php /app/www/public/occ config:system:set enable_previews --value=false
# Remove variables
echo "... disabling thumbnails"
sudo -u abc php /app/www/public/occ config:system:set enable_previews --value=false
fi
##########################
@@ -156,6 +156,6 @@ fi
##########################
if [[ "$(occ config:system:get maintenance_window_start)" == "" ]]; then
echo "... maintenance windows not set, it will be changed to 1"
sudo -u abc php /app/www/public/occ config:system:set maintenance_window_start --type=integer --value=1
echo "... maintenance windows not set, it will be changed to 1"
sudo -u abc php /app/www/public/occ config:system:set maintenance_window_start --type=integer --value=1
fi

View File

@@ -8,12 +8,12 @@ if [ ! -f /app/www/public/occ ]; then cp /etc/cont-init.d/"$(basename "${BASH_SO
if bashio::services.available 'mysql'; then
bashio::log.green "---"
bashio::log.yellow "MariaDB addon was found! It can't be configured automatically due to the way Nextcloud works, but you can configure it manually when running the web UI for the first time using those values :"
bashio::log.blue "Database user : $(bashio::services "mysql" "username")"
bashio::log.blue "Database password : $(bashio::services "mysql" "password")"
bashio::log.blue "Database name : nextcloud"
bashio::log.blue "Host-name : $(bashio::services "mysql" "host"):$(bashio::services "mysql" "port")"
bashio::log.green "---"
bashio::log.green "---"
bashio::log.yellow "MariaDB addon was found! It can't be configured automatically due to the way Nextcloud works, but you can configure it manually when running the web UI for the first time using those values :"
bashio::log.blue "Database user : $(bashio::services "mysql" "username")"
bashio::log.blue "Database password : $(bashio::services "mysql" "password")"
bashio::log.blue "Database name : nextcloud"
bashio::log.blue "Host-name : $(bashio::services "mysql" "host"):$(bashio::services "mysql" "port")"
bashio::log.green "---"
fi

View File

@@ -4,22 +4,22 @@ set -e
if bashio::config.true 'use_own_certs'; then
bashio::log.green "Using referenced ssl certificates"
CERTFILE=$(bashio::config 'certfile')
KEYFILE=$(bashio::config 'keyfile')
bashio::log.green "Using referenced ssl certificates"
CERTFILE=$(bashio::config 'certfile')
KEYFILE=$(bashio::config 'keyfile')
# Validate ssl
bashio::config.require.ssl
# Validate ssl
bashio::config.require.ssl
#Check if files exist
echo "... checking if referenced files exist"
[ ! -f /ssl/"$CERTFILE" ] && bashio::log.fatal "... use_own_certs is true but certificate /ssl/$CERTFILE not found" && bashio::exit.nok
[ ! -f /ssl/"$KEYFILE" ] && bashio::log.fatal "... use_own_certs is true but certificate /ssl/$KEYFILE not found" && bashio::exit.nok
#Check if files exist
echo "... checking if referenced files exist"
[ ! -f /ssl/"$CERTFILE" ] && bashio::log.fatal "... use_own_certs is true but certificate /ssl/$CERTFILE not found" && bashio::exit.nok
[ ! -f /ssl/"$KEYFILE" ] && bashio::log.fatal "... use_own_certs is true but certificate /ssl/$KEYFILE not found" && bashio::exit.nok
[[ -f /data/config/keys/cert.key ]] && rm /data/config/keys/cert.key
[[ -f /data/config/keys/cert.crt ]] && rm /data/config/keys/cert.crt
cp /ssl/"$CERTFILE" /data/config/keys/cert.crt
cp /ssl/"$KEYFILE" /data/config/keys/cert.key
echo "... done"
[[ -f /data/config/keys/cert.key ]] && rm /data/config/keys/cert.key
[[ -f /data/config/keys/cert.crt ]] && rm /data/config/keys/cert.crt
cp /ssl/"$CERTFILE" /data/config/keys/cert.crt
cp /ssl/"$KEYFILE" /data/config/keys/cert.key
echo "... done"
fi

View File

@@ -8,31 +8,30 @@ if [ ! -f /app/www/public/occ ]; then cp /etc/cont-init.d/"$(basename "${BASH_SO
# Install specific packages
if [ ! -d /data/config/www/nextcloud/apps/pdfannotate ]; then
CURRENT="$PWD"
cd /data/config/www/nextcloud/apps || exit
git clone https://gitlab.com/nextcloud-other/nextcloud-annotate pdfannotate
cd "$CURRENT" || exit
apk add --no-cache ghostscript >/dev/null
echo "Nextcloud annotate app added to Nextcloud app store"
CURRENT="$PWD"
cd /data/config/www/nextcloud/apps || exit
git clone https://gitlab.com/nextcloud-other/nextcloud-annotate pdfannotate
cd "$CURRENT" || exit
apk add --no-cache ghostscript >/dev/null
echo "Nextcloud annotate app added to Nextcloud app store"
fi
# Install specific apps
if bashio::config.has_value 'additional_apps'; then
bashio::log.info "Installing additional apps :"
NEWAPPS="$(bashio::config 'additional_apps')"
OIFS=$IFS
IFS=","
re='^( *).*'
read -ra array <<< "$NEWAPPS"
IFS=$OIFS
for element in "${array[@]}"
do
if [[ $element =~ $re ]]; then
# shellcheck disable=SC2295
APP="${element#${BASH_REMATCH[1]}}"
bashio::log.green "... $APP"
# shellcheck disable=SC2015,SC2086
apk add --no-cache $APP >/dev/null || bashio::log.red "... not successful, please check $APP package name"
fi
done
bashio::log.info "Installing additional apps :"
NEWAPPS="$(bashio::config 'additional_apps')"
OIFS=$IFS
IFS=","
re='^( *).*'
read -ra array <<<"$NEWAPPS"
IFS=$OIFS
for element in "${array[@]}"; do
if [[ $element =~ $re ]]; then
# shellcheck disable=SC2295
APP="${element#${BASH_REMATCH[1]}}"
bashio::log.green "... $APP"
# shellcheck disable=SC2015,SC2086
apk add --no-cache $APP >/dev/null || bashio::log.red "... not successful, please check $APP package name"
fi
done
fi

View File

@@ -16,54 +16,54 @@ PGID=$(bashio::config "PGID")
LAUNCHER="sudo -u abc php /app/www/public/occ"
if $LAUNCHER fulltextsearch:test &>/dev/null; then
echo "Full Text Search is already working"
echo "Full Text Search is already working"
############
# BASED ON #
#################################################################################
# https://raw.githubusercontent.com/nextcloud/vm/master/apps/fulltextsearch.sh #
# T&M Hansson IT AB © - 2021, https://www.hanssonit.se/ #
# SwITNet Ltd © - 2021, https://switnet.net/ #
#################################################################################
############
# BASED ON #
#################################################################################
# https://raw.githubusercontent.com/nextcloud/vm/master/apps/fulltextsearch.sh #
# T&M Hansson IT AB © - 2021, https://www.hanssonit.se/ #
# SwITNet Ltd © - 2021, https://switnet.net/ #
#################################################################################
if bashio::config.true 'Full_Text_Search'; then
if bashio::config.true 'Full_Text_Search'; then
# Get Full Text Search app for nextcloud
echo "Installing Full Text Search"
for app in "${APPS[@]}"; do
echo "... installing apps : $app"
$LAUNCHER app:install $app >/dev/null
$LAUNCHER app:enable $app >/dev/null
done
chown -R "$PUID":"$PGID" $NEXTCLOUD_PATH/apps
# Get Full Text Search app for nextcloud
echo "Installing Full Text Search"
for app in "${APPS[@]}"; do
echo "... installing apps : $app"
$LAUNCHER app:install $app >/dev/null
$LAUNCHER app:enable $app >/dev/null
done
chown -R "$PUID":"$PGID" $NEXTCLOUD_PATH/apps
if bashio::config.has_value 'elasticsearch_server'; then
HOST=$(bashio::config 'elasticsearch_server')
else
bashio::log.warning 'Please define elasticsearch server url in addon options. Default value of http://db21ed7f-elasticsearch:9200 will be used'
HOST=http://db21ed7f-elasticsearch:9200
fi
if bashio::config.has_value 'elasticsearch_server'; then
HOST=$(bashio::config 'elasticsearch_server')
else
bashio::log.warning 'Please define elasticsearch server url in addon options. Default value of http://db21ed7f-elasticsearch:9200 will be used'
HOST=http://db21ed7f-elasticsearch:9200
fi
# Final setup
echo "... settings apps"
$LAUNCHER fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"$HOST\"}" &>/dev/null
$LAUNCHER fulltextsearch_elasticsearch:configure "{\"elastic_index\":\"my_index\"}" &>/dev/null
$LAUNCHER fulltextsearch_elasticsearch:configure "{\"analyzer_tokenizer\":\"standard\"}" &>/dev/null
$LAUNCHER fulltextsearch:configure '{"search_platform":"OCA\\FullTextSearch_Elasticsearch\\Platform\\ElasticSearchPlatform"}' &>/dev/null || true
$LAUNCHER files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}" &>/dev/null || true
# Final setup
echo "... settings apps"
$LAUNCHER fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"$HOST\"}" &>/dev/null
$LAUNCHER fulltextsearch_elasticsearch:configure "{\"elastic_index\":\"my_index\"}" &>/dev/null
$LAUNCHER fulltextsearch_elasticsearch:configure "{\"analyzer_tokenizer\":\"standard\"}" &>/dev/null
$LAUNCHER fulltextsearch:configure '{"search_platform":"OCA\\FullTextSearch_Elasticsearch\\Platform\\ElasticSearchPlatform"}' &>/dev/null || true
$LAUNCHER files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}" &>/dev/null || true
# Is server detected
# Wait further for cache for index to work
echo "Waiting for a few seconds before indexing starts..."
sleep 5s
if $LAUNCHER fulltextsearch:test &>/dev/null; then
bashio::log.info "Full Text Search was successfully installed using elasticsearch server $HOST!"
# Is server detected
# Wait further for cache for index to work
echo "Waiting for a few seconds before indexing starts..."
sleep 5s
if $LAUNCHER fulltextsearch:test &>/dev/null; then
bashio::log.info "Full Text Search was successfully installed using elasticsearch server $HOST!"
else
else
bashio::log.warning "Elasticsearch can't connect. Please manually define its server in the options"
fi
else
echo "Full_Text_Search option not set"
fi
bashio::log.warning "Elasticsearch can't connect. Please manually define its server in the options"
fi
else
echo "Full_Text_Search option not set"
fi
fi

View File

@@ -11,36 +11,36 @@ if [ -f /notinstalled ]; then exit 0; fi
# Install OCR if requested
if [ "$(bashio::config 'OCR')" = "true" ]; then
# Install package
if bashio::config.true 'OCR'; then
# Install package
if bashio::config.true 'OCR'; then
# Get Full Text Search app for nextcloud
echo "... installing apps : fulltextsearch"
occ app:install files_fulltextsearch_tesseract &>/dev/null || true
occ app:enable files_fulltextsearch_tesseract &>/dev/null || true
# Get Full Text Search app for nextcloud
echo "... installing apps : fulltextsearch"
occ app:install files_fulltextsearch_tesseract &>/dev/null || true
occ app:enable files_fulltextsearch_tesseract &>/dev/null || true
echo "Installing OCR"
apk add --quiet --no-cache ocrmypdf
apk add --quiet --no-cache tesseract-ocr || apk add --quiet --no-cache tesseract-ocr@community
# Install additional language if requested
if bashio::config.has_value 'OCRLANG'; then
OCRLANG=$(bashio::config 'OCRLANG')
for LANG in $(echo "$OCRLANG" | tr "," " "); do
if [ "$LANG" != "eng" ]; then
apk add --quiet --no-cache tesseract-ocr-data-"$LANG" || apk add --quiet --no-cache tesseract-ocr-data-"$LANG"@community
fi
bashio::log.info "OCR Language installed : $LANG" || bashio::log.fatal "Couldn't install OCR lang $LANG. Please check its format is conform"
# Downloading trainer data
cd /usr/share/tessdata || true
rm -r "$LANG".traineddata &>/dev/null || true
wget https://github.com/tesseract-ocr/tessdata/raw/main/"$LANG".traineddata &>/dev/null
done
fi
elif [ "$(bashio::config 'OCR')" = "false" ]; then
bashio::log.info 'Removing OCR'
# Delete package
apk del tesseract-ocr.* &>/dev/null || true
# Remove app
occ app:disable files_fulltextsearch_tesseract &>/dev/null || true
fi
echo "Installing OCR"
apk add --quiet --no-cache ocrmypdf
apk add --quiet --no-cache tesseract-ocr || apk add --quiet --no-cache tesseract-ocr@community
# Install additional language if requested
if bashio::config.has_value 'OCRLANG'; then
OCRLANG=$(bashio::config 'OCRLANG')
for LANG in $(echo "$OCRLANG" | tr "," " "); do
if [ "$LANG" != "eng" ]; then
apk add --quiet --no-cache tesseract-ocr-data-"$LANG" || apk add --quiet --no-cache tesseract-ocr-data-"$LANG"@community
fi
bashio::log.info "OCR Language installed : $LANG" || bashio::log.fatal "Couldn't install OCR lang $LANG. Please check its format is conform"
# Downloading trainer data
cd /usr/share/tessdata || true
rm -r "$LANG".traineddata &>/dev/null || true
wget https://github.com/tesseract-ocr/tessdata/raw/main/"$LANG".traineddata &>/dev/null
done
fi
elif [ "$(bashio::config 'OCR')" = "false" ]; then
bashio::log.info 'Removing OCR'
# Delete package
apk del tesseract-ocr.* &>/dev/null || true
# Remove app
occ app:disable files_fulltextsearch_tesseract &>/dev/null || true
fi
fi

View File

@@ -19,33 +19,33 @@ LAUNCHER="sudo -u abc php /app/www/public/occ"
if bashio::config.has_value 'trusted_domains'; then
bashio::log.info "Currently set trusted domains :"
$LAUNCHER config:system:get trusted_domains || bashio::log.info "No trusted domain set yet. The first one will be set when doing initial configuration"
bashio::log.info "Currently set trusted domains :"
$LAUNCHER config:system:get trusted_domains || bashio::log.info "No trusted domain set yet. The first one will be set when doing initial configuration"
bashio::log.info "Trusted domains set in the configuration. Refreshing domains." &&
###################################
# Remove previous trusted domains #
###################################
bashio::log.info "... removing previously added trusted domain (except for first one created)"
i=2
until [ $i -gt 5 ]; do
$LAUNCHER config:system:delete trusted_domains $i &&
((i = i + 1)) || exit
done
bashio::log.info "Trusted domains set in the configuration. Refreshing domains." &&
###################################
# Remove previous trusted domains #
###################################
bashio::log.info "... removing previously added trusted domain (except for first one created)"
i=2
until [ $i -gt 5 ]; do
$LAUNCHER config:system:delete trusted_domains $i &&
((i = i + 1)) || exit
done
###########################
# Add new trusted domains #
###########################
TRUSTEDDOMAINS=$(bashio::config 'trusted_domains')
bashio::log.info "... alignement with trusted domains list : ${TRUSTEDDOMAINS}"
for domain in ${TRUSTEDDOMAINS//,/ }; do # Comma separated values
bashio::log.info "... adding ${domain}"
# shellcheck disable=SC2086
$LAUNCHER config:system:set trusted_domains $i --value="${domain}"
i=$((i + 1))
done
###########################
# Add new trusted domains #
###########################
TRUSTEDDOMAINS=$(bashio::config 'trusted_domains')
bashio::log.info "... alignement with trusted domains list : ${TRUSTEDDOMAINS}"
for domain in ${TRUSTEDDOMAINS//,/ }; do # Comma separated values
bashio::log.info "... adding ${domain}"
# shellcheck disable=SC2086
$LAUNCHER config:system:set trusted_domains $i --value="${domain}"
i=$((i + 1))
done
bashio::log.info "Remaining configurated trusted domains :"
bashio::log.info "$($LAUNCHER config:system:get trusted_domains)" || exit
bashio::log.info "Remaining configurated trusted domains :"
bashio::log.info "$($LAUNCHER config:system:get trusted_domains)" || exit
fi