Skip to content

Commit

Permalink
Update pre/postinst scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
adeepn committed Jun 3, 2024
1 parent b442a57 commit ea4ef82
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
33 changes: 32 additions & 1 deletion homeassistant-supervised/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ URL_CHECK_ONLINE="checkonline.home-assistant.io"
URL_VERSION="https://haversion.jethome.ru/stable.json"
#URL_VERSION="version.home-assistant.io/stable.json"
HASSIO_VERSION=$(curl -s ${URL_VERSION} | jq -e -r '.supervisor')
URL_APPARMOR_PROFILE="https://haversion.jethome.ru/apparmor.txt"
URL_APPARMOR_PROFILE="https://haversion.jethome.ru/apparmor_stable.txt"
#URL_APPARMOR_PROFILE="https://version.home-assistant.io/apparmor.txt"

# reload systemd
Expand Down Expand Up @@ -63,6 +63,37 @@ if [ "$(systemctl is-active nfs-utils.service)" = 'inactive' ]; then
systemctl start nfs-utils.service
fi

## Add docker proxyies for unban docker.com
# Define the new registry mirrors
new_registry_mirrors='[
"https://mirror.gcr.io",
"https://dockerhub.timeweb.cloud",
"https://daocloud.io",
"https://c.163.com/",
"https://huecker.io/",
"https://registry.docker-cn.com"
]'

# Define the path to the Docker daemon.json file
daemon_json="/etc/docker/daemon.json"

# Create the Docker configuration directory if it does not exist
mkdir -p /etc/docker

# If the daemon.json file does not exist or is empty, create it with the new registry mirrors
if [[ ! -f "$daemon_json" || ! -s "$daemon_json" ]]; then
echo "{\"registry-mirrors\": $new_registry_mirrors}" | jq > "$daemon_json"
echo "Created $daemon_json with new registry mirrors."
else
# If the registry-mirrors key does not exist, add it
if ! jq -e 'has("registry-mirrors")' "$daemon_json" > /dev/null; then
jq ". + {\"registry-mirrors\": $new_registry_mirrors}" "$daemon_json" > "${daemon_json}.tmp" && mv "${daemon_json}.tmp" "$daemon_json"
echo "Added new registry mirrors to $daemon_json."
else
echo "registry-mirrors already exists in $daemon_json. not added new"
fi
fi

# Restart Docker service
info "Restarting docker service"
systemctl restart "${SERVICE_DOCKER}"
Expand Down
2 changes: 1 addition & 1 deletion homeassistant-supervised/DEBIAN/preinst
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ dpkg-divert --package homeassistant-supervised --add --rename \
--divert /etc/network/interfaces.real /etc/network/interfaces

dpkg-divert --package homeassistant-supervised --add --rename \
--divert /etc/systemd/resolved.conf.real /etc/systemd/resolved.conf
--divert /etc/systemd/resolved.conf.real /etc/systemd/resolved.conf

0 comments on commit ea4ef82

Please sign in to comment.