diff --git a/README.md b/README.md index 0f3b8838b..1d8018ed3 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ https://github.com/alexbelgium/hassio-addons ## ✓ Security tools - [Bitwarden](bitwarden/) : Open source password management solution +- [whoogle-search](whoogle/) is a Self-hosted, ad-free, privacy-respecting metasearch engine ## ✓ Torrent tools diff --git a/whoogle/CHANGELOG.md b/whoogle/CHANGELOG.md new file mode 100644 index 000000000..d896562e1 --- /dev/null +++ b/whoogle/CHANGELOG.md @@ -0,0 +1 @@ +- Initial release (latest builds) diff --git a/whoogle/Dockerfile b/whoogle/Dockerfile new file mode 100644 index 000000000..438f0ed6a --- /dev/null +++ b/whoogle/Dockerfile @@ -0,0 +1,81 @@ +#==========================# +# ALEXBELGIUM'S DOCKERFILE # +#==========================# +#           _.------. +#       _.-`    ('>.-`"""-. +# '.--'`       _'`   _ .--.) +#    -'         '-.-';`   ` +#    ' -      _.'  ``'--.  +#        '---`    .-'""` +#               /` + +################# +# 1 Build Image # +################# + +ARG BUILD_FROM +ARG BUILD_VERSION +FROM ${BUILD_FROM} + +################## +# 2 Modify Image # +################## + + + +################## +# 3 Install apps # +################## + +# Copy local files +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="" + +# Automatic apps & bashio +RUN 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] + +############ +# 5 Labels # +############ + +ARG BUILD_ARCH +ARG BUILD_DATE +ARG BUILD_DESCRIPTION +ARG BUILD_NAME +ARG BUILD_REF +ARG BUILD_REPOSITORY +ARG BUILD_VERSION +LABEL \ + io.hass.name="${BUILD_NAME}" \ + io.hass.description="${BUILD_DESCRIPTION}" \ + io.hass.arch="${BUILD_ARCH}" \ + io.hass.type="addon" \ + io.hass.version=${BUILD_VERSION} \ + maintainer="alexbelgium (https://github.com/alexbelgium)" \ + org.opencontainers.image.title="${BUILD_NAME}" \ + org.opencontainers.image.description="${BUILD_DESCRIPTION}" \ + org.opencontainers.image.vendor="Home Assistant Add-ons" \ + org.opencontainers.image.authors="alexbelgium (https://github.com/alexbelgium)" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.url="https://github.com/alexbelgium" \ + org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \ + org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \ + org.opencontainers.image.created=${BUILD_DATE} \ + org.opencontainers.image.revision=${BUILD_REF} \ + org.opencontainers.image.version=${BUILD_VERSION} diff --git a/whoogle/Readme.md b/whoogle/Readme.md new file mode 100644 index 000000000..814375077 --- /dev/null +++ b/whoogle/Readme.md @@ -0,0 +1,63 @@ +# Home assistant add-on: whoogle-search + +[![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium) + +[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white + +![Supports + Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armhf Architecture][armhf-shield] ![Supports armv7 Architecture][armv7-shield] +![Supports smb mounts][smb-shield] + +_Thanks to everyone having starred my repo! To star it click on the image below, then it will be on top right. Thanks!_ + +[![Stargazers repo roster for @alexbelgium/hassio-addons](https://reporoster.com/stars/alexbelgium/hassio-addons)](https://github.com/alexbelgium/hassio-addons/stargazers) + +## About + +[whoogle-search](https://github.com/benbusby/whoogle-search) is a Self-hosted, ad-free, privacy-respecting metasearch engine. +This addon is based on the docker image https://hub.docker.com/r/benbusby/whoogle-search/tags + +## Configuration + +Webui can be found at . +Configurations can be done through the app webUI, except for the following options + +Options can be configured through two ways : + +- Addon options + +```yaml +"CONFIG_LOCATION": location of the config.yaml (see below) +``` + +- Config.yaml + +Custom env variables can be added to the config.yaml file referenced in the addon options. Full env variables can be found here : https://github.com/benbusby/whoogle-search#environment-variables. It must be entered in a valid yaml format, that is verified at launch of the addon. + +## Installation + +The installation of this add-on is pretty straightforward and not different in comparison to installing any other add-on. + +1. Add my add-ons repository to your home assistant instance (in supervisor addons store at top right, or click button below if you have configured my HA) + [![Open your Home Assistant instance and show the add add-on repository dialog with a specific repository URL pre-filled.](https://my.home-assistant.io/badges/supervisor_add_addon_repository.svg)](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Falexbelgium%2Fhassio-addons) +1. Install this add-on. +1. Click the `Save` button to store your configuration. +1. Set the add-on options to your preferences +1. Start the add-on. +1. Check the logs of the add-on to see if everything went well. +1. Open the webUI and adapt the software options + +## Support + +Create an issue on github + +## Illustration + +![illustration](https://github.com/benbusby/whoogle-search/raw/main/docs/screenshot_desktop.jpg) + +[repository]: https://github.com/alexbelgium/hassio-addons +[smb-shield]: https://img.shields.io/badge/smb-yes-green.svg +[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg +[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg +[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg +[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg diff --git a/whoogle/apparmor.txt b/whoogle/apparmor.txt new file mode 100644 index 000000000..212b99b11 --- /dev/null +++ b/whoogle/apparmor.txt @@ -0,0 +1,48 @@ +#include + +profile whoogle-search_addon flags=(attach_disconnected,mediate_deleted) { + #include + + capability, + file, + mount, + umount, + remount, + + capability setgid, + capability setuid, + capability sys_admin, + capability dac_read_search, + # capability dac_override, + # capability sys_rawio, + +# S6-Overlay + /bin/** ix, + /usr/bin/** ix, + /usr/lib/bashio/** ix, + /etc/s6/** rix, + /run/s6/** rix, + /etc/services.d/** rwix, + /etc/cont-init.d/** rwix, + /etc/cont-finish.d/** rwix, + /init rix, + /var/run/** mrwkl, + /var/run/ mrwkl, + /dev/i2c-1 mrwkl, + # Files required + /dev/sda1 mrwkl, + /dev/sdb1 mrwkl, + /dev/mmcblk0p1 mrwkl, + /dev/* mrwkl, + /tmp/** mrkwl, + + # Data access + /data/** rw, + + # suppress ptrace denials when using 'docker ps' or using 'ps' inside a container + ptrace (trace,read) peer=docker-default, + + # docker daemon confinement requires explict allow rule for signal + signal (receive) set=(kill,term) peer=/usr/bin/docker, + +} diff --git a/whoogle/build.json b/whoogle/build.json new file mode 100644 index 000000000..51080de9c --- /dev/null +++ b/whoogle/build.json @@ -0,0 +1,8 @@ +{ + "build_from": { + "armhf": "benbusby/whoogle-search:latest", + "armv7": "benbusby/whoogle-search:latest", + "aarch64": "benbusby/whoogle-search:latest", + "amd64": "benbusby/whoogle-search:latest" + } +} diff --git a/whoogle/config.json b/whoogle/config.json new file mode 100644 index 000000000..b90d4c825 --- /dev/null +++ b/whoogle/config.json @@ -0,0 +1,29 @@ +{ + "apparmor": true, + "arch": ["aarch64", "amd64", "armv7", "armhf"], + "boot": "auto", + "description": "Self-hosted, ad-free, privacy-respecting metasearch engine", + "devices": [], + "environment": { + "CONFIG_VOLUME": "/data" + }, + "map": ["config:rw"], + "name": "Whoogle Search", + "options": { + "CONFIG_LOCATION": "/config/addons_config/whoogle_search/config.yaml" + }, + "ports": { + "5000/tcp": 5000 + }, + "ports_description": { + "5000/tcp": "web interface" + }, + "schema": { + "CONFIG_LOCATION": "str" + }, + "slug": "whoogle-search", + "upstream": "0.7.0", + "url": "https://github.com/alexbelgium/hassio-addons", + "version": "0.7.0", + "webui": "http://[HOST]:[PORT:5000]" +} diff --git a/whoogle/icon.png b/whoogle/icon.png new file mode 100644 index 000000000..56b7268b4 Binary files /dev/null and b/whoogle/icon.png differ diff --git a/whoogle/logo.png b/whoogle/logo.png new file mode 100644 index 000000000..56b7268b4 Binary files /dev/null and b/whoogle/logo.png differ diff --git a/whoogle/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/whoogle/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/whoogle/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/whoogle/rootfs/etc/cont-init.d/00-banner.sh b/whoogle/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/whoogle/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/whoogle/rootfs/etc/cont-init.d/90-config_yaml.sh b/whoogle/rootfs/etc/cont-init.d/90-config_yaml.sh new file mode 100644 index 000000000..0863cb6e5 --- /dev/null +++ b/whoogle/rootfs/etc/cont-init.d/90-config_yaml.sh @@ -0,0 +1,102 @@ +#!/usr/bin/with-contenv bashio + +################## +# INITIALIZATION # +################## + +# Where is the config +CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION") + +# Check if config file is there, or create one from template +if [ -f $CONFIGSOURCE ]; then + echo "Using config file found in $CONFIGSOURCE" +else + echo "No config file, creating one from template" + # Create folder + mkdir -p "$(dirname "${CONFIGSOURCE}")" + # Placing template in config + if [ -f /templates/config.yaml ]; then + # Use available template + cp /templates/config.yaml "$(dirname "${CONFIGSOURCE}")" + else + # Download template + TEMPLATESOURCE="https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/config.template" + curl -L -f -s $TEMPLATESOURCE --output $CONFIGSOURCE + fi + # Need to restart + bashio::log.fatal "Config file not found, creating a new one. Please customize the file in $CONFIGSOURCE before restarting." + # bashio::exit.nok +fi + +# Check if yaml is valid +EXIT_CODE=0 +yamllint -d relaxed --no-warnings $CONFIGSOURCE &>ERROR || EXIT_CODE=$? +if [ $EXIT_CODE = 0 ]; then + echo "Config file is a valid yaml" +else + cat ERROR + bashio::log.fatal "Config file has an invalid yaml format. Please check the file in $CONFIGSOURCE. Errors list above." + # bashio::exit.nok +fi + +# Export all yaml entries as env variables +# Helper function +function parse_yaml { + local prefix=$2 || local prefix="" + local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @ | tr @ '\034') + sed -ne "s|^\($s\):|\1|" \ + -e "s| #.*$||g" \ + -e "s|#.*$||g" \ + -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \ + -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | + awk -F$fs '{ + indent = length($1)/2; + vname[indent] = $2; + for (i in vname) {if (i > indent) {delete vname[i]}} + if (length($3) > 0) { + vn=""; for (i=0; i/tmpfile +while IFS= read -r line; do + # Clean output + line=${line//[\"\']/} + # Check if secret + if [[ "${line}" == *'!secret '* ]]; then + echo "secret detected" + secret=${line#*secret } + # Check if single match + secretnum=$(sed -n "/$secret:/=" /config/secrets.yaml) + [[ $(echo $secretnum) == *' '* ]] && bashio::exit.nok "There are multiple matches for your password name. Please check your secrets.yaml file" + # Get text + secret=$(sed -n "/$secret:/p" /config/secrets.yaml) + secret=${secret#*: } + line="${line%%=*}=$secret" + fi + # Data validation + if [[ $line =~ ^.+[=].+$ ]]; then + export $line + # Export the variable + sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || true + sed -i "1a export $line" /scripts/*run* 2>/dev/null || true + # Show in log + if ! bashio::config.false "verbose"; then bashio::log.blue "$line"; fi + else + bashio::exit.nok "$line does not follow the correct structure. Please check your yaml file." + fi +done <"/tmpfile" + +# Test mode +TZ=$(bashio::config "TZ") +if [ $TZ = "test" ]; then + echo "secret mode found, launching script in /config/test.sh" + cd /config + chmod 777 test.sh + ./test.sh +fi