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,55 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
ocpath="${NEXTCLOUD_PATH}"
htuser='abc'
htgroup='abc'
rootuser='root'
datadirectory=$(bashio::config 'data_directory')
printf "Creating possible missing Directories\n"
mkdir -p "$ocpath"/data
mkdir -p "$ocpath"/assets
mkdir -p "$ocpath"/updater
mkdir -p "$ocpath"/apps
mkdir -p "$ocpath"/assets
mkdir -p "$ocpath"/config
mkdir -p "$ocpath"/data
mkdir -p "$ocpath"/themes
mkdir -p /data/config/nextcloud/config
mkdir -p /data/config/nextcloud/data
mkdir -p /data/config/www/nextcloud/occ 2>/dev/null
mkdir -p "$datadirectory"
mkdir -p /ssl/nextcloud/keys
printf "chmod Files and Directories. This could take some time, please wait...\n"
#chmod -R 777 "${ocpath}"
find "${ocpath}"/ -type f -exec chmod 0640 {} \;
find "${ocpath}"/ -type d -exec chmod 0750 {} \;
#find "${ocpath}"/ -type f -print0 | xargs -0 chmod 0640
#find "${ocpath}"/ -type d -print0 | xargs -0 chmod 0750
printf "chown Directories. This could take some time, please wait...\n"
chown -R ${rootuser}:${htgroup} "${ocpath}"/
chown -R ${htuser}:${htgroup} "${ocpath}"/apps/
chown -R ${htuser}:${htgroup} "${ocpath}"/assets/
chown -R ${htuser}:${htgroup} "${ocpath}"/config/
chown -R ${htuser}:${htgroup} "${ocpath}"/data/
chown -R ${htuser}:${htgroup} "${ocpath}"/themes/
chown -R ${htuser}:${htgroup} "${ocpath}"/updater/
chown -R ${htuser}:${htgroup} "${datadirectory}"
chown -R ${htuser}:${htgroup} /ssl/nextcloud/keys || true
chmod +x "${ocpath}"/occ
printf "chmod/chown .htaccess\n"
if [ -f "${ocpath}"/.htaccess ]; then
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
fi

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,43 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
PUID=$(bashio::config "PUID")
PGID=$(bashio::config "PGID")
datadirectory=$(bashio::config 'data_directory')
groupmod -o -g "$PGID" abc
usermod -o -u "$PUID" abc
mkdir -p /data/config
mkdir -p "$datadirectory"
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
rm /config/nginx/site-confs/default 2>/dev/null || true

View File

@@ -1,38 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
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 [[ -n "$LINE" ]]; then
sed -i "/ssl_certificate/ d" $NGINXFILE
sed -i "$LINE i ssl_certificate_key /ssl/$KEYFILE;" $NGINXFILE
sed -i "$LINE i ssl_certificate /ssl/$CERTFILE;" $NGINXFILE
fi
fi
done
bashio::log.info "... done"

View File

@@ -1,30 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
#create folders
echo "Creating folders"
datadirectory=$(bashio::config 'data_directory')
mkdir -p \
"$datadirectory" \
/data/config/nextcloud/config \
/data/config/nextcloud/data \
/data/config/www/nextcloud/config
#permissions
PUID="$(bashio::config 'PUID')"
PGID="$(bashio::config 'PGID')"
chown -R "$PUID":"$PGID" \
"$datadirectory" \
/data/config/nextcloud/config \
/data/config/nextcloud/data \
/data/config/www/nextcloud/config \
/data
chown -R abc:abc \
/var/lib/nginx
rm -r /data/config/www/nextcloud/assets &>/dev/null || true
echo "Updating permissions"
chmod -R 777 /data/config
chmod -R 755 "$datadirectory"

View File

@@ -1,22 +0,0 @@
#!/bin/bash
NEXTCLOUD_PATH="/data/config/www/nextcloud"
# 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

View File

@@ -1,15 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
# Change data directory
datadirectory=$(bashio::config 'data_directory')
bashio::log.info "Setting data diretory: ${datadirectory}"
sed -i "s|%%datadirectory%%|$datadirectory|g" /defaults/config.php
# 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

View File

@@ -1,10 +0,0 @@
#!/bin/bash
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"
fi

View File

@@ -1,79 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
# shellcheck disable=SC2086
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
# shellcheck disable=SC1073,SC1072,SC1009
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
[ -n $($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

View File

@@ -1,10 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
if bashio::services.available 'mysql'; then
bashio::log.warning "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")"
fi

View File

@@ -1,48 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
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 'OCR')" = "true" ]; 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
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
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

@@ -1,50 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
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}"
# 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
fi