chmod +x scripts

This commit is contained in:
Alexandre
2022-06-15 20:44:11 +02:00
parent 0047e2489f
commit 3351e5b29c
218 changed files with 0 additions and 9448 deletions

View File

@@ -1,50 +0,0 @@
#!/bin/bash
# If dockerfile failed install manually
##############################
# Automatic modules download #
##############################
if [ -e "/MODULESFILE" ]; then
MODULES=$(</MODULESFILE)
MODULES="${MODULES:-00-banner.sh}"
echo "Executing modules script : $MODULES"
if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
&& apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \
&& mkdir -p /etc/cont-init.d \
&& for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \
&& chmod -R 755 /etc/cont-init.d
fi
#######################
# Automatic installer #
#######################
if [ -e "/ENVFILE" ]; then
PACKAGES=$(</ENVFILE)
echo "Executing dependency script with custom elements : $PACKAGES"
if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
&& curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \
&& chmod 777 /automatic_packages.sh \
&& eval /./automatic_packages.sh "${PACKAGES:-}" \
&& rm /automatic_packages.sh
fi
if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then
for scripts in $MODULES; do
echo "$scripts : executing"
chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts"
chmod a+x /etc/cont-init.d/"$scripts"
/./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?"
rm /etc/cont-init.d/"$scripts"
done | tac
fi
#######################
# Correct permissions #
#######################
[ -d /etc/services.d ] && chmod -R 777 /etc/services.d
[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d

View File

@@ -1,14 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
# Config location
CONFIGLOCATION="$(bashio::config 'CONFIG_LOCATION')"
# Text
bashio::log.info "Setting config location to $CONFIGLOCATION"
# Adapt files
sed -i "s|/data/config|$CONFIGLOCATION|g" /etc/cont-init.d/*
# Avoid tamper issues
chown -R root:root "$CONFIGLOCATION"/custom*

View File

@@ -1,58 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
# Allow OCR setting
OCRLANG="$(bashio::config "ocrlang")"
#Define location place
CONFIGLOCATION="$(bashio::config "CONFIG_LOCATION")"
#If it's a file, get the folder
if [ ! -d "$CONFIGLOCATION" ]; then
CONFIGLOCATION="$(dirname "$CONFIGLOCATION")"
fi
#Correct previous bug
sed -i "s|OCRLANG|OCR_LANGUAGES|g" "$CONFIGLOCATION"/papermerge.conf.py
languageCount=$(echo "$OCRLANG" | tr -cd ',' | wc -c)
languageCount=$((languageCount+1))
bashio::log.info "Configuring ${languageCount} languages"
if [ -n "$OCRLANG" ]; then
lineStart=$(sed -n '/OCR_LANGUAGES/=' "$CONFIGLOCATION"/papermerge.conf.py)
bashio::log.info "OCRLANG variable is set, processing the language packages"
lineEnd=$(sed -n '/}/=' "$CONFIGLOCATION"/papermerge.conf.py)
sed -i "${lineStart},${lineEnd}d" "$CONFIGLOCATION"/papermerge.conf.py
bashio::log.info "Writing new configuration"
echo "OCR_LANGUAGES = {" >> "$CONFIGLOCATION"/papermerge.conf.py
languages=$(echo "$OCRLANG" | tr "," "\n")
apt-get update >/dev/null
i=0
for language in $languages; do
bashio::log.info "Processing language ${language}"
if apt-cache show tesseract-ocr-"${language}" >/dev/null 2>&1; then
bashio::log.info "Installing tesseract-ocr-${language}"
apt-get install -yqq tesseract-ocr-"${language}" >/dev/null
languageFullName=$(apt-cache show tesseract-ocr-"${language}" | grep -E '^(Description|Description-en):' | grep -oE '[^ ]+$')
bashio::log.info "${language} identified as ${languageFullName}"
i=$((i+1))
if [[ $i -eq $languageCount ]]; then
echo " \"$language\" : \"$languageFullName\"" >> "$CONFIGLOCATION"/papermerge.conf.py
elif [[ $i -eq 1 ]]; then
echo " \"$language\" : \"$languageFullName\"," >> "$CONFIGLOCATION"/papermerge.conf.py
bashio::log.info "Setting default language to ${language}"
sed -i "s/^OCR_DEFAULT_LANGUAGE = \"eng\"/OCR_DEFAULT_LANGUAGE = \"${language}\"/g" "$CONFIGLOCATION"/papermerge.conf.py
else
echo " \"$language\" : \"$languageFullName\"," >> "$CONFIGLOCATION"/papermerge.conf.py
fi
bashio::log.info "... ${language} installed"
else
bashio::log.info "Package tesseract-ocr-${language} not found in the repository, skipping"
fi
done
echo "}" >> "$CONFIGLOCATION"/papermerge.conf.py
fi

View File

@@ -1,73 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
##################
# SELECT FOLDERS #
##################
#Set media dir
MEDIADIR=$(bashio::config 'storage_dir')
#clean data
sed -i '/MEDIA_DIR/d' /data/config/papermerge.conf.py
#add data
sed -i "2 i\MEDIA_DIR = \"$MEDIADIR\"" /data/config/papermerge.conf.py
bashio::log.info "Storage dir set to $MEDIADIR"
#Set import dir
IMPORTDIR=$(bashio::config 'import_dir')
#clean data
sed -i '/IMPORTER_DIR/d' /data/config/papermerge.conf.py || true
#add data
sed -i "2 i\IMPORTER_DIR = \"$IMPORTDIR\"" /data/config/papermerge.conf.py
bashio::log.info "Import dir set to $IMPORTDIR"
##################
# CREATE FOLDERS #
##################
#if [ ! -d /data/config ]; then
# echo "Creating /config"
# mkdir -p /config
#fi
#chown -R abc:abc /config
if [ ! -d "$MEDIADIR" ]; then
echo "Creating $MEDIADIR"
mkdir -p "$MEDIADIR"
fi
chown -R abc:abc "$MEDIADIR"
if [ ! -d "$IMPORTDIR" ]; then
echo "Creating $IMPORTDIR"
mkdir -p "$IMPORTDIR"
fi
chown -R abc:abc "$IMPORTDIR"
##################
# CONFIGURE IMAP #
##################
IMAPHOST=$(bashio::config 'imaphost')
IMAPUSERNAME=$(bashio::config 'imapusername')
IMAPPASSWORD=$(bashio::config 'imappassword')
if [ "$IMAPHOST" != "null" ]; then
printf "\nIMPORT_MAIL_HOST = \"%s\"" "$IMAPHOST" >> /data/config/papermerge.conf.py
bashio::log.info "IMPORT_MAIL_HOST set to $IMAPHOST"
if [ "$IMAPUSERNAME" != "null" ]; then
printf "\nIMPORT_MAIL_USER = \"%s\"" "$IMAPUSERNAME" >> /data/config/papermerge.conf.py
bashio::log.info "IMPORT_MAIL_USER set to $IMAPUSERNAME"
else
bashio::log.info "! IMAPHOST has been set, but no IMAPUSERNAME. Please check your configuration!"
fi
if [ "$IMAPPASSWORD" != "null" ]; then
printf "\nIMPORT_MAIL_PASS = \"%s\"" "$IMAPPASSWORD" >> /data/config/papermerge.conf.py
IMAPPASSWORDMASKED=$(echo "$IMAPPASSWORD" | sed -r 's/./x/g')
bashio::log.info "IMPORT_MAIL_PASS set to $IMAPPASSWORDMASKED"
else
bashio::log.info "! IMAPHOST has been set, but no IMAPPASSWORD. Please check your configuration!"
fi
fi