From 42bef66f081a5a9deaea222a808520155b1a10c1 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Wed, 15 Jun 2022 21:03:13 +0200 Subject: [PATCH] Revert "chmod +x scripts" This reverts commit 3351e5b29c271f0dbb4b45628bab8829a9fd5ff2. --- .templates/00-aaa_dockerfile_backup.sh | 50 ++++ .templates/00-banner.sh | 46 ++++ .templates/00-bettercomments.sh | 8 + .templates/00-global_var.sh | 41 +++ .templates/19-json_repair.sh | 45 ++++ .templates/90-config_yaml.sh | 126 +++++++++ .templates/90-dns_set.sh | 43 +++ .templates/91-silent.sh | 13 + .templates/92-local_mounts.sh | 36 +++ .templates/92-smb_mounts.sh | 97 +++++++ .templates/99-custom_script.sh | 9 + .templates/automatic_packages.sh | 244 ++++++++++++++++++ addons_updater/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/99-run.sh | 210 +++++++++++++++ arpspoof/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ arpspoof/rootfs/etc/cont-init.d/99-run.sh | 12 + .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ bazarr/rootfs/etc/cont-init.d/20-folders.sh | 33 +++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ bitwarden/rootfs/etc/cont-init.d/nginx.sh | 30 +++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../etc/cont-init.d/00-data_location.sh | 47 ++++ calibre/rootfs/etc/cont-init.d/20-folders.sh | 8 + calibre/rootfs/etc/cont-init.d/32-nginx.sh | 33 +++ .../etc/cont-init.d/80-configuration.sh | 33 +++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../etc/cont-init.d/00-data_location.sh | 47 ++++ .../rootfs/etc/cont-init.d/20-folders.sh | 8 + .../rootfs/etc/cont-init.d/32-nginx.sh | 55 ++++ .../etc/cont-init.d/80-configuration.sh | 15 ++ cloudcommander/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/99-run.sh | 54 ++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ emby/rootfs/etc/cont-init.d/20-folders.sh | 75 ++++++ emby/rootfs/etc/cont-init.d/32-nginx.sh | 20 ++ emby/rootfs/etc/cont-init.d/91-silent.sh | 12 + enedisgateway2mqtt/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../etc/cont-init.d/91-mqtt_autodiscover.sh | 26 ++ .../rootfs/etc/cont-init.d/99-run.sh | 78 ++++++ enedisgateway2mqtt_dev/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/99-run.sh | 78 ++++++ filebrowser/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/20-folders.sh | 16 ++ filebrowser/rootfs/etc/cont-init.d/99-run.sh | 99 +++++++ fireflyiii/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ fireflyiii/rootfs/etc/cont-init.d/99-run.sh | 157 +++++++++++ fireflyiii_data_importer/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/20-folders.sh | 14 + .../rootfs/etc/cont-init.d/99-run.sh | 67 +++++ .../rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/20-folders.sh | 17 ++ .../rootfs/etc/cont-init.d/99-run.sh | 63 +++++ flaresolverr/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ flaresolverr/rootfs/etc/cont-init.d/99-run.sh | 10 + .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ flexget/rootfs/etc/cont-init.d/00-folders.sh | 18 ++ gazpar2mqtt/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../etc/cont-init.d/89-mqtt_autodiscover.sh | 30 +++ gazpar2mqtt/rootfs/etc/cont-init.d/99-run.sh | 11 + .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ grav/rootfs/etc/cont-init.d/20-folders.sh | 12 + .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ inadyn/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ inadyn/rootfs/etc/cont-init.d/99-run.sh | 15 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ jackett/rootfs/etc/cont-init.d/20-folders.sh | 22 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../etc/cont-init.d/00-data_location.sh | 22 ++ jellyfin/rootfs/etc/cont-init.d/20-folders.sh | 87 +++++++ jellyfin/rootfs/etc/cont-init.d/32-ingress.sh | 35 +++ .../etc/cont-init.d/99-database_clean.sh | 9 + joal/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ joal/rootfs/etc/cont-init.d/99-run.sh | 125 +++++++++ joplin/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ joplin/rootfs/etc/cont-init.d/99-run.sh | 67 +++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ lidarr/rootfs/etc/cont-init.d/20-folders.sh | 28 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ nextcloud/rootfs/defaults/nextcloud-perms.sh | 55 ++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/10-adduser.sh | 43 +++ nextcloud/rootfs/etc/cont-init.d/30-keygen.sh | 38 +++ nextcloud/rootfs/etc/cont-init.d/40-config.sh | 30 +++ .../rootfs/etc/cont-init.d/50-install.sh | 22 ++ .../rootfs/etc/cont-init.d/60-memcache.sh | 15 ++ .../rootfs/etc/cont-init.d/99-add_packages.sh | 10 + .../etc/cont-init.d/99-elasticsearch.sh | 79 ++++++ .../etc/cont-init.d/99-mariadb_discovery.sh | 10 + nextcloud/rootfs/etc/cont-init.d/99-ocr.sh | 48 ++++ .../etc/cont-init.d/99-trusted_domains.sh | 50 ++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ nzbget/rootfs/etc/cont-init.d/20-folders.sh | 19 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ omada/rootfs/etc/cont-init.d/00-folders.sh | 30 +++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ ombi/rootfs/etc/cont-init.d/20-folders.sh | 19 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ organizr/rootfs/etc/cont-init.d/00-folders.sh | 8 + .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../etc/cont-init.d/00-config_location.sh | 11 + .../rootfs/etc/cont-init.d/20-folders.sh | 8 + .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/20-folders.sh | 19 ++ .../rootfs/etc/cont-init.d/91-pikepdf.sh | 14 + .../rootfs/etc/cont-init.d/93-multiocr.sh | 16 ++ .../rootfs/etc/cont-init.d/99-run.sh | 4 + .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/00-folders.sh | 14 + papermerge/rootfs/etc/cont-init.d/91-OCR.sh | 58 +++++ .../etc/cont-init.d/99-configuration.sh | 73 ++++++ photoprism/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../etc/cont-init.d/32-nginx_ingress.sh | 18 ++ .../rootfs/etc/cont-init.d/32-nginx_ssl.sh | 33 +++ photoprism/rootfs/etc/cont-init.d/99-run.sh | 100 +++++++ photoprism/rootfs/run.sh | 55 ++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ piwigo/rootfs/etc/cont-init.d/41-folders.sh | 44 ++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ plex/rootfs/etc/cont-init.d/21-folders.sh | 27 ++ .../rootfs/etc/cont-init.d/90-create_links.sh | 24 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../etc/cont-init.d/20-configuration.sh | 31 +++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../cont-init.d/00-aaa_portainer_install.sh | 23 ++ portainer/rootfs/etc/cont-init.d/30-nginx.sh | 32 +++ portainer/rootfs/etc/cont-init.d/portainer.sh | 7 + .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ prowlarr/rootfs/etc/cont-init.d/20-folders.sh | 15 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/00-folders.sh | 5 + .../rootfs/etc/cont-init.d/30-nginx.sh | 51 ++++ .../91-qbittorrent_configuration.sh | 171 ++++++++++++ .../rootfs/etc/cont-init.d/93-openvpn.sh | 115 +++++++++ qbittorrent/rootfs/etc/openvpn/down.sh | 34 +++ .../rootfs/etc/openvpn/up-qbittorrent.sh | 6 + qbittorrent/rootfs/etc/openvpn/up.sh | 95 +++++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ radarr/rootfs/etc/cont-init.d/20-folders.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../etc/cont-init.d/00-config_location.sh | 11 + readarr/rootfs/etc/cont-init.d/20-folders.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/00-folders.sh | 65 +++++ .../rootfs/etc/cont-init.d/90-ingress.sh | 13 + .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ scrutiny/rootfs/etc/cont-init.d/31-run.sh | 50 ++++ .../etc/cont-init.d/32-nginx_ingress.sh | 33 +++ scrutiny/rootfs/run.sh | 13 + .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ scrutiny_fa/rootfs/etc/cont-init.d/31-run.sh | 56 ++++ .../etc/cont-init.d/32-nginx_ingress.sh | 33 +++ scrutiny_fa/rootfs/run.sh | 13 + seafile/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ seafile/rootfs/etc/cont-init.d/99-run.sh | 111 ++++++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ sonarr/rootfs/etc/cont-init.d/20-folders.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ tandoor_recipes/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/20-folders.sh | 10 + .../rootfs/etc/cont-init.d/99-run.sh | 79 ++++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../etc/cont-init.d/00-configuration.sh | 47 ++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/20-folders.sh | 14 + .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/19-config.sh | 124 +++++++++ .../rootfs/etc/cont-init.d/19-json_repair.sh | 54 ++++ .../etc/cont-init.d/32-nginx_ingress.sh | 18 ++ transmission_openvpn/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../etc/cont-init.d/32-nginx_ingress.sh | 18 ++ .../rootfs/etc/cont-init.d/99-run.sh | 32 +++ ubooquity/rootfs/etc/32-nginx_ingress.sh | 26 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/20-folders.sh | 19 ++ .../rootfs/etc/cont-init.d/32-nginx_ssl.sh | 27 ++ .../etc/cont-init.d/91-configuration.sh | 12 + .../rootfs/etc/cont-init.d/93-custom_webUI.sh | 34 +++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../etc/cont-init.d/00-data_location.sh | 47 ++++ .../rootfs/etc/cont-init.d/20-folders.sh | 10 + .../etc/cont-init.d/80-configuration.sh | 59 +++++ .../rootfs/etc/cont-init.d/90-ingress.sh | 36 +++ webtrees/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ webtrees/rootfs/etc/cont-init.d/99-run.sh | 133 ++++++++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ whoogle/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../etc/cont-init.d/32-nginx_ingress.sh | 49 ++++ whoogle/rootfs/etc/cont-init.d/99-run.sh | 5 + .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ zoneminder/rootfs/entrypoint.sh | 27 ++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 ++++ .../rootfs/etc/cont-init.d/00-folders.sh | 31 +++ zoneminder/rootfs/etc/cont-init.d/99-run.sh | 83 ++++++ 218 files changed, 9448 insertions(+) create mode 100644 .templates/00-aaa_dockerfile_backup.sh create mode 100644 .templates/00-banner.sh create mode 100644 .templates/00-bettercomments.sh create mode 100644 .templates/00-global_var.sh create mode 100644 .templates/19-json_repair.sh create mode 100644 .templates/90-config_yaml.sh create mode 100644 .templates/90-dns_set.sh create mode 100644 .templates/91-silent.sh create mode 100644 .templates/92-local_mounts.sh create mode 100644 .templates/92-smb_mounts.sh create mode 100644 .templates/99-custom_script.sh create mode 100644 .templates/automatic_packages.sh create mode 100644 addons_updater/rootfs/entrypoint.sh create mode 100644 addons_updater/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 addons_updater/rootfs/etc/cont-init.d/99-run.sh create mode 100644 arpspoof/rootfs/entrypoint.sh create mode 100644 arpspoof/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 arpspoof/rootfs/etc/cont-init.d/99-run.sh create mode 100644 bazarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 bazarr/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 bitwarden/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 bitwarden/rootfs/etc/cont-init.d/nginx.sh create mode 100644 booksonic_air/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 calibre/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 calibre/rootfs/etc/cont-init.d/00-data_location.sh create mode 100644 calibre/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 calibre/rootfs/etc/cont-init.d/32-nginx.sh create mode 100644 calibre/rootfs/etc/cont-init.d/80-configuration.sh create mode 100644 calibre_web/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 calibre_web/rootfs/etc/cont-init.d/00-data_location.sh create mode 100644 calibre_web/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 calibre_web/rootfs/etc/cont-init.d/32-nginx.sh create mode 100644 calibre_web/rootfs/etc/cont-init.d/80-configuration.sh create mode 100644 cloudcommander/rootfs/entrypoint.sh create mode 100644 cloudcommander/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 cloudcommander/rootfs/etc/cont-init.d/99-run.sh create mode 100644 code-server/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 elasticsearch/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 emby/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 emby/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 emby/rootfs/etc/cont-init.d/32-nginx.sh create mode 100644 emby/rootfs/etc/cont-init.d/91-silent.sh create mode 100644 enedisgateway2mqtt/rootfs/entrypoint.sh create mode 100644 enedisgateway2mqtt/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 enedisgateway2mqtt/rootfs/etc/cont-init.d/91-mqtt_autodiscover.sh create mode 100644 enedisgateway2mqtt/rootfs/etc/cont-init.d/99-run.sh create mode 100644 enedisgateway2mqtt_dev/rootfs/entrypoint.sh create mode 100644 enedisgateway2mqtt_dev/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 enedisgateway2mqtt_dev/rootfs/etc/cont-init.d/99-run.sh create mode 100644 filebrowser/rootfs/entrypoint.sh create mode 100644 filebrowser/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 filebrowser/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 filebrowser/rootfs/etc/cont-init.d/99-run.sh create mode 100644 fireflyiii/rootfs/entrypoint.sh create mode 100644 fireflyiii/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 fireflyiii/rootfs/etc/cont-init.d/99-run.sh create mode 100644 fireflyiii_data_importer/rootfs/entrypoint.sh create mode 100644 fireflyiii_data_importer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 fireflyiii_data_importer/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 fireflyiii_data_importer/rootfs/etc/cont-init.d/99-run.sh create mode 100644 fireflyiii_fints_importer/rootfs/entrypoint.sh create mode 100644 fireflyiii_fints_importer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 fireflyiii_fints_importer/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 fireflyiii_fints_importer/rootfs/etc/cont-init.d/99-run.sh create mode 100644 flaresolverr/rootfs/entrypoint.sh create mode 100644 flaresolverr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 flaresolverr/rootfs/etc/cont-init.d/99-run.sh create mode 100644 flexget/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 flexget/rootfs/etc/cont-init.d/00-folders.sh create mode 100644 gazpar2mqtt/rootfs/entrypoint.sh create mode 100644 gazpar2mqtt/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 gazpar2mqtt/rootfs/etc/cont-init.d/89-mqtt_autodiscover.sh create mode 100644 gazpar2mqtt/rootfs/etc/cont-init.d/99-run.sh create mode 100644 grav/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 grav/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 guacamole/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 inadyn/rootfs/entrypoint.sh create mode 100644 inadyn/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 inadyn/rootfs/etc/cont-init.d/99-run.sh create mode 100644 jackett/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 jackett/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 jellyfin/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 jellyfin/rootfs/etc/cont-init.d/00-data_location.sh create mode 100644 jellyfin/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 jellyfin/rootfs/etc/cont-init.d/32-ingress.sh create mode 100644 jellyfin/rootfs/etc/cont-init.d/99-database_clean.sh create mode 100644 joal/rootfs/entrypoint.sh create mode 100644 joal/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 joal/rootfs/etc/cont-init.d/99-run.sh create mode 100644 joplin/rootfs/entrypoint.sh create mode 100644 joplin/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 joplin/rootfs/etc/cont-init.d/99-run.sh create mode 100644 lidarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 lidarr/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 mealie/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 mylar3/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 nextcloud/rootfs/defaults/nextcloud-perms.sh create mode 100644 nextcloud/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 nextcloud/rootfs/etc/cont-init.d/10-adduser.sh create mode 100644 nextcloud/rootfs/etc/cont-init.d/30-keygen.sh create mode 100644 nextcloud/rootfs/etc/cont-init.d/40-config.sh create mode 100644 nextcloud/rootfs/etc/cont-init.d/50-install.sh create mode 100644 nextcloud/rootfs/etc/cont-init.d/60-memcache.sh create mode 100644 nextcloud/rootfs/etc/cont-init.d/99-add_packages.sh create mode 100644 nextcloud/rootfs/etc/cont-init.d/99-elasticsearch.sh create mode 100644 nextcloud/rootfs/etc/cont-init.d/99-mariadb_discovery.sh create mode 100644 nextcloud/rootfs/etc/cont-init.d/99-ocr.sh create mode 100644 nextcloud/rootfs/etc/cont-init.d/99-trusted_domains.sh create mode 100644 nzbget/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 nzbget/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 omada/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 omada/rootfs/etc/cont-init.d/00-folders.sh create mode 100644 ombi/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 ombi/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 organizr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 organizr/rootfs/etc/cont-init.d/00-folders.sh create mode 100644 overseerr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 overseerr/rootfs/etc/cont-init.d/00-config_location.sh create mode 100644 overseerr/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 paperless_ngx/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 paperless_ngx/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 paperless_ngx/rootfs/etc/cont-init.d/91-pikepdf.sh create mode 100644 paperless_ngx/rootfs/etc/cont-init.d/93-multiocr.sh create mode 100644 paperless_ngx/rootfs/etc/cont-init.d/99-run.sh create mode 100644 papermerge/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 papermerge/rootfs/etc/cont-init.d/00-folders.sh create mode 100644 papermerge/rootfs/etc/cont-init.d/91-OCR.sh create mode 100644 papermerge/rootfs/etc/cont-init.d/99-configuration.sh create mode 100644 photoprism/rootfs/entrypoint.sh create mode 100644 photoprism/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 photoprism/rootfs/etc/cont-init.d/32-nginx_ingress.sh create mode 100644 photoprism/rootfs/etc/cont-init.d/32-nginx_ssl.sh create mode 100644 photoprism/rootfs/etc/cont-init.d/99-run.sh create mode 100644 photoprism/rootfs/run.sh create mode 100644 piwigo/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 piwigo/rootfs/etc/cont-init.d/41-folders.sh create mode 100644 plex/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 plex/rootfs/etc/cont-init.d/21-folders.sh create mode 100644 plex/rootfs/etc/cont-init.d/90-create_links.sh create mode 100644 plex_meta_manager/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 plex_meta_manager/rootfs/etc/cont-init.d/20-configuration.sh create mode 100644 portainer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 portainer/rootfs/etc/cont-init.d/00-aaa_portainer_install.sh create mode 100644 portainer/rootfs/etc/cont-init.d/30-nginx.sh create mode 100644 portainer/rootfs/etc/cont-init.d/portainer.sh create mode 100644 prowlarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 prowlarr/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 qbittorrent/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 qbittorrent/rootfs/etc/cont-init.d/00-folders.sh create mode 100644 qbittorrent/rootfs/etc/cont-init.d/30-nginx.sh create mode 100644 qbittorrent/rootfs/etc/cont-init.d/91-qbittorrent_configuration.sh create mode 100644 qbittorrent/rootfs/etc/cont-init.d/93-openvpn.sh create mode 100644 qbittorrent/rootfs/etc/openvpn/down.sh create mode 100644 qbittorrent/rootfs/etc/openvpn/up-qbittorrent.sh create mode 100644 qbittorrent/rootfs/etc/openvpn/up.sh create mode 100644 radarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 radarr/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 readarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 readarr/rootfs/etc/cont-init.d/00-config_location.sh create mode 100644 readarr/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 requestrr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 resiliosync/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 resiliosync/rootfs/etc/cont-init.d/00-folders.sh create mode 100644 resiliosync/rootfs/etc/cont-init.d/90-ingress.sh create mode 100644 scrutiny/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 scrutiny/rootfs/etc/cont-init.d/31-run.sh create mode 100644 scrutiny/rootfs/etc/cont-init.d/32-nginx_ingress.sh create mode 100644 scrutiny/rootfs/run.sh create mode 100644 scrutiny_fa/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 scrutiny_fa/rootfs/etc/cont-init.d/31-run.sh create mode 100644 scrutiny_fa/rootfs/etc/cont-init.d/32-nginx_ingress.sh create mode 100644 scrutiny_fa/rootfs/run.sh create mode 100644 seafile/rootfs/entrypoint.sh create mode 100644 seafile/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 seafile/rootfs/etc/cont-init.d/99-run.sh create mode 100644 sonarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 sonarr/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 spotweb/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 tandoor_recipes/rootfs/entrypoint.sh create mode 100644 tandoor_recipes/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 tandoor_recipes/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 tandoor_recipes/rootfs/etc/cont-init.d/99-run.sh create mode 100644 tdarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 tdarr/rootfs/etc/cont-init.d/00-configuration.sh create mode 100644 teamspeak/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 teamspeak/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 transmission/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 transmission/rootfs/etc/cont-init.d/19-config.sh create mode 100644 transmission/rootfs/etc/cont-init.d/19-json_repair.sh create mode 100644 transmission/rootfs/etc/cont-init.d/32-nginx_ingress.sh create mode 100644 transmission_openvpn/rootfs/entrypoint.sh create mode 100644 transmission_openvpn/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 transmission_openvpn/rootfs/etc/cont-init.d/32-nginx_ingress.sh create mode 100644 transmission_openvpn/rootfs/etc/cont-init.d/99-run.sh create mode 100644 ubooquity/rootfs/etc/32-nginx_ingress.sh create mode 100644 ubooquity/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 ubooquity/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 ubooquity/rootfs/etc/cont-init.d/32-nginx_ssl.sh create mode 100644 ubooquity/rootfs/etc/cont-init.d/91-configuration.sh create mode 100644 ubooquity/rootfs/etc/cont-init.d/93-custom_webUI.sh create mode 100644 webtop_kde/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 webtop_kde/rootfs/etc/cont-init.d/00-data_location.sh create mode 100644 webtop_kde/rootfs/etc/cont-init.d/20-folders.sh create mode 100644 webtop_kde/rootfs/etc/cont-init.d/80-configuration.sh create mode 100644 webtop_kde/rootfs/etc/cont-init.d/90-ingress.sh create mode 100644 webtrees/rootfs/entrypoint.sh create mode 100644 webtrees/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 webtrees/rootfs/etc/cont-init.d/99-run.sh create mode 100644 wger/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 whoogle/rootfs/entrypoint.sh create mode 100644 whoogle/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 whoogle/rootfs/etc/cont-init.d/32-nginx_ingress.sh create mode 100644 whoogle/rootfs/etc/cont-init.d/99-run.sh create mode 100644 xteve/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 zoneminder/rootfs/entrypoint.sh create mode 100644 zoneminder/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 zoneminder/rootfs/etc/cont-init.d/00-folders.sh create mode 100644 zoneminder/rootfs/etc/cont-init.d/99-run.sh diff --git a/.templates/00-aaa_dockerfile_backup.sh b/.templates/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/.templates/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/.templates/00-banner.sh b/.templates/00-banner.sh new file mode 100644 index 000000000..7eca588bf --- /dev/null +++ b/.templates/00-banner.sh @@ -0,0 +1,46 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== +# 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 + +# ============================================================================== +# Global actions for all addons +# ============================================================================== + +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d diff --git a/.templates/00-bettercomments.sh b/.templates/00-bettercomments.sh new file mode 100644 index 000000000..32acdb462 --- /dev/null +++ b/.templates/00-bettercomments.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Color comments +#! Red +#? Question +#// Done +#todo To do +#* Green diff --git a/.templates/00-global_var.sh b/.templates/00-global_var.sh new file mode 100644 index 000000000..8f032234e --- /dev/null +++ b/.templates/00-global_var.sh @@ -0,0 +1,41 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################################### +# Export all addon options as env # +################################### + +# For all keys in options.json +JSONSOURCE="/data/options.json" + +# Export keys as env variables +# echo "All addon options were exported as variables" +mapfile -t arr < <(jq -r 'keys[]' "${JSONSOURCE}") + +for KEYS in "${arr[@]}"; do + # export key + VALUE=$(jq ."$KEYS" "${JSONSOURCE}") + line="${KEYS}='${VALUE//[\"\']/}'" + # text + if bashio::config.false "verbose" || [[ "${KEYS}" == *"PASS"* ]]; then + bashio::log.blue "${KEYS}=******" + else + bashio::log.blue "$line" + fi + # Use locally + export "${KEYS}='${VALUE//[\"\']/}'" + # Export the variable to run scripts + if cat /etc/services.d/*/*run* &>/dev/null; then sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null; fi + if cat /etc/cont-init.d/*run* &>/dev/null; then sed -i "1a export $line" /etc/cont-init.d/*run* 2>/dev/null; fi +done + +################ +# Set timezone # +################ +set +e +if [ -n "$TZ" ] && [ -f /etc/localtime ]; then + if [ -f /usr/share/zoneinfo/"$TZ" ]; then + echo "Timezone set from $(cat /etc/timezone) to $TZ" + ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" >/etc/timezone + fi +fi diff --git a/.templates/19-json_repair.sh b/.templates/19-json_repair.sh new file mode 100644 index 000000000..727c11257 --- /dev/null +++ b/.templates/19-json_repair.sh @@ -0,0 +1,45 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# shellchek disable=SC2015 + +JSONTOCHECK='/config/transmission/settings.json' +JSONSOURCE='/defaults/settings.json' + +# If json already exists +if [ -f "${JSONTOCHECK}" ]; then + # Variables + echo "Checking settings.json format" + + # Check if json file valid or not + jq . -S "${JSONTOCHECK}" &>/dev/null && ERROR=false || ERROR=true + if [ $ERROR = true ]; then + bashio::log.fatal "Settings.json structure is abnormal, restoring options from scratch. Your old file is renamed as settings.json_old" + mv "${JSONSOURCE}" "${JSONSOURCE}"_old + cp "${JSONSOURCE}" "${JSONTOCHECK}" + exit 0 + fi + + # Get the default keys from the original file + mapfile -t arr < <(jq -r 'keys[]' "${JSONSOURCE}") + + # Check if all keys are still there, or add them + # spellcheck disable=SC2068 + for KEYS in "${arr[@]}"; do + # Check if key exists + KEYSTHERE=$(jq "has(\"${KEYS}\")" "${JSONTOCHECK}") + if [ "$KEYSTHERE" != "true" ]; then + #Fetch initial value + JSONSOURCEVALUE=$(jq -r ".\"$KEYS\"" "${JSONSOURCE}") + #Add key + sed -i "3 i\"${KEYS}\": \"${JSONSOURCEVALUE}\"," "${JSONTOCHECK}" + # Message + bashio::log.warning "${KEYS} was missing from your settings.json, it was added with the default value ${JSONSOURCEVALUE}" + fi + done + + # Show structure in a nice way + jq . -S "${JSONTOCHECK}" | cat >temp.json && mv temp.json "${JSONTOCHECK}" + + # Message + bashio::log.info "Your settings.json was checked and seems perfectly normal!" +fi diff --git a/.templates/90-config_yaml.sh b/.templates/90-config_yaml.sh new file mode 100644 index 000000000..68882274c --- /dev/null +++ b/.templates/90-config_yaml.sh @@ -0,0 +1,126 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# shellcheck disable=SC2155,SC1087,SC2163,SC2116,SC2086 + +################## +# INITIALIZATION # +################## + +# Where is the config +CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION") + +# Check if config is located in an acceptable location +LOCATIONOK="" +for location in "/share" "/config" "/data"; do + if [[ "$CONFIGSOURCE" == "$location"* ]]; then + LOCATIONOK=true + fi +done + +if [ -z "$LOCATIONOK" ]; then + CONFIGSOURCE=/config/addons_config/${HOSTNAME#*-} + bashio::log.fatal "Your CONFIG_LOCATION values can only be set in /share, /config or /data (internal to addon). It will be reset to the default location : $CONFIGSOURCE" +fi + +# 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/.templates/config.template" + curl -f -L -s -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 + +# Permissions +chmod -R 755 "$(dirname "${CONFIGSOURCE}")" + +# Check if yaml is valid +EXIT_CODE=0 +yamllint -d relaxed "$CONFIGSOURCE" &>ERROR || EXIT_CODE=$? +if [ "$EXIT_CODE" = 0 ]; then + echo "Config file is a valid yaml" +else + cat ERROR + bashio::log.warning "Config file has an invalid yaml format. Please check the file in $CONFIGSOURCE. Errors list above." + # bashio::exit.nok +fi + +# Check if = instead of : +if [[ "$(grep -c "=" "$CONFIGSOURCE")" -gt 2 ]]; then + bashio::log.warning 'Are you sure you did not use "KEY=VALUE" ? yaml nomenclature requires "KEY:VALUE"' +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" /etc/cont-init.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 || exit + chmod 777 test.sh + ./test.sh +fi diff --git a/.templates/90-dns_set.sh b/.templates/90-dns_set.sh new file mode 100644 index 000000000..1a7eb7ed9 --- /dev/null +++ b/.templates/90-dns_set.sh @@ -0,0 +1,43 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +############### +# DNS SETTING # +############### + +# Avoid usage of local dns such as adguard home or pihole\n" + +if bashio::config.has_value 'DNS_server'; then + # Define variables + DNSSERVER=$(bashio::config 'DNS_server') + DNS="" + DNSLIST="" + + # Get DNS servers + # shellcheck disable=SC2086 + for server in ${DNSSERVER//,/ }; do # Separate comma separated values + # Only add DNS if successful + if ping -c 1 "$server" &> /dev/null + then + DNS="${DNS}nameserver $server\n" + DNSLIST="$server $DNSLIST" + else + bashio::log.warning "DNS $server was requested but can't be pinged. It won't be used" + fi + done + + # Only add DNS if there are DNS set + # shellcheck disable=SC2236 + if [[ ! -z "$DNS" ]]; then + # Write resolv.conf + # shellcheck disable=SC2059 + printf "${DNS}" >/etc/resolv.conf + chmod 644 /etc/resolv.conf + bashio::log.info "DNS SERVERS set to $DNSLIST" + else + bashio::log.warning "No valid DNS were found. Using default router (or HA) dns servers." + fi + +else + bashio::log.info "DNS Servers option empty. Using default router (or HA) dns servers." +fi diff --git a/.templates/91-silent.sh b/.templates/91-silent.sh new file mode 100644 index 000000000..c2ba4e49c --- /dev/null +++ b/.templates/91-silent.sh @@ -0,0 +1,13 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +############### +# SILENT MODE # +############### + +if bashio::config.true 'silent'; then + APPEND=' > /dev/null' + sed -i '$s|$|'"$APPEND"'|' /etc/services.d/*/run &>/dev/null || true + sed -i '$s|$|'"$APPEND"'|' /etc/cont-init.d/*/*run* &>/dev/null || true + bashio::log.info 'Silent mode activated, all logs from emby server are hidden. Disable this option if you need to troubleshoot the addon.' +fi diff --git a/.templates/92-local_mounts.sh b/.templates/92-local_mounts.sh new file mode 100644 index 000000000..b492e7587 --- /dev/null +++ b/.templates/92-local_mounts.sh @@ -0,0 +1,36 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +###################### +# MOUNT LOCAL SHARES # +###################### + +# Mount local Share if configured +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + echo "Local Disks mounting..." + + # Separate comma separated values + # shellcheck disable=SC2086 + for disk in ${MOREDISKS//,/ }; do + + # Mount by device as default + devpath=/dev + + # Mount as label + [ "${disk:0:2}" != "sd" ] && devpath=/dev/disk/by-label + + # Creates dir + mkdir -p /mnt/"$disk" + chown -R "$(id -u)":"$(id -g)" /mnt/"$disk" + # Legacy mounting : mount to share if still exists (avoid breaking changes) + # shellcheck disable=SC2015 + [ -d /share/"$disk" ] && mount "$devpath"/"$disk" /share/"$disk" || true + # Mount + # shellcheck disable=SC2015 + mount "$devpath"/"$disk" /mnt/"$disk" && bashio::log.info "Success! $disk mounted to /mnt/$disk" || (bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk) + + done + +fi diff --git a/.templates/92-smb_mounts.sh b/.templates/92-smb_mounts.sh new file mode 100644 index 000000000..7155263b6 --- /dev/null +++ b/.templates/92-smb_mounts.sh @@ -0,0 +1,97 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# shellcheck disable= + +######################### +# MOUNT SMB SHARES v1.6 # +######################### +if bashio::config.has_value 'networkdisks'; then + + # Define variables + MOREDISKS=$(bashio::config 'networkdisks') + CIFS_USERNAME=$(bashio::config 'cifsusername') + CIFS_PASSWORD=$(bashio::config 'cifspassword') + MOUNTED=false + SMBVERS="" + SECVERS="" + + # Mount CIFS Share if configured and if Protection Mode is active + echo 'Mounting smb share(s)...' + + if bashio::config.has_value 'cifsdomain'; then + DOMAIN=",domain=$(bashio::config 'cifsdomain')" + else + DOMAIN="" + fi + + # Mounting disks + # shellcheck disable=SC2086 + for disk in ${MOREDISKS//,/ }; do # Separate comma separated values + + # Clean name of network share + # shellcheck disable=SC2116,SC2001 + disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name + diskname="${disk//\\//}" #replace \ with / + diskname="${diskname##*/}" # Get only last part of the name + + # Data validation + if [[ ! $disk =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then + bashio::log.fatal "The structure of your \"networkdisks\" option : \"$disk\" doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2. If you don't use it, you can simply remove the text, this will avoid this error message in the future." + exit 0 + fi + + # Prepare mount point + mkdir -p /mnt/"$diskname" + chown -R root:root /mnt/"$diskname" + + # Tries to mount with default options + # shellcheck disable=SC2140 + mount -t cifs -o rw,username="$CIFS_USERNAME",password="${CIFS_PASSWORD}$DOMAIN" "$disk" /mnt/"$diskname" 2>ERRORCODE && MOUNTED=true || MOUNTED=false + + # if Fail test different smb and sec versions + if [ "$MOUNTED" = false ]; then + for SMBVERS in ",vers=3" ",vers=1.0" ",vers=2.1" ",vers=3.0" ",nodfs" ",uid=0,gid=0,forceuid,forcegid" ",noforceuid,noforcegid" ",${DOMAIN:-WORKGROUP}" ",noserverino"; do + mount -t cifs -o "rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS" "$disk" /mnt/"$diskname" 2>/dev/null && MOUNTED=true && break || MOUNTED=false + for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" ",iocharset=utf8" ",noserverino"; do + mount -t cifs -o "rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS" "$disk" /mnt/"$diskname" 2>/dev/null && MOUNTED=true && break 2 && break || MOUNTED=false + done + done + fi + + # Messages + if [ "$MOUNTED" = true ] && mountpoint -q /mnt/"$diskname"; then + #Test write permissions + # shellcheck disable=SC2015 + touch "/mnt/$diskname/testaze" && rm "/mnt/$diskname/testaze" && + bashio::log.info "... $disk successfully mounted to /mnt/$diskname with options $SMBVERS$SECVERS" || + bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" + + # Test for serverino + # shellcheck disable=SC2015 + touch "/mnt/$diskname/testaze" && cp "/mnt/$diskname/testaze" "/mnt/$diskname/testaze2" && rm "/mnt/$diskname/testaze2" || + (umount "/mnt/$diskname" && mount -t cifs -o "rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS,noserverino" "$disk" /mnt/"$diskname" && bashio::log.warning "noserverino option used") + + else + # Mounting failed messages + bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" + bashio::log.fatal "Here is some debugging info :" + + # Download smbclient + if command -v "apk" &>/dev/null; then apk add --no-cache samba-client &>/dev/null; fi + if command -v "apt" &>/dev/null; then apt-get install smbclient &>/dev/null; fi + if command -v "pacman" &>/dev/null; then pacman -S smbclient; fi + + # Provide debugging info + smbclient -L $disk -U "$CIFS_USERNAME%$CIFS_PASSWORD" || true + + # Error code + bashio::log.fatal "Error read : $(/dev/null || true + rmdir "/mnt/$diskname" || true + fi + + done +fi diff --git a/.templates/99-custom_script.sh b/.templates/99-custom_script.sh new file mode 100644 index 000000000..5ba4e28c9 --- /dev/null +++ b/.templates/99-custom_script.sh @@ -0,0 +1,9 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION") +CONFIGSOURCE="$(dirname "${CONFIGSOURCE}")" + +if [ -f "$CONFIGSOURCE"/script.sh ]; then + "$CONFIGSOURCE"./script.sh +fi diff --git a/.templates/automatic_packages.sh b/.templates/automatic_packages.sh new file mode 100644 index 000000000..5af7eba95 --- /dev/null +++ b/.templates/automatic_packages.sh @@ -0,0 +1,244 @@ +#!/bin/bash + +######## +# INIT # +######## + +#Verbose or not +VERBOSE=false +#Avoid fails on non declared variables +set +u 2>/dev/null || true +#If no packages, empty +PACKAGES="${*:-}" +#Avoids messages if non interactive +(echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections) &>/dev/null || true + +[ "$VERBOSE" = true ] && echo "ENV : $PACKAGES" + +############################ +# CHECK WHICH BASE IS USED # +############################ + +if command -v "apk" &>/dev/null; then + # If apk based + [ "$VERBOSE" = true ] && echo "apk based" + PACKMANAGER="apk" +elif command -v "apt" &>/dev/null; then + # If apt-get based + [ "$VERBOSE" = true ] && echo "apt based" + PACKMANAGER="apt" +elif command -v "pacman" &>/dev/null; then + # If apt-get based + [ "$VERBOSE" = true ] && echo "pacman based" + PACKMANAGER="pacman" +fi + +################### +# DEFINE PACKAGES # +################### + +# ADD GENERAL ELEMENTS +###################### + +PACKAGES="$PACKAGES jq curl vim ca-certificates" + +# FOR EACH SCRIPT, SELECT PACKAGES +################################## + +# Scripts +for files in "/etc/cont-init.d" "/etc/services.d"; do + # Next directory if does not exists + if ! ls $files 1>/dev/null 2>&1; then continue; fi + + # Test each possible command + COMMAND="nginx" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES nginx" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES nginx" + [ "$PACKMANAGER" = "pacman" ] && PACKAGES="$PACKAGES nginx" + if ls /etc/nginx 1>/dev/null 2>&1; then mv /etc/nginx /etc/nginx2; fi + fi + + COMMAND="mount" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES exfat-fuse exfat-utils ntfs-3g" + #[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES exfat-fuse exfat-utils ntfs-3g" + #[ "$PACKMANAGER" = "pacman" ] && PACKAGES="$PACKAGES exfat-fuse exfat-utils ntfs-3g" + fi + + COMMAND="cifs" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES cifs-utils keyutils" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES cifs-utils keyutils" + [ "$PACKMANAGER" = "pacman" ] && PACKAGES="$PACKAGES cifs-utils keyutils" + fi + + COMMAND="smbclient" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES samba samba-client" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES samba smbclient" + [ "$PACKMANAGER" = "pacman" ] && PACKAGES="$PACKAGES samba smbclient" + fi + + COMMAND="openvpn" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES coreutils openvpn" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES coreutils openvpn" + [ "$PACKMANAGER" = "pacman" ] && PACKAGES="$PACKAGES coreutils openvpn" + fi + + COMMAND="jq" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES jq" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES jq" + [ "$PACKMANAGER" = "pacman" ] && PACKAGES="$PACKAGES jq" + fi + + COMMAND="yamllint" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES yamllint" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES yamllint" + [ "$PACKMANAGER" = "pacman" ] && PACKAGES="$PACKAGES yamllint" + fi + + COMMAND="git" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES git" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES git" + [ "$PACKMANAGER" = "pacman" ] && PACKAGES="$PACKAGES git" + fi + + COMMAND="sponge" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES moreutils" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES moreutils" + [ "$PACKMANAGER" = "pacman " ] && PACKAGES="$PACKAGES moreutils" + fi + + COMMAND="sqlite3" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES sqlite" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES sqlite3" + [ "$PACKMANAGER" = "pacman" ] && PACKAGES="$PACKAGES sqlite3" + fi + + COMMAND="pip" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES py3-pip" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES pip" + [ "$PACKMANAGER" = "pacman" ] && PACKAGES="$PACKAGES pip" + fi + + COMMAND="wget" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES wget" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES wget" + [ "$PACKMANAGER" = "wget" ] && PACKAGES="$PACKAGES wget" + fi + +done + +#################### +# INSTALL ELEMENTS # +#################### + +# Install apps +[ "$VERBOSE" = true ] && echo "installing packages $PACKAGES" +if [ "$PACKMANAGER" = "apt" ]; then apt-get update >/dev/null; fi +if [ "$PACKMANAGER" = "pacman" ]; then pacman -Sy >/dev/null; fi + +# Install apps one by one to allow failures +# shellcheck disable=SC2086 +for packagestoinstall in $PACKAGES; do + [ "$VERBOSE" = true ] && echo "... $packagestoinstall" + if [ "$PACKMANAGER" = "apk" ]; then + apk add --no-cache "$packagestoinstall" &>/dev/null || (echo "Error : $packagestoinstall not found" && touch /ERROR) + elif [ "$PACKMANAGER" = "apt" ]; then + apt-get install -yqq --no-install-recommends "$packagestoinstall" &>/dev/null || (echo "Error : $packagestoinstall not found" && touch /ERROR) + elif [ "$PACKMANAGER" = "pacman" ]; then + pacman --noconfirm -S "$packagestoinstall" &>/dev/null || (echo "Error : $packagestoinstall not found" && touch /ERROR) + fi + [ "$VERBOSE" = true ] && echo "... $packagestoinstall done" +done + +# Clean after install +[ "$VERBOSE" = true ] && echo "Cleaning apt cache" +if [ "$PACKMANAGER" = "apt" ]; then apt-get clean >/dev/null; fi + +# Replace nginx if installed +if ls /etc/nginx2 1>/dev/null 2>&1; then + [ "$VERBOSE" = true ] && echo "replace nginx2" + rm -r /etc/nginx + mv /etc/nginx2 /etc/nginx + mkdir -p /var/log/nginx + touch /var/log/nginx/error.log +fi + +####################### +# INSTALL MANUAL APPS # +####################### + +for files in "/etc/services.d" "/etc/cont-init.d"; do + + # Next directory if does not exists + if ! ls $files 1>/dev/null 2>&1; then continue; fi + + # Bashio + if grep -q -rnw "$files/" -e 'bashio' && [ ! -f "/usr/bin/bashio" ]; then + [ "$VERBOSE" = true ] && echo "install bashio" + BASHIO_VERSION="0.14.3" + mkdir -p /tmp/bashio + curl -f -L -s -S "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | tar -xzf - --strip 1 -C /tmp/bashio + mv /tmp/bashio/lib /usr/lib/bashio + ln -s /usr/lib/bashio/bashio /usr/bin/bashio + rm -rf /tmp/bashio + fi + + # Lastversion + COMMAND="lastversion" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "install $COMMAND" + pip install $COMMAND + fi + + # Tempio + if grep -q -rnw "$files/" -e 'tempio' && [ ! -f "/usr/bin/tempio" ]; then + [ "$VERBOSE" = true ] && echo "install tempio" + TEMPIO_VERSION="2021.09.0" + BUILD_ARCH="$(bashio::info.arch)" + curl -f -L -f -s -o /usr/bin/tempio "https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}" + chmod a+x /usr/bin/tempio + fi + + # Mustache + COMMAND="mustache" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && apk add --no-cache go npm && + apk upgrade --no-cache && + apk add --no-cache --virtual .build-deps build-base git go && + go get -u github.com/quantumew/mustache-cli && + cp "$GOPATH"/bin/* /usr/bin/ && + rm -rf "$GOPATH" /var/cache/apk/* /tmp/src && + apk del .build-deps xz build-base + [ "$PACKMANAGER" = "apt" ] && apt-get update && + apt-get install -yqq go npm node-mustache + fi + +done + +if [ -f /ERROR ]; then + exit 1 +fi diff --git a/addons_updater/rootfs/entrypoint.sh b/addons_updater/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/addons_updater/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/addons_updater/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/addons_updater/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/addons_updater/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/addons_updater/rootfs/etc/cont-init.d/99-run.sh b/addons_updater/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..daab52427 --- /dev/null +++ b/addons_updater/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,210 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +########## +# UPDATE # +########## + +bashio::log.info "Starting $(lastversion --version)" + +bashio::log.info "Checking status of referenced repositoriess..." +VERBOSE=$(bashio::config 'verbose') + +#Defining github value +LOGINFO="... github authentification" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + +GITUSER=$(bashio::config 'gituser') +GITPASS=$(bashio::config 'gitpass') +GITMAIL=$(bashio::config 'gitmail') +git config --system http.sslVerify false +git config --system credential.helper 'cache --timeout 7200' +git config --system user.name "${GITUSER}" +git config --system user.password "${GITPASS}" +if [[ "$GITMAIL" != "null" ]]; then git config --system user.email "${GITMAIL}"; fi + +if bashio::config.has_value 'gitapi'; then + LOGINFO="... setting github API" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + GITHUB_API_TOKEN=$(bashio::config 'gitapi') + export GITHUB_API_TOKEN +fi + +#Create or update local version +REPOSITORY=$(bashio::config 'repository') +BASENAME=$(basename "https://github.com/$REPOSITORY") + +if [ ! -d "/data/$BASENAME" ]; then + LOGINFO="... cloning ${REPOSITORY}" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + cd /data/ || exit + git clone "https://github.com/${REPOSITORY}" +else + LOGINFO="... updating ${REPOSITORY}" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + cd "/data/$BASENAME" || exit + git pull --rebase &>/dev/null || git reset --hard &>/dev/null + git pull --rebase &>/dev/null +fi + +LOGINFO="... parse addons" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + +# Go through all folders, add to filters if not existing + +cd /data/"$BASENAME" || exit +for f in */; do + + if [ -f /data/"$BASENAME"/"$f"/updater.json ]; then + SLUG=${f//\/} + + # Rebase + LOGINFO="... updating ${REPOSITORY}" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + cd "/data/$BASENAME" || exit + git pull --rebase &>/dev/null || git reset --hard &>/dev/null + git pull --rebase &>/dev/null + + #Define the folder addon + LOGINFO="... $SLUG : checking slug exists in repo" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + cd /data/"${BASENAME}"/"${SLUG}" || { bashio::log.error "$SLUG addon not found in this repository. Exiting."; continue; } + + # Get variables + UPSTREAM=$(jq -r .upstream_repo updater.json) + BETA=$(jq -r .github_beta updater.json) + FULLTAG=$(jq -r .github_fulltag updater.json) + HAVINGASSET=$(jq -r .github_havingasset updater.json) + SOURCE=$(jq -r .source updater.json) + FILTER_TEXT=$(jq -r .github_tagfilter updater.json) + PAUSED=$(jq -r .paused updater.json) + DATE="$(date '+%d-%m-%Y')" + + #Skip if paused + if [[ "$PAUSED" = true ]]; then bashio::log.magenta "... $SLUG addon updates are paused, skipping"; continue; fi + + #Find current version + LOGINFO="... $SLUG : get current version" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + CURRENT=$(jq .upstream_version updater.json) || { bashio::log.error "$SLUG addon upstream tag not found in updater.json. Exiting."; continue; } + + if [[ "$SOURCE" = dockerhub ]]; then + # Use dockerhub as upstream + # shellcheck disable=SC2116 + DOCKERHUB_REPO=$(echo "${UPSTREAM%%/*}") + DOCKERHUB_IMAGE=$(echo "$UPSTREAM" | cut -d "/" -f2) + LASTVERSION=$( + curl -f -L -s --fail "https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags/?page_size=10" | + jq '.results | .[] | .name' -r | + sed -e '/.*latest.*/d' | + sed -e '/.*dev.*/d' | + sort -V | + tail -n 1 + ) + [ "${BETA}" = true ] && + LASTVERSION=$( + curl -f -L -s --fail "https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags/?page_size=10" | + jq '.results | .[] | .name' -r | + sed -e '/.*latest.*/d' | + sed -e '/.*dev.*/!d' | + sort -V | + tail -n 1 + ) + else + + # Use source as upstream + ARGUMENTS="--at $SOURCE" + LOGINFO="... $SLUG : source is $SOURCE" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + + #Prepare tag flag + if [ "${FULLTAG}" = true ]; then + LOGINFO="... $SLUG : fulltag is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + ARGUMENTS="$ARGUMENTS --format tag" + else + LOGINFO="... $SLUG : fulltag is off" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + fi + + #Prepare tag flag + if [ "${HAVINGASSET}" = true ]; then + LOGINFO="... $SLUG : asset_only tag is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + ARGUMENTS="$ARGUMENTS --having-asset" + else + LOGINFO="... $SLUG : asset_only is off" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + fi + + #Prepare tag flag + if [ "${FILTER_TEXT}" = "null" ] || [ "${FILTER_TEXT}" = "" ]; then + FILTER_TEXT="" + else + LOGINFO="... $SLUG : filter_text is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + ARGUMENTS="$ARGUMENTS --only $FILTER_TEXT" + fi + + #If beta flag, select beta version + if [ "${BETA}" = true ]; then + LOGINFO="... $SLUG : beta is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + ARGUMENTS="$ARGUMENTS --pre" + else + LOGINFO="... $SLUG : beta is off" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + fi + + #Execute version search + # shellcheck disable=SC2086 + LASTVERSION=$(lastversion "$UPSTREAM" $ARGUMENTS) || continue + fi + + + # Add brackets + LASTVERSION='"'${LASTVERSION}'"' + + # Do not compare with ls tag for linuxserver images (to avoid updating only for dependencies) + #LASTVERSION2=${LASTVERSION%-ls*} + #CURRENT2=${CURRENT%-ls*} + LASTVERSION2=${LASTVERSION} + CURRENT2=${CURRENT} + + # Update if needed + if [ "${CURRENT2}" != "${LASTVERSION2}" ]; then + LOGINFO="... $SLUG : update from ${CURRENT} to ${LASTVERSION}" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + + #Change all instances of version + LOGINFO="... $SLUG : updating files" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + for files in "config.json" "config.yaml" "Dockerfile" "build.json" "build.yaml";do + if [ -f /data/"${BASENAME}"/"${SLUG}"/$files ]; then + sed -i "s/${CURRENT}/${LASTVERSION}/g" /data/"${BASENAME}"/"${SLUG}"/"$files" + fi + done + + # Remove " and modify version + LASTVERSION=${LASTVERSION//\"/} + CURRENT=${CURRENT//\"/} + jq --arg variable "$LASTVERSION" '.version = $variable' /data/"${BASENAME}"/"${SLUG}"/config.json | sponge /data/"${BASENAME}"/"${SLUG}"/config.json # Replace version tag + jq --arg variable "$LASTVERSION" '.upstream_version = $variable' /data/"${BASENAME}"/"${SLUG}"/updater.json | sponge /data/"${BASENAME}"/"${SLUG}"/updater.json # Replace upstream tag + jq --arg variable "$DATE" '.last_update = $variable' /data/"${BASENAME}"/"${SLUG}"/updater.json | sponge /data/"${BASENAME}"/"${SLUG}"/updater.json # Replace date tag + + #Update changelog + touch "/data/${BASENAME}/${SLUG}/CHANGELOG.md" + sed -i "1i - Update to latest version from $UPSTREAM" "/data/${BASENAME}/${SLUG}/CHANGELOG.md" + sed -i "1i ## ${LASTVERSION} (${DATE})" "/data/${BASENAME}/${SLUG}/CHANGELOG.md" + sed -i "1i " "/data/${BASENAME}/${SLUG}/CHANGELOG.md" + LOGINFO="... $SLUG : files updated" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + + #Git commit and push + git add -A # add all modified files + + git commit -m "Updater bot : $SLUG updated to ${LASTVERSION}" >/dev/null + + LOGINFO="... $SLUG : push to github" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi + + # if API is set + if bashio::config.has_value 'gitapi'; then + git remote set-url origin "https://${GITUSER}:${GITHUB_API_TOKEN}@github.com/${REPOSITORY}" &>/dev/null + else + git remote set-url origin "https://${GITUSER}:${GITPASS}@github.com/${REPOSITORY}" &>/dev/null + fi + + # Push + git push &>/dev/null + + #Log + bashio::log.yellow "... $SLUG updated from ${CURRENT} to ${LASTVERSION}" + + else + bashio::log.green "... $SLUG is up-to-date ${CURRENT}" + fi + fi +done || true # Continue even if issue + +bashio::log.info "Addons update completed" diff --git a/arpspoof/rootfs/entrypoint.sh b/arpspoof/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/arpspoof/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/arpspoof/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/arpspoof/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/arpspoof/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/arpspoof/rootfs/etc/cont-init.d/99-run.sh b/arpspoof/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..4c633a894 --- /dev/null +++ b/arpspoof/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +# Autodefine if not defined +if [ -n "$INTERFACE_NAME" ]; then + # shellcheck disable=SC2155 + export INTERFACE_NAME="$(ip route get 8.8.8.8 | sed -nr 's/.*dev ([^\ ]+).*/\1/p')" + bashio::log.blue "Autodetection : INTERFACE_NAME=$INTERFACE_NAME" +fi + +bashio::log.info "Starting..." +/usr/bin/python3 /opt/arpspoof/arpspoof.py diff --git a/bazarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/bazarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/bazarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/bazarr/rootfs/etc/cont-init.d/20-folders.sh b/bazarr/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..322c1fb2d --- /dev/null +++ b/bazarr/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +if [ ! -d /share/storage/movies ]; then + echo "Creating /share/storage/movies" + mkdir -p /share/storage/movies + chown -R abc:abc /share/storage/movies +fi + +if [ ! -d /share/storage/tv ]; then + echo "Creating /share/storage/tv" + mkdir -p /share/storage/tv + chown -R abc:abc /share/storage/tv +fi + +if [ ! -d /share/downloads ]; then + echo "Creating /share/downloads" + mkdir -p /share/downloads + chown -R abc:abc /share/downloads +fi + +if [ -d /config/bazarr ] && [ ! -d /config/addons_config/bazarr ]; then + echo "Moving to new location /config/addons_config/bazarr" + mkdir -p /config/addons_config/bazarr + chown -R abc:abc /config/addons_config/bazarr + mv /config/bazarr/* /config/addons_config/bazarr/ + rm -r /config/bazarr +fi + +if [ ! -d /config/addons_config/bazarr ]; then + echo "Creating /config/addons_config/bazarr" + mkdir -p /config/addons_config/bazarr + chown -R abc:abc /config/addons_config/bazarr +fi diff --git a/bitwarden/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/bitwarden/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/bitwarden/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/bitwarden/rootfs/etc/cont-init.d/nginx.sh b/bitwarden/rootfs/etc/cont-init.d/nginx.sh new file mode 100644 index 000000000..aa680976a --- /dev/null +++ b/bitwarden/rootfs/etc/cont-init.d/nginx.sh @@ -0,0 +1,30 @@ +#!/command/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== +# Home Assistant Community Add-on: Bitwarden +# This file configures nginx +# ============================================================================== +declare certfile +declare keyfile +declare max_body_size + +bashio::config.require.ssl + +if bashio::config.true 'ssl'; then + certfile=$(bashio::config 'certfile') + keyfile=$(bashio::config 'keyfile') + + mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf + sed -i "s#%%certfile%%#${certfile}#g" /etc/nginx/servers/direct.conf + sed -i "s#%%keyfile%%#${keyfile}#g" /etc/nginx/servers/direct.conf +else + mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf +fi + +max_body_size="10M" +# Increase body size to match config +if bashio::config.has_value 'request_size_limit'; then + max_body_size=$(bashio::config 'request_size_limit') +fi +sed -i "s/%%max_body_size%%/${max_body_size}/g" \ + /etc/nginx/includes/server_params.conf diff --git a/booksonic_air/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/booksonic_air/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/booksonic_air/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/calibre/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/calibre/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/calibre/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/calibre/rootfs/etc/cont-init.d/00-data_location.sh b/calibre/rootfs/etc/cont-init.d/00-data_location.sh new file mode 100644 index 000000000..14827a107 --- /dev/null +++ b/calibre/rootfs/etc/cont-init.d/00-data_location.sh @@ -0,0 +1,47 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# 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="/config/addons_config/calibre" +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=/config/addons_config/${HOSTNAME#*-} + 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" +sed -i "1a export HOME=$LOCATION" /etc/services.d/web/run +sed -i "1a export FM_HOME=$LOCATION" /etc/services.d/web/run +sed -i "s|/config/addons_config/calibre|$LOCATION|g" /defaults/* +sed -i "s|/config/addons_config/calibre|$LOCATION|g" /etc/cont-init.d/* +sed -i "s|/config/addons_config/calibre|$LOCATION|g" /etc/services.d/*/run +usermod --home "$LOCATION" abc + +# Create folder +echo "Creating $LOCATION" +mkdir -p "$LOCATION" + +# Set ownership +bashio::log.info "Setting ownership to $PUID:$PGID" +chown "$PUID":"$PGID" "$LOCATION" diff --git a/calibre/rootfs/etc/cont-init.d/20-folders.sh b/calibre/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..a84c02095 --- /dev/null +++ b/calibre/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ ! -d /config/addons_config/calibre ]; then + echo "Creating /config/addons_config/calibre" + mkdir -p /config/addons_config/calibre +fi + +chown -R abc:abc /config/addons_config/calibre diff --git a/calibre/rootfs/etc/cont-init.d/32-nginx.sh b/calibre/rootfs/etc/cont-init.d/32-nginx.sh new file mode 100644 index 000000000..6ac38a5b6 --- /dev/null +++ b/calibre/rootfs/etc/cont-init.d/32-nginx.sh @@ -0,0 +1,33 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# +declare port +declare certfile +declare ingress_interface +declare ingress_port +declare keyfile + +port=$(bashio::addon.port 80) +if bashio::var.has_value "${port}"; then + bashio::config.require.ssl + + if bashio::config.true 'ssl'; then + certfile=$(bashio::config 'certfile') + keyfile=$(bashio::config 'keyfile') + + mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf + sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/servers/direct.conf + sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/servers/direct.conf + + else + mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf + fi +fi + +ingress_port=$(bashio::addon.ingress_port) +ingress_interface=$(bashio::addon.ip_address) +sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf +sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf diff --git a/calibre/rootfs/etc/cont-init.d/80-configuration.sh b/calibre/rootfs/etc/cont-init.d/80-configuration.sh new file mode 100644 index 000000000..13e770aec --- /dev/null +++ b/calibre/rootfs/etc/cont-init.d/80-configuration.sh @@ -0,0 +1,33 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# shellcheck disable=SC2015 + +# Set TZ +if bashio::config.has_value 'TZ'; then + TIMEZONE=$(bashio::config 'TZ') + bashio::log.info "Setting timezone to $TIMEZONE" + ln -snf /usr/share/zoneinfo/"$TIMEZONE" /etc/localtime && echo "$TIMEZONE" >/etc/timezone +fi + +# Set keyboard +if bashio::config.has_value 'KEYBOARD'; then + KEYBOARD=$(bashio::config 'KEYBOARD') + bashio::log.info "Setting keyboard to $KEYBOARD" + sed -i "1a export KEYBOARD=$KEYBOARD" /etc/services.d/web/run +fi + +# Set cli args +if bashio::config.has_value 'CLI_ARGS'; then + bashio::log.info "Setting password to the value defined in options" + CLI_ARGS=$(bashio::config 'CLI_ARGS') + bashio::log.info "Setting arguments to $CLI_ARGS" + sed -i "1a export CLI_ARGS=$CLI_ARGS" /etc/services.d/web/run +fi + +# Set password +if bashio::config.has_value 'PASSWORD'; then + bashio::log.info "Setting password to the value defined in options" + PASSWORD=$(bashio::config 'PASSWORD') + bashio::log.info "Setting password to $PASSWORD" + sed -i "1a export PASSWORD=$PASSWORD" /etc/services.d/web/run +fi diff --git a/calibre_web/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/calibre_web/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/calibre_web/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/calibre_web/rootfs/etc/cont-init.d/00-data_location.sh b/calibre_web/rootfs/etc/cont-init.d/00-data_location.sh new file mode 100644 index 000000000..228258806 --- /dev/null +++ b/calibre_web/rootfs/etc/cont-init.d/00-data_location.sh @@ -0,0 +1,47 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# 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="/config/addons_config/calibre-web" +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=/config/addons_config/${HOSTNAME#*-} + 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" +sed -i "1a export HOME=$LOCATION" /etc/services.d/*/run +sed -i "1a export FM_HOME=$LOCATION" /etc/services.d/*/run +sed -i "s|/config/addons_config/calibre-web|$LOCATION|g" /defaults/* +sed -i "s|/config/addons_config/calibre-web|$LOCATION|g" /etc/cont-init.d/* +sed -i "s|/config/addons_config/calibre-web|$LOCATION|g" /etc/services.d/*/run +usermod --home "$LOCATION" abc + +# Create folder +echo "Creating $LOCATION" +mkdir -p "$LOCATION" + +# Set ownership +bashio::log.info "Setting ownership to $PUID:$PGID" +chown "$PUID":"$PGID" "$LOCATION" diff --git a/calibre_web/rootfs/etc/cont-init.d/20-folders.sh b/calibre_web/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..45f435b52 --- /dev/null +++ b/calibre_web/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ ! -d /config/addons_config/calibre-web ]; then + echo "Creating /config/addons_config/calibre-web" + mkdir -p /config/addons_config/calibre-web +fi + +chown -R abc:abc /config/addons_config/calibre-web diff --git a/calibre_web/rootfs/etc/cont-init.d/32-nginx.sh b/calibre_web/rootfs/etc/cont-init.d/32-nginx.sh new file mode 100644 index 000000000..0ef42f45e --- /dev/null +++ b/calibre_web/rootfs/etc/cont-init.d/32-nginx.sh @@ -0,0 +1,55 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# +#declare port +#declare certfile +declare ingress_user +declare ingress_interface +declare ingress_port +#declare keyfile + +#port=$(bashio::addon.port 80) +#if bashio::var.has_value "${port}"; then +# bashio::config.require.ssl +# +# if bashio::config.true 'ssl'; then +# certfile=$(bashio::config 'certfile') +# keyfile=$(bashio::config 'keyfile') +# +# mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf +# sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/servers/direct.conf +# sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/servers/direct.conf +# +# else +# mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf +# fi +#fi + +## Force scheme +#if bashio::config.true 'force_scheme_https'; then +# # shellcheck disable=SC2016 +# sed -i 's|$scheme|https|g' /etc/nginx/servers/ingress.conf +#fi + +## Force external port +#if bashio::config.has_value 'force_external_port'; then +# sed -i "s|%%haport%%|$(bashio::config 'force_external_port')|g" /etc/nginx/servers/ingress.conf +#fi + +ingress_user='admin' +if bashio::config.has_value 'ingress_user'; then + ingress_user=$(bashio::config 'ingress_user') +fi + +ingress_port=$(bashio::addon.ingress_port) +ingress_interface=$(bashio::addon.ip_address) +#ha_port=$(bashio::core.port) + +sed -i "s/%%ingress_user%%/${ingress_user}/g" /etc/nginx/servers/ingress.conf +sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf +#sed -i "s/%%haport%%/${ha_port}/g" /etc/nginx/servers/ingress.conf +sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf +sed -i "s|%%UIPATH%%|$(bashio::addon.ingress_entry)|g" /etc/nginx/servers/ingress.conf diff --git a/calibre_web/rootfs/etc/cont-init.d/80-configuration.sh b/calibre_web/rootfs/etc/cont-init.d/80-configuration.sh new file mode 100644 index 000000000..9b2f43ab6 --- /dev/null +++ b/calibre_web/rootfs/etc/cont-init.d/80-configuration.sh @@ -0,0 +1,15 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# shellcheck disable=SC2015 + +# Set TZ +if bashio::config.has_value 'TZ'; then + TIMEZONE=$(bashio::config 'TZ') + bashio::log.info "Setting timezone to $TIMEZONE" + ln -snf /usr/share/zoneinfo/"$TIMEZONE" /etc/localtime && echo "$TIMEZONE" >/etc/timezone +fi + +# Set Ingress login +sqlite3 /config/addons_config/calibre-web/app.db 'update settings set config_reverse_proxy_login_header_name="X-WebAuth-User",config_allow_reverse_proxy_header_login=1' + +bashio::log.info "Default username:password is admin:admin123" diff --git a/cloudcommander/rootfs/entrypoint.sh b/cloudcommander/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/cloudcommander/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/cloudcommander/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/cloudcommander/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/cloudcommander/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/cloudcommander/rootfs/etc/cont-init.d/99-run.sh b/cloudcommander/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..0b0fee452 --- /dev/null +++ b/cloudcommander/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# + +# declare port +# declare certfile +declare ingress_interface +declare ingress_port +# declare keyfile + +CLOUDCMD_PREFIX=$(bashio::addon.ingress_entry) +export CLOUDCMD_PREFIX + +declare ADDON_PROTOCOL=http +if bashio::config.true 'ssl'; then + ADDON_PROTOCOL=https + bashio::config.require.ssl +fi + +# port=$(bashio::addon.port 80) +ingress_port=$(bashio::addon.ingress_port) +ingress_interface=$(bashio::addon.ip_address) +sed -i "s|%%protocol%%|${ADDON_PROTOCOL}|g" /etc/nginx/servers/ingress.conf +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|%%subpath%%|${CLOUDCMD_PREFIX}/|g" /etc/nginx/servers/ingress.conf +mkdir -p /var/log/nginx && touch /var/log/nginx/error.log + +############### +# LAUNCH APPS # +############### + +if bashio::config.has_value 'CUSTOM_OPTIONS'; then + CUSTOMOPTIONS=" $(bashio::config 'CUSTOM_OPTIONS')" +else + CUSTOMOPTIONS="" +fi + +if bashio::config.has_value 'DROPBOX_TOKEN'; then + DROPBOX_TOKEN="--dropbox --dropbox-token $(bashio::config 'DROPBOX_TOKEN')" +else + DROPBOX_TOKEN="" +fi + +bashio::log.info "Starting..." + +cd / +./usr/src/app/bin/cloudcmd.mjs '"'"$DROPBOX_TOKEN""$CUSTOMOPTIONS"'"' & +bashio::net.wait_for 8000 localhost 900 || true +bashio::log.info "Started !" +exec nginx diff --git a/code-server/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/code-server/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/code-server/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/elasticsearch/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/elasticsearch/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/elasticsearch/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/emby/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/emby/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..881f79e61 --- /dev/null +++ b/emby/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +#[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +#[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/emby/rootfs/etc/cont-init.d/20-folders.sh b/emby/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..90bc61989 --- /dev/null +++ b/emby/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,75 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +bashio::log.info "Updating folder structure and permission" + +echo "Internal location : /emby" +mkdir -p /emby +chown -R abc:abc /emby + +echo "Files location : /share/storage/tv" +mkdir -p /share/storage/tv +chown -R abc:abc /share/storage/tv + +echo "Files location : /share/storage/movies" +mkdir -p /share/storage/movies +chown -R abc:abc /share/storage/movies + +echo "Data location : /share/emby" +mkdir -p /share/emby +chown -R abc:abc /share/emby + +echo "Config location : /config/addons_config/emby" +mkdir -p /config/addons_config/emby +chown -R abc:abc /config/addons_config/emby + +# links + +if [ ! -d /emby/cache ]; then + echo "... link for /emby/cache" + mkdir -p /share/emby/cache + chown -R abc:abc /share/emby/cache + ln -s /share/emby/cache /emby/cache +fi + +if [ ! -d /emby/config ]; then + echo "Creating link for /emby/config" + mkdir -p /config/emby + chown -R abc:abc /config/emby + ln -s /config/emby /emby/config +fi + +if [ ! -d /emby/data ]; then + echo "Creating link for /emby/data" + mkdir -p /share/emby/data + chown -R abc:abc /share/emby/data + ln -s /share/emby/data /emby/data +fi + +if [ ! -d /emby/logs ]; then + echo "Creating link for /emby/logs" + mkdir -p /share/emby/logs + chown -R abc:abc /share/emby/logs + ln -s /share/emby/logs /emby/logs +fi + +if [ ! -d /emby/metadata ]; then + echo "Creating link for /emby/metadata" + mkdir -p /share/emby/metadata + chown -R abc:abc /share/emby/metadata + ln -s /share/emby/metadata /emby/metadata +fi + +if [ ! -d /emby/plugins ]; then + echo "Creating link for /emby/plugins" + mkdir -p /share/emby/plugins + chown -R abc:abc /share/emby/plugins + ln -s /share/emby/plugins /emby/plugins +fi + +if [ ! -d /emby/root ]; then + echo "Creating link for /emby/root" + mkdir -p /share/emby/root + chown -R abc:abc /share/emby/root + ln -s /share/emby/root /emby/root +fi diff --git a/emby/rootfs/etc/cont-init.d/32-nginx.sh b/emby/rootfs/etc/cont-init.d/32-nginx.sh new file mode 100644 index 000000000..af5d656c2 --- /dev/null +++ b/emby/rootfs/etc/cont-init.d/32-nginx.sh @@ -0,0 +1,20 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# + +declare ingress_interface +declare ingress_port + +echo "Adapting for ingress" +ingress_port=$(bashio::addon.ingress_port) +ingress_interface=$(bashio::addon.ip_address) +sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf +sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf + +# Allow uppercase url +echo "Allowing case sensitive url" +grep -rl toLowerCase /app/emby/dashboard-ui/app.js | xargs sed -i 's/toLowerCase()/toString()/g' +grep -rl toLowerCase /app/emby/dashboard-ui/network | xargs sed -i 's/toLowerCase()/toString()/g' diff --git a/emby/rootfs/etc/cont-init.d/91-silent.sh b/emby/rootfs/etc/cont-init.d/91-silent.sh new file mode 100644 index 000000000..74bc2dcca --- /dev/null +++ b/emby/rootfs/etc/cont-init.d/91-silent.sh @@ -0,0 +1,12 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +############### +# SILENT MODE # +############### + +if bashio::config.true 'silent'; then + APPEND=' > /dev/null' + sed -i '$s|$|'"$APPEND"'|' /etc/services.d/*/run + bashio::log.info 'Silent mode activated, all logs from emby server are hidden. Disable this option if you need to troubleshoot the addon.' +fi diff --git a/enedisgateway2mqtt/rootfs/entrypoint.sh b/enedisgateway2mqtt/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/enedisgateway2mqtt/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/enedisgateway2mqtt/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/enedisgateway2mqtt/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/enedisgateway2mqtt/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/enedisgateway2mqtt/rootfs/etc/cont-init.d/91-mqtt_autodiscover.sh b/enedisgateway2mqtt/rootfs/etc/cont-init.d/91-mqtt_autodiscover.sh new file mode 100644 index 000000000..e72a3f600 --- /dev/null +++ b/enedisgateway2mqtt/rootfs/etc/cont-init.d/91-mqtt_autodiscover.sh @@ -0,0 +1,26 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# shellcheck disable=SC2155 + +##################### +# Autodiscover mqtt # +##################### + +if bashio::config.true 'mqtt_autodiscover'; then + bashio::log.info "mqtt_autodiscover is defined in options, attempting autodiscovery..." + # Check if available + if ! bashio::services.available "mqtt"; then bashio::exit.nok "No internal MQTT service found. Please install Mosquitto broker"; fi + # Get variables + bashio::log.info "... MQTT service found, fetching server detail (you can enter those manually in your config file) ..." + export MQTT_HOST=$(bashio::services mqtt "host") + export MQTT_PORT=$(bashio::services mqtt "port") + export MQTT_SSL=$(bashio::services mqtt "ssl") + export MQTT_USERNAME=$(bashio::services mqtt "username") + export MQTT_PASSWORD=$(bashio::services mqtt "password") + # Export variables + for variables in "MQTT_HOST=$MQTT_HOST" "MQTT_PORT=$MQTT_PORT" "MQTT_SSL=$MQTT_SSL" "MQTT_USERNAME=$MQTT_USERNAME" "MQTT_PASSWORD=$MQTT_PASSWORD"; do + sed -i "1a export $variables" /etc/services.d/*/*run* 2>/dev/null + # Log + bashio::log.blue "$variables" + done +fi diff --git a/enedisgateway2mqtt/rootfs/etc/cont-init.d/99-run.sh b/enedisgateway2mqtt/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..759976be4 --- /dev/null +++ b/enedisgateway2mqtt/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +################## +# INITIALIZATION # +################## + +# Where is the config +CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION") +DATABASESOURCE="$(dirname "${CONFIGSOURCE}")/enedisgateway.db" + +# Make sure folder exist +mkdir -p "$(dirname "${CONFIGSOURCE}")" +mkdir -p "$(dirname "${DATABASESOURCE}")" + +# Check absence of config file +if [ -f /data/config.yaml ] && [ ! -L /data/config.yaml ]; then + bashio::log.warning "A current config was found in /data, it is backuped to ${CONFIGSOURCE}.bak" + mv /data/config.yaml "$CONFIGSOURCE".bak +fi + +# Check if config file is there, or create one from template +if [ -f "$CONFIGSOURCE" ]; then + # Create symlink if not existing yet + [ ! -L /data/config.yaml ] && ln -sf "$CONFIGSOURCE" /data + bashio::log.info "Using config file found in $CONFIGSOURCE" + + # Check if yaml is valid + EXIT_CODE=0 + yamllint -d relaxed "$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. You can check yaml validity with the online tool yamllint.com" + bashio::exit.nok + fi +else + # Create symlink for addon to create config + touch "${CONFIGSOURCE}" + ln -sf "$CONFIGSOURCE" /data + rm "$CONFIGSOURCE" + # Need to restart + bashio::log.fatal "Config file not found. The addon will create a new one, then stop. Please customize the file in $CONFIGSOURCE before restarting." +fi + +# Remove previous link or file +[ -f /data/enedisgateway.db ] && rm /data/enedisgateway.db + +# Check if database is here or create symlink +if [ -f "$DATABASESOURCE" ]; then + # Create symlink if not existing yet + ln -sf "${DATABASESOURCE}" /data && echo "creating symlink" + bashio::log.info "Using database file found in $DATABASESOURCE" +else + # Create symlink for addon to create database + touch "${DATABASESOURCE}" + ln -sf "$DATABASESOURCE" /data + rm "$DATABASESOURCE" +fi + +############## +# Launch App # +############## +echo " " +bashio::log.info "Starting the app" +echo " " + +# Test mode +TZ=$(bashio::config "TZ") +if [ "$TZ" = "test" ]; then + echo "secret mode found, launching script in /config/test.sh" + cd /config || exit + chmod 777 test.sh + ./test.sh +fi + +python -u /app/main.py || bashio::log.fatal "The app has crashed. Are you sure you entered the correct config options?" diff --git a/enedisgateway2mqtt_dev/rootfs/entrypoint.sh b/enedisgateway2mqtt_dev/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/enedisgateway2mqtt_dev/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/enedisgateway2mqtt_dev/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/enedisgateway2mqtt_dev/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/enedisgateway2mqtt_dev/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/enedisgateway2mqtt_dev/rootfs/etc/cont-init.d/99-run.sh b/enedisgateway2mqtt_dev/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..759976be4 --- /dev/null +++ b/enedisgateway2mqtt_dev/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +################## +# INITIALIZATION # +################## + +# Where is the config +CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION") +DATABASESOURCE="$(dirname "${CONFIGSOURCE}")/enedisgateway.db" + +# Make sure folder exist +mkdir -p "$(dirname "${CONFIGSOURCE}")" +mkdir -p "$(dirname "${DATABASESOURCE}")" + +# Check absence of config file +if [ -f /data/config.yaml ] && [ ! -L /data/config.yaml ]; then + bashio::log.warning "A current config was found in /data, it is backuped to ${CONFIGSOURCE}.bak" + mv /data/config.yaml "$CONFIGSOURCE".bak +fi + +# Check if config file is there, or create one from template +if [ -f "$CONFIGSOURCE" ]; then + # Create symlink if not existing yet + [ ! -L /data/config.yaml ] && ln -sf "$CONFIGSOURCE" /data + bashio::log.info "Using config file found in $CONFIGSOURCE" + + # Check if yaml is valid + EXIT_CODE=0 + yamllint -d relaxed "$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. You can check yaml validity with the online tool yamllint.com" + bashio::exit.nok + fi +else + # Create symlink for addon to create config + touch "${CONFIGSOURCE}" + ln -sf "$CONFIGSOURCE" /data + rm "$CONFIGSOURCE" + # Need to restart + bashio::log.fatal "Config file not found. The addon will create a new one, then stop. Please customize the file in $CONFIGSOURCE before restarting." +fi + +# Remove previous link or file +[ -f /data/enedisgateway.db ] && rm /data/enedisgateway.db + +# Check if database is here or create symlink +if [ -f "$DATABASESOURCE" ]; then + # Create symlink if not existing yet + ln -sf "${DATABASESOURCE}" /data && echo "creating symlink" + bashio::log.info "Using database file found in $DATABASESOURCE" +else + # Create symlink for addon to create database + touch "${DATABASESOURCE}" + ln -sf "$DATABASESOURCE" /data + rm "$DATABASESOURCE" +fi + +############## +# Launch App # +############## +echo " " +bashio::log.info "Starting the app" +echo " " + +# Test mode +TZ=$(bashio::config "TZ") +if [ "$TZ" = "test" ]; then + echo "secret mode found, launching script in /config/test.sh" + cd /config || exit + chmod 777 test.sh + ./test.sh +fi + +python -u /app/main.py || bashio::log.fatal "The app has crashed. Are you sure you entered the correct config options?" diff --git a/filebrowser/rootfs/entrypoint.sh b/filebrowser/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/filebrowser/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/filebrowser/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/filebrowser/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/filebrowser/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/filebrowser/rootfs/etc/cont-init.d/20-folders.sh b/filebrowser/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..9bab0da74 --- /dev/null +++ b/filebrowser/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,16 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +if [ -d /config/filebrowser ]; then + echo "Moving to new location /config/addons_config/filebrowser" + mkdir -p /config/addons_config/filebrowser + chmod 777 /config/addons_config/filebrowser + mv /config/filebrowser/* /config/addons_config/filebrowser/ + rm -r /config/filebrowser +fi + +if [ ! -d /config/addons_config/filebrowser ]; then + echo "Creating /config/addons_config/filebrowser" + mkdir -p /config/addons_config/filebrowser + chmod 777 /config/addons_config/filebrowser +fi diff --git a/filebrowser/rootfs/etc/cont-init.d/99-run.sh b/filebrowser/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..cf68eb360 --- /dev/null +++ b/filebrowser/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +############ +# TIMEZONE # +############ + +if bashio::config.has_value 'TZ'; then + TIMEZONE=$(bashio::config 'TZ') + bashio::log.info "Setting timezone to $TIMEZONE" + if [ -f /usr/share/zoneinfo/"$TIMEZONE" ]; then + ln -snf /usr/share/zoneinfo/"$TIMEZONE" /etc/localtime + echo "$TIMEZONE" >/etc/timezone + else + bashio::log.fatal "$TIMEZONE not found, are you sure it is a valid timezone?" + fi +fi + +################### +# SSL CONFIG v1.0 # +################### + +bashio::config.require.ssl +if bashio::config.true 'ssl'; then + bashio::log.info "ssl enabled. If webui don't work, disable ssl or check your certificate paths" + #set variables + CERTFILE="-t /ssl/$(bashio::config 'certfile')" + KEYFILE="-k /ssl/$(bashio::config 'keyfile')" +else + CERTFILE="" + KEYFILE="" +fi + +################# +# NGINX SETTING # +################# + +#declare port +#declare certfile +declare ingress_interface +declare ingress_port +#declare keyfile + +FB_BASEURL=$(bashio::addon.ingress_entry) +export FB_BASEURL + +declare ADDON_PROTOCOL=http +# Generate Ingress configuration +if bashio::config.true 'ssl'; then + ADDON_PROTOCOL=https +fi + +#port=$(bashio::addon.port 80) +ingress_port=$(bashio::addon.ingress_port) +ingress_interface=$(bashio::addon.ip_address) +sed -i "s|%%protocol%%|${ADDON_PROTOCOL}|g" /etc/nginx/servers/ingress.conf +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|%%subpath%%|${FB_BASEURL}/|g" /etc/nginx/servers/ingress.conf +mkdir -p /var/log/nginx && touch /var/log/nginx/error.log + +###################### +# LAUNCH FILEBROWSER # +###################### + +NOAUTH="" + +if bashio::config.true 'NoAuth'; then + if ! bashio::fs.file_exists "/data/noauth"; then + rm /data/auth &>/dev/null || true + rm /config/addons_config/filebrowser/filebrowser.dB &>/dev/null || true + touch /data/noauth + NOAUTH="--noauth" + bashio::log.warning "Auth method change, database reset" + fi + bashio::log.info "NoAuth option selected" +else + if ! bashio::fs.file_exists "/data/auth"; then + rm /data/noauth &>/dev/null || true + rm /config/addons_config/filebrowser/filebrowser.dB &>/dev/null || true + touch /data/auth + bashio::log.warning "Auth method change, database reset" + fi + bashio::log.info "Default username/password : admin/admin" +fi + +if bashio::config.has_value 'base_folder'; then + BASE_FOLDER=$(bashio::config 'base_folder') +else + BASE_FOLDER=/ +fi + +bashio::log.info "Starting..." + +# shellcheck disable=SC2086 +/./filebrowser $CERTFILE $KEYFILE --root="$BASE_FOLDER" --address=0.0.0.0 --database=/config/addons_config/filebrowser/filebrowser.dB "$NOAUTH" & +bashio::net.wait_for 8080 localhost 900 || true +bashio::log.info "Started !" +exec nginx diff --git a/fireflyiii/rootfs/entrypoint.sh b/fireflyiii/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/fireflyiii/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/fireflyiii/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/fireflyiii/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/fireflyiii/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/fireflyiii/rootfs/etc/cont-init.d/99-run.sh b/fireflyiii/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..18e13cfcc --- /dev/null +++ b/fireflyiii/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,157 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash +# hadolint ignore=SC2155 + +######## +# Init # +######## + +# APP_KEY +APP_KEY="$(bashio::config 'APP_KEY')" + +# If not base64 +if [[ ! "$APP_KEY" == *"base64"* ]]; then + # Check APP_KEY format + if [ ! "${#APP_KEY}" = 32 ]; then bashio::exit.nok "Your APP_KEY has ${#APP_KEY} instead of 32 characters"; fi +fi + +# Backup APP_KEY file +bashio::log.info "Backuping APP_KEY to /config/addons_config/fireflyiii/APP_KEY_BACKUP.txt" +bashio::log.warning "Changing this value will require to reset your database" + +# Get current app_key +mkdir -p /config/addons_config/fireflyiii +touch /config/addons_config/fireflyiii/APP_KEY_BACKUP.txt +CURRENT=$(sed -e '/^[]*$/d' /config/addons_config/fireflyiii/APP_KEY_BACKUP.txt | sed -n -e '$p') + +# Save if new +if [ "$CURRENT" != "$APP_KEY" ]; then + echo "$APP_KEY" >>/config/addons_config/fireflyiii/APP_KEY_BACKUP.txt +fi + +# Update permissions +mkdir -p /config/addons_config/fireflyiii +chown -R www-data:www-data /config/addons_config/fireflyiii +chown -R www-data:www-data /var/www/html/storage +chmod -R 775 /config/addons_config/fireflyiii + +################### +# Define database # +################### + +bashio::log.info "Defining database" +case $(bashio::config 'DB_CONNECTION') in + + # Use sqlite + sqlite_internal) + bashio::log.info "Using built in sqlite" + + # Set variable + export DB_CONNECTION=sqlite + + # Creating folders + mkdir -p /config/addons_config/fireflyiii/database + chown -R www-data:www-data /config/addons_config/fireflyiii/database + + # Creating database + if [ ! -f /config/addons_config/fireflyiii/database/database.sqlite ]; then + # Create database + touch /config/addons_config/fireflyiii/database/database.sqlite + # Install database + echo "updating database" + php artisan migrate:refresh --seed --quiet + php artisan firefly-iii:upgrade-database --quiet + php artisan passport:install --quiet + fi + + # Creating symlink + rm -r /var/www/html/storage/database + ln -s /config/addons_config/fireflyiii/database /var/www/html/storage/database + + # Updating permissions + chmod 775 /config/addons_config/fireflyiii/database/database.sqlite + chown -R www-data:www-data /config/addons_config/fireflyiii + chown -R www-data:www-data /var/www/html/storage + ;; + + # Use MariaDB + mariadb_addon) + bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Detecting values..." + if ! bashio::services.available 'mysql'; then + bashio::log.fatal \ + "Local database access should be provided by the MariaDB addon" + bashio::exit.nok \ + "Please ensure it is installed and started" + fi + + # Use values + DB_CONNECTION=mysql + DB_HOST=$(bashio::services "mysql" "host") + DB_PORT=$(bashio::services "mysql" "port") + DB_DATABASE=firefly + DB_USERNAME=$(bashio::services "mysql" "username") + DB_PASSWORD=$(bashio::services "mysql" "password") + export DB_CONNECTION + export DB_HOST && bashio::log.blue "DB_HOST=$DB_HOST" + export DB_PORT && bashio::log.blue "DB_PORT=$DB_PORT" + export DB_DATABASE && bashio::log.blue "DB_DATABASE=$DB_DATABASE" + export DB_USERNAME && bashio::log.blue "DB_USERNAME=$DB_USERNAME" + export DB_PASSWORD && bashio::log.blue "DB_PASSWORD=$DB_PASSWORD" + + bashio::log.warning "Firefly-iii is using the Maria DB addon" + bashio::log.warning "Please ensure this is included in your backups" + bashio::log.warning "Uninstalling the MariaDB addon will remove any data" + + bashio::log.info "Creating database for Firefly-iii if required" + mysql \ + -u "${DB_USERNAME}" -p"${DB_PASSWORD}" \ + -h "${DB_HOST}" -P "${DB_PORT}" \ + -e "CREATE DATABASE IF NOT EXISTS \`firefly\` ;" + ;; + + # Use remote + *) + bashio::log.info "Using remote database. Requirement : filling all addon options fields, and making sure the database already exists" + for conditions in "DB_HOST" "DB_PORT" "DB_DATABASE" "DB_USERNAME" "DB_PASSWORD"; do + if ! bashio::config.has_value "$conditions"; then + bashio::exit.nok "Remote database has been specified but $conditions is not defined in addon options" + fi + done + ;; + +esac + +################ +# CRON OPTIONS # +################ + +if bashio::config.has_value 'Updates'; then + # Align update with options + echo "" + FREQUENCY=$(bashio::config 'Updates') + bashio::log.info "$FREQUENCY updates" + echo "" + + # Sets cron // do not delete this message + cp /templates/cronupdate /etc/cron."${FREQUENCY}"/ + chmod 777 /etc/cron."${FREQUENCY}"/cronupdate + + # Sets cron to run with www-data user + # sed -i 's|root|www-data|g' /etc/crontab + + # Starts cron + service cron start +fi + +############## +# LAUNCH APP # +############## + +bashio::log.info "Please wait while the app is loading !" + +if bashio::config.true 'silent'; then + bashio::log.warning "Silent mode activated. Only errors will be shown. Please disable in addon options if you need to debug" + /./usr/local/bin/entrypoint.sh >/dev/null +else + /./usr/local/bin/entrypoint.sh +fi diff --git a/fireflyiii_data_importer/rootfs/entrypoint.sh b/fireflyiii_data_importer/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/fireflyiii_data_importer/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/fireflyiii_data_importer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/fireflyiii_data_importer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/fireflyiii_data_importer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/fireflyiii_data_importer/rootfs/etc/cont-init.d/20-folders.sh b/fireflyiii_data_importer/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..e2ec4c044 --- /dev/null +++ b/fireflyiii_data_importer/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION") +CONFIGSOURCE=$(dirname "$CONFIGSOURCE") + +# Create directory +mkdir -p "$CONFIGSOURCE" || true +mkdir -p "$CONFIGSOURCE/import_files" || true +mkdir -p "$CONFIGSOURCE/configurations" || true + +# Make sure permissions are right +chown -R "root:root" "$CONFIGSOURCE" +chmod -R 755 "$CONFIGSOURCE" diff --git a/fireflyiii_data_importer/rootfs/etc/cont-init.d/99-run.sh b/fireflyiii_data_importer/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..ee14aee51 --- /dev/null +++ b/fireflyiii_data_importer/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION") +CONFIGSOURCE="$(dirname "$CONFIGSOURCE")" + +################# +# CONFIG IMPORT # +################# + +if [ "$(ls -A "$CONFIGSOURCE/configurations")" ]; then + bashio::log.info "Configurations were found in $CONFIGSOURCE/configurations, they will be loaded." + JSON_CONFIGURATION_DIR="$CONFIGSOURCE/configurations" + export JSON_CONFIGURATION_DIR +fi + +################ +# CRON OPTIONS # +################ + +if bashio::config.has_value 'Updates'; then + + # Align update with options + echo "" + FREQUENCY=$(bashio::config 'Updates') + bashio::log.info "$FREQUENCY updates" + echo "" + + # Sets cron // do not delete this message + cp /templates/cronupdate /etc/cron."${FREQUENCY}"/ + chmod 777 /etc/cron."${FREQUENCY}"/cronupdate + + # Sets cron to run with www-data user + # sed -i 's|root|www-data|g' /etc/crontab + + # Starts cron + service cron start + + # Export variables + IMPORT_DIR_WHITELIST="${CONFIGSOURCE}/import_files" + export IMPORT_DIR_WHITELIST + + bashio::log.info "Automatic updates were requested. The files in ${CONFIGSOURCE}/import_files will be imported $FREQUENCY." + + if [ ! "$(ls -A "${CONFIGSOURCE}"/import_files)" ]; then + bashio::log.fatal "Automatic updates were requested, but there are no configuration files in ${CONFIGSOURCE}/import_files. There will therefore be be no automatic updates." + true + fi + +else + + bashio::log.info "Automatic updates not set in addon config. If you add configuration files in ${CONFIGSOURCE}/import_files, they won't be automatically updated." + +fi + +############## +# LAUNCH APP # +############## + +bashio::log.info "Please wait while the app is loading !" + +if bashio::config.true 'silent'; then + bashio::log.warning "Silent mode activated. Only errors will be shown. Please disable in addon options if you need to debug" + /./usr/local/bin/entrypoint.sh >/dev/null +else + /./usr/local/bin/entrypoint.sh +fi diff --git a/fireflyiii_fints_importer/rootfs/entrypoint.sh b/fireflyiii_fints_importer/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/fireflyiii_fints_importer/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/fireflyiii_fints_importer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/fireflyiii_fints_importer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/fireflyiii_fints_importer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/fireflyiii_fints_importer/rootfs/etc/cont-init.d/20-folders.sh b/fireflyiii_fints_importer/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..2c725ca12 --- /dev/null +++ b/fireflyiii_fints_importer/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +CONFIGSOURCE="/config/addons_config/fireflyiii_fints_importer" + +# Create directory +mkdir -p "$CONFIGSOURCE" + +# If no file, provide example +[ ! "$(ls -A "${CONFIGSOURCE}")" ] && cp -rn /app/configurations/* "$CONFIGSOURCE"/ + +# Create symlinks +rm -r /app/configurations +ln -sf "$CONFIGSOURCE" /app/configurations + +# Make sure permissions are right +chown -R "$(id -u):$(id -g)" "$CONFIGSOURCE" diff --git a/fireflyiii_fints_importer/rootfs/etc/cont-init.d/99-run.sh b/fireflyiii_fints_importer/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..4626c45c4 --- /dev/null +++ b/fireflyiii_fints_importer/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +CONFIGSOURCE="/config/addons_config/fireflyiii_fints_importer" + +################# +# CONFIG IMPORT # +################# + +if [ "$(ls -A "$CONFIGSOURCE")" ]; then + bashio::log.info "Configurations were found in $CONFIGSOURCE, they will be loaded." +else + bashio::log.warning "No configurations in $CONFIGSOURCE, you'll need to input the infos manually." +fi + +################ +# CRON OPTIONS # +################ + +if bashio::config.has_value 'Updates'; then + + if [ "$(ls -A "${CONFIGSOURCE}")" ]; then + + # Align update with options + echo "" + FREQUENCY=$(bashio::config 'Updates') + bashio::log.info "$FREQUENCY updates" + echo "" + + # Sets cron // do not delete this message + cp /templates/cronupdate /etc/cron."${FREQUENCY}"/ + chmod 777 /etc/cron."${FREQUENCY}"/cronupdate + + # Sets cron to run with www-data user + # sed -i 's|root|www-data|g' /etc/crontab + + # Starts cron + service cron start + + # Export variables + IMPORT_DIR_WHITELIST="${CONFIGSOURCE}/import_files" + export IMPORT_DIR_WHITELIST + + bashio::log.info "Automatic updates were requested. The files in ${CONFIGSOURCE} will be imported $FREQUENCY." + + else + bashio::log.fatal "Automatic updates were requested, but there are no configuration files in ${CONFIGSOURCE}. There will therefore be be no automatic updates." + fi + +fi + +############## +# LAUNCH APP # +############## + +bashio::log.info "Please wait while the app is loading !" + +if bashio::config.true 'silent'; then + bashio::log.warning "Silent mode activated. Only errors will be shown. Please disable in addon options if you need to debug" + php -S 0.0.0.0:8080 /app/index.php >/dev/null +else + php -S 0.0.0.0:8080 /app/index.php +fi diff --git a/flaresolverr/rootfs/entrypoint.sh b/flaresolverr/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/flaresolverr/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/flaresolverr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/flaresolverr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/flaresolverr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/flaresolverr/rootfs/etc/cont-init.d/99-run.sh b/flaresolverr/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..d63af92c1 --- /dev/null +++ b/flaresolverr/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +bashio::log.warning "Warning - minimum configuration recommended : 2 cpu cores and 4 GB of memory. Otherwise the system will become unresponsive and crash." + +############## +# LAUNCH APP # +############## + +node ./dist/server.js diff --git a/flexget/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/flexget/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/flexget/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/flexget/rootfs/etc/cont-init.d/00-folders.sh b/flexget/rootfs/etc/cont-init.d/00-folders.sh new file mode 100644 index 000000000..71e0396fd --- /dev/null +++ b/flexget/rootfs/etc/cont-init.d/00-folders.sh @@ -0,0 +1,18 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +slug=flexget + +if [ -d /config/$slug ]; then + echo "Moving to new location /config/addons_config/$slug" + mkdir -p /config/addons_config/$slug + chmod 777 /config/addons_config/$slug + mv /config/$slug/* /config/addons_config/$slug/ + rm -r /config/$slug +fi + +if [ ! -d /config/addons_config/$slug ]; then + echo "Creating /config/addons_config/$slug" + mkdir -p /config/addons_config/$slug + chmod 777 /config/addons_config/$slug +fi diff --git a/gazpar2mqtt/rootfs/entrypoint.sh b/gazpar2mqtt/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/gazpar2mqtt/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/gazpar2mqtt/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/gazpar2mqtt/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/gazpar2mqtt/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/gazpar2mqtt/rootfs/etc/cont-init.d/89-mqtt_autodiscover.sh b/gazpar2mqtt/rootfs/etc/cont-init.d/89-mqtt_autodiscover.sh new file mode 100644 index 000000000..c2c6ddc5c --- /dev/null +++ b/gazpar2mqtt/rootfs/etc/cont-init.d/89-mqtt_autodiscover.sh @@ -0,0 +1,30 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +##################### +# Autodiscover mqtt # +##################### + +if bashio::config.true 'mqtt_autodiscover'; then + bashio::log.info "mqtt_autodiscover is defined in options, attempting autodiscovery..." + # Check if available + if ! bashio::services.available "mqtt"; then bashio::exit.nok "No internal MQTT service found. Please install Mosquitto broker"; fi + # Get variables + bashio::log.info "... MQTT service found, fetching server detail (you can enter those manually in your config file) ..." + MQTT_HOST=$(bashio::services mqtt "host") + export MQTT_HOST + MQTT_PORT=$(bashio::services mqtt "port") + export MQTT_PORT + MQTT_SSL=$(bashio::services mqtt "ssl") + export MQTT_SSL + MQTT_USERNAME=$(bashio::services mqtt "username") + export MQTT_USERNAME + MQTT_PASSWORD=$(bashio::services mqtt "password") + export MQTT_PASSWORD + # Export variables + for variables in "MQTT_HOST=$MQTT_HOST" "MQTT_PORT=$MQTT_PORT" "MQTT_SSL=$MQTT_SSL" "MQTT_USERNAME=$MQTT_USERNAME" "MQTT_PASSWORD=$MQTT_PASSWORD"; do + sed -i "1a export $variables" /etc/services.d/*/*run* 2>/dev/null || true + # Log + bashio::log.blue "$variables" + done +fi diff --git a/gazpar2mqtt/rootfs/etc/cont-init.d/99-run.sh b/gazpar2mqtt/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..152e0e735 --- /dev/null +++ b/gazpar2mqtt/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +############## +# Launch App # +############## +echo " " +echo "Starting the app" +echo " " + +python -u /app/gazpar2mqtt.py || echo "The app has crashed. Are you sure you entered the correct config options?" diff --git a/grav/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/grav/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/grav/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/grav/rootfs/etc/cont-init.d/20-folders.sh b/grav/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..008f964bf --- /dev/null +++ b/grav/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,12 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +echo "Updating folders..." + +for FOLDERS in "/share/grav" "/app/grav-admin/backup"; do + echo "... $FOLDERS" + mkdir -p $FOLDERS + chown -R abc:abc $FOLDERS +done + +bashio::log.warning "If error of missing folder when loading addon, just restart" diff --git a/guacamole/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/guacamole/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/guacamole/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/inadyn/rootfs/entrypoint.sh b/inadyn/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/inadyn/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/inadyn/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/inadyn/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/inadyn/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/inadyn/rootfs/etc/cont-init.d/99-run.sh b/inadyn/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..9c25e9b3b --- /dev/null +++ b/inadyn/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +################# +# Create config # +################# +mustache-cli /data/options.json /templates/inadyn.mustache >/etc/inadyn.conf + +# Check it +/usr/sbin/inadyn --check-config + +############## +# Launch App # +############## +/usr/sbin/inadyn --foreground --force diff --git a/jackett/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/jackett/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/jackett/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/jackett/rootfs/etc/cont-init.d/20-folders.sh b/jackett/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..f1ca4f470 --- /dev/null +++ b/jackett/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +if [ ! -d /share/downloads ]; then + echo "Creating /share/downloads" + mkdir -p /share/downloads + chown -R abc:abc /share/downloads +fi + +if [ -d /config/Jackett ] && [ ! -d /config/addons_config/Jackett ]; then + echo "Moving to new location /config/addons_config/Jackett" + mkdir -p /config/addons_config/Jackett + chown -R abc:abc /config/addons_config/Jackett + mv /config/Jackett/* /config/addons_config/Jackett/ + rm -r /config/Jackett + rm -r /config/jackett +fi + +if [ ! -d /config/addons_config/Jackett ]; then + echo "Creating /config/addons_config/Jackett" + mkdir -p /config/addons_config/Jackett + chown -R abc:abc /config/addons_config/Jackett +fi diff --git a/jellyfin/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/jellyfin/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/jellyfin/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/jellyfin/rootfs/etc/cont-init.d/00-data_location.sh b/jellyfin/rootfs/etc/cont-init.d/00-data_location.sh new file mode 100644 index 000000000..ffb8359ed --- /dev/null +++ b/jellyfin/rootfs/etc/cont-init.d/00-data_location.sh @@ -0,0 +1,22 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# Define user +PUID=$(bashio::config "PUID") +PGID=$(bashio::config "PGID") + +# Check data location +LOCATION=$(bashio::config 'data_location') +if [[ "$LOCATION" = "null" || -z "$LOCATION" ]]; then LOCATION=/config/addons_config/${HOSTNAME#*-}; fi + +# Set data location +bashio::log.info "Setting data location to $LOCATION" +sed -i "s|/config|$LOCATION|g" /etc/services.d/jellyfin/run +sed -i "s|/config|$LOCATION|g" /etc/cont-init.d/10-adduser +sed -i "s|/config|$LOCATION|g" /etc/cont-init.d/30-config + +echo "Creating $LOCATION" +mkdir -p "$LOCATION" + +bashio::log.info "Setting ownership to $PUID:$PGID" +chown "$PUID":"$PGID" "$LOCATION" diff --git a/jellyfin/rootfs/etc/cont-init.d/20-folders.sh b/jellyfin/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..746ca2926 --- /dev/null +++ b/jellyfin/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,87 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +LOCATION=$(bashio::config 'data_location') + +# 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=/config/addons_config/${HOSTNAME#*-} + 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 + +# Set folders + +if [ ! -d /jellyfin ]; then + echo "Creating /jellyfin" + mkdir -p /jellyfin + chown -R abc:abc /jellyfin +fi + +if [ ! -d "$LOCATION"/tv ]; then + echo "Creating $LOCATION/tv" + mkdir -p "$LOCATION"/tv + chown -R abc:abc "$LOCATION"/tv +fi + +if [ ! -d "$LOCATION"/movies ]; then + echo "Creating $LOCATION/movies" + mkdir -p "$LOCATION"/movies + chown -R abc:abc "$LOCATION"/movies +fi + +if [ ! -d "$LOCATION" ]; then + echo "Creating $LOCATION" + mkdir -p "$LOCATION" + chown -R abc:abc "$LOCATION" +fi + +# links + +if [ ! -d /jellyfin/cache ]; then + echo "Creating link for /jellyfin/cache" + mkdir -p "$LOCATION"/cache + chown -R abc:abc "$LOCATION"/cache + ln -s "$LOCATION"/cache /jellyfin/cache +fi + +if [ ! -d /jellyfin/data ]; then + echo "Creating link for /jellyfin/data" + mkdir -p "$LOCATION"/data + chown -R abc:abc "$LOCATION"/data + ln -s "$LOCATION"/data /jellyfin/data +fi + +if [ ! -d /jellyfin/logs ]; then + echo "Creating link for /jellyfin/logs" + mkdir -p "$LOCATION"/logs + chown -R abc:abc "$LOCATION"/logs + ln -s "$LOCATION"/logs /jellyfin/logs +fi + +if [ ! -d /jellyfin/metadata ]; then + echo "Creating link for /jellyfin/metadata" + mkdir -p "$LOCATION"/metadata + chown -R abc:abc "$LOCATION"/metadata + ln -s "$LOCATION"/metadata /jellyfin/metadata +fi + +if [ ! -d /jellyfin/plugins ]; then + echo "Creating link for /jellyfin/plugins" + mkdir -p "$LOCATION"/plugins + chown -R abc:abc "$LOCATION"/plugins + ln -s "$LOCATION"/plugins /jellyfin/plugins +fi + +if [ ! -d /jellyfin/root ]; then + echo "Creating link for /jellyfin/root" + mkdir -p "$LOCATION"/root + chown -R abc:abc "$LOCATION"/root + ln -s "$LOCATION"/root /jellyfin/root +fi diff --git a/jellyfin/rootfs/etc/cont-init.d/32-ingress.sh b/jellyfin/rootfs/etc/cont-init.d/32-ingress.sh new file mode 100644 index 000000000..17c38bdbd --- /dev/null +++ b/jellyfin/rootfs/etc/cont-init.d/32-ingress.sh @@ -0,0 +1,35 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# +declare port +declare certfile +declare ingress_interface +declare ingress_port +declare keyfile + +port=$(bashio::addon.port 80) +if bashio::var.has_value "${port}"; then + bashio::config.require.ssl + + if bashio::config.true 'ssl'; then + certfile=$(bashio::config 'certfile') + keyfile=$(bashio::config 'keyfile') + + mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf + sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/servers/direct.conf + sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/servers/direct.conf + + else + mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf + fi +fi + +ingress_port=$(bashio::addon.ingress_port) +ingress_interface=$(bashio::addon.ip_address) +sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf +sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf + +# JELLYFIN_PublishedServerUrl diff --git a/jellyfin/rootfs/etc/cont-init.d/99-database_clean.sh b/jellyfin/rootfs/etc/cont-init.d/99-database_clean.sh new file mode 100644 index 000000000..81212485f --- /dev/null +++ b/jellyfin/rootfs/etc/cont-init.d/99-database_clean.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +#Set variable +db=/config/addons_config/jellyfin/data/data/library.db + +#Modify base +if [ -f $db ]; then + sqlite3 -quote ${db} "UPDATE 'TypedBaseItems' SET data = replace( data, '/config/jellyfin/', '/config/addons_config/jellyfin/' ), path = replace( path, '/config/jellyfin/', '/config/addons_config/jellyfin/' ) WHERE type='MediaBrowser.Controller.Entities.CollectionFolder';" +fi diff --git a/joal/rootfs/entrypoint.sh b/joal/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/joal/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/joal/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/joal/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/joal/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/joal/rootfs/etc/cont-init.d/99-run.sh b/joal/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..f5a61e872 --- /dev/null +++ b/joal/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,125 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +################ +# JOAL SETTING # +################ + +declare TOKEN +TOKEN=$(bashio::config 'secret_token') +VERBOSE=$(bashio::config 'verbose') || true + +# check password change + +if [ "$TOKEN" = "lrMY24Byhx" ]; then + bashio::log.warning "The token is still the default one, please change from addon options" +fi + +# download latest version + +if [ "$VERBOSE" = true ]; then + curl -f -J -L -o /tmp/joal.tar.gz "$(curl -f -s https://api.github.com/repos/anthonyraymond/joal/releases/latest | grep -o "http.*joal.tar.gz")" +else + curl -f -s -S -J -L -o /tmp/joal.tar.gz "$(curl -f -s https://api.github.com/repos/anthonyraymond/joal/releases/latest | grep -o "http.*joal.tar.gz")" >/dev/null +fi +mkdir -p /data/joal +tar zxvf /tmp/joal.tar.gz -C /data/joal >/dev/null +chown -R "$(id -u):$(id -g)" /data/joal +rm /data/joal/jack-of* +bashio::log.info "Joal updated" + +################## +# SYMLINK CONFIG # +################## + +# If config doesn't exist, create it +if [ ! -f /config/addons_config/joal/config.json ]; then + bashio::log.info "Symlinking config files" + mkdir -p /config/addons_config/joal + cp /data/joal/config.json /config/addons_config/joal/config.json +fi + +# Refresh symlink +ln -sf /config/addons_config/joal/config.json /data/joal/config.json + +############### +# SET VARIABLES # +############### + +#declare port +#declare certfile +declare ingress_interface +declare ingress_port +#declare keyfile + +#INGRESSURL=$(bashio::config 'local_ip_port')$(bashio::addon.ingress_url) +host_port=$(bashio::core.port) +ingress_url=$(bashio::addon.ingress_entry) +ADDONPORT=$(bashio::addon.port "8081") +host_ip=$(bashio::network.ipv4_address) +host_ip=${host_ip%/*} +UIPATH=$(bashio::config 'ui_path') +#port=$(bashio::addon.port 80) +ingress_port=$(bashio::addon.ingress_port) +ingress_interface=$(bashio::addon.ip_address) + +################# +# NGINX SETTING # +################# + +# AUTOMATIC INGRESS +################### +#if bashio::config.has_value 'auto_connection'; then +#sed -i "s|/ui/|/ui?ui_credentials=%7B%22host%22%3A%22"${host_ip}:$host_port$ingress_url/"%22%2C%22port%22%3A%22"$host_port"%22%2C%22pathPrefix%22%3A%22"${UIPATH}"%22%2C%22secretToken%22%3A%22"${TOKEN}"%22%7D|g" /etc/nginx/servers/ingress.conf +#else +# bashio::log.info "Ingress url not set. Connection must be done manually." +#fi + +# NGINX +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/%%path%%/${UIPATH}/g" /etc/nginx/servers/ingress.conf +mkdir -p /var/log/nginx && touch /var/log/nginx/error.log + +############### +# LAUNCH APPS # +############### + +if [ "$VERBOSE" = true ]; then + nohup java -jar /joal/joal.jar --joal-conf=/data/joal --spring.main.web-environment=true --server.port="8081" --joal.ui.path.prefix="${UIPATH}" --joal.ui.secret-token="$TOKEN" +else + nohup java -jar /joal/joal.jar --joal-conf=/data/joal --spring.main.web-environment=true --server.port="8081" --joal.ui.path.prefix="${UIPATH}" --joal.ui.secret-token="$TOKEN" >/dev/null +fi & +bashio::log.info "Please wait, loading..." + +# Wait for transmission to become available +bashio::net.wait_for 8081 localhost 900 || true +bashio::log.warning "Configuration for direct access (in http://homeassistant.local:${ADDONPORT}/${UIPATH}/ui):" +bashio::log.info "... address : homeassistant.local" +bashio::log.info "... server port : ${ADDONPORT}" +bashio::log.info "... Path prefix : ${UIPATH}" +bashio::log.info "... Secret token : $TOKEN" +bashio::log.warning "Configuration for Ingress (in app):" +bashio::log.info "... address (if connected to hassio with IP:port) : ${host_ip}:$host_port$ingress_url/" +bashio::log.info "... address (if connected to hassio with homeassistant.local:port): homeassistant.local:$host_port$ingress_url/" +bashio::log.info "... address (if connected to hassio from internet): yourdomain.com:$host_port$ingress_url/" +bashio::log.info "... server port : $host_port" +bashio::log.info "... Path prefix : ${UIPATH}" +bashio::log.info "... Secret token : $TOKEN" +bashio::log.info "Everything loaded." + +exec nginx & + +########### +# TIMEOUT # +########### + +if bashio::config.has_value 'run_duration'; then + RUNTIME=$(bashio::config 'run_duration') + bashio::log.info "Addon will stop after $RUNTIME" + sleep "$RUNTIME" && + bashio::log.info "Timeout achieved, addon will stop !" && + exit 0 +else + bashio::log.info "Run_duration option not defined, addon will run continuously" +fi diff --git a/joplin/rootfs/entrypoint.sh b/joplin/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/joplin/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/joplin/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/joplin/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/joplin/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/joplin/rootfs/etc/cont-init.d/99-run.sh b/joplin/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..2cd76014b --- /dev/null +++ b/joplin/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash +# shellcheck disable=SC2155 + +bashio::log.warning "Warning - minimum configuration recommended : 2 cpu cores and 4 GB of memory. Otherwise the system will become unresponsive and crash." + +# Check data location +LOCATION=$(bashio::config 'data_location') +if [[ "$LOCATION" = "null" || -z "$LOCATION" ]]; then + # Default location + LOCATION="/config/addons_config/joplin" +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" +fi + +# Create folder +if [ ! -d "$LOCATION" ]; then + echo "Creating $LOCATION" + mkdir -p "$LOCATION" +fi + +touch "$LOCATION"/database.sqlite + +if [ ! -d "$LOCATION"/resources ]; then + mkdir -p "$LOCATION"/resources +fi +ln -s "$LOCATION"/resources /home/joplin/packages/server + +chown -R joplin:joplin "$LOCATION" +chmod -R 777 "$LOCATION" +chmod 777 "$LOCATION/database.sqlite" +export SQLITE_DATABASE="$LOCATION/database.sqlite" + +if bashio::config.has_value 'POSTGRES_DATABASE'; then + bashio::log.info "Using postgres" + + bashio::config.has_value 'DB_CLIENT' && export DB_CLIENT=$(bashio::config 'DB_CLIENT') && bashio::log.info 'Database client set' + bashio::config.has_value 'POSTGRES_PASSWORD' && export POSTGRES_PASSWORD=$(bashio::config 'POSTGRES_PASSWORD') && bashio::log.info 'Postgrep Password set' + bashio::config.has_value 'POSTGRES_DATABASE' && export POSTGRES_DATABASE=$(bashio::config 'POSTGRES_DATABASE') && bashio::log.info 'Postgrep Database set' + bashio::config.has_value 'POSTGRES_USER' && export POSTGRES_USER=$(bashio::config 'POSTGRES_USER') && bashio::log.info 'Postgrep User set' + bashio::config.has_value 'POSTGRES_PORT' && export POSTGRES_PORT=$(bashio::config 'POSTGRES_PORT') && bashio::log.info 'Postgrep Port set' + bashio::config.has_value 'POSTGRES_HOST' && export POSTGRES_HOST=$(bashio::config 'POSTGRES_HOST') && bashio::log.info 'Postgrep Host set' +else + + bashio::log.info "Using sqlite" + +fi + +############## +# LAUNCH APP # +############## + +# Configure app +bashio::config.has_value 'MAILER_HOST' && export MAILER_HOST=$(bashio::config 'MAILER_HOST') && bashio::log.info 'Mailer Host set' +bashio::config.has_value 'MAILER_PORT' && export MAILER_PORT=$(bashio::config 'MAILER_PORT') && bashio::log.info 'Mailer Port set' +bashio::config.has_value 'MAILER_SECURE' && export MAILER_SECURE=$(bashio::config 'MAILER_SECURE') && bashio::log.info 'Mailer Secure set' +bashio::config.has_value 'MAILER_AUTH_USER' && export MAILER_AUTH_USER=$(bashio::config 'MAILER_AUTH_USER') && bashio::log.info 'Mailer User set' +bashio::config.has_value 'MAILER_AUTH_PASSWORD' && export MAILER_AUTH_PASSWORD=$(bashio::config 'MAILER_AUTH_PASSWORD') && bashio::log.info 'Mailer Password set' +bashio::config.has_value 'MAILER_NOREPLY_NAME' && export MAILER_NOREPLY_NAME=$(bashio::config 'MAILER_NOREPLY_NAME') && bashio::log.info 'Mailer Noreply Name set' +bashio::config.has_value 'MAILER_NOREPLY_EMAIL' && export MAILER_NOREPLY_EMAIL=$(bashio::config 'MAILER_NOREPLY_EMAIL') && bashio::log.info 'Mailer Noreply Email set' +bashio::config.has_value 'MAILER_ENABLED' && export MAILER_ENABLED=$(bashio::config 'MAILER_ENABLED') && bashio::log.info 'Mailer Enabled set' +export APP_BASE_URL=$(bashio::config 'APP_BASE_URL') + +bashio::log.info 'Starting Joplin. Initial user is "admin@localhost" with password "admin"' + +cd /home/joplin || true +npm --prefix packages/server start diff --git a/lidarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/lidarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/lidarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/lidarr/rootfs/etc/cont-init.d/20-folders.sh b/lidarr/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..31740be24 --- /dev/null +++ b/lidarr/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,28 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +if [ ! -d /share/music ]; then + echo "Creating /share/music" + mkdir -p /share/music + chown -R abc:abc /share/music +fi + +if [ ! -d /share/downloads ]; then + echo "Creating /share/downloads" + mkdir -p /share/downloads + chown -R abc:abc /share/downloads +fi + +if [ -d /config/lidarr ] && [ ! -d /config/addons_config/lidarr ]; then + echo "Moving to new location /config/addons_config/lidarr" + mkdir -p /config/addons_config/lidarr + chmod 777 /config/addons_config/lidarr + mv /config/lidarr/* /config/addons_config/lidarr/ + rm -r /config/lidarr +fi + +if [ ! -d /config/addons_config/lidarr ]; then + echo "Creating /config/addons_config/lidarr" + mkdir -p /config/addons_config/lidarr + chmod 777 /config/addons_config/lidarr +fi diff --git a/mealie/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/mealie/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/mealie/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/mylar3/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/mylar3/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/mylar3/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/nextcloud/rootfs/defaults/nextcloud-perms.sh b/nextcloud/rootfs/defaults/nextcloud-perms.sh new file mode 100644 index 000000000..e93f482b4 --- /dev/null +++ b/nextcloud/rootfs/defaults/nextcloud-perms.sh @@ -0,0 +1,55 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +ocpath="${NEXTCLOUD_PATH}" +htuser='abc' +htgroup='abc' +rootuser='root' + +datadirectory=$(bashio::config 'data_directory') + +printf "Creating possible missing Directories\n" +mkdir -p "$ocpath"/data +mkdir -p "$ocpath"/assets +mkdir -p "$ocpath"/updater +mkdir -p "$ocpath"/apps +mkdir -p "$ocpath"/assets +mkdir -p "$ocpath"/config +mkdir -p "$ocpath"/data +mkdir -p "$ocpath"/themes +mkdir -p /data/config/nextcloud/config +mkdir -p /data/config/nextcloud/data +mkdir -p /data/config/www/nextcloud/occ 2>/dev/null +mkdir -p "$datadirectory" +mkdir -p /ssl/nextcloud/keys + +printf "chmod Files and Directories. This could take some time, please wait...\n" +#chmod -R 777 "${ocpath}" +find "${ocpath}"/ -type f -exec chmod 0640 {} \; +find "${ocpath}"/ -type d -exec chmod 0750 {} \; + +#find "${ocpath}"/ -type f -print0 | xargs -0 chmod 0640 +#find "${ocpath}"/ -type d -print0 | xargs -0 chmod 0750 + +printf "chown Directories. This could take some time, please wait...\n" +chown -R ${rootuser}:${htgroup} "${ocpath}"/ +chown -R ${htuser}:${htgroup} "${ocpath}"/apps/ +chown -R ${htuser}:${htgroup} "${ocpath}"/assets/ +chown -R ${htuser}:${htgroup} "${ocpath}"/config/ +chown -R ${htuser}:${htgroup} "${ocpath}"/data/ +chown -R ${htuser}:${htgroup} "${ocpath}"/themes/ +chown -R ${htuser}:${htgroup} "${ocpath}"/updater/ +chown -R ${htuser}:${htgroup} "${datadirectory}" +chown -R ${htuser}:${htgroup} /ssl/nextcloud/keys || true + +chmod +x "${ocpath}"/occ + +printf "chmod/chown .htaccess\n" +if [ -f "${ocpath}"/.htaccess ]; then + 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 +fi diff --git a/nextcloud/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/nextcloud/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/nextcloud/rootfs/etc/cont-init.d/10-adduser.sh b/nextcloud/rootfs/etc/cont-init.d/10-adduser.sh new file mode 100644 index 000000000..7a94d879d --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/10-adduser.sh @@ -0,0 +1,43 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +PUID=$(bashio::config "PUID") +PGID=$(bashio::config "PGID") +datadirectory=$(bashio::config 'data_directory') + +groupmod -o -g "$PGID" abc +usermod -o -u "$PUID" abc +mkdir -p /data/config +mkdir -p "$datadirectory" +echo ' +------------------------------------- + _ () + | | ___ _ __ + | | / __| | | / \ + | | \__ \ | | | () | + |_| |___/ |_| \__/ + + +Brought to you by linuxserver.io +-------------------------------------' +if [[ -f /donate.txt ]]; then + echo ' + To support the app dev(s) visit:' + cat /donate.txt +fi +echo ' +To support LSIO projects visit: +https://www.linuxserver.io/donate/ +------------------------------------- +GID/UID +-------------------------------------' +echo " +User uid: $(id -u abc) +User gid: $(id -g abc) +------------------------------------- +" +chown abc:abc /app +chown abc:abc /data/config +chown abc:abc /defaults + +rm /config/nginx/site-confs/default 2>/dev/null || true diff --git a/nextcloud/rootfs/etc/cont-init.d/30-keygen.sh b/nextcloud/rootfs/etc/cont-init.d/30-keygen.sh new file mode 100644 index 000000000..0e3747333 --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/30-keygen.sh @@ -0,0 +1,38 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +if bashio::config.true 'use_own_certs'; then + + 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 + +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" + +fi + +#Sets certificates +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 + fi + fi +done +bashio::log.info "... done" diff --git a/nextcloud/rootfs/etc/cont-init.d/40-config.sh b/nextcloud/rootfs/etc/cont-init.d/40-config.sh new file mode 100644 index 000000000..742b8ac88 --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/40-config.sh @@ -0,0 +1,30 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +#create folders +echo "Creating folders" +datadirectory=$(bashio::config 'data_directory') +mkdir -p \ + "$datadirectory" \ + /data/config/nextcloud/config \ + /data/config/nextcloud/data \ + /data/config/www/nextcloud/config + +#permissions +PUID="$(bashio::config 'PUID')" +PGID="$(bashio::config 'PGID')" +chown -R "$PUID":"$PGID" \ + "$datadirectory" \ + /data/config/nextcloud/config \ + /data/config/nextcloud/data \ + /data/config/www/nextcloud/config \ + /data + +chown -R abc:abc \ + /var/lib/nginx + +rm -r /data/config/www/nextcloud/assets &>/dev/null || true + +echo "Updating permissions" +chmod -R 777 /data/config +chmod -R 755 "$datadirectory" diff --git a/nextcloud/rootfs/etc/cont-init.d/50-install.sh b/nextcloud/rootfs/etc/cont-init.d/50-install.sh new file mode 100644 index 000000000..26d314db9 --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/50-install.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +NEXTCLOUD_PATH="/data/config/www/nextcloud" + +# create folders +mkdir -p \ + "${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" +fi + +#?set cronjob +[[ ! -f /data/config/crontabs/root ]] && \ + cp /defaults/root /data/config/crontabs/root +cp /data/config/crontabs/root /etc/crontabs/root diff --git a/nextcloud/rootfs/etc/cont-init.d/60-memcache.sh b/nextcloud/rootfs/etc/cont-init.d/60-memcache.sh new file mode 100644 index 000000000..c6bbb33be --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/60-memcache.sh @@ -0,0 +1,15 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# Change data directory +datadirectory=$(bashio::config 'data_directory') +bashio::log.info "Setting data diretory: ${datadirectory}" +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 + +# permissions +chown abc:abc \ + /data/config/www/nextcloud/config/config.php diff --git a/nextcloud/rootfs/etc/cont-init.d/99-add_packages.sh b/nextcloud/rootfs/etc/cont-init.d/99-add_packages.sh new file mode 100644 index 000000000..de0d63b3c --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/99-add_packages.sh @@ -0,0 +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" +fi diff --git a/nextcloud/rootfs/etc/cont-init.d/99-elasticsearch.sh b/nextcloud/rootfs/etc/cont-init.d/99-elasticsearch.sh new file mode 100644 index 000000000..6e149cde6 --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/99-elasticsearch.sh @@ -0,0 +1,79 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# shellcheck disable=SC2086 + +LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ" || bashio::log.info "/data/config/www/nextcloud/occ not found" +if ! bashio::fs.file_exists '/data/config/www/nextcloud/occ'; then + LAUNCHER=$(find / -name "occ" -print -quit) +fi || bashio::log.info "occ not found" + +# Make sure there is an Nextcloud installation +if [[ $($LAUNCHER -V) == *"not installed"* ]]; then + bashio::log.warning "It seems there is no Nextcloud server installed. Please restart the addon after initialization of the user." + exit 0 +fi + +############ +# BASED ON # +################################################################################# +# https://raw.githubusercontent.com/nextcloud/vm/master/apps/fulltextsearch.sh # +# T&M Hansson IT AB © - 2021, https://www.hanssonit.se/ # +# SwITNet Ltd © - 2021, https://switnet.net/ # +################################################################################# + +if bashio::config.true 'Full_Text_Search'; then + # shellcheck disable=SC1073,SC1072,SC1009 + if [ $LAUNCHER fulltextsearch:index &>/dev/null ]; then + echo "Full Text Search is already working" + break 2 + fi + + echo "Installing Full Text Search" + # Reset Full Text Search to be able to index again, and also remove the app to be able to install it again + occ fulltextsearch:reset &>/dev/null || true + APPS=(fulltextsearch fulltextsearch_elasticsearch files_fulltextsearch) + for app in "${APPS[@]}"; do + # If app exists, remove it + [ -n $($LAUNCHER app:getpath $app) ] && $LAUNCHER app:remove $app &>/dev/null + done + + # Get Full Text Search app for nextcloud + for app in "${APPS[@]}"; do + echo "... installing apps : $app" + $LAUNCHER app:install $app >/dev/null + $LAUNCHER app:enable $app >/dev/null + done + chown -R abc:abc $NEXTCLOUD_PATH/apps + + if bashio::config.has_value 'elasticsearch_server'; then + HOST=$(bashio::config 'elasticsearch_server') + else + bashio::log.warning 'Please define elasticsearch server url in addon options with the format "ip:port" such as "192.168.178.1:9200"' + HOST=$(bashio::network.ipv4_address) + HOST="${HOST%/*}:9200" + fi + + # Final setup + echo "... settings apps" + #occ fulltextsearch:configure '{"search_platform":"ElasticSearchPlatform"}' + $LAUNCHER fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"http://$HOST:9200\"}" &>/dev/null + $LAUNCHER fulltextsearch_elasticsearch:configure "{\"elastic_index\":\"my_index\"}" &>/dev/null + $LAUNCHER fulltextsearch_elasticsearch:configure "{\"analyzer_tokenizer\":\"standard\"}" &>/dev/null + $LAUNCHER fulltextsearch:configure '{"search_platform":"OCA\\FullTextSearch_Elasticsearch\\Platform\\ElasticSearchPlatform"}' &>/dev/null || true + $LAUNCHER files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}" &>/dev/null || true + + # Is server detected + # if [ curl $HOST ] &>/dev/null; then + # Wait further for cache for index to work + echo "Waiting for a few seconds before indexing starts..." + sleep 10s + if $LAUNCHER fulltextsearch:index &>/dev/null; then + bashio::log.info "Full Text Search was successfully installed using elasticsearch server $HOST!" + + else + + bashio::log.warning "Elasticsearch can't connect. Please manually define its server in the options" + fi +else + echo "Full_Text_Search option not set" +fi diff --git a/nextcloud/rootfs/etc/cont-init.d/99-mariadb_discovery.sh b/nextcloud/rootfs/etc/cont-init.d/99-mariadb_discovery.sh new file mode 100644 index 000000000..f1e1cb43e --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/99-mariadb_discovery.sh @@ -0,0 +1,10 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +if bashio::services.available 'mysql'; then + bashio::log.warning "MariaDB addon was found! It can't be configured automatically due to the way Nextcloud works, but you can configure it manually when running the web UI for the first time using those values :" + bashio::log.blue "Database user : $(bashio::services "mysql" "username")" + bashio::log.blue "Database password : $(bashio::services "mysql" "password")" + bashio::log.blue "Database name : nextcloud" + bashio::log.blue "Host-name : $(bashio::services "mysql" "host"):$(bashio::services "mysql" "port")" +fi diff --git a/nextcloud/rootfs/etc/cont-init.d/99-ocr.sh b/nextcloud/rootfs/etc/cont-init.d/99-ocr.sh new file mode 100644 index 000000000..db9e68318 --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/99-ocr.sh @@ -0,0 +1,48 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ" || bashio::log.info "/data/config/www/nextcloud/occ not found" +if ! bashio::fs.file_exists '/data/config/www/nextcloud/occ'; then + LAUNCHER=$(find / -name "occ" -print -quit) +fi || bashio::log.info "occ not found" + +# Make sure there is an Nextcloud installation +if [[ $($LAUNCHER -V) == *"not installed"* ]]; then + bashio::log.warning "It seems there is no Nextcloud server installed. Please restart the addon after initialization of the user." + exit 0 +fi + +# Install OCR if requested +if [ "$(bashio::config 'OCR')" = "true" ]; then + # Install package + if bashio::config.true 'OCR'; then + + # Get Full Text Search app for nextcloud + echo "... installing apps : fulltextsearch" + occ app:install files_fulltextsearch_tesseract &>/dev/null || true + occ app:enable files_fulltextsearch_tesseract &>/dev/null || true + + echo "Installing OCR" + apk add --quiet --no-cache tesseract-ocr || apk add --quiet --no-cache tesseract-ocr@community + # Install additional language if requested + if bashio::config.has_value 'OCRLANG'; then + OCRLANG=$(bashio::config 'OCRLANG') + for LANG in $(echo "$OCRLANG" | tr "," " "); do + if [ "$LANG" != "eng" ]; then + apk add --quiet --no-cache tesseract-ocr-data-"$LANG" || apk add --quiet --no-cache tesseract-ocr-data-"$LANG"@community + fi + bashio::log.info "OCR Language installed : $LANG" || bashio::log.fatal "Couldn't install OCR lang $LANG. Please check its format is conform" + # Downloading trainer data + cd /usr/share/tessdata || true + rm -r "$LANG".traineddata &>/dev/null || true + wget https://github.com/tesseract-ocr/tessdata/raw/main/"$LANG".traineddata &>/dev/null + done + fi + elif [ "$(bashio::config 'OCR')" = "false" ]; then + bashio::log.info 'Removing OCR' + # Delete package + apk del tesseract-ocr.* &>/dev/null || true + # Remove app + occ app:disable files_fulltextsearch_tesseract &>/dev/null || true + fi +fi diff --git a/nextcloud/rootfs/etc/cont-init.d/99-trusted_domains.sh b/nextcloud/rootfs/etc/cont-init.d/99-trusted_domains.sh new file mode 100644 index 000000000..41826993d --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/99-trusted_domains.sh @@ -0,0 +1,50 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ" || bashio::log.info "/data/config/www/nextcloud/occ not found" +if ! bashio::fs.file_exists '/data/config/www/nextcloud/occ'; then + LAUNCHER=$(find / -name "occ" -print -quit) +fi || bashio::log.info "occ not found" + +# Make sure there is an Nextcloud installation +if [[ $($LAUNCHER -V) == *"not installed"* ]]; then + bashio::log.warning "It seems there is no Nextcloud server installed. Please restart the addon after initialization of the user." + exit 0 +fi + +#################### +# Initialization # +#################### + +if bashio::config.has_value 'trusted_domains'; then + + bashio::log.info "Currently set trusted domains :" + $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)" + i=2 + until [ $i -gt 5 ]; do + $LAUNCHER config:system:delete trusted_domains $i && + ((i = i + 1)) || exit + done + + ########################### + # Add new trusted domains # + ########################### + TRUSTEDDOMAINS=$(bashio::config 'trusted_domains') + bashio::log.info "... alignement with trusted domains list : ${TRUSTEDDOMAINS}" + for domain in ${TRUSTEDDOMAINS//,/ }; do # Comma separated values + bashio::log.info "... adding ${domain}" + # shellcheck disable=SC2086 + $LAUNCHER config:system:set trusted_domains $i --value="${domain}" + i=$((i + 1)) + done + + bashio::log.info "Remaining configurated trusted domains :" + bashio::log.info "$($LAUNCHER config:system:get trusted_domains)" || exit + +fi diff --git a/nzbget/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/nzbget/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/nzbget/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/nzbget/rootfs/etc/cont-init.d/20-folders.sh b/nzbget/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..287c42782 --- /dev/null +++ b/nzbget/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,19 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +slug=nzbget + +if [ ! -d /config/addons_config/$slug ]; then + + if [ -d /config/$slug ]; then + echo "Moving to new location /config/addons_config/$slug" + mkdir -p /config/addons_config/$slug + chmod 777 /config/addons_config/$slug + mv /config/$slug/* /config/addons_config/$slug/ + rm -r /config/$slug + fi + + echo "Creating /config/addons_config/$slug" + mkdir -p /config/addons_config/$slug + chmod 777 /config/addons_config/$slug +fi diff --git a/omada/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/omada/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/omada/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/omada/rootfs/etc/cont-init.d/00-folders.sh b/omada/rootfs/etc/cont-init.d/00-folders.sh new file mode 100644 index 000000000..e41e5cafe --- /dev/null +++ b/omada/rootfs/etc/cont-init.d/00-folders.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# shellcheck shell=bash + +CONFIGSOURCE="/config/addons_config/omada" + +# Create directory +if [ ! -f "$CONFIGSOURCE" ]; then + echo "Creating directory" + mkdir -p "$CONFIGSOURCE" +fi + +# Ensure structure is correct +mkdir -p "$CONFIGSOURCE"/db "$CONFIGSOURCE"/html "$CONFIGSOURCE"/pdf +cp -rnf /opt/tplink/EAPController/data/* "$CONFIGSOURCE" + +# Make sure permissions are right +echo "Updating permissions" +chown -R "508:508" "$CONFIGSOURCE" + +# Delete previous directories +echo "Removing previous directories" +rm -r /opt/tplink/EAPController/data/html +rm -r /opt/tplink/EAPController/data/pdf +rm -r /opt/tplink/EAPController/data/db + +# Create symlink +echo "Creating symlink" +ln -s /config/addons_config/omada/pdf /opt/tplink/EAPController/data/pdf +ln -s /config/addons_config/omada/html /opt/tplink/EAPController/data/html +ln -s /config/addons_config/omada/db /opt/tplink/EAPController/data/db diff --git a/ombi/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/ombi/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/ombi/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/ombi/rootfs/etc/cont-init.d/20-folders.sh b/ombi/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..30190a685 --- /dev/null +++ b/ombi/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,19 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +slug=ombi + +if [ ! -d /config/addons_config/$slug ]; then + + if [ -d /config/$slug ]; then + echo "Moving to new location /config/addons_config/$slug" + mkdir -p /config/addons_config/$slug + chmod 777 /config/addons_config/$slug + mv /config/$slug/* /config/addons_config/$slug/ + rm -r /config/$slug + fi + + echo "Creating /config/addons_config/$slug" + mkdir -p /config/addons_config/$slug + chmod 777 /config/addons_config/$slug +fi diff --git a/organizr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/organizr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/organizr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/organizr/rootfs/etc/cont-init.d/00-folders.sh b/organizr/rootfs/etc/cont-init.d/00-folders.sh new file mode 100644 index 000000000..a27545499 --- /dev/null +++ b/organizr/rootfs/etc/cont-init.d/00-folders.sh @@ -0,0 +1,8 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +if [ ! -d /data/organizr ]; then + echo "Creating /data/organizr" + mkdir -p /data/organizr + chown -R abc:abc /data/organizr +fi diff --git a/overseerr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/overseerr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/overseerr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/overseerr/rootfs/etc/cont-init.d/00-config_location.sh b/overseerr/rootfs/etc/cont-init.d/00-config_location.sh new file mode 100644 index 000000000..daf491450 --- /dev/null +++ b/overseerr/rootfs/etc/cont-init.d/00-config_location.sh @@ -0,0 +1,11 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +CONFIG_LOCATION=$(bashio::config 'CONFIG_LOCATION') +bashio::log.info "Config stored in $CONFIG_LOCATION" + +mkdir -p "$CONFIG_LOCATION" +chown -R abc:abc "$CONFIG_LOCATION" + +sed -i "s|/config/addons_config/overseerr|$CONFIG_LOCATION|g" /etc/services.d/overseerr/run +sed -i "s|/config/addons_config/overseerr|$CONFIG_LOCATION|g" /etc/cont-init.d/30-config diff --git a/overseerr/rootfs/etc/cont-init.d/20-folders.sh b/overseerr/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..e38c8a57d --- /dev/null +++ b/overseerr/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ ! -d /config/addons_config/overseerr ]; then + echo "Creating /config/addons_config/overseerr" + mkdir -p /config/addons_config/overseerr +fi + +chown -R abc:abc /config/addons_config/overseerr diff --git a/paperless_ngx/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/paperless_ngx/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/paperless_ngx/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/paperless_ngx/rootfs/etc/cont-init.d/20-folders.sh b/paperless_ngx/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..bd2369978 --- /dev/null +++ b/paperless_ngx/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,19 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +slug=paperless_ng + +if [ ! -d /config/addons_config/$slug ]; then + + if [ -d /config/$slug ]; then + echo "Moving to new location /config/addons_config/$slug" + mkdir -p /config/addons_config/$slug + chmod 777 /config/addons_config/$slug + mv /config/$slug/* /config/addons_config/$slug/ + rm -r /config/$slug + fi + + echo "Creating /config/addons_config/$slug" + mkdir -p /config/addons_config/$slug + chmod 777 /config/addons_config/$slug +fi diff --git a/paperless_ngx/rootfs/etc/cont-init.d/91-pikepdf.sh b/paperless_ngx/rootfs/etc/cont-init.d/91-pikepdf.sh new file mode 100644 index 000000000..bf7a9682b --- /dev/null +++ b/paperless_ngx/rootfs/etc/cont-init.d/91-pikepdf.sh @@ -0,0 +1,14 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +echo "Installing pikepdf..." +( + export DEBIAN_FRONTEND="noninteractive" + export TERM="xterm-256color" + apt-get update + apt-get install -yq libxml2-dev libxslt-dev python-dev + apt-get install -yq libjpeg-dev zlib1g-dev + apt-get install -yq python3-dev build-essential + pip install pikepdf --force-reinstall +) >/dev/null +echo "... success!" diff --git a/paperless_ngx/rootfs/etc/cont-init.d/93-multiocr.sh b/paperless_ngx/rootfs/etc/cont-init.d/93-multiocr.sh new file mode 100644 index 000000000..36578a964 --- /dev/null +++ b/paperless_ngx/rootfs/etc/cont-init.d/93-multiocr.sh @@ -0,0 +1,16 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +OCRLANG=$(bashio::config 'OCRLANG') +if [ -n "$OCRLANG" ]; then + apt-get update &>/dev/null + echo "OCRLANG variable is set, processing the language packages" + for i in ${OCRLANG//,/ }; do + if apt-cache show tesseract-ocr-"${i}" >/dev/null 2>&1; then + apt-get install -yq tesseract-ocr-"${i}" + bashio::log.info "OCR Language installed : $i" || bashio::log.fatal "Couldn't install OCR lang $i. Please check its format is conform" + else + echo "package tesseract-ocr-${i} not found in the repository, skipping" + fi + done +fi diff --git a/paperless_ngx/rootfs/etc/cont-init.d/99-run.sh b/paperless_ngx/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..bccae88fc --- /dev/null +++ b/paperless_ngx/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +bashio::log.info "Initial username and password are admin. Please change in the administration panel of the webUI after login." diff --git a/papermerge/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/papermerge/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/papermerge/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/papermerge/rootfs/etc/cont-init.d/00-folders.sh b/papermerge/rootfs/etc/cont-init.d/00-folders.sh new file mode 100644 index 000000000..f9fbf4494 --- /dev/null +++ b/papermerge/rootfs/etc/cont-init.d/00-folders.sh @@ -0,0 +1,14 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# Config location +CONFIGLOCATION="$(bashio::config 'CONFIG_LOCATION')" + +# Text +bashio::log.info "Setting config location to $CONFIGLOCATION" + +# Adapt files +sed -i "s|/data/config|$CONFIGLOCATION|g" /etc/cont-init.d/* + +# Avoid tamper issues +chown -R root:root "$CONFIGLOCATION"/custom* diff --git a/papermerge/rootfs/etc/cont-init.d/91-OCR.sh b/papermerge/rootfs/etc/cont-init.d/91-OCR.sh new file mode 100644 index 000000000..6da3dce38 --- /dev/null +++ b/papermerge/rootfs/etc/cont-init.d/91-OCR.sh @@ -0,0 +1,58 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# Allow OCR setting +OCRLANG="$(bashio::config "ocrlang")" + +#Define location place +CONFIGLOCATION="$(bashio::config "CONFIG_LOCATION")" +#If it's a file, get the folder +if [ ! -d "$CONFIGLOCATION" ]; then + CONFIGLOCATION="$(dirname "$CONFIGLOCATION")" +fi + +#Correct previous bug +sed -i "s|OCRLANG|OCR_LANGUAGES|g" "$CONFIGLOCATION"/papermerge.conf.py + +languageCount=$(echo "$OCRLANG" | tr -cd ',' | wc -c) +languageCount=$((languageCount+1)) +bashio::log.info "Configuring ${languageCount} languages" + +if [ -n "$OCRLANG" ]; then + lineStart=$(sed -n '/OCR_LANGUAGES/=' "$CONFIGLOCATION"/papermerge.conf.py) + bashio::log.info "OCRLANG variable is set, processing the language packages" + lineEnd=$(sed -n '/}/=' "$CONFIGLOCATION"/papermerge.conf.py) + sed -i "${lineStart},${lineEnd}d" "$CONFIGLOCATION"/papermerge.conf.py + + bashio::log.info "Writing new configuration" + echo "OCR_LANGUAGES = {" >> "$CONFIGLOCATION"/papermerge.conf.py + + languages=$(echo "$OCRLANG" | tr "," "\n") + + apt-get update >/dev/null + + i=0 + for language in $languages; do + bashio::log.info "Processing language ${language}" + if apt-cache show tesseract-ocr-"${language}" >/dev/null 2>&1; then + bashio::log.info "Installing tesseract-ocr-${language}" + apt-get install -yqq tesseract-ocr-"${language}" >/dev/null + languageFullName=$(apt-cache show tesseract-ocr-"${language}" | grep -E '^(Description|Description-en):' | grep -oE '[^ ]+$') + bashio::log.info "${language} identified as ${languageFullName}" + i=$((i+1)) + if [[ $i -eq $languageCount ]]; then + echo " \"$language\" : \"$languageFullName\"" >> "$CONFIGLOCATION"/papermerge.conf.py + elif [[ $i -eq 1 ]]; then + echo " \"$language\" : \"$languageFullName\"," >> "$CONFIGLOCATION"/papermerge.conf.py + bashio::log.info "Setting default language to ${language}" + sed -i "s/^OCR_DEFAULT_LANGUAGE = \"eng\"/OCR_DEFAULT_LANGUAGE = \"${language}\"/g" "$CONFIGLOCATION"/papermerge.conf.py + else + echo " \"$language\" : \"$languageFullName\"," >> "$CONFIGLOCATION"/papermerge.conf.py + fi + bashio::log.info "... ${language} installed" + else + bashio::log.info "Package tesseract-ocr-${language} not found in the repository, skipping" + fi + done + echo "}" >> "$CONFIGLOCATION"/papermerge.conf.py +fi diff --git a/papermerge/rootfs/etc/cont-init.d/99-configuration.sh b/papermerge/rootfs/etc/cont-init.d/99-configuration.sh new file mode 100644 index 000000000..7ec417a0c --- /dev/null +++ b/papermerge/rootfs/etc/cont-init.d/99-configuration.sh @@ -0,0 +1,73 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################## +# SELECT FOLDERS # +################## + +#Set media dir +MEDIADIR=$(bashio::config 'storage_dir') +#clean data +sed -i '/MEDIA_DIR/d' /data/config/papermerge.conf.py +#add data +sed -i "2 i\MEDIA_DIR = \"$MEDIADIR\"" /data/config/papermerge.conf.py +bashio::log.info "Storage dir set to $MEDIADIR" + +#Set import dir +IMPORTDIR=$(bashio::config 'import_dir') +#clean data +sed -i '/IMPORTER_DIR/d' /data/config/papermerge.conf.py || true +#add data +sed -i "2 i\IMPORTER_DIR = \"$IMPORTDIR\"" /data/config/papermerge.conf.py +bashio::log.info "Import dir set to $IMPORTDIR" + +################## +# CREATE FOLDERS # +################## + +#if [ ! -d /data/config ]; then +# echo "Creating /config" +# mkdir -p /config +#fi +#chown -R abc:abc /config + +if [ ! -d "$MEDIADIR" ]; then + echo "Creating $MEDIADIR" + mkdir -p "$MEDIADIR" +fi +chown -R abc:abc "$MEDIADIR" + +if [ ! -d "$IMPORTDIR" ]; then + echo "Creating $IMPORTDIR" + mkdir -p "$IMPORTDIR" +fi +chown -R abc:abc "$IMPORTDIR" + +################## +# CONFIGURE IMAP # +################## + +IMAPHOST=$(bashio::config 'imaphost') +IMAPUSERNAME=$(bashio::config 'imapusername') +IMAPPASSWORD=$(bashio::config 'imappassword') + +if [ "$IMAPHOST" != "null" ]; then + printf "\nIMPORT_MAIL_HOST = \"%s\"" "$IMAPHOST" >> /data/config/papermerge.conf.py + bashio::log.info "IMPORT_MAIL_HOST set to $IMAPHOST" + + if [ "$IMAPUSERNAME" != "null" ]; then + printf "\nIMPORT_MAIL_USER = \"%s\"" "$IMAPUSERNAME" >> /data/config/papermerge.conf.py + bashio::log.info "IMPORT_MAIL_USER set to $IMAPUSERNAME" + else + bashio::log.info "! IMAPHOST has been set, but no IMAPUSERNAME. Please check your configuration!" + fi + + if [ "$IMAPPASSWORD" != "null" ]; then + printf "\nIMPORT_MAIL_PASS = \"%s\"" "$IMAPPASSWORD" >> /data/config/papermerge.conf.py + IMAPPASSWORDMASKED=$(echo "$IMAPPASSWORD" | sed -r 's/./x/g') + bashio::log.info "IMPORT_MAIL_PASS set to $IMAPPASSWORDMASKED" + else + bashio::log.info "! IMAPHOST has been set, but no IMAPPASSWORD. Please check your configuration!" + fi + +fi diff --git a/photoprism/rootfs/entrypoint.sh b/photoprism/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/photoprism/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/photoprism/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/photoprism/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/photoprism/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/photoprism/rootfs/etc/cont-init.d/32-nginx_ingress.sh b/photoprism/rootfs/etc/cont-init.d/32-nginx_ingress.sh new file mode 100644 index 000000000..6b4aa4d24 --- /dev/null +++ b/photoprism/rootfs/etc/cont-init.d/32-nginx_ingress.sh @@ -0,0 +1,18 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# +declare ingress_interface +declare ingress_port + +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 + +# Avoid error message +grep -rnl "PhotoPrism has been updated…" /opt/photoprism | xargs sed -i "s|PhotoPrism has been updated…|Please click cancel|g" diff --git a/photoprism/rootfs/etc/cont-init.d/32-nginx_ssl.sh b/photoprism/rootfs/etc/cont-init.d/32-nginx_ssl.sh new file mode 100644 index 000000000..1e0186384 --- /dev/null +++ b/photoprism/rootfs/etc/cont-init.d/32-nginx_ssl.sh @@ -0,0 +1,33 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +############### +# SSL SETTING # +############### +declare port +declare certfile +declare keyfile + +# General values +port=2342 +sed -i "s|%%port%%|$port|g" /etc/nginx/servers/ssl.conf +sed -i "s|%%interface%%|$(bashio::addon.ip_address)|g" /etc/nginx/servers/ssl.conf + +# Ssl values +if bashio::config.true 'ssl'; then + echo "Defining ssl configuration" + bashio::config.require.ssl + certfile=$(bashio::config 'certfile') + keyfile=$(bashio::config 'keyfile') + + #Check if files exist + echo "... checking if referenced certificates 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 + + + sed -i "s|default_server|ssl|g" /etc/nginx/servers/ssl.conf + sed -i "/proxy_params.conf/a ssl_certificate /ssl/$certfile;" /etc/nginx/servers/ssl.conf + sed -i "/proxy_params.conf/a ssl_certificate_key /ssl/$keyfile;" /etc/nginx/servers/ssl.conf + bashio::log.info "Ssl enabled, please use https for connection. UI is at https://YOURIP:$(bashio::addon.port 2342)" +fi diff --git a/photoprism/rootfs/etc/cont-init.d/99-run.sh b/photoprism/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..1b69225ee --- /dev/null +++ b/photoprism/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +############ +# Base url # +############ + +#PHOTOPRISM_SITE_URL="$(bashio::config 'PHOTOPRISM_SITE_URL')$(bashio::addon.ingress_entry)" +#bashio::log.blue "Site url : $PHOTOPRISM_SITE_URL" +#export PHOTOPRISM_SITE_URL + +################### +# Define database # +################### + +bashio::log.info "Defining database" + +case $(bashio::config 'DB_TYPE') in + + # Use sqlite + sqlite) + bashio::log.info "Using a local sqlite database" + ;; + + mariadb_addon) + bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Discovering values..." + if ! bashio::services.available 'mysql'; then + bashio::log.fatal \ + "Local database access should be provided by the MariaDB addon" + bashio::exit.nok \ + "Please ensure it is installed and started" + fi + + # Install mysqlclient + pip install pymysql &>/dev/null || true + + # Use values + PHOTOPRISM_DATABASE_DRIVER="mysql" + PHOTOPRISM_DATABASE_SERVER="$(bashio::services 'mysql' 'host'):$(bashio::services 'mysql' 'port')" + PHOTOPRISM_DATABASE_NAME="photoprism" + PHOTOPRISM_DATABASE_USER="$(bashio::services 'mysql' 'username')" + PHOTOPRISM_DATABASE_PASSWORD="$(bashio::services 'mysql' 'password')" + export PHOTOPRISM_DATABASE_DRIVER && bashio::log.blue "PHOTOPRISM_DATABASE_DRIVER=$PHOTOPRISM_DATABASE_DRIVER" + export PHOTOPRISM_DATABASE_SERVER && bashio::log.blue "PHOTOPRISM_DATABASE_SERVER=$PHOTOPRISM_DATABASE_SERVER" + export PHOTOPRISM_DATABASE_NAME && bashio::log.blue "PHOTOPRISM_DATABASE_NAME=$PHOTOPRISM_DATABASE_NAME" + export PHOTOPRISM_DATABASE_USER && bashio::log.blue "PHOTOPRISM_DATABASE_USER=$PHOTOPRISM_DATABASE_USER" + export PHOTOPRISM_DATABASE_PASSWORD && bashio::log.blue "PHOTOPRISM_DATABASE_PASSWORD=$PHOTOPRISM_DATABASE_PASSWORD" + + bashio::log.warning "Webtrees is using the Maria DB addon" + bashio::log.warning "Please ensure this is included in your backups" + bashio::log.warning "Uninstalling the MariaDB addon will remove any data" + + # Create database + mysql --host="$(bashio::services 'mysql' 'host')" --port="$(bashio::services 'mysql' 'port')" --user="$PHOTOPRISM_DATABASE_USER" --password="$PHOTOPRISM_DATABASE_PASSWORD" -e"CREATE DATABASE IF NOT EXISTS $PHOTOPRISM_DATABASE_NAME;" + # Force character set + mysql --host="$(bashio::services 'mysql' 'host')" --port="$(bashio::services 'mysql' 'port')" --user="$PHOTOPRISM_DATABASE_USER" --password="$PHOTOPRISM_DATABASE_PASSWORD" -e"ALTER DATABASE $PHOTOPRISM_DATABASE_NAME CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;" || true + ;; +esac + +############## +# LAUNCH APP # +############## + +# Configure app +PHOTOPRISM_UPLOAD_NSFW=$(bashio::config 'UPLOAD_NSFW') +PHOTOPRISM_STORAGE_PATH=$(bashio::config 'STORAGE_PATH') +PHOTOPRISM_ORIGINALS_PATH=$(bashio::config 'ORIGINALS_PATH') +PHOTOPRISM_IMPORT_PATH=$(bashio::config 'IMPORT_PATH') +PHOTOPRISM_BACKUP_PATH=$(bashio::config 'BACKUP_PATH') +export PHOTOPRISM_UPLOAD_NSFW +export PHOTOPRISM_STORAGE_PATH +export PHOTOPRISM_ORIGINALS_PATH +export PHOTOPRISM_IMPORT_PATH +export PHOTOPRISM_BACKUP_PATH + +# Test configs +for variabletest in $PHOTOPRISM_STORAGE_PATH $PHOTOPRISM_ORIGINALS_PATH $PHOTOPRISM_IMPORT_PATH $PHOTOPRISM_BACKUP_PATH; do + # Check if path exists + if bashio::fs.directory_exists "$variabletest"; then + true + else + bashio::log.info "Path $variabletest doesn't exist. Creating it now..." + mkdir -p "$variabletest" || bashio::log.fatal "Can't create $variabletest path" + fi + # Check if path writable + # shellcheck disable=SC2015 + touch "$variabletest"/aze && rm "$variabletest"/aze || bashio::log.fatal "$variabletest path is not writable" +done + +# Start messages +bashio::log.info "Please wait 1 or 2 minutes to allow the server to load" +bashio::log.info 'Default username : admin, default password: "please_change_password"' + +cd / +./scripts/entrypoint.sh photoprism start & bashio::log.info "Starting, please wait for next green text..." + +bashio::net.wait_for 2341 localhost 900 +bashio::log.info "App launched" + +exec nginx diff --git a/photoprism/rootfs/run.sh b/photoprism/rootfs/run.sh new file mode 100644 index 000000000..7f399b516 --- /dev/null +++ b/photoprism/rootfs/run.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash +# shellcheck disable=SC2155,SC2015 + +########### +# SCRIPTS # +########### + +for SCRIPTS in "/00-banner.sh" "/92-local_mounts.sh" "/92-smb_mounts.sh"; do + echo $SCRIPTS + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x $SCRIPTS + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' $SCRIPTS + /.$SCRIPTS && + true || true # Prevents script crash on failure + echo "exit $?" +done + +############## +# LAUNCH APP # +############## + +# Configure app +export PHOTOPRISM_UPLOAD_NSFW=$(bashio::config 'UPLOAD_NSFW') +export PHOTOPRISM_STORAGE_PATH=$(bashio::config 'STORAGE_PATH') +export PHOTOPRISM_ORIGINALS_PATH=$(bashio::config 'ORIGINALS_PATH') +export PHOTOPRISM_IMPORT_PATH=$(bashio::config 'IMPORT_PATH') +export PHOTOPRISM_BACKUP_PATH=$(bashio::config 'BACKUP_PATH') + +if bashio::config.has_value 'CUSTOM_OPTIONS'; then + CUSTOMOPTIONS=$(bashio::config 'CUSTOM_OPTIONS') +else + CUSTOMOPTIONS="" +fi + +# Test configs +for variabletest in $PHOTOPRISM_STORAGE_PATH $PHOTOPRISM_ORIGINALS_PATH $PHOTOPRISM_IMPORT_PATH $PHOTOPRISM_BACKUP_PATH; do + # Check if path exists + if bashio::fs.directory_exists "$variabletest"; then + true + else + bashio::log.info "Path $variabletest doesn't exist. Creating it now..." + mkdir -p "$variabletest" || bashio::log.fatal "Can't create $variabletest path" + fi + # Check if path writable + # shellcheck disable=SC2015 + touch "$variabletest"/aze && rm "$variabletest"/aze || bashio::log.fatal "$variabletest path is not writable" +done + +# Start messages +bashio::log.info "Please wait 1 or 2 minutes to allow the server to load" +bashio::log.info 'Default username : admin, default password: "please_change_password"' + +cd / +./entrypoint.sh photoprism start '"'"$CUSTOMOPTIONS"'"' diff --git a/piwigo/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/piwigo/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/piwigo/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/piwigo/rootfs/etc/cont-init.d/41-folders.sh b/piwigo/rootfs/etc/cont-init.d/41-folders.sh new file mode 100644 index 000000000..ececf91ad --- /dev/null +++ b/piwigo/rootfs/etc/cont-init.d/41-folders.sh @@ -0,0 +1,44 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################## +# SYMLINK CONFIG # +################## + +#Create folders + +if [ ! -d /share/piwigo ]; then + echo "Creating /share/piwigo" + mkdir -p /share/piwigo + chown -R abc:abc /share/piwigo +else + chown -R abc:abc /share/piwigo +fi + +if [ ! -d /share/piwigo/config ]; then + echo "moving config folder" + mv /gallery/local/config /share/piwigo + ln -s /share/piwigo/config /gallery/local + echo "links done" +else + rm -r /gallery/local/config + ln -s /share/piwigo/config /gallery/local + echo "Using existing config" +fi + +if [ ! -d /share/piwigo/keys ]; then + echo "moving keys folder" + mv /config/keys /share/piwigo + ln -s /share/piwigo/keys /config + echo "links done" +else + rm -r /config/keys + ln -s /share/piwigo/keys /config + echo "Using existing keys folder" +fi + +################## +# CORRECT CONFIG # +################## +# shellcheck disable=SC2015 +sed -i 's|E_ALL|""|g' /share/piwigo/config/config.inc.php && echo "config corrected for php error" || true diff --git a/plex/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/plex/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/plex/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/plex/rootfs/etc/cont-init.d/21-folders.sh b/plex/rootfs/etc/cont-init.d/21-folders.sh new file mode 100644 index 000000000..224a316cd --- /dev/null +++ b/plex/rootfs/etc/cont-init.d/21-folders.sh @@ -0,0 +1,27 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################## +# SYMLINK CONFIG # +################## + +echo "Database stored in /share/plex" + +if [ ! -d "/share/plex/Plex Media Server" ]; then + echo "... creating /share/plex/Plex Media Server" + mkdir -p "/share/plex/Plex Media Server" +fi + +if [ -d "/config/Library/Application Support/Plex Media Server" ]; then + echo "... creating /symlink" + rm -r "/config/Library/Application Support/*" + ln -s "/share/plex/Plex Media Server" "/config/Library/Application Support" +fi + +if [ ! -d "/config/Library/Application Support" ]; then + echo "... creating /symlink" + mkdir -p "/config/Library/Application Support" + ln -s "/share/plex/Plex Media Server" "/config/Library/Application Support" +fi + +chown -R abc:abc /share/plex diff --git a/plex/rootfs/etc/cont-init.d/90-create_links.sh b/plex/rootfs/etc/cont-init.d/90-create_links.sh new file mode 100644 index 000000000..76515c838 --- /dev/null +++ b/plex/rootfs/etc/cont-init.d/90-create_links.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +################## +# SYMLINK CONFIG # +################## + +if [ ! -d /share/plex ]; then + echo "Creating /share/plex" + mkdir -p /share/plex + chown -R abc:abc /share/plex +else + chown -R abc:abc /share/plex +fi + +if [ ! -d /share/plex/Library ]; then + echo "moving Library folder" + mv /config/Library /share/plex + ln -s /share/plex/Library /config + echo "links done" +else + rm -r /config/Library + ln -s /share/plex/Library /config + echo "Using existing config" +fi diff --git a/plex_meta_manager/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/plex_meta_manager/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/plex_meta_manager/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/plex_meta_manager/rootfs/etc/cont-init.d/20-configuration.sh b/plex_meta_manager/rootfs/etc/cont-init.d/20-configuration.sh new file mode 100644 index 000000000..67dc1ab3e --- /dev/null +++ b/plex_meta_manager/rootfs/etc/cont-init.d/20-configuration.sh @@ -0,0 +1,31 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# Where is the config +CONFIGSOURCE=$(bashio::config "PMM_CONFIG") + +################## +# Create folders # +################## + +PUID=$(bashio::config 'PUID') +PGID=$(bashio::config 'PGID') + +if [ ! -d "$(dirname "${CONFIGSOURCE}")" ]; then + echo "Creating $(dirname "${CONFIGSOURCE}")" + mkdir -p "$(dirname "${CONFIGSOURCE}")" +fi + +chown -R "$PUID":"$PGID" "$(dirname "${CONFIGSOURCE}")" + +################### +# Set config.yaml # +################### + +# Check if config file is there, or create one from template +if [ -f "$CONFIGSOURCE" ]; then + bashio::log.info "Using config file found in $CONFIGSOURCE" +else + cp /templates/config.yml "$(dirname "${CONFIGSOURCE}")" + bashio::log.warning "No config file, creating one from template. Please correct the config.yml file before restarting the addon !" +fi diff --git a/portainer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/portainer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/portainer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/portainer/rootfs/etc/cont-init.d/00-aaa_portainer_install.sh b/portainer/rootfs/etc/cont-init.d/00-aaa_portainer_install.sh new file mode 100644 index 000000000..0728b6b21 --- /dev/null +++ b/portainer/rootfs/etc/cont-init.d/00-aaa_portainer_install.sh @@ -0,0 +1,23 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +if [ -e "/PORTFILE" ]; then + echo "Installing portainer..." + BUILD_UPSTREAM=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/prowlarr/rootfs/etc/cont-init.d/20-folders.sh b/prowlarr/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..d1887dc88 --- /dev/null +++ b/prowlarr/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +if [ -d /config/prowlarr ] && [ ! -d /config/addons_config/prowlarr ]; then + echo "Moving to new location /config/addons_config/prowlarr" + mkdir -p /config/addons_config/prowlarr + chown -R abc:abc /config/addons_config/prowlarr + mv /config/prowlarr/* /config/addons_config/prowlarr/ + rm -r /config/prowlarr +fi + +if [ ! -d /config/addons_config/prowlarr ]; then + echo "Creating /config/addons_config/prowlarr" + mkdir -p /config/addons_config/prowlarr + chown -R abc:abc /config/addons_config/prowlarr +fi diff --git a/qbittorrent/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/qbittorrent/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/qbittorrent/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/qbittorrent/rootfs/etc/cont-init.d/00-folders.sh b/qbittorrent/rootfs/etc/cont-init.d/00-folders.sh new file mode 100644 index 000000000..46fec2399 --- /dev/null +++ b/qbittorrent/rootfs/etc/cont-init.d/00-folders.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# Avoid linuxserver anti tamper issues +chown root:root /config/custom-cont-init.d* &>/dev/null || true +chown root:root /config/custom-services* &>/dev/null || true diff --git a/qbittorrent/rootfs/etc/cont-init.d/30-nginx.sh b/qbittorrent/rootfs/etc/cont-init.d/30-nginx.sh new file mode 100644 index 000000000..55350e45d --- /dev/null +++ b/qbittorrent/rootfs/etc/cont-init.d/30-nginx.sh @@ -0,0 +1,51 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +DEBUG=$(bashio::config 'TZ') +[ "$DEBUG" = "debug" ] && echo "Before declare" + +################# +# NGINX SETTING # +################# + +#declare admin_port +declare qbittorrent_protocol=http + +[ "$DEBUG" = "debug" ] && echo "Before ssl" + +# Generate Ingress configuration +if bashio::config.true 'ssl'; then + qbittorrent_protocol=https +fi + +[ "$DEBUG" = "debug" ] && echo "Before cp" + +cp /etc/nginx/templates/ingress.gtpl /etc/nginx/servers/ingress.conf + +[ "$DEBUG" = "debug" ] && echo "Before sed" +sed -i "s|{{ .interface }}|$(bashio::addon.ip_address)|g" /etc/nginx/servers/ingress.conf +sed -i "s|{{ .port }}|$(bashio::addon.ingress_port)|g" /etc/nginx/servers/ingress.conf +sed -i "s|{{ .protocol }}|${qbittorrent_protocol}|g" /etc/nginx/servers/ingress.conf +sed -i "s|{{ .certfile }}|$(bashio::config 'certfile')|g" /etc/nginx/servers/ingress.conf +sed -i "s|{{ .keyfile }}|$(bashio::config 'keyfile')|g" /etc/nginx/servers/ingress.conf +sed -i "s|{{ .ssl }}|$(bashio::config 'ssl')|g" /etc/nginx/servers/ingress.conf + +###################### +# VUETORRENT INSTALL # +###################### + +[ "$DEBUG" = "debug" ] && echo "Before var" +LATEST_RELEASE=$(curl -f -s --retry 5 -L https://api.github.com/repos/wdaan/vuetorrent/releases/latest | + grep "browser_download_url.*zip" | + cut -d : -f 2,3 | + tr -d \" | +xargs) + +[ "$DEBUG" = "debug" ] && echo "Before curl" +curl -f -s -S -O -J -L "$LATEST_RELEASE" + +[ "$DEBUG" = "debug" ] && echo "Before unzip" +unzip -o vuetorrent.zip -d / >/dev/null + +[ "$DEBUG" = "debug" ] && echo "Before rm" +rm /vuetorrent.zip >/dev/null diff --git a/qbittorrent/rootfs/etc/cont-init.d/91-qbittorrent_configuration.sh b/qbittorrent/rootfs/etc/cont-init.d/91-qbittorrent_configuration.sh new file mode 100644 index 000000000..e4fea8c31 --- /dev/null +++ b/qbittorrent/rootfs/etc/cont-init.d/91-qbittorrent_configuration.sh @@ -0,0 +1,171 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +########## +# INIT # +########## + +# Define preferences line +mkdir -p /config/qBittorrent +cd /config/qBittorrent/ || true +LINE=$(sed -n '/Preferences/=' qBittorrent.conf) +LINE=$((LINE + 1)) + +########### +# TIMEOUT # +########### + +if bashio::config.has_value 'run_duration'; then + rm /etc/services.d/qbittorrent/run + mv /etc/services.d/qbittorrent/timer /etc/services.d/qbittorrent/run + chmod +x /etc/services.d/qbittorrent/run +else + rm /etc/services.d/qbittorrent/timer +fi + +################## +# Default folder # +################## + +# Set variable +DOWNLOADS=$(bashio::config 'SavePath') + +# Set configuration +if bashio::config.has_value 'SavePath'; then + + # Replace save path + CURRENTSAVEPATH=$(sed -n '/Downloads\\SavePath/p' qBittorrent.conf) + sed -i "s|${CURRENTSAVEPATH#*=}|$DOWNLOADS|g" qBittorrent.conf 2>/dev/null || true + + # Replace session save path + CURRENTSAVEPATH=$(sed -n '/Session\\DefaultSavePath/p' qBittorrent.conf) + sed -i "s|${CURRENTSAVEPATH#*=}|$DOWNLOADS|g" qBittorrent.conf 2>/dev/null || true + + # Info + bashio::log.info "Downloads can be found in $DOWNLOADS" +fi + +# Create default location +mkdir -p "$DOWNLOADS" || bashio::log.fatal "Error : folder defined in SavePath doesn't exist and can't be created. Check path" +chown -R abc:abc "$DOWNLOADS" || bashio::log.fatal "Error, please check default save folder configuration in addon" + +############## +# Avoid bugs # +############## + +sed -i '/CSRFProtection/d' qBittorrent.conf +sed -i '/ClickjackingProtection/d' qBittorrent.conf +sed -i '/HostHeaderValidation/d' qBittorrent.conf +sed -i '/WebUI\Address/d' qBittorrent.conf +sed -i "$LINE i\WebUI\\\CSRFProtection=false" qBittorrent.conf +sed -i "$LINE i\WebUI\\\ClickjackingProtection=false" qBittorrent.conf +sed -i "$LINE i\WebUI\\\HostHeaderValidation=false" qBittorrent.conf +sed -i "$LINE i\WebUI\\\Address=*" qBittorrent.conf + +################ +# Correct Port # +################ + +# sed -i '/PortRangeMin/d' qBittorrent.conf +# sed -i "$LINE i\Connection\\\PortRangeMin=6881" qBittorrent.conf + +################ +# SSL CONFIG # +################ + +# Clean data +sed -i '/HTTPS/d' qBittorrent.conf + +bashio::config.require.ssl +if bashio::config.true 'ssl'; then + bashio::log.info "ssl enabled. If webui don't work, disable ssl or check your certificate paths" + #set variables + CERTFILE=$(bashio::config 'certfile') + KEYFILE=$(bashio::config 'keyfile') + + #Modify configuration + sed -i "$LINE i\WebUI\\\HTTPS\\\Enabled=True" qBittorrent.conf + sed -i "$LINE i\WebUI\\\HTTPS\\\CertificatePath=/ssl/$CERTFILE" qBittorrent.conf + sed -i "$LINE i\WebUI\\\HTTPS\\\KeyPath=/ssl/$KEYFILE" qBittorrent.conf +fi + +################ +# WHITELIST # +################ + +cd /config/qBittorrent/ || true +if bashio::config.has_value 'whitelist'; then + WHITELIST=$(bashio::config 'whitelist') + #clean data + sed -i '/AuthSubnetWhitelist/d' qBittorrent.conf + sed -i "$LINE i\WebUI\\\AuthSubnetWhitelistEnabled=true" qBittorrent.conf + sed -i "$LINE i\WebUI\\\AuthSubnetWhitelist=$WHITELIST" qBittorrent.conf + bashio::log.info "Whitelisted subsets will not require a password : $WHITELIST" +fi + +############### +# USERNAME # +############### + +cd /config/qBittorrent/ || true +if bashio::config.has_value 'Username'; then + USERNAME=$(bashio::config 'Username') + #clean data + sed -i '/WebUI\\\Username/d' qBittorrent.conf + #add data + sed -i "$LINE i\WebUI\\\Username=$USERNAME" qBittorrent.conf + bashio::log.info "WEBUI username set to $USERNAME" +fi + +################ +# Alternate UI # +################ + +# Clean data +sed -i '/AlternativeUIEnabled/d' qBittorrent.conf +sed -i '/RootFolder/d' qBittorrent.conf +rm -f -r /webui +mkdir -p /webui +chown abc:abc /webui + +CUSTOMUI=$(bashio::config 'customUI') +if bashio::config.has_value 'customUI' && [ ! "$CUSTOMUI" = default ]; then + ### Variables + bashio::log.info "Alternate UI enabled : $CUSTOMUI. If webui don't work, disable this option" + + ### Download WebUI + case $CUSTOMUI in + "vuetorrent") + curl -f -s -S -J -L -o /webui/release.zip "$(curl -f -s https://api.github.com/repos/WDaan/VueTorrent/releases/latest | grep -o "http.*vuetorrent.zip" | head -1)" >/dev/null + ;; + + "qbit-matUI") + curl -f -s -S -J -L -o /webui/release.zip "$(curl -f -s https://api.github.com/repos/bill-ahmed/qbit-matUI/releases/latest | grep -o "http.*Unix.*.zip" | head -1)" >/dev/null + ;; + + "qb-web") + curl -f -s -S -J -L -o /webui/release.zip "$(curl -f -s https://api.github.com/repos/CzBiX/qb-web/releases | grep -o "http.*qb-web-.*zip" | head -1)" >/dev/null + ;; + + esac + + ### Install WebUI + mkdir -p /webui/"$CUSTOMUI" + unzip -q /webui/release.zip -d /webui/"$CUSTOMUI" + rm /webui/*.zip + CUSTOMUIDIR="$(dirname "$(find /webui/"$CUSTOMUI" -iname "public" -type d)")" + # Set qbittorrent + sed -i "$LINE i\WebUI\\\AlternativeUIEnabled=true" /config/qBittorrent/qBittorrent.conf + sed -i "$LINE i\WebUI\\\RootFolder=$CUSTOMUIDIR" /config/qBittorrent/qBittorrent.conf + # Set nginx + #sed -i "s=/vuetorrent/public/=$CUSTOMUIDIR/public/=g" /etc/nginx/servers/ingress.conf + #sed -i "s=vue.torrent=$CUSTOMUI.torrent=g" /etc/nginx/servers/ingress.conf + +fi + +########## +# CLOSE # +########## + +bashio::log.info "Default username/password : admin/adminadmin" +bashio::log.info "Configuration can be found in /config/qBittorrent" diff --git a/qbittorrent/rootfs/etc/cont-init.d/93-openvpn.sh b/qbittorrent/rootfs/etc/cont-init.d/93-openvpn.sh new file mode 100644 index 000000000..91fcc6604 --- /dev/null +++ b/qbittorrent/rootfs/etc/cont-init.d/93-openvpn.sh @@ -0,0 +1,115 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# ============================================================================== + +declare openvpn_config +declare openvpn_username +declare openvpn_password + +QBT_CONFIG_FILE="/config/qBittorrent/qBittorrent.conf" + +if bashio::config.true 'openvpn_enabled'; then + + bashio::log.info "Configuring openvpn" + + # Get current ip + curl -s ipecho.net/plain > /currentip + + ##################### + # CONFIGURE OPENVPN # + ##################### + + openvpn_config=$(bashio::config 'openvpn_config') + + cp "/config/openvpn/${openvpn_config}" /etc/openvpn/config.ovpn || bashio::log.error "openvpn config file not found in /config/openvpn/${openvpn_config}" + + openvpn_username=$(bashio::config 'openvpn_username') + echo "${openvpn_username}" >/etc/openvpn/credentials + openvpn_password=$(bashio::config 'openvpn_password') + echo "${openvpn_password}" >>/etc/openvpn/credentials + sed -i 's/auth-user-pass.*/auth-user-pass \/etc\/openvpn\/credentials/g' /etc/openvpn/config.ovpn + + # Permissions + chmod 600 /etc/openvpn/credentials + chmod 755 /etc/openvpn/up.sh + chmod 755 /etc/openvpn/down.sh + chmod 755 /etc/openvpn/up-qbittorrent.sh + chmod +x /etc/openvpn/up.sh + chmod +x /etc/openvpn/up-qbittorrent.sh + + bashio::log.info "openvpn correctly set, qbittorrent will run tunnelled through openvpn" + + ######################### + # CONFIGURE QBITTORRENT # + ######################### + + # WITH CONTAINER BINDING + ######################### + # If alternative mode enabled, bind container + if bashio::config.true 'openvpn_alt_mode'; then + echo "Using container binding" + + # Remove interface + echo "... deleting previous interface settings" + sed -i '/Interface/d' "$QBT_CONFIG_FILE" + + # Modify ovpn config + if grep -q route-nopull /etc/openvpn/config.ovpn; then + echo "... removing route-nopull from your config.ovpn" + sed -i '/route-nopull/d' /etc/openvpn/config.ovpn + fi + + # Exit + exit 0 + fi + + # WITH INTERFACE BINDING + ######################### + # Connection with interface binding + echo "Using interface binding in the qBittorrent app" + + # Define preferences line + cd /config/qBittorrent/ || exit 1 + LINE=$(sed -n '/Preferences/=' "$QBT_CONFIG_FILE") + LINE=$((LINE + 1)) + SESSION=$(sed -n '/BitTorrent/=' "$QBT_CONFIG_FILE") + + # If qBittorrent.conf exists + if [ -f "$QBT_CONFIG_FILE" ]; then + # Remove previous line and bind tun0 + echo "... deleting previous interface settings" + sed -i '/Interface/d' "$QBT_CONFIG_FILE" + + # Bind tun0 + echo "... binding tun0 interface in qBittorrent configuration" + sed -i "$LINE i\Connection\\\Interface=tun0" "$QBT_CONFIG_FILE" + sed -i "$LINE i\Connection\\\InterfaceName=tun0" "$QBT_CONFIG_FILE" + + if [ "$SESSION" != "" ]; then + SESSION=$((SESSION + 1)) + sed -i "$SESSION i\Session\\\Interface=tun0" "$QBT_CONFIG_FILE" + sed -i "$SESSION i\Session\\\InterfaceName=tun0" "$QBT_CONFIG_FILE" + fi + + else + bashio::log.error "qBittorrent config file doesn't exist, openvpn must be added manually to qbittorrent options " + exit 1 + fi + + # Modify ovpn config + if ! grep -q route-nopull /etc/openvpn/config.ovpn; then + echo "... adding route-nopull to your config.ovpn" + sed -i "1a route-nopull" /etc/openvpn/config.ovpn + fi + +else + + ################## + # REMOVE OPENVPN # + ################## + + # Ensure no redirection by removing the direction tag + sed -i '/Interface/d' "$QBT_CONFIG_FILE" + bashio::log.info "Direct connection without VPN enabled" + +fi diff --git a/qbittorrent/rootfs/etc/openvpn/down.sh b/qbittorrent/rootfs/etc/openvpn/down.sh new file mode 100644 index 000000000..a83f98272 --- /dev/null +++ b/qbittorrent/rootfs/etc/openvpn/down.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# shellcheck disable=SC2154,SC2004,SC2059,SC2086 +# Copyright (c) 2006-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# Contributed by Roy Marples (uberlord@gentoo.org) + +# If we have a service specific script, run this now +if [ -x /etc/openvpn/"${RC_SVCNAME}"-down.sh ] ; then + /etc/openvpn/"${RC_SVCNAME}"-down.sh "$@" +fi + +# Restore resolv.conf to how it was +if [ "${PEER_DNS}" != "no" ]; then + if [ -x /sbin/resolvconf ] ; then + /sbin/resolvconf -d "${dev}" + elif [ -e /etc/resolv.conf-"${dev}".sv ] ; then + # Important that we cat instead of move incase resolv.conf is + # a symlink and not an actual file + cat /etc/resolv.conf-"${dev}".sv > /etc/resolv.conf + rm -f /etc/resolv.conf-"${dev}".sv + fi +fi + +if [ -n "${RC_SVCNAME}" ]; then + # Re-enter the init script to start any dependant services + if /etc/init.d/"${RC_SVCNAME}" --quiet status ; then + export IN_BACKGROUND=true + /etc/init.d/"${RC_SVCNAME}" --quiet stop + fi +fi + +exit 0 + +# vim: ts=4 : diff --git a/qbittorrent/rootfs/etc/openvpn/up-qbittorrent.sh b/qbittorrent/rootfs/etc/openvpn/up-qbittorrent.sh new file mode 100644 index 000000000..e5adbdf04 --- /dev/null +++ b/qbittorrent/rootfs/etc/openvpn/up-qbittorrent.sh @@ -0,0 +1,6 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +WEBUI_PORT=${WEBUI_PORT:-8080} + +exec s6-setuidgid abc /usr/bin/qbittorrent-nox --webui-port="${WEBUI_PORT}" diff --git a/qbittorrent/rootfs/etc/openvpn/up.sh b/qbittorrent/rootfs/etc/openvpn/up.sh new file mode 100644 index 000000000..c5486d267 --- /dev/null +++ b/qbittorrent/rootfs/etc/openvpn/up.sh @@ -0,0 +1,95 @@ +#!/bin/sh +# shellcheck disable=SC2154,SC2004,SC2059,SC2086 + +# launch qbittorrent +/etc/openvpn/up-qbittorrent.sh "${4}" & + +# Copyright (c) 2006-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# Contributed by Roy Marples (uberlord@gentoo.org) + +# Setup our resolv.conf +# Vitally important that we use the domain entry in resolv.conf so we +# can setup the nameservers are for the domain ONLY in resolvconf if +# we're using a decent dns cache/forwarder like dnsmasq and NOT nscd/libc. +# nscd/libc users will get the VPN nameservers before their other ones +# and will use the first one that responds - maybe the LAN ones? +# non resolvconf users just the the VPN resolv.conf + +# FIXME:- if we have >1 domain, then we have to use search :/ +# We need to add a flag to resolvconf to say +# "these nameservers should only be used for the listed search domains +# if other global nameservers are present on other interfaces" +# This however, will break compatibility with Debians resolvconf +# A possible workaround would be to just list multiple domain lines +# and try and let resolvconf handle it + +if [ "${PEER_DNS}" != "no" ]; then + NS= + DOMAIN= + SEARCH= + i=1 + while true ; do + eval opt=\$foreign_option_${i} + [ -z "${opt}" ] && break + if [ "${opt}" != "${opt#dhcp-option DOMAIN *}" ] ; then + if [ -z "${DOMAIN}" ] ; then + DOMAIN="${opt#dhcp-option DOMAIN *}" + else + SEARCH="${SEARCH}${SEARCH:+ }${opt#dhcp-option DOMAIN *}" + fi + elif [ "${opt}" != "${opt#dhcp-option DNS *}" ] ; then + NS="${NS}nameserver ${opt#dhcp-option DNS *}\n" + fi + i=$((${i} + 1)) + done + + if [ -n "${NS}" ] ; then + DNS="# Generated by openvpn for interface ${dev}\n" + if [ -n "${SEARCH}" ] ; then + DNS="${DNS}search ${DOMAIN} ${SEARCH}\n" + elif [ -n "${DOMAIN}" ]; then + DNS="${DNS}domain ${DOMAIN}\n" + fi + DNS="${DNS}${NS}" + if [ -x /sbin/resolvconf ] ; then + printf "${DNS}" | /sbin/resolvconf -a "${dev}" + else + # Preserve the existing resolv.conf + if [ -e /etc/resolv.conf ] ; then + cp /etc/resolv.conf /etc/resolv.conf-"${dev}".sv + fi + printf "${DNS}" > /etc/resolv.conf + chmod 644 /etc/resolv.conf + fi + fi +fi + +# Below section is Gentoo specific +# Quick summary - our init scripts are re-entrant and set the RC_SVCNAME env var +# as we could have >1 openvpn service + +if [ -n "${RC_SVCNAME}" ]; then + # If we have a service specific script, run this now + if [ -x /etc/openvpn/"${RC_SVCNAME}"-up.sh ] ; then + /etc/openvpn/"${RC_SVCNAME}"-up.sh "$@" + fi + + # Re-enter the init script to start any dependant services + if ! /etc/init.d/"${RC_SVCNAME}" --quiet status ; then + export IN_BACKGROUND=true + /etc/init.d/${RC_SVCNAME} --quiet start + fi +fi + +############### +# ALLOW WEBUI # +############### + +ip route add 10.0.0.0/8 via 172.30.32.1 +ip route add 192.168.0.0/16 via 172.30.32.1 +ip route add 172.16.0.0/12 via 172.30.32.1 + +exit 0 + +# vim: ts=4 : diff --git a/radarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/radarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/radarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/radarr/rootfs/etc/cont-init.d/20-folders.sh b/radarr/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..3785e80ea --- /dev/null +++ b/radarr/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ ! -d /share/storage/movies ]; then + echo "Creating /share/storage/movies" + mkdir -p /share/storage/movies + chown -R abc:abc /share/storage/movies +fi + +if [ ! -d /share/downloads ]; then + echo "Creating /share/downloads" + mkdir -p /share/downloads + chown -R abc:abc /share/downloads +fi + +if [ -d /config/radarr ] && [ ! -d /config/addons_config/radarr ]; then + echo "Moving to new location /config/addons_config/radarr" + mkdir -p /config/addons_config/radarr + chown -R abc:abc /config/addons_config/radarr + mv /config/radarr/* /config/addons_config/radarr/ + rm -r /config/radarr +fi + +if [ ! -d /config/addons_config/radarr ]; then + echo "Creating /config/addons_config/radarr" + mkdir -p /config/addons_config/radarr + chown -R abc:abc /config/addons_config/radarr +fi diff --git a/readarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/readarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/readarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/readarr/rootfs/etc/cont-init.d/00-config_location.sh b/readarr/rootfs/etc/cont-init.d/00-config_location.sh new file mode 100644 index 000000000..3216aab5c --- /dev/null +++ b/readarr/rootfs/etc/cont-init.d/00-config_location.sh @@ -0,0 +1,11 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +CONFIG_LOCATION=$(bashio::config 'CONFIG_LOCATION') +bashio::log.info "Config stored in $CONFIG_LOCATION" + +mkdir -p "$CONFIG_LOCATION" +chown -R abc:abc "$CONFIG_LOCATION" + +sed -i "s|/config/readarr|$CONFIG_LOCATION|g" /etc/services.d/readarr/run +sed -i "s|/config/readarr|$CONFIG_LOCATION|g" /etc/cont-init.d/30-config diff --git a/readarr/rootfs/etc/cont-init.d/20-folders.sh b/readarr/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..122bd888b --- /dev/null +++ b/readarr/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ ! -d /share/storage/ebook ]; then + echo "Creating /share/storage/ebook" + mkdir -p /share/storage/ebook + chown -R abc:abc /share/storage/ebook +fi + +if [ ! -d /share/downloads ]; then + echo "Creating /share/downloads" + mkdir -p /share/downloads + chown -R abc:abc /share/downloads +fi + +if [ -d /config/readarr ] && [ ! -d /config/addons_config/readarr ]; then + echo "Moving to new location /config/addons_config/readarr" + mkdir -p /config/addons_config/readarr + chown -R abc:abc /config/addons_config/readarr + mv /config/readarr/* /config/addons_config/readarr/ + rm -r /config/readarr +fi + +if [ ! -d /config/addons_config/readarr ]; then + echo "Creating /config/addons_config/readarr" + mkdir -p /config/addons_config/readarr + chown -R abc:abc /config/addons_config/readarr +fi diff --git a/requestrr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/requestrr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/requestrr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/resiliosync/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/resiliosync/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/resiliosync/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/resiliosync/rootfs/etc/cont-init.d/00-folders.sh b/resiliosync/rootfs/etc/cont-init.d/00-folders.sh new file mode 100644 index 000000000..1a435b3e9 --- /dev/null +++ b/resiliosync/rootfs/etc/cont-init.d/00-folders.sh @@ -0,0 +1,65 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +############### +# Define user # +############### + +PUID=$(bashio::config "PUID") +PGID=$(bashio::config "PGID") + +################### +# Create function # +################### + +change_folders () { + CONFIGLOCATION=$1 + ORIGINALLOCATION=$2 + TYPE=$3 + + # Inform + bashio::log.info "Setting $TYPE to $CONFIGLOCATION" + + # Modify files + echo "Adapting files" + grep -rl "$ORIGINALLOCATION" /etc/cont-init.d | xargs sed -i "s|$ORIGINALLOCATION|$CONFIGLOCATION|g" || true + grep -rl "$ORIGINALLOCATION" /etc/services.d | xargs sed -i "s|$ORIGINALLOCATION|$CONFIGLOCATION|g" || true + sed -i "s=$ORIGINALLOCATION=$CONFIGLOCATION=g" /etc/cont-init.d/10-adduser || true + sed -i "s=$ORIGINALLOCATION=$CONFIGLOCATION=g" /defaults/* || true + + # Adapt sync.conf + for FILE in "$ORIGINALLOCATION/sync.conf" "$CONFIGLOCATION/sync.conf" "/defaults/sync.conf"; do + if [ "$TYPE" = "config_location" ]; then + [ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION" '.storage_path = $variable' "$FILE" | sponge "$FILE" + fi + if [ "$TYPE" = "data_location" ]; then + [ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION" '.directory_root = $variable' "$FILE" | sponge "$FILE" + [ -f "$FILE" ] && jq --arg variable "$CONFIGLOCATION/downloads" '.files_default_path = $variable' "$FILE" | sponge "$FILE" + fi + done + + # Create folders + echo "Checking if folders exist" + for FOLDER in "$CONFIGLOCATION" "$CONFIGLOCATION"/folders "$CONFIGLOCATION"/mounted_folders "$CONFIGLOCATION"/downloads; do + [ ! -d "$FOLDER" ] && echo "Creating $FOLDER" && mkdir -p "$FOLDER" + done + + # Set permissions + echo "Setting ownership to $PUID:$PGID" + chown -R "$PUID":"$PGID" "$CONFIGLOCATION" + + # Transfer files + if [ -d "$ORIGINALLOCATION" ] && [ "$(ls -A "$ORIGINALLOCATION" 2>/dev/null)" ]; then + echo "Files were existing in $ORIGINALLOCATION, they will be moved to $CONFIGLOCATION" + mv "$ORIGINALLOCATION"/* "$CONFIGLOCATION"/ + rmdir "$ORIGINALLOCATION" + fi +} + +######################## +# Change data location # +######################## + +# Adapt files +change_folders "$(bashio::config 'config_location')" "/share/resiliosync_config" "config_location" +change_folders "$(bashio::config 'data_location')" "/share/resiliosync" "data_location" diff --git a/resiliosync/rootfs/etc/cont-init.d/90-ingress.sh b/resiliosync/rootfs/etc/cont-init.d/90-ingress.sh new file mode 100644 index 000000000..98246f17d --- /dev/null +++ b/resiliosync/rootfs/etc/cont-init.d/90-ingress.sh @@ -0,0 +1,13 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# +declare ingress_interface +declare ingress_port + +ingress_port=$(bashio::addon.ingress_port) +ingress_interface=$(bashio::addon.ip_address) +sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf +sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf diff --git a/scrutiny/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/scrutiny/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/scrutiny/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/scrutiny/rootfs/etc/cont-init.d/31-run.sh b/scrutiny/rootfs/etc/cont-init.d/31-run.sh new file mode 100644 index 000000000..209a63bcd --- /dev/null +++ b/scrutiny/rootfs/etc/cont-init.d/31-run.sh @@ -0,0 +1,50 @@ +#!/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 diff --git a/scrutiny/rootfs/etc/cont-init.d/32-nginx_ingress.sh b/scrutiny/rootfs/etc/cont-init.d/32-nginx_ingress.sh new file mode 100644 index 000000000..6ac38a5b6 --- /dev/null +++ b/scrutiny/rootfs/etc/cont-init.d/32-nginx_ingress.sh @@ -0,0 +1,33 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# +declare port +declare certfile +declare ingress_interface +declare ingress_port +declare keyfile + +port=$(bashio::addon.port 80) +if bashio::var.has_value "${port}"; then + bashio::config.require.ssl + + if bashio::config.true 'ssl'; then + certfile=$(bashio::config 'certfile') + keyfile=$(bashio::config 'keyfile') + + mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf + sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/servers/direct.conf + sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/servers/direct.conf + + else + mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf + fi +fi + +ingress_port=$(bashio::addon.ingress_port) +ingress_interface=$(bashio::addon.ip_address) +sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf +sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf diff --git a/scrutiny/rootfs/run.sh b/scrutiny/rootfs/run.sh new file mode 100644 index 000000000..30bc73d68 --- /dev/null +++ b/scrutiny/rootfs/run.sh @@ -0,0 +1,13 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# wait for scrutiny to load +bashio::net.wait_for 8080 + +##################### +# ADD LOCAL DEVICES # +##################### + +# search for local devices +# shellcheck disable=SC2015 +scrutiny-collector-metrics run >/dev/null && bashio::log.info "Local Devices Added" || bashio::log.error "Local Devices Not Added" diff --git a/scrutiny_fa/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/scrutiny_fa/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/scrutiny_fa/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/scrutiny_fa/rootfs/etc/cont-init.d/31-run.sh b/scrutiny_fa/rootfs/etc/cont-init.d/31-run.sh new file mode 100644 index 000000000..24f0fcb7a --- /dev/null +++ b/scrutiny_fa/rootfs/etc/cont-init.d/31-run.sh @@ -0,0 +1,56 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +####################### +# Require unprotected # +####################### + +bashio::require.unprotected + +############## +# 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 diff --git a/scrutiny_fa/rootfs/etc/cont-init.d/32-nginx_ingress.sh b/scrutiny_fa/rootfs/etc/cont-init.d/32-nginx_ingress.sh new file mode 100644 index 000000000..6ac38a5b6 --- /dev/null +++ b/scrutiny_fa/rootfs/etc/cont-init.d/32-nginx_ingress.sh @@ -0,0 +1,33 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# +declare port +declare certfile +declare ingress_interface +declare ingress_port +declare keyfile + +port=$(bashio::addon.port 80) +if bashio::var.has_value "${port}"; then + bashio::config.require.ssl + + if bashio::config.true 'ssl'; then + certfile=$(bashio::config 'certfile') + keyfile=$(bashio::config 'keyfile') + + mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf + sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/servers/direct.conf + sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/servers/direct.conf + + else + mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf + fi +fi + +ingress_port=$(bashio::addon.ingress_port) +ingress_interface=$(bashio::addon.ip_address) +sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf +sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf diff --git a/scrutiny_fa/rootfs/run.sh b/scrutiny_fa/rootfs/run.sh new file mode 100644 index 000000000..30bc73d68 --- /dev/null +++ b/scrutiny_fa/rootfs/run.sh @@ -0,0 +1,13 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# wait for scrutiny to load +bashio::net.wait_for 8080 + +##################### +# ADD LOCAL DEVICES # +##################### + +# search for local devices +# shellcheck disable=SC2015 +scrutiny-collector-metrics run >/dev/null && bashio::log.info "Local Devices Added" || bashio::log.error "Local Devices Not Added" diff --git a/seafile/rootfs/entrypoint.sh b/seafile/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/seafile/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/seafile/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/seafile/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/seafile/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/seafile/rootfs/etc/cont-init.d/99-run.sh b/seafile/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..1d512f54b --- /dev/null +++ b/seafile/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,111 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash +# shellcheck disable=SC2155,SC2016 + +################################### +# Export all addon options as env # +################################### + +bashio::log.info "Setting variables" + +# For all keys in options.json +JSONSOURCE="/data/options.json" + +# Export keys as env variables +# echo "All addon options were exported as variables" +mapfile -t arr < <(jq -r 'keys[]' "${JSONSOURCE}") + +for KEYS in "${arr[@]}"; do + # export key + VALUE=$(jq ."$KEYS" "${JSONSOURCE}") + line="${KEYS}='${VALUE//[\"\']/}'" + # text + if bashio::config.false "verbose" || [[ "${KEYS}" == *"PASS"* ]]; then + bashio::log.blue "${KEYS}=******" + else + bashio::log.blue "$line" + fi + # Use locally + export "${KEYS}=${VALUE//[\"\']/}" + # Export the variable to run scripts + sed -i "1a export $line" /home/seafile/*.sh 2>/dev/null + find /opt/seafile -name '*.sh' -print0 | xargs -0 sed -i "1a export $line" +done + +################# +# DATA_LOCATION # +################# + +bashio::log.info "Setting data location" +DATA_LOCATION=$(bashio::config 'data_location') + +echo "Check $DATA_LOCATION folder exists" +mkdir -p "$DATA_LOCATION" + +echo "Setting permissions" +chown -R "$(bashio::config 'PUID'):$(bashio::config 'PGID')" "$DATA_LOCATION" +chmod -R 755 "$DATA_LOCATION" + +echo "Creating symlink" +ln -sf "$DATA_LOCATION" /shared + +#export SEAFILE_CONF_DIR="$DATA_LOCATION/conf" && sed -i "1a export SEAFILE_CONF_DIR=$DATA_LOCATION/conf" /home/seafile/*.sh +#export SEAFILE_LOGS_DIR="$DATA_LOCATION/logs" && sed -i "1a export SEAFILE_LOGS_DIR=$DATA_LOCATION/logs" /home/seafile/*.sh +#export SEAFILE_DATA_DIR="$DATA_LOCATION/seafile-data" && sed -i "1a export SEAFILE_DATA_DIR=$DATA_LOCATION/seafile-data" /home/seafile/*.sh +#export SEAFILE_SEAHUB_DIR="$DATA_LOCATION/seahub-data" && sed -i "1a export SEAFILE_SEAHUB_DIR=$DATA_LOCATION/seahub-data" /home/seafile/*.sh +#export SEAFILE_SQLITE_DIR="$DATA_LOCATION/sqlite" && sed -i "1a export SEAFILE_SQLITE_DIR=$DATA_LOCATION/sqlite" /home/seafile/*.sh +export DATABASE_DIR="$DATA_LOCATION/db" && sed -i "1a export DATABASE_DIR=$DATA_LOCATION/db" /home/seafile/*.sh + +################### +# Define database # +################### + +bashio::log.info "Defining database" + +case $(bashio::config 'database') in + + # Use sqlite + sqlite) + export "SQLITE=1" && sed -i "1a export SQLITE=1" /home/seafile/*.sh + ;; + + # Use mariadb + mariadb_addon) + bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Discovering values..." + if ! bashio::services.available 'mysql'; then + bashio::log.fatal \ + "Local database access should be provided by the MariaDB addon" + bashio::exit.nok \ + "Please ensure it is installed and started" + fi + + # Use values + export MYSQL_HOST="$(bashio::services 'mysql' 'host')" && sed -i "1a export MYSQL_HOST=$(bashio::services 'mysql' 'host')" /home/seafile/*.sh + export MYSQL_PORT="$(bashio::services 'mysql' 'port')" && sed -i "1a export MYSQL_PORT=$(bashio::services 'mysql' 'port')" /home/seafile/*.sh + export MYSQL_USER="$(bashio::services "mysql" "username")" && sed -i "1a export MYSQL_USER=$(bashio::services 'mysql' 'username')" /home/seafile/*.sh + export MYSQL_USER_PASSWD="$(bashio::services "mysql" "password")" && sed -i "1a export MYSQL_USER_PASSWD=$(bashio::services 'mysql' 'password')" /home/seafile/*.sh + export MYSQL_ROOT_PASSWD="$(bashio::services "mysql" "password")" && sed -i "1a export MYSQL_ROOT_PASSWD=$(bashio::services 'mysql' 'password')" /home/seafile/*.sh + + # Mariadb requires a user + echo "Adapting scripts" + sed -i 's|port=${MYSQL_PORT})|port=${MYSQL_PORT}, user="${MYSQL_USER}")|g' /home/seafile/wait_for_db.sh + + # Mariadb has no root user + echo "Adapting root name" + sed -i 's|user="root"|user="service"|g' /home/seafile/clean_db.sh + sed -i "s|'root'|'service'|g" /opt/seafile/*/setup-seafile-mysql.sh + sed -i "s|'root'|'service'|g" /opt/seafile/*/setup-seafile-mysql.py + + # Informations + bashio::log.warning "This addon is using the Maria DB addon" + bashio::log.warning "Please ensure this is included in your backups" + bashio::log.warning "Uninstalling the MariaDB addon will remove any data" + ;; +esac + +############## +# LAUNCH APP # +############## + +bashio::log.info "Starting app" +/./docker_entrypoint.sh diff --git a/sonarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/sonarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/sonarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/sonarr/rootfs/etc/cont-init.d/20-folders.sh b/sonarr/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..f48deff0d --- /dev/null +++ b/sonarr/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ ! -d /share/storage/tv ]; then + echo "Creating /share/storage/tv" + mkdir -p /share/storage/tv + chown -R abc:abc /share/storage/tv +fi + +if [ ! -d /share/downloads ]; then + echo "Creating /share/downloads" + mkdir -p /share/downloads + chown -R abc:abc /share/downloads +fi + +if [ -d /config/sonarr ] && [ ! -d /config/addons_config/sonarr ]; then + echo "Moving to new location /config/addons_config/sonarr" + mkdir -p /config/addons_config/sonarr + chown -R abc:abc /config/addons_config/sonarr + mv /config/sonarr/* /config/addons_config/sonarr/ + rm -r /config/sonarr +fi + +if [ ! -d /config/addons_config/sonarr ]; then + echo "Creating /config/addons_config/sonarr" + mkdir -p /config/addons_config/sonarr + chown -R abc:abc /config/addons_config/sonarr +fi diff --git a/spotweb/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/spotweb/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/spotweb/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/tandoor_recipes/rootfs/entrypoint.sh b/tandoor_recipes/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/tandoor_recipes/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/tandoor_recipes/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/tandoor_recipes/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/tandoor_recipes/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/tandoor_recipes/rootfs/etc/cont-init.d/20-folders.sh b/tandoor_recipes/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..bfefebf96 --- /dev/null +++ b/tandoor_recipes/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,10 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +slug="tandoor_recipes" + +if [ ! -d /config/addons_config/$slug ]; then + echo "Creating /config/addons_config/$slug" + mkdir -p /config/addons_config/$slug +fi +chmod -R 755 /config/addons_config/$slug diff --git a/tandoor_recipes/rootfs/etc/cont-init.d/99-run.sh b/tandoor_recipes/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..2b2372432 --- /dev/null +++ b/tandoor_recipes/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,79 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# shellcheck disable=SC2155 + +##################### +# Export env values # +##################### + +export ALLOWED_HOSTS=$(bashio::config 'ALLOWED_HOSTS') && bashio::log.blue "ALLOWED_HOSTS=$ALLOWED_HOSTS" +export SECRET_KEY=$(bashio::config 'SECRET_KEY') && bashio::log.blue "SECRET_KEY=$SECRET_KEY" + +################### +# Define database # +################### + +bashio::log.info "Defining database" +export DB_TYPE=$(bashio::config 'DB_TYPE') +case $(bashio::config 'DB_TYPE') in + + # Use sqlite + sqlite) + bashio::log.info "Using a local sqlite database" + export DB_ENGINE="django.db.backends.sqlite3" + export POSTGRES_DB="/config/addons_config/tandoor_recipes/recipes.db" + ;; + + mariadb_addon) + bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Discovering values..." + if ! bashio::services.available 'mysql'; then + bashio::log.fatal \ + "Local database access should be provided by the MariaDB addon" + bashio::exit.nok \ + "Please ensure it is installed and started" + fi + + # Install mysqlclient + pip install pymysql &>/dev/null + + # Use values + export DB_ENGINE=django.db.backends.mysql + export POSTGRES_HOST=$(bashio::services "mysql" "host") && bashio::log.blue "POSTGRES_HOST=$POSTGRES_HOST" + export POSTGRES_PORT=$(bashio::services "mysql" "port") && bashio::log.blue "POSTGRES_PORT=$POSTGRES_PORT" + export POSTGRES_DB=/data/ + + .db && bashio::log.blue "POSTGRES_DB=$POSTGRES_DB" + export POSTGRES_USER=$(bashio::services "mysql" "username") && bashio::log.blue "POSTGRES_USER=$POSTGRES_USER" + export POSTGRES_PASSWORD=$(bashio::services "mysql" "password") && bashio::log.blue "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" + + bashio::log.warning "Webtrees is using the Maria DB addon" + bashio::log.warning "Please ensure this is included in your backups" + bashio::log.warning "Uninstalling the MariaDB addon will remove any data" + ;; + + postgresql_external) + bashio::log.info "Using an external database, please populate all required fields in the addons config" + export DB_ENGINE=django.db.backends.postgresql + export POSTGRES_HOST=$(bashio::config "POSTGRES_HOST") && bashio::log.blue "POSTGRES_HOST=$POSTGRES_HOST" + export POSTGRES_PORT=$(bashio::config "POSTGRES_PORT") && bashio::log.blue "POSTGRES_PORT=$POSTGRES_PORT" + export POSTGRES_DB=$(bashio::config "POSTGRES_DB") && bashio::log.blue "POSTGRES_DB=$POSTGRES_DB" + export POSTGRES_USER=$(bashio::config "POSTGRES_USER") && bashio::log.blue "POSTGRES_USER=$POSTGRES_USER" + export POSTGRES_PASSWORD=$(bashio::config "POSTGRES_PASSWORD") && bashio::log.blue "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" + ;; + +esac + +############## +# Launch app # +############## +echo "Creating symlinks" +mkdir -p /config/addons_config/tandoor_recipes/mediafiles +chmod -R 755 /config/addons_config/tandoor_recipes +mkdir -p /data/recipes/staticfiles +chmod 755 /data/recipes/staticfiles +ln -s /config/addons_config/tandoor_recipes/mediafiles /opt/recipes +ln -s /data/recipes/staticfiles /opt/recipes + +bashio::log.info "Launching app" +cd /opt/recipes || exit +./boot.sh diff --git a/tdarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/tdarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/tdarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/tdarr/rootfs/etc/cont-init.d/00-configuration.sh b/tdarr/rootfs/etc/cont-init.d/00-configuration.sh new file mode 100644 index 000000000..be564052e --- /dev/null +++ b/tdarr/rootfs/etc/cont-init.d/00-configuration.sh @@ -0,0 +1,47 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# Set PUID PGID # +################# + +# Get from options +PGID=$(bashio::config 'PGID') +PUID=$(bashio::config 'PUID') +# If blank, set 0 +[[ "$PUID" = "null" ]] && PUID=0 +[[ "$PGID" = "null" ]] && PGID=0 +# Write in permission file +sed -i "1a PGID=$PGID" /etc/cont-init.d/01-setup-perms +sed -i "1a PUID=$PUID" /etc/cont-init.d/01-setup-perms +# Information +bashio::log.info "Setting PUID=$PUID, PGID=$PGID" + +##################### +# Set Configuration # +##################### + +cd / + +# Config location +CONFIGLOCATION="$(bashio::config 'CONFIG_LOCATION')" + +# Create folder +mkdir -p "$CONFIGLOCATION" + +# Rename base folder +mv /app /tdarr +sed -i "s|/app|/tdarr|g" /etc/cont-init.d/* +sed -i "s|/app|/tdarr|g" /etc/services.d/*/run + +# Symlink configs +[ -d /tdarr/configs ] && rm -r /tdarr/configs +ln -s "$CONFIGLOCATION" /tdarr/configs + +# Symlink server data +[ -d /tdarr/server/Tdarr ] && rm -r /tdarr/server/Tdarr +mkdir -p /tdarr/server +ln -s "$CONFIGLOCATION" /tdarr/server/Tdarr + +# Text +bashio::log.info "Setting config location to $CONFIGLOCATION" diff --git a/teamspeak/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/teamspeak/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/teamspeak/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/teamspeak/rootfs/etc/cont-init.d/20-folders.sh b/teamspeak/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..0429bd7f7 --- /dev/null +++ b/teamspeak/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,14 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# Data remanence for /teamspeak/save +if [ -d /teamspeak/save ]; then + cp -rn /teamspeak/save/* /data + rm -r /teamspeak/save +fi +mkdir -p /teamspeak/save +ln -sf /data /teamspeak/save +#chown -R PUID:GUID /data +chmod -R 777 /data +#chown -R PUID:GUID /data +chmod -R 777 /teamspeak diff --git a/transmission/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/transmission/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/transmission/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/transmission/rootfs/etc/cont-init.d/19-config.sh b/transmission/rootfs/etc/cont-init.d/19-config.sh new file mode 100644 index 000000000..448053412 --- /dev/null +++ b/transmission/rootfs/etc/cont-init.d/19-config.sh @@ -0,0 +1,124 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +rm -rf /etc/cont-init.d/20-config || true + +declare CONFIG +#declare incomplete_bool +declare download_dir +declare incomplete_dir +declare USER +declare PASS +declare WHITELIST +#declare HOST_WHITELIST + +CONFIGDIR="/config/transmission" + +############### +# PERMISSIONS # +############### + +#Default folders +echo "Updating folders" +mkdir -p /config/transmission || true +mkdir -p /watch || true +chown -R abc:abc /config/transmission || true + +if ! bashio::fs.file_exists "$CONFIGDIR/settings.json"; then + echo "Creating default config" + cp "/defaults/settings.json" "$CONFIGDIR/settings.json" +fi + +################# +# CONFIGURATION # +################# + +# Alternate UI +############## + +if bashio::config.has_value 'customUI'; then + CUSTOMUI=$(bashio::config 'customUI') + [ "$CUSTOMUI" != "standard" ] && sed -i "1a export TRANSMISSION_WEB_HOME=\"/$CUSTOMUI/\"" /etc/services.d/transmission/run + + # Enable transmission-web-control return to default UI + if [ ! -f "/transmission-web-control/index.original.html" ]; then + ln -s /usr/share/transmission/web/style /transmission-web-control + ln -s /usr/share/transmission/web/images /transmission-web-control + ln -s /usr/share/transmission/web/javascript /transmission-web-control + ln -s /usr/share/transmission/web/index.html /transmission-web-control/index.original.html + fi +fi +bashio::log.info "UI selected : $CUSTOMUI" + +# INCOMPLETE DIR +################ + +echo "Creating config" +download_dir=$(bashio::config 'download_dir') +incomplete_dir=$(bashio::config 'incomplete_dir') +CONFIG=$(<$CONFIGDIR/settings.json) + +# Permissions +echo "Updating permissions" +mkdir -p "$download_dir" +chown abc:abc "$download_dir" + +# if incomplete dir > 2, to allow both null and '', set it as existing +if [ ${#incomplete_dir} -ge 2 ]; then + echo "Incomplete dir set: $incomplete_dir" + CONFIG=$(bashio::jq "${CONFIG}" ".\"incomplete-dir-enabled\"=true") + mkdir -p "$incomplete_dir" + chown abc:abc "$incomplete_dir" +else + echo "Incomplete dir disabled" + CONFIG=$(bashio::jq "${CONFIG}" ".\"incomplete-dir-enabled\"=false") +fi + +# Defaults +CONFIG=$(bashio::jq "${CONFIG}" ".\"incomplete-dir\"=\"${incomplete_dir}\"") +CONFIG=$(bashio::jq "${CONFIG}" ".\"download-dir\"=\"${download_dir}\"") +CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-host-whitelist-enabled\"=false") +CONFIG=$(bashio::jq "${CONFIG}" ".\"bind-address-ipv4\"=\"0.0.0.0\"") + +if bashio::config.has_value 'watch_dir'; then + CONFIG=$(bashio::jq "${CONFIG}" ".\"watch-dir\"=\"$(bashio::config 'watch_dir')\"") +fi + +echo "${CONFIG}" >"$CONFIGDIR"/settings.json && +jq . -S "$CONFIGDIR"/settings.json | cat >temp.json && mv temp.json $CONFIGDIR/settings.json + +# USER and PASS +############### + +CONFIG=$(<"$CONFIGDIR"/settings.json) +USER=$(bashio::config 'user') +PASS=$(bashio::config 'pass') +if bashio::config.has_value 'user'; then + BOOLEAN=true + bashio::log.info "User & Pass set, authentification will be with user : $USER and pass : $PASS" +else + BOOLEAN=false + bashio::log.warning "User & Pass not set, no authentification required" +fi +CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-authentication-required\"=${BOOLEAN}") +CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-username\"=\"${USER}\"") +CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-password\"=\"${PASS}\"") +echo "${CONFIG}" >"$CONFIGDIR"/settings.json && +jq . -S "$CONFIGDIR"/settings.json | cat >temp.json && mv temp.json "$CONFIGDIR"/settings.json + +# WHITELIST +########### + +CONFIG=$(<"$CONFIGDIR"/settings.json) +WHITELIST=$(bashio::config 'whitelist') +if bashio::config.has_value 'whitelist'; then + BOOLEAN=true + bashio::log.info "Whitelist set, no authentification from IP $WHITELIST" +else + BOOLEAN=false + sed -i "2 i\"rpc-whitelist-enabled\": false," "$CONFIGDIR"/settings.json +fi +CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-whitelist-enabled\"=${BOOLEAN}") +CONFIG=$(bashio::jq "${CONFIG}" ".\"rpc-whitelist\"=\"$WHITELIST\"") +echo "${CONFIG}" >"$CONFIGDIR"/settings.json && +jq . -S "$CONFIGDIR"/settings.json | cat >temp.json && mv temp.json "$CONFIGDIR"/settings.json diff --git a/transmission/rootfs/etc/cont-init.d/19-json_repair.sh b/transmission/rootfs/etc/cont-init.d/19-json_repair.sh new file mode 100644 index 000000000..e6ed80a4d --- /dev/null +++ b/transmission/rootfs/etc/cont-init.d/19-json_repair.sh @@ -0,0 +1,54 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +JSONTOCHECK='/config/transmission/settings.json' +JSONSOURCE='/defaults/settings.json' + +# If json already exists +if [ -f "${JSONTOCHECK}" ]; then + # Variables + echo "Checking settings.json format" + + # Check if json file valid or not + jq . -S "${JSONTOCHECK}" &>/dev/null && ERROR=false || ERROR=true + if [ $ERROR = true ]; then + bashio::log.fatal "Settings.json structure is abnormal, restoring options from scratch. Your old file is renamed as settings.json_old" + mv "${JSONSOURCE}" "${JSONSOURCE}"_old + cp "${JSONSOURCE}" "${JSONTOCHECK}" + exit 0 + fi + + # Get the default keys from the original file + mapfile -t arr < <(jq -r 'keys[]' "${JSONSOURCE}") + + # Check if all keys are still there, or add them + # shellcheck disable=SC2086 + for KEYS in "${arr[@]}"; do + # Check if key exists + KEYSTHERE=$(jq "has(\"${KEYS}\")" "${JSONTOCHECK}") + if [ "$KEYSTHERE" != "true" ]; then + #Fetch initial value + JSONSOURCEVALUE=$(jq -r ".\"$KEYS\"" "${JSONSOURCE}") + #Add key + sed -i "3 i\"${KEYS}\": \"${JSONSOURCEVALUE}\"," "${JSONTOCHECK}" + # Message + bashio::log.warning "${KEYS} was missing from your settings.json, it was added with the default value ${JSONSOURCEVALUE}" + fi + done + + # Show structure in a nice way + jq . -S "${JSONTOCHECK}" | cat >temp.json && mv temp.json "${JSONTOCHECK}" + + # Message + bashio::log.info "Your settings.json was checked and seems perfectly normal!" +fi + +# Repair structure +################ +#jq . -S $CONFIGDIR/settings.json | cat >temp.json && mv temp.json $CONFIGDIR/settings.json +#echo "Making sure settings.json structure is good" +#for KEYS in "incomplete-dir" "download-dir" "rpc-host-whitelist-enabled" "rpc-authentication-required" "rpc-username" "rpc-password" "rpc-whitelist-enabled" "rpc-whitelist"; do +# KEYSTHERE=$(jq "has(\"${KEYS}\")" $CONFIGDIR/settings.json) +# [ "$KEYSTHERE" != "true" ] && sed -i "3 i\"${KEYS}\": null," $CONFIGDIR/settings.json && echo "... $KEYS was missing, added" +#done +#jq . -S $CONFIGDIR/settings.json | cat >temp.json && mv temp.json $CONFIGDIR/settings.json diff --git a/transmission/rootfs/etc/cont-init.d/32-nginx_ingress.sh b/transmission/rootfs/etc/cont-init.d/32-nginx_ingress.sh new file mode 100644 index 000000000..6b4aa4d24 --- /dev/null +++ b/transmission/rootfs/etc/cont-init.d/32-nginx_ingress.sh @@ -0,0 +1,18 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# +declare ingress_interface +declare ingress_port + +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 + +# Avoid error message +grep -rnl "PhotoPrism has been updated…" /opt/photoprism | xargs sed -i "s|PhotoPrism has been updated…|Please click cancel|g" diff --git a/transmission_openvpn/rootfs/entrypoint.sh b/transmission_openvpn/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/transmission_openvpn/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/transmission_openvpn/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/transmission_openvpn/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/transmission_openvpn/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/transmission_openvpn/rootfs/etc/cont-init.d/32-nginx_ingress.sh b/transmission_openvpn/rootfs/etc/cont-init.d/32-nginx_ingress.sh new file mode 100644 index 000000000..6b4aa4d24 --- /dev/null +++ b/transmission_openvpn/rootfs/etc/cont-init.d/32-nginx_ingress.sh @@ -0,0 +1,18 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# +declare ingress_interface +declare ingress_port + +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 + +# Avoid error message +grep -rnl "PhotoPrism has been updated…" /opt/photoprism | xargs sed -i "s|PhotoPrism has been updated…|Please click cancel|g" diff --git a/transmission_openvpn/rootfs/etc/cont-init.d/99-run.sh b/transmission_openvpn/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..f9d381db5 --- /dev/null +++ b/transmission_openvpn/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,32 @@ +#!/usr/bin/bashio + +#################### +# Export variables # +#################### + +bashio::log.info "Exporting variables" +for k in $(bashio::jq "/data/options.json" 'keys | .[]'); do + bashio::log.blue "$k"="$(bashio::config "$k")" + export "$k"="$(bashio::config "$k")" +done +echo "" + +####################### +# Run haugene scripts # +####################### + +bashio::log.info "Running userscript" +chmod +x /etc/transmission/userSetup.sh +/./etc/transmission/userSetup.sh +echo "" + +bashio::log.info "Starting app" +/./etc/openvpn/start.sh & echo "" + +################# +# Allow ingress # +################# + +bashio::net.wait_for 9091 localhost 900 +bashio::log.info "Ingress ready" +exec nginx diff --git a/ubooquity/rootfs/etc/32-nginx_ingress.sh b/ubooquity/rootfs/etc/32-nginx_ingress.sh new file mode 100644 index 000000000..a41162763 --- /dev/null +++ b/ubooquity/rootfs/etc/32-nginx_ingress.sh @@ -0,0 +1,26 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################### +# INGRESS SETTING # +################### +declare port +#declare certfile +#declare ingress_interface +#declare ingress_port +#declare keyfile + +# General values +port=$(bashio::addon.ingress_port) +# shellcheck disable=SC2210 +if [ "$port" ] >1; then + # Adapt nginx + sed -i "s|%%port%%|$port|g" /etc/nginx/servers/ingress.conf + sed -i "s|%%interface%%|$(bashio::addon.ip_address)|g" /etc/nginx/servers/ingress.conf + # Removebaseurl + jq '.reverseProxyPrefix = ""' /config/addons_config/ubooquity/preferences.json | sponge /config/addons_config/ubooquity/preferences.json + # Log + bashio::log.info "Ingress enabled" +else + rm /etc/nginx/servers/ingress.conf +fi diff --git a/ubooquity/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/ubooquity/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/ubooquity/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/ubooquity/rootfs/etc/cont-init.d/20-folders.sh b/ubooquity/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..aa3708a4d --- /dev/null +++ b/ubooquity/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,19 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +slug=ubooquity + +if [ ! -d /config/addons_config/$slug ]; then + + if [ -d /config/$slug ]; then + echo "Moving to new location /config/addons_config/$slug" + mkdir -p /config/addons_config/$slug + chmod 777 /config/addons_config/$slug + mv /config/$slug/* /config/addons_config/$slug/ + rm -r /config/$slug + fi + + echo "Creating /config/addons_config/$slug" + mkdir -p /config/addons_config/$slug + chmod 777 /config/addons_config/$slug +fi diff --git a/ubooquity/rootfs/etc/cont-init.d/32-nginx_ssl.sh b/ubooquity/rootfs/etc/cont-init.d/32-nginx_ssl.sh new file mode 100644 index 000000000..98bc7c320 --- /dev/null +++ b/ubooquity/rootfs/etc/cont-init.d/32-nginx_ssl.sh @@ -0,0 +1,27 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +############### +# SSL SETTING # +############### +declare port +declare certfile +#declare ingress_interface +#declare ingress_port +declare keyfile + +# General values +port=2205 +sed -i "s|%%port%%|$port|g" /etc/nginx/servers/ssl.conf +sed -i "s|%%interface%%|$(bashio::addon.ip_address)|g" /etc/nginx/servers/ssl.conf + +# Ssl values +if bashio::config.true 'ssl'; then + bashio::config.require.ssl + certfile=$(bashio::config 'certfile') + keyfile=$(bashio::config 'keyfile') + sed -i "s|default_server|ssl|g" /etc/nginx/servers/ssl.conf + sed -i "/proxy_params.conf/a ssl_certificate /ssl/$certfile;" /etc/nginx/servers/ssl.conf + sed -i "/proxy_params.conf/a ssl_certificate_key /ssl/$keyfile;" /etc/nginx/servers/ssl.conf + bashio::log.info "Ssl enabled, please use https for connection. UI is at https://YOURIP:$(bashio::addon.port 2205)/ubooquity ; admin is at https://YOURIP:$(bashio::addon.port 2206)/ubooquity/admin" +fi diff --git a/ubooquity/rootfs/etc/cont-init.d/91-configuration.sh b/ubooquity/rootfs/etc/cont-init.d/91-configuration.sh new file mode 100644 index 000000000..ca15ecd48 --- /dev/null +++ b/ubooquity/rootfs/etc/cont-init.d/91-configuration.sh @@ -0,0 +1,12 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +########### +# FOLDERS # +########### +FILES=$(jq ".filesPaths[0].pathString" /config/addons_config/ubooquity/preferences.json) +COMICS=$(jq ".comicsPaths[0].pathString" /config/addons_config/ubooquity/preferences.json) +BOOKS=$(jq ".booksPaths[0].pathString" /config/addons_config/ubooquity/preferences.json) + +mkdir -p "$FILES" "$COMICS" "$BOOKS" /config/addons_config/ubooquity || true +chown -R abc:abc "$FILES" "$COMICS" "$BOOKS" /config/addons_config/ubooquity || true diff --git a/ubooquity/rootfs/etc/cont-init.d/93-custom_webUI.sh b/ubooquity/rootfs/etc/cont-init.d/93-custom_webUI.sh new file mode 100644 index 000000000..aa57e4a71 --- /dev/null +++ b/ubooquity/rootfs/etc/cont-init.d/93-custom_webUI.sh @@ -0,0 +1,34 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################ +# Alternate UI # +################ + +if bashio::config.has_value 'theme'; then + ### Variables + CUSTOMUI=$(bashio::config 'theme') + bashio::log.info "Alternate theme enabled : $CUSTOMUI. If webui don't work, disable this option" + + ### Download WebUI + case "$CUSTOMUI" in + "comixology2") + curl -f -s -S -J -L -o /data/release.zip https://github.com/scooterpsu/Comixology_Ubooquity_2/releases/download/v3.4/comixology2.zip >/dev/null && + unzip -o -q /data/release.zip -d /config/addons_config/ubooquity/themes/ + ;; + + "plextheme-master") + curl -f -s -S -J -L -o /data/release.zip https://github.com/FinalAngel/plextheme/archive/master.zip >/dev/null && + unzip -q /data/release.zip -d /config/addons_config/ubooquity/themes/ + # && mv /config/addons_config/ubooquity/themes/plextheme-master/ /config/addons_config/ubooquity/themes/ + ;; + + esac + + ### Clean files + rm /data/release.zip || true + + ### Set preference + jq --arg variable "$CUSTOMUI" '.theme = $variable' /config/addons_config/ubooquity/preferences.json | sponge /config/addons_config/ubooquity/preferences.json + +fi diff --git a/webtop_kde/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/webtop_kde/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/webtop_kde/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/webtop_kde/rootfs/etc/cont-init.d/00-data_location.sh b/webtop_kde/rootfs/etc/cont-init.d/00-data_location.sh new file mode 100644 index 000000000..2475f9d73 --- /dev/null +++ b/webtop_kde/rootfs/etc/cont-init.d/00-data_location.sh @@ -0,0 +1,47 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# 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=/config/addons_config/${HOSTNAME#*-} + 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" +sed -i "1a export HOME=$LOCATION" /etc/services.d/web/run +sed -i "1a export FM_HOME=$LOCATION" /etc/services.d/web/run +sed -i "s|/share/webtop_kde|$LOCATION|g" /defaults/* +sed -i "s|/share/webtop_kde|$LOCATION|g" /etc/cont-init.d/* +sed -i "s|/share/webtop_kde|$LOCATION|g" /etc/services.d/*/run +usermod --home "$LOCATION" abc + +# Create folder +echo "Creating $LOCATION" +mkdir -p "$LOCATION" + +# Set ownership +bashio::log.info "Setting ownership to $PUID:$PGID" +chown "$PUID":"$PGID" "$LOCATION" diff --git a/webtop_kde/rootfs/etc/cont-init.d/20-folders.sh b/webtop_kde/rootfs/etc/cont-init.d/20-folders.sh new file mode 100644 index 000000000..1dd6488e4 --- /dev/null +++ b/webtop_kde/rootfs/etc/cont-init.d/20-folders.sh @@ -0,0 +1,10 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +# Define home +HOME="/share/webtop_kde" +mkdir -p $HOME +chown -R abc:abc $HOME + +#adduser USERNAME +#useradd -m abc -p abc diff --git a/webtop_kde/rootfs/etc/cont-init.d/80-configuration.sh b/webtop_kde/rootfs/etc/cont-init.d/80-configuration.sh new file mode 100644 index 000000000..1f3eabaa7 --- /dev/null +++ b/webtop_kde/rootfs/etc/cont-init.d/80-configuration.sh @@ -0,0 +1,59 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash +# shellcheck disable=SC2015 + +# Add Edge repositories +if bashio::config.true 'edge_repositories'; then + bashio::log.info "Changing app repositories to edge" + { echo "https://dl-cdn.alpinelinux.org/alpine/edge/community"; + echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing"; + echo "https://dl-cdn.alpinelinux.org/alpine/edge/main"; } > /etc/apk/repositories +fi + +# Install rpi video drivers +if bashio::config.true 'rpi_video_drivers'; then + bashio::log.info "Installing Rpi graphic drivers" + apk add --no-cache mesa-dri-vc4 mesa-dri-swrast mesa-gbm xf86-video-fbdev >/dev/null && bashio::log.green "... done" || + bashio::log.red "... not successful. Are you on a rpi?" +fi + +# Fix mate software center +if [ -f /usr/lib/dbus-1.0/dbus-daemon-launch-helper ]; then + echo "Allow software center" + chmod u+s /usr/lib/dbus-1.0/dbus-daemon-launch-helper + service dbus restart +fi + +# Install specific apps +if bashio::config.has_value 'additional_apps'; then + bashio::log.info "Installing additional apps :" + # hadolint ignore=SC2005 + NEWAPPS=$(bashio::config 'additional_apps') + for APP in ${NEWAPPS//,/ }; do + bashio::log.green "... $APP" + # shellcheck disable=SC2015 + apk add --no-cache "$APP" >/dev/null || bashio::log.red "... not successful, please check package name" + done +fi + +# Set TZ +if bashio::config.has_value 'TZ'; then + TIMEZONE=$(bashio::config 'TZ') + bashio::log.info "Setting timezone to $TIMEZONE" + ln -snf /usr/share/zoneinfo/"$TIMEZONE" /etc/localtime && echo "$TIMEZONE" >/etc/timezone +fi + +# Set keyboard +if bashio::config.has_value 'KEYBOARD'; then + KEYBOARD=$(bashio::config 'KEYBOARD') + bashio::log.info "Setting keyboard to $KEYBOARD" + sed -i "1a export KEYBOARD=$KEYBOARD" /etc/services.d/web/run +fi + +# Set password +if bashio::config.has_value 'PASSWORD'; then + bashio::log.info "Setting password to the value defined in options" + PASSWORD=$(bashio::config 'PASSWORD') + passwd -d abc + echo -e "$PASSWORD\n$PASSWORD" | passwd abc +fi diff --git a/webtop_kde/rootfs/etc/cont-init.d/90-ingress.sh b/webtop_kde/rootfs/etc/cont-init.d/90-ingress.sh new file mode 100644 index 000000000..2aba20d0a --- /dev/null +++ b/webtop_kde/rootfs/etc/cont-init.d/90-ingress.sh @@ -0,0 +1,36 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# NGINX SETTING # +################# +declare port +declare certfile +declare ingress_interface +declare ingress_port +declare keyfile + +port=$(bashio::addon.port 80) +if bashio::var.has_value "${port}"; then + bashio::config.require.ssl + + if bashio::config.true 'ssl'; then + certfile=$(bashio::config 'certfile') + keyfile=$(bashio::config 'keyfile') + + mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf + sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/servers/direct.conf + sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/servers/direct.conf + + else + mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf + fi +fi + +ingress_port=$(bashio::addon.ingress_port) +ingress_interface=$(bashio::addon.ip_address) +sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf +sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf + +# Implement SUBFOLDER value +sed -i "1a SUBFOLDER=$(bashio::addon.ingress_url)" /etc/services.d/autostart/run diff --git a/webtrees/rootfs/entrypoint.sh b/webtrees/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/webtrees/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/webtrees/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/webtrees/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/webtrees/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/webtrees/rootfs/etc/cont-init.d/99-run.sh b/webtrees/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..8a7d8bfde --- /dev/null +++ b/webtrees/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,133 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash +# shellcheck disable=SC2155 + +#################### +# GLOBAL VARIABLES # +#################### + +export BASE_URL=$(bashio::config 'BASE_URL'):$(bashio::addon.port 80) +#export LANG=$(bashio::config 'LANG') + + +################### +# Define database # +################### + +bashio::log.info "Defining database" +export DB_TYPE=$(bashio::config 'DB_TYPE') +case $(bashio::config 'DB_TYPE') in + + # Use sqlite + sqlite) + bashio::log.info "Using a local sqlite database $WEBTREES_HOME/$DB_NAME please wait then login. Default credentials : $WT_USER : $WT_PASS" + ;; + + mariadb_addon) + bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Discovering values..." + if ! bashio::services.available 'mysql'; then + bashio::log.fatal \ + "Local database access should be provided by the MariaDB addon" + bashio::exit.nok \ + "Please ensure it is installed and started" + fi + + # Use values + export DB_TYPE=mysql + export DB_HOST=$(bashio::services "mysql" "host") && bashio::log.blue "DB_HOST=$DB_HOST" + export DB_PORT=$(bashio::services "mysql" "port") && bashio::log.blue "DB_PORT=$DB_PORT" + export DB_NAME=webtrees && bashio::log.blue "DB_NAME=$DB_NAME" + export DB_USER=$(bashio::services "mysql" "username") && bashio::log.blue "DB_USER=$DB_USER" + export DB_PASS=$(bashio::services "mysql" "password") && bashio::log.blue "DB_PASS=$DB_PASS" + + bashio::log.warning "Webtrees is using the Maria DB addon" + bashio::log.warning "Please ensure this is included in your backups" + bashio::log.warning "Uninstalling the MariaDB addon will remove any data" + ;; + + external) + bashio::log.info "Using an external database, please populate all required fields in the config.yaml according to dovumentation" + ;; + +esac + + +################ +# SSL CONFIG # +################ + +bashio::config.require.ssl +if bashio::config.true 'ssl'; then + + #set variables + CERTFILE=$(bashio::config 'certfile') + KEYFILE=$(bashio::config 'keyfile') + + #Replace variables + sed -i "s|/certs/webtrees.crt|/ssl/$CERTFILE|g" /etc/apache2/sites-available/default-ssl.conf + sed -i "s|/certs/webtrees.key|/ssl/$KEYFILE|g" /etc/apache2/sites-available/default-ssl.conf + sed -i "s|/certs/webtrees.crt|/ssl/$CERTFILE|g" /etc/apache2/sites-available/webtrees-ssl.conf + sed -i "s|/certs/webtrees.key|/ssl/$KEYFILE|g" /etc/apache2/sites-available/webtrees-ssl.conf + + #Send env variables + export HTTPS=true + export SSL=true + BASE_URL="$BASE_URL":$(bashio::addon.port 443) + export BASE_URL="${BASE_URL/http:/https:}" + + #Communication + bashio::log.info "Ssl enabled. If webui don't work, disable ssl or check your certificate paths" +fi + +############## +# LAUNCH APP # +############## + +bashio::log.info "Launching app, please wait" + +# Change data location +echo "... update data with image" +OLD_WEBTREES_HOME="$WEBTREES_HOME" +export WEBTREES_HOME="/share/webtrees" +cp -rn /var/www/webtrees "$(dirname "$OLD_WEBTREES_HOME")" &>/dev/null || true +mkdir -p "$WEBTREES_HOME" + +echo "... update permissions" +chown -R www-data:www-data "$OLD_WEBTREES_HOME" +chown -R www-data:www-data "$WEBTREES_HOME" + +# Make links with share +echo "... make links with data in /share" +for VOL in "data" "modules_v4"; do + mkdir -p "$OLD_WEBTREES_HOME"/"$VOL" + cp -rn "$OLD_WEBTREES_HOME"/"$VOL" "$WEBTREES_HOME" || true + # shellcheck disable=SC2115 + rm -r "$OLD_WEBTREES_HOME"/"$VOL" || true + echo "... linking $VOL" + ln -s "$WEBTREES_HOME"/"$VOL" "$OLD_WEBTREES_HOME" +done + +chown -R www-data:www-data "$WEBTREES_HOME" + +# Correct base url if needed +echo "... align base url with latest addon value" +if [ -f "$WEBTREES_HOME"/data/config.ini.php ]; then + echo "Aligning base_url addon config" + LINE=$(sed -n '/base_url/=' "$WEBTREES_HOME"/data/config.ini.php) + sed -i "$LINE a base_url=\"$BASE_URL\"" "$WEBTREES_HOME"/data/config.ini.php + sed -i "$LINE d" "$WEBTREES_HOME"/data/config.ini.php +fi || true + +############ +# END INFO # +############ + +DB_NAME=$(echo "$DB_NAME" | tr -d '"') + +bashio::log.info "Data is stored in $WEBTREES_HOME" +bashio::log.info "Webui can be accessed at : $BASE_URL" + +# Execute main script +echo "python3 /docker-entrypoint.py" +cd / +python3 /docker-entrypoint.py diff --git a/wger/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/wger/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/wger/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/whoogle/rootfs/entrypoint.sh b/whoogle/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/whoogle/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done 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..b983e4efc --- /dev/null +++ b/whoogle/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/whoogle/rootfs/etc/cont-init.d/32-nginx_ingress.sh b/whoogle/rootfs/etc/cont-init.d/32-nginx_ingress.sh new file mode 100644 index 000000000..405044aec --- /dev/null +++ b/whoogle/rootfs/etc/cont-init.d/32-nginx_ingress.sh @@ -0,0 +1,49 @@ +#!/usr/bin/with-contenv bashio +# shellcheck shell=bash + +################# +# CORRECT IMAGE # +################# +#Allow images access +#chmod -R 755 /whoogle/app +#Allow manifest access +#sed -i 's|manifest.json">|manifest.json" crossorigin="use-credentials">|g' /whoogle/app/templates/index.html + +#Allow ingress +sed -i "1a export WHOOGLE_URL_PREFIX=$(bashio::addon.ingress_entry)" /etc/cont-init.d/99-run.sh + +################# +# NGINX SETTING # +################# +declare port +declare certfile +declare ingress_interface +declare ingress_port +declare keyfile + +port=$(bashio::addon.port 80) +if bashio::var.has_value "${port}"; then + bashio::config.require.ssl + + if bashio::config.true 'ssl'; then + certfile=$(bashio::config 'certfile') + keyfile=$(bashio::config 'keyfile') + + mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf + sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/servers/direct.conf + sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/servers/direct.conf + + else + mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf + fi +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 + +dns_host=127.0.0.11 +sed -i "s/%%dns_host%%/${dns_host}/g" /etc/nginx/includes/resolver.conf diff --git a/whoogle/rootfs/etc/cont-init.d/99-run.sh b/whoogle/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..762e0594a --- /dev/null +++ b/whoogle/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +exec misc/tor/start-tor.sh & ./run & echo "Starting NGinx..." + +exec nginx diff --git a/xteve/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/xteve/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/xteve/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/zoneminder/rootfs/entrypoint.sh b/zoneminder/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/zoneminder/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# Starting scripts # +#################### + +for SCRIPTS in /etc/cont-init.d/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown "$(id -u)":"$(id -g)" "$SCRIPTS" + chmod a+x "$SCRIPTS" + # Change shebang if no s6 supervision + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS" + /."$SCRIPTS" || echo "$SCRIPTS: exiting $?" +done diff --git a/zoneminder/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/zoneminder/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/zoneminder/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 \ + && apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \ + && 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 + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/zoneminder/rootfs/etc/cont-init.d/00-folders.sh b/zoneminder/rootfs/etc/cont-init.d/00-folders.sh new file mode 100644 index 000000000..bf713d4bf --- /dev/null +++ b/zoneminder/rootfs/etc/cont-init.d/00-folders.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# shellcheck shell=bash + +#CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION") +#CONFIGSOURCE=$(dirname "$CONFIGSOURCE") +CONFIGSOURCE="/config/addons_config/zoneminder" + +# Set image location +if bashio::config.has_value "Images_location"; then + IMAGESOURCE=$(bashio::config "Images_location") +else + IMAGESOURCE="$CONFIGSOURCE"/images +fi + +# Create directory +echo "... making sure $CONFIGSOURCE exists" +if [ ! -d "$CONFIGSOURCE" ]; then mkdir "$CONFIGSOURCE"; fi +if [ ! -d "$CONFIGSOURCE"/events ]; then mkdir "$CONFIGSOURCE"/events; fi +if [ ! -d "$CONFIGSOURCE"/sounds ]; then mkdir "$CONFIGSOURCE"/sounds; fi +if [ ! -d "$IMAGESOURCE" ]; then mkdir "$IMAGESOURCE"; fi + +# Make sure permissions are right +echo "... checking permissions" +chown -R "$(id -u):$(id -g)" "$CONFIGSOURCE" +chown -R "$(id -u):$(id -g)" "$IMAGESOURCE" + +# Make symlinks +echo "... making symlinks" +ln -s "$CONFIGSOURCE"/events /var/cache/zoneminder/events2 +ln -s "$CONFIGSOURCE"/sounds /var/cache/zoneminder/sounds2 +ln -s "$IMAGESOURCE" /var/cache/zoneminder/images2 diff --git a/zoneminder/rootfs/etc/cont-init.d/99-run.sh b/zoneminder/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..d2c0fa8c6 --- /dev/null +++ b/zoneminder/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash +# hadolint ignore=SC2155 + +################# +# Define config # +################# + +CONFIGSOURCE="/config/addons_config/zoneminder" +if [ ! -f "$CONFIGSOURCE"/zm.conf ]; then + + # Copy conf files + cp /etc/zm/zm.conf "$CONFIGSOURCE" +fi + +################### +# Define database # +################### + +bashio::log.info "Defining database" +case "$(bashio::config "DB_CONNECTION")" in + + # Use MariaDB + mariadb_addon) + bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Detecting values..." + if ! bashio::services.available 'mysql'; then + bashio::log.fatal \ + "Local database access should be provided by the MariaDB addon" + bashio::exit.nok \ + "Please ensure it is installed and started" + fi + + # Use values + DB_CONNECTION=mysql + ZM_DB_HOST=$(bashio::services "mysql" "host") + ZM_DB_PORT=$(bashio::services "mysql" "port") + ZM_DB_NAME=firefly + ZM_DB_USER=$(bashio::services "mysql" "username") + ZM_DB_PASS=$(bashio::services "mysql" "password") + export DB_CONNECTION + export remoteDB=1 + export ZM_DB_HOST && bashio::log.blue "ZM_DB_HOST=$ZM_DB_HOST" + export ZM_DB_PORT && bashio::log.blue "ZM_DB_PORT=$ZM_DB_PORT" + export ZM_DB_NAME && bashio::log.blue "ZM_DB_NAME=$ZM_DB_NAME" + export ZM_DB_USER && bashio::log.blue "ZM_DB_USER=$ZM_DB_USER" + export ZM_DB_PASS && bashio::log.blue "ZM_DB_PASS=$ZM_DB_PASS" + + bashio::log.warning "Firefly-iii is using the Maria DB addon" + bashio::log.warning "Please ensure this is included in your backups" + bashio::log.warning "Uninstalling the MariaDB addon will remove any data" + + bashio::log.info "Creating database for Firefly-iii if required" + mysql \ + -u "${ZM_DB_USER}" -p"${ZM_DB_PASS}" \ + -h "${ZM_DB_HOST}" -P "${ZM_DB_PORT}" \ + -e "CREATE DATABASE IF NOT EXISTS \`firefly\` ;" + ;; + + # Use remote + external) + bashio::log.info "Using remote database. Requirement : filling all addon options fields, and making sure the database already exists" + for conditions in "ZM_DB_HOST" "ZM_DB_PORT" "ZM_DB_NAME" "ZM_DB_USER" "ZM_DB_PASS"; do + if ! bashio::config.has_value "$conditions"; then + bashio::exit.nok "Remote database has been specified but $conditions is not defined in addon options" + fi + done + ;; + + + # Use remote + *) + bashio::log.info "Using internal database" + ;; + +esac + +############## +# LAUNCH APP # +############## + +bashio::log.info "Please wait while the app is loading !" + +./usr/local/bin/entrypoint.sh