mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-04-14 03:18:02 +02:00
New logic
This commit is contained in:
18
nextcloud/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh
Normal file
18
nextcloud/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
# If dockerfile failed install manually
|
||||
if [ -e "/ENVFILE" ]; then
|
||||
echo "Executing script"
|
||||
PACKAGES=$(</ENVFILE)
|
||||
(
|
||||
#######################
|
||||
# Automatic installer #
|
||||
#######################
|
||||
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); 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); fi &&
|
||||
curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh &&
|
||||
chmod 777 /automatic_packages.sh &&
|
||||
eval /./automatic_packages.sh "$PACKAGES" &&
|
||||
rm /automatic_packages.sh
|
||||
) >/dev/null
|
||||
|
||||
fi
|
||||
39
nextcloud/rootfs/etc/cont-init.d/00-banner.sh
Normal file
39
nextcloud/rootfs/etc/cont-init.d/00-banner.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Displays a simple add-on banner on startup
|
||||
# ==============================================================================
|
||||
|
||||
if bashio::supervisor.ping; then
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
bashio::log.blue " Add-on: $(bashio::addon.name)"
|
||||
bashio::log.blue " $(bashio::addon.description)"
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
|
||||
bashio::log.blue " Add-on version: $(bashio::addon.version)"
|
||||
if bashio::var.true "$(bashio::addon.update_available)"; then
|
||||
bashio::log.magenta ' There is an update available for this add-on!'
|
||||
bashio::log.magenta \
|
||||
" Latest add-on version: $(bashio::addon.version_latest)"
|
||||
bashio::log.magenta ' Please consider upgrading as soon as possible.'
|
||||
else
|
||||
bashio::log.green ' You are running the latest version of this add-on.'
|
||||
fi
|
||||
|
||||
bashio::log.blue " System: $(bashio::info.operating_system)" \
|
||||
" ($(bashio::info.arch) / $(bashio::info.machine))"
|
||||
bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)"
|
||||
bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)"
|
||||
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
bashio::log.blue \
|
||||
' Please, share the above information when looking for help'
|
||||
bashio::log.blue \
|
||||
' or support in, e.g., GitHub, forums'
|
||||
bashio::log.green \
|
||||
' https://github.com/alexbelgium/hassio-addons'
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
fi
|
||||
39
nextcloud/rootfs/etc/cont-init.d/10-adduser
Normal file
39
nextcloud/rootfs/etc/cont-init.d/10-adduser
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
PUID=$(bashio::config "PUID")
|
||||
PGID=$(bashio::config "PGID")
|
||||
|
||||
groupmod -o -g "$PGID" abc
|
||||
usermod -o -u "$PUID" abc
|
||||
mkdir -p /data/config
|
||||
mkdir -p /share/nextcloud
|
||||
echo '
|
||||
-------------------------------------
|
||||
_ ()
|
||||
| | ___ _ __
|
||||
| | / __| | | / \
|
||||
| | \__ \ | | | () |
|
||||
|_| |___/ |_| \__/
|
||||
|
||||
|
||||
Brought to you by linuxserver.io
|
||||
-------------------------------------'
|
||||
if [[ -f /donate.txt ]]; then
|
||||
echo '
|
||||
To support the app dev(s) visit:'
|
||||
cat /donate.txt
|
||||
fi
|
||||
echo '
|
||||
To support LSIO projects visit:
|
||||
https://www.linuxserver.io/donate/
|
||||
-------------------------------------
|
||||
GID/UID
|
||||
-------------------------------------'
|
||||
echo "
|
||||
User uid: $(id -u abc)
|
||||
User gid: $(id -g abc)
|
||||
-------------------------------------
|
||||
"
|
||||
chown abc:abc /app
|
||||
chown abc:abc /data/config
|
||||
chown abc:abc /defaults
|
||||
37
nextcloud/rootfs/etc/cont-init.d/30-keygen
Normal file
37
nextcloud/rootfs/etc/cont-init.d/30-keygen
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
if bashio::config.true 'use_own_certs'; then
|
||||
|
||||
bashio::log.info "Using referenced ssl certificates..."
|
||||
CERTFILE=$(bashio::config 'certfile')
|
||||
KEYFILE=$(bashio::config 'keyfile')
|
||||
|
||||
#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
|
||||
|
||||
else
|
||||
mkdir -p /ssl/nextcloud/keys
|
||||
bashio::log.info "No ssl certificates set. Auto generating ones..."
|
||||
SUBJECT="/C=US/ST=CA/L=Carlsbad/O=Linuxserver.io/OU=LSIO Server/CN=*"
|
||||
openssl req -new -x509 -days 3650 -nodes -out /ssl/nextcloud/keys/cert.crt -keyout /ssl/nextcloud/keys/cert.key -subj "$SUBJECT"
|
||||
CERTFILE="nextcloud/keys/cert.crt"
|
||||
KEYFILE="nextcloud/keys/cert.key"
|
||||
|
||||
fi
|
||||
|
||||
#Sets certificates
|
||||
echo "... adding ssl certs in files"
|
||||
#Sets certificates
|
||||
for NGINXFILE in "/defaults/default" "/config/nginx/site-confs/default" "/data/config/nginx/site-confs/default"; do
|
||||
if [ -f $NGINXFILE ]; then
|
||||
LINE=$(sed -n "/ssl_certificate /=" $NGINXFILE)
|
||||
if [ ! -z $LINE ]; then
|
||||
sed -i "/ssl_certificate/ d" $NGINXFILE
|
||||
sed -i "$LINE a ssl_certificate_key /ssl/$KEYFILE;" $NGINXFILE
|
||||
sed -i "$LINE a ssl_certificate /ssl/$CERTFILE;" $NGINXFILE
|
||||
fi
|
||||
fi
|
||||
done
|
||||
bashio::log.info "... done"
|
||||
19
nextcloud/rootfs/etc/cont-init.d/40-config
Normal file
19
nextcloud/rootfs/etc/cont-init.d/40-config
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
#create folders
|
||||
mkdir -p \
|
||||
/share/nextcloud \
|
||||
/data/config/nextcloud/config \
|
||||
/data/config/nextcloud/data
|
||||
|
||||
#permissions
|
||||
chown abc:abc \
|
||||
/share/nextcloud \
|
||||
/data/config/nextcloud/config \
|
||||
/data/config/nextcloud/data
|
||||
|
||||
chown -R abc:abc \
|
||||
/var/lib/nginx
|
||||
|
||||
rm -r /data/config/www/nextcloud/assets &>/dev/null
|
||||
chmod -R 777 /data/config
|
||||
21
nextcloud/rootfs/etc/cont-init.d/50-install
Normal file
21
nextcloud/rootfs/etc/cont-init.d/50-install
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# create folders
|
||||
mkdir -p \
|
||||
"${NEXTCLOUD_PATH}" \
|
||||
/data/config/crontabs
|
||||
|
||||
# install app
|
||||
if [ ! -e "${NEXTCLOUD_PATH}/index.php" ]; then
|
||||
tar xf /app/nextcloud.tar.bz2 -C \
|
||||
"${NEXTCLOUD_PATH}" --strip-components=1
|
||||
chown abc:abc -R \
|
||||
"${NEXTCLOUD_PATH}"
|
||||
chmod +x "${NEXTCLOUD_PATH}/occ"
|
||||
fi
|
||||
|
||||
#?set cronjob
|
||||
[[ ! -f /data/config/crontabs/root ]] && \
|
||||
cp /defaults/root /data/config/crontabs/root
|
||||
cp /data/config/crontabs/root /etc/crontabs/root
|
||||
|
||||
9
nextcloud/rootfs/etc/cont-init.d/60-memcache
Normal file
9
nextcloud/rootfs/etc/cont-init.d/60-memcache
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# copy config
|
||||
[[ ! -f /data/config/www/nextcloud/config/config.php ]] && \
|
||||
cp /defaults/config.php /data/config/www/nextcloud/config/config.php
|
||||
|
||||
# permissions
|
||||
chown abc:abc \
|
||||
/data/config/www/nextcloud/config/config.php
|
||||
76
nextcloud/rootfs/etc/cont-init.d/99-elasticsearch
Normal file
76
nextcloud/rootfs/etc/cont-init.d/99-elasticsearch
Normal file
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ" || bashio::log.info "/data/config/www/nextcloud/occ not found"
|
||||
if ! bashio::fs.file_exists '/data/config/www/nextcloud/occ'; then
|
||||
LAUNCHER=$(find / -name "occ" -print -quit)
|
||||
fi || bashio::log.info "occ not found"
|
||||
|
||||
# Make sure there is an Nextcloud installation
|
||||
if [[ $($LAUNCHER -V) == *"not installed"* ]]; then
|
||||
bashio::log.warning "It seems there is no Nextcloud server installed. Please restart the addon after initialization of the user."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
############
|
||||
# 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 [ $LAUNCHER fulltextsearch:index ] &>/dev/null; then
|
||||
echo "Full Text Search is already working"
|
||||
break 2
|
||||
fi
|
||||
|
||||
echo "Installing Full Text Search"
|
||||
# Reset Full Text Search to be able to index again, and also remove the app to be able to install it again
|
||||
occ fulltextsearch:reset &>/dev/null || true
|
||||
APPS=(fulltextsearch fulltextsearch_elasticsearch files_fulltextsearch)
|
||||
for app in "${APPS[@]}"; do
|
||||
# If app exists, remove it
|
||||
[ ! -z $($LAUNCHER app:getpath $app) ] && $LAUNCHER app:remove $app &>/dev/null
|
||||
done
|
||||
|
||||
# Get Full Text Search app for nextcloud
|
||||
for app in "${APPS[@]}"; do
|
||||
echo "... installing apps : $app"
|
||||
$LAUNCHER app:install $app >/dev/null
|
||||
$LAUNCHER app:enable $app >/dev/null
|
||||
done
|
||||
chown -R abc:abc $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 with the format "ip:port" such as "192.168.178.1:9200"'
|
||||
HOST=$(bashio::network.ipv4_address)
|
||||
HOST="${HOST%/*}:9200"
|
||||
fi
|
||||
|
||||
# Final setup
|
||||
echo "... settings apps"
|
||||
#occ fulltextsearch:configure '{"search_platform":"ElasticSearchPlatform"}'
|
||||
$LAUNCHER fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"http://$HOST:9200\"}" &>/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
|
||||
# if [ curl $HOST ] &>/dev/null; then
|
||||
# Wait further for cache for index to work
|
||||
echo "Waiting for a few seconds before indexing starts..."
|
||||
sleep 10s
|
||||
if $LAUNCHER fulltextsearch:index &>/dev/null; then
|
||||
bashio::log.info "Full Text Search was successfully installed using elasticsearch server $HOST!"
|
||||
|
||||
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
|
||||
45
nextcloud/rootfs/etc/cont-init.d/99-ocr
Normal file
45
nextcloud/rootfs/etc/cont-init.d/99-ocr
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ" || bashio::log.info "/data/config/www/nextcloud/occ not found"
|
||||
if ! bashio::fs.file_exists '/data/config/www/nextcloud/occ'; then
|
||||
LAUNCHER=$(find / -name "occ" -print -quit)
|
||||
fi || bashio::log.info "occ not found"
|
||||
|
||||
# Make sure there is an Nextcloud installation
|
||||
if [[ $($LAUNCHER -V) == *"not installed"* ]]; then
|
||||
bashio::log.warning "It seems there is no Nextcloud server installed. Please restart the addon after initialization of the user."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Install OCR if requested
|
||||
if bashio::config.has_value 'OCR'; then
|
||||
# Install package
|
||||
if $(bashio::config 'OCR') = true; 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
|
||||
|
||||
echo "Installing OCR"
|
||||
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
|
||||
LANG=$(bashio::config 'OCRLANG')
|
||||
apk add --quiet --no-cache tesseract-ocr-data-$LANG || apk add --quiet --no-cache tesseract-ocr-data-$LANG@community && \
|
||||
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
|
||||
sudo rm -r $LANG.traineddata &>/dev/null || true
|
||||
wget https://github.com/tesseract-ocr/tessdata/raw/main/$LANG.traineddata &>/dev/null
|
||||
|
||||
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
|
||||
48
nextcloud/rootfs/etc/cont-init.d/99-trusted_domains
Normal file
48
nextcloud/rootfs/etc/cont-init.d/99-trusted_domains
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
|
||||
LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ" || bashio::log.info "/data/config/www/nextcloud/occ not found"
|
||||
if ! bashio::fs.file_exists '/data/config/www/nextcloud/occ'; then
|
||||
LAUNCHER=$(find / -name "occ" -print -quit)
|
||||
fi || bashio::log.info "occ not found"
|
||||
|
||||
# Make sure there is an Nextcloud installation
|
||||
if [[ $($LAUNCHER -V) == *"not installed"* ]]; then
|
||||
bashio::log.warning "It seems there is no Nextcloud server installed. Please restart the addon after initialization of the user."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
####################
|
||||
# Initialization #
|
||||
####################
|
||||
|
||||
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 "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}"
|
||||
$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
|
||||
|
||||
fi
|
||||
3
nextcloud/rootfs/etc/services.d/cron/run
Normal file
3
nextcloud/rootfs/etc/services.d/cron/run
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
/usr/sbin/crond -f -S -l 0 -c /etc/crontabs
|
||||
Reference in New Issue
Block a user