mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-23 17:21:56 +02:00
Migration to v5.0
https://github.com/alexbelgium/hassio-addons/issues/416
This commit is contained in:
58
scrutiny/rootfs/etc/cont-init.d/01-run.sh
Normal file
58
scrutiny/rootfs/etc/cont-init.d/01-run.sh
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
|
||||
#################
|
||||
# Create folder #
|
||||
#################
|
||||
|
||||
echo "Updating folders structure"
|
||||
DATABASELOCATION="/data"
|
||||
mkdir -p "$DATABASELOCATION"/config
|
||||
mkdir -p "$DATABASELOCATION"/influxdb
|
||||
if [ -d /opt/scrutiny/config ]; then rm -r /opt/scrutiny/config; fi
|
||||
if [ -d /opt/scrutiny/influxdb ]; then rm -r /opt/scrutiny/influxdb; fi
|
||||
ln -s "$DATABASELOCATION"/config /opt/scrutiny
|
||||
ln -s "$DATABASELOCATION"/influxdb /opt/scrutiny
|
||||
|
||||
###############################
|
||||
# Migrating previous database #
|
||||
###############################
|
||||
|
||||
if [ -f /data/scrutiny.db ]; then
|
||||
bashio::log.warning "Previous database detected, migration will start. Backup stored in /share/scrutiny.db.bak"
|
||||
cp /data/scrutiny.db /share/scrutiny.db.bak
|
||||
mv /data/scrutiny.db "$DATABASELOCATION"/config/
|
||||
fi
|
||||
|
||||
######
|
||||
# TZ #
|
||||
######
|
||||
|
||||
# Align timezone with options
|
||||
if bashio::config.has_value "TZ"; then
|
||||
TZ="$(bashio::config 'TZ')"
|
||||
bashio::log.info "Timezone : $TZ"
|
||||
sed -i "1a export TZ=$TZ" /etc/cont-init.d/10-timezone
|
||||
fi
|
||||
|
||||
################
|
||||
# CRON OPTIONS #
|
||||
################
|
||||
|
||||
# Align update with options
|
||||
FREQUENCY="$(bashio::config 'Updates')"
|
||||
bashio::log.info "$FREQUENCY updates"
|
||||
|
||||
case "$FREQUENCY" in
|
||||
"Hourly")
|
||||
sed -i "1a export COLLECTOR_CRON_SCHEDULE=\"0 * * * *\"" /etc/cont-init.d/50-cron-config
|
||||
;;
|
||||
|
||||
"Daily")
|
||||
sed -i "1a export COLLECTOR_CRON_SCHEDULE=\"0 0 * * *\"" /etc/cont-init.d/50-cron-config
|
||||
;;
|
||||
|
||||
"Weekly")
|
||||
sed -i "1a export COLLECTOR_CRON_SCHEDULE=\"0 0 * * 0\"" /etc/cont-init.d/50-cron-config
|
||||
;;
|
||||
esac
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
|
||||
##############
|
||||
# Data usage #
|
||||
##############
|
||||
|
||||
bashio::log.info "Setting permissions"
|
||||
chown -R abc:abc /data
|
||||
|
||||
#######################
|
||||
# VIEWPORT CORRECTION #
|
||||
#######################
|
||||
|
||||
# correct viewport bug
|
||||
# grep -rl '"lt-md":"(max-width: 959px)"' /app | xargs sed -i 's|"lt-md":"(max-width: 959px)"|"lt-md":"(max-width: 100px)"|g' || true
|
||||
|
||||
######################
|
||||
# API URL CORRECTION #
|
||||
######################
|
||||
|
||||
# allow true url for ingress
|
||||
grep -rl '/api/' /app | xargs sed -i 's|/api/|api/|g' || true
|
||||
grep -rl 'api/' /app | xargs sed -i 's|api/|./api/|g' || true
|
||||
|
||||
################
|
||||
# CRON OPTIONS #
|
||||
################
|
||||
|
||||
rm /config/crontabs/* || true
|
||||
sed -i '$d' /etc/crontabs/root
|
||||
sed -i -e '$a @reboot /run.sh' /etc/crontabs/root
|
||||
|
||||
# Align update with options
|
||||
FREQUENCY=$(bashio::config 'Updates')
|
||||
bashio::log.info "$FREQUENCY updates"
|
||||
|
||||
case $FREQUENCY in
|
||||
"Hourly")
|
||||
sed -i -e '$a 0 * * * * /run.sh' /etc/crontabs/root
|
||||
;;
|
||||
|
||||
"Daily")
|
||||
sed -i -e '$a 0 0 * * * /run.sh' /etc/crontabs/root
|
||||
;;
|
||||
|
||||
"Weekly")
|
||||
sed -i -e '$a 0 0 * * 0 /run.sh' /etc/crontabs/root
|
||||
;;
|
||||
esac
|
||||
@@ -29,5 +29,7 @@ fi
|
||||
|
||||
ingress_port=$(bashio::addon.ingress_port)
|
||||
ingress_interface=$(bashio::addon.ip_address)
|
||||
ingress_entry=$(bashio::addon.ingress_entry)
|
||||
sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf
|
||||
sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf
|
||||
sed -i "s|%%ingress_entry%%|${ingress_entry}|g" /etc/nginx/servers/ingress.conf
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
root /dev/null;
|
||||
server_name $hostname;
|
||||
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
|
||||
@@ -6,16 +6,34 @@ server {
|
||||
|
||||
client_max_body_size 0;
|
||||
|
||||
location / {
|
||||
root /opt/scrutiny/web;
|
||||
|
||||
if ($http_referer ~* "^(http[s]?)://([^:]+):(\d*)(/.*)$") {
|
||||
set $x_scheme $1;
|
||||
set $x_host $2;
|
||||
set $x_port $3;
|
||||
}
|
||||
|
||||
if ($http_referer ~* "^(http[s]?)://([^:]+)(/.*)$") {
|
||||
set $x_scheme $1;
|
||||
set $x_host $2;
|
||||
set $x_port "";
|
||||
}
|
||||
|
||||
location = / {
|
||||
return 301 $x_scheme://$host:$x_port%%ingress_entry%%/web/dashboard;
|
||||
}
|
||||
|
||||
location /api {
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
proxy_read_timeout 30;
|
||||
proxy_pass http://backend/api;
|
||||
}
|
||||
|
||||
location /web/ {
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
proxy_read_timeout 30;
|
||||
proxy_pass http://backend/web/;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
proxy_read_timeout 30;
|
||||
proxy_pass http://backend/api/;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user