mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-28 02:06:04 +02:00
nginx update
This commit is contained in:
@@ -117,6 +117,6 @@
|
|||||||
},
|
},
|
||||||
"slug": "webtop-kde",
|
"slug": "webtop-kde",
|
||||||
"url": "https://github.com/alexbelgium/hassio-addons",
|
"url": "https://github.com/alexbelgium/hassio-addons",
|
||||||
"version": "4.16-r0-ls89-test10",
|
"version": "4.16-r0-ls89-test11",
|
||||||
"video": true
|
"video": true
|
||||||
}
|
}
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
|
||||||
# shellcheck shell=bash
|
|
||||||
# shellcheck disable=SC2046
|
|
||||||
|
|
||||||
# Define user
|
|
||||||
PUID=$(bashio::config "PUID")
|
|
||||||
PGID=$(bashio::config "PGID")
|
|
||||||
|
|
||||||
# Check data location
|
|
||||||
LOCATION=$(bashio::config 'data_location')
|
|
||||||
|
|
||||||
if [[ "$LOCATION" = "null" || -z "$LOCATION" ]]; then
|
|
||||||
# Default location
|
|
||||||
LOCATION="/share/webtop_kde"
|
|
||||||
else
|
|
||||||
bashio::log.warning "Warning : a custom data location was selected, but the previous folder will NOT be copied. You need to do it manually"
|
|
||||||
|
|
||||||
# Check if config is located in an acceptable location
|
|
||||||
LOCATIONOK=""
|
|
||||||
for location in "/share" "/config" "/data" "/mnt"; do
|
|
||||||
if [[ "$LOCATION" == "$location"* ]]; then
|
|
||||||
LOCATIONOK=true
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -z "$LOCATIONOK" ]; then
|
|
||||||
LOCATION="/share/webtop_kde"
|
|
||||||
bashio::log.fatal "Your data_location value can only be set in /share, /config or /data (internal to addon). It will be reset to the default location : $LOCATION"
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set data location
|
|
||||||
bashio::log.info "Setting data location to $LOCATION"
|
|
||||||
|
|
||||||
# Correct home locations
|
|
||||||
for file in /etc/s6-overlay/s6-rc.d/*/run; do
|
|
||||||
if [ "$(sed -n '1{/bash/p};q' "$file")" ]; then
|
|
||||||
sed -i "1a export HOME=$LOCATION" "$file"
|
|
||||||
sed -i "1a export FM_HOME=$LOCATION" "$file"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Correct home location
|
|
||||||
for folders in /defaults /etc/cont-init.d /etc/services.d /etc/s6-overlay/s6-rc.d; do
|
|
||||||
if [ -d "$folders" ]; then
|
|
||||||
sed -i "s|/share/webtop_kde|$LOCATION|g" $(find "$folders" -type f)
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Change user home
|
|
||||||
usermod --home "$LOCATION" abc
|
|
||||||
|
|
||||||
# Add environment variables
|
|
||||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$LOCATION" > /var/run/s6/container_environment/HOME; fi
|
|
||||||
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$LOCATION" > /var/run/s6/container_environment/FM_HOME; fi
|
|
||||||
{
|
|
||||||
printf "%s" "HOME=\"$LOCATION\""
|
|
||||||
printf "%s" "FM_HOME=\"$LOCATION\""
|
|
||||||
} >> ~/.bashrc
|
|
||||||
|
|
||||||
# Create folder
|
|
||||||
echo "Creating $LOCATION"
|
|
||||||
mkdir -p "$LOCATION"
|
|
||||||
|
|
||||||
# Set ownership
|
|
||||||
bashio::log.info "Setting ownership to $PUID:$PGID"
|
|
||||||
chown -R "$PUID":"$PGID" "$LOCATION"
|
|
||||||
@@ -1,10 +1,68 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
#!/usr/bin/with-contenv bashio
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
# shellcheck disable=SC2046
|
||||||
|
|
||||||
# Define home
|
# Define user
|
||||||
HOME="/share/webtop_kde"
|
PUID=$(bashio::config "PUID")
|
||||||
mkdir -p $HOME
|
PGID=$(bashio::config "PGID")
|
||||||
chown -R abc:abc $HOME
|
|
||||||
|
|
||||||
#adduser USERNAME
|
# Check data location
|
||||||
#useradd -m abc -p abc
|
LOCATION=$(bashio::config 'data_location')
|
||||||
|
|
||||||
|
if [[ "$LOCATION" = "null" || -z "$LOCATION" ]]; then
|
||||||
|
# Default location
|
||||||
|
LOCATION="/share/webtop_kde"
|
||||||
|
else
|
||||||
|
bashio::log.warning "Warning : a custom data location was selected, but the previous folder will NOT be copied. You need to do it manually"
|
||||||
|
|
||||||
|
# Check if config is located in an acceptable location
|
||||||
|
LOCATIONOK=""
|
||||||
|
for location in "/share" "/config" "/data" "/mnt"; do
|
||||||
|
if [[ "$LOCATION" == "$location"* ]]; then
|
||||||
|
LOCATIONOK=true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$LOCATIONOK" ]; then
|
||||||
|
LOCATION="/share/webtop_kde"
|
||||||
|
bashio::log.fatal "Your data_location value can only be set in /share, /config or /data (internal to addon). It will be reset to the default location : $LOCATION"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set data location
|
||||||
|
bashio::log.info "Setting data location to $LOCATION"
|
||||||
|
|
||||||
|
# Correct home locations
|
||||||
|
for file in /etc/s6-overlay/s6-rc.d/*/run; do
|
||||||
|
if [ "$(sed -n '1{/bash/p};q' "$file")" ]; then
|
||||||
|
sed -i "1a export HOME=$LOCATION" "$file"
|
||||||
|
sed -i "1a export FM_HOME=$LOCATION" "$file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Correct home location
|
||||||
|
for folders in /defaults /etc/cont-init.d /etc/services.d /etc/s6-overlay/s6-rc.d; do
|
||||||
|
if [ -d "$folders" ]; then
|
||||||
|
sed -i "s|/share/webtop_kde|$LOCATION|g" $(find "$folders" -type f)
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Change user home
|
||||||
|
usermod --home "$LOCATION" abc
|
||||||
|
|
||||||
|
# Add environment variables
|
||||||
|
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$LOCATION" > /var/run/s6/container_environment/HOME; fi
|
||||||
|
if [ -d /var/run/s6/container_environment ]; then printf "%s" "$LOCATION" > /var/run/s6/container_environment/FM_HOME; fi
|
||||||
|
{
|
||||||
|
printf "%s" "HOME=\"$LOCATION\""
|
||||||
|
printf "%s" "FM_HOME=\"$LOCATION\""
|
||||||
|
} >> ~/.bashrc
|
||||||
|
|
||||||
|
# Create folder
|
||||||
|
echo "Creating $LOCATION"
|
||||||
|
mkdir -p "$LOCATION"
|
||||||
|
|
||||||
|
# Set ownership
|
||||||
|
bashio::log.info "Setting ownership to $PUID:$PGID"
|
||||||
|
chown -R "$PUID":"$PGID" "$LOCATION"
|
||||||
|
|||||||
@@ -2,41 +2,24 @@
|
|||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
# nginx Path
|
# nginx Path
|
||||||
NGINX_CONFIG=/etc/nginx/http.d/ingress.conf
|
NGINX_CONFIG=/etc/nginx/sites-available/ingress.conf
|
||||||
|
|
||||||
# user passed env vars
|
# user passed env vars
|
||||||
CPORT="${CUSTOM_PORT:-3000}"
|
CPORT="${CUSTOM_PORT:-3000}"
|
||||||
CHPORT="${CUSTOM_HTTPS_PORT:-3001}"
|
CHPORT="${CUSTOM_HTTPS_PORT:-3001}"
|
||||||
CUSER="${CUSTOM_USER:-abc}"
|
CUSER="${CUSTOM_USER:-abc}"
|
||||||
|
|
||||||
# create self signed cert
|
|
||||||
if [ ! -f "/config/ssl/cert.pem" ]; then
|
|
||||||
mkdir -p /config/ssl
|
|
||||||
openssl req -new -x509 \
|
|
||||||
-days 3650 -nodes \
|
|
||||||
-out /config/ssl/cert.pem \
|
|
||||||
-keyout /config/ssl/cert.key \
|
|
||||||
-subj "/C=US/ST=CA/L=Carlsbad/O=Linuxserver.io/OU=LSIO Server/CN=*"
|
|
||||||
chmod 600 /config/ssl/cert.key
|
|
||||||
chown -R abc:abc /config/ssl
|
|
||||||
fi
|
|
||||||
|
|
||||||
# modify nginx config
|
# modify nginx config
|
||||||
cp /defaults/default.conf ${NGINX_CONFIG}
|
cp /defaults/default.conf ${NGINX_CONFIG}
|
||||||
sed -i "s/3000/$CPORT/g" ${NGINX_CONFIG}
|
sed -i '/listen \[::\]/d' ${NGINX_CONFIG}
|
||||||
sed -i "s/3001/$CHPORT/g" ${NGINX_CONFIG}
|
|
||||||
if [ ! -z ${DISABLE_IPV6+x} ]; then
|
|
||||||
sed -i '/listen \[::\]/d' ${NGINX_CONFIG}
|
|
||||||
fi
|
|
||||||
if [ ! -z ${PASSWORD+x} ]; then
|
|
||||||
printf "${CUSER}:$(openssl passwd -apr1 ${PASSWORD})\n" > /etc/nginx/.htpasswd
|
|
||||||
sed -i 's/#//g' ${NGINX_CONFIG}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add ingress parameters
|
# Add ingress parameters
|
||||||
sed -i '/server {/a include /etc/nginx/includes/server_params.conf;' ${NGINX_CONFIG}
|
sed -i '/server {/a include /etc/nginx/includes/server_params.conf;' ${NGINX_CONFIG}
|
||||||
sed -i '/server {/a include /etc/nginx/includes/proxy_params.conf;;' ${NGINX_CONFIG}
|
sed -i '/server {/a include /etc/nginx/includes/proxy_params.conf;;' ${NGINX_CONFIG}
|
||||||
sed -i 's|3000 default_server;|%%interface%%:%%port%% default_server;|g' ${NGINX_CONFIG}
|
sed -i 's|3000 default_server;|%%port%% default_server;|g' ${NGINX_CONFIG}
|
||||||
|
|
||||||
# Implement SUBFOLDER value
|
# Implement SUBFOLDER value
|
||||||
sed -i "1a SUBFOLDER=$(bashio::addon.ingress_url)" /etc/s6-overlay/s6-rc.d/svc-autostart/run || true
|
sed -i "1a SUBFOLDER=$(bashio::addon.ingress_url)" /etc/s6-overlay/s6-rc.d/svc-autostart/run || true
|
||||||
|
|
||||||
|
# Enable ingress
|
||||||
|
cp /etc/nginx/sites-available/ingress.conf /etc/nginx/sites-enabled
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
# This is run inside Docker.
|
|
||||||
user root;
|
|
||||||
|
|
||||||
# Pid storage location.
|
|
||||||
pid /var/run/nginx.pid;
|
|
||||||
|
|
||||||
# Set number of worker processes.
|
|
||||||
worker_processes 1;
|
|
||||||
|
|
||||||
# Enables the use of JIT for regular expressions to speed-up their processing.
|
|
||||||
pcre_jit on;
|
|
||||||
|
|
||||||
# Write error log to Hass.io add-on log.
|
|
||||||
error_log /proc/1/fd/1 error;
|
|
||||||
|
|
||||||
# Load allowed environment vars
|
|
||||||
env HASSIO_TOKEN;
|
|
||||||
|
|
||||||
# Load dynamic modules.
|
|
||||||
include /etc/nginx/modules/*.conf;
|
|
||||||
|
|
||||||
# Max num of simultaneous connections by a worker process.
|
|
||||||
events {
|
|
||||||
worker_connections 512;
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
include /etc/nginx/includes/mime.types;
|
|
||||||
|
|
||||||
log_format hassio '[$time_local] $status '
|
|
||||||
'$http_x_forwarded_for($remote_addr) '
|
|
||||||
'$request ($http_user_agent)';
|
|
||||||
|
|
||||||
access_log /proc/1/fd/1 hassio;
|
|
||||||
client_max_body_size 4G;
|
|
||||||
default_type application/octet-stream;
|
|
||||||
gzip on;
|
|
||||||
keepalive_timeout 65;
|
|
||||||
sendfile on;
|
|
||||||
server_tokens off;
|
|
||||||
tcp_nodelay on;
|
|
||||||
tcp_nopush on;
|
|
||||||
|
|
||||||
map $http_upgrade $connection_upgrade {
|
|
||||||
default upgrade;
|
|
||||||
'' close;
|
|
||||||
}
|
|
||||||
|
|
||||||
include /etc/nginx/includes/resolver.conf;
|
|
||||||
include /etc/nginx/includes/upstream.conf;
|
|
||||||
|
|
||||||
include /etc/nginx/servers/*.conf;
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/usr/bin/execlineb -S0
|
|
||||||
# ==============================================================================
|
|
||||||
# Take down the S6 supervision tree when Nginx fails
|
|
||||||
# ==============================================================================
|
|
||||||
if { s6-test ${1} -ne 0 }
|
|
||||||
if { s6-test ${1} -ne 256 }
|
|
||||||
|
|
||||||
s6-svscanctl -t /var/run/s6/services
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
|
||||||
# shellcheck shell=bash
|
|
||||||
# ==============================================================================
|
|
||||||
|
|
||||||
# Wait for transmission to become available
|
|
||||||
bashio::net.wait_for 3000 localhost 900
|
|
||||||
|
|
||||||
bashio::log.info "Starting NGinx..."
|
|
||||||
|
|
||||||
exec nginx
|
|
||||||
Reference in New Issue
Block a user