mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-19 19:18:10 +01:00
Beautify bash
This commit is contained in:
@@ -46,10 +46,10 @@ chmod +x "${ocpath}"/occ
|
||||
|
||||
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
|
||||
|
||||
@@ -11,10 +11,10 @@ if [ -e "/MODULESFILE" ]; then
|
||||
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 \
|
||||
&& 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
|
||||
&& 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 \
|
||||
&& 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
|
||||
|
||||
#######################
|
||||
@@ -25,9 +25,9 @@ if [ -e "/ENVFILE" ]; then
|
||||
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
|
||||
&& 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
|
||||
|
||||
@@ -22,7 +22,7 @@ Brought to you by linuxserver.io
|
||||
-------------------------------------'
|
||||
if [[ -f /donate.txt ]]; then
|
||||
echo '
|
||||
To support the app dev(s) visit:'
|
||||
To support the app dev(s) visit:'
|
||||
cat /donate.txt
|
||||
fi
|
||||
echo '
|
||||
|
||||
@@ -3,22 +3,22 @@
|
||||
|
||||
if bashio::config.true 'use_own_certs'; then
|
||||
|
||||
bashio::log.info "Using referenced ssl certificates..."
|
||||
CERTFILE=$(bashio::config 'certfile')
|
||||
KEYFILE=$(bashio::config 'keyfile')
|
||||
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
|
||||
#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"
|
||||
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
|
||||
|
||||
@@ -26,13 +26,13 @@ fi
|
||||
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
|
||||
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
|
||||
fi
|
||||
done
|
||||
bashio::log.info "... done"
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
#create folders
|
||||
datadirectory=$(bashio::config 'data_directory')
|
||||
mkdir -p \
|
||||
"$datadirectory" \
|
||||
/data/config/nextcloud/config \
|
||||
/data/config/nextcloud/data \
|
||||
/data/config/www/nextcloud/config
|
||||
"$datadirectory" \
|
||||
/data/config/nextcloud/config \
|
||||
/data/config/nextcloud/data \
|
||||
/data/config/www/nextcloud/config
|
||||
|
||||
#permissions
|
||||
chown abc:abc \
|
||||
"$datadirectory" \
|
||||
/data/config/nextcloud/config \
|
||||
/data/config/nextcloud/data \
|
||||
/data/config/www/nextcloud/config
|
||||
"$datadirectory" \
|
||||
/data/config/nextcloud/config \
|
||||
/data/config/nextcloud/data \
|
||||
/data/config/www/nextcloud/config
|
||||
|
||||
chown -R abc:abc \
|
||||
/var/lib/nginx
|
||||
/var/lib/nginx
|
||||
|
||||
rm -r /data/config/www/nextcloud/assets &>/dev/null
|
||||
chmod -R 777 /data/config
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
# create folders
|
||||
mkdir -p \
|
||||
"${NEXTCLOUD_PATH}" \
|
||||
/data/config/crontabs
|
||||
"${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"
|
||||
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 /defaults/root /data/config/crontabs/root
|
||||
cp /data/config/crontabs/root /etc/crontabs/root
|
||||
|
||||
@@ -8,8 +8,8 @@ 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
|
||||
cp /defaults/config.php /data/config/www/nextcloud/config/config.php
|
||||
|
||||
# permissions
|
||||
chown abc:abc \
|
||||
/data/config/www/nextcloud/config/config.php
|
||||
/data/config/www/nextcloud/config/config.php
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#!/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"
|
||||
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
|
||||
|
||||
@@ -22,14 +22,14 @@ if bashio::config.has_value 'trusted_domains'; then
|
||||
$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)"
|
||||
###################################
|
||||
# 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
|
||||
((i = i + 1)) || exit
|
||||
done
|
||||
|
||||
###########################
|
||||
|
||||
Reference in New Issue
Block a user