diff --git a/.all-contributorsrc b/.all-contributorsrc new file mode 100644 index 00000000..09cad16c --- /dev/null +++ b/.all-contributorsrc @@ -0,0 +1,22 @@ +{ + "projectName": "thetvapp-docker", + "projectOwner": "Aetherinox", + "repoType": "github", + "repoHost": "https://github.com", + "files": ["README.md"], + "imageSize": 40, + "commit": true, + "commitConvention": "angular", + "contributors": [ + { + "login": "Aetherinox", + "name": "Aetherinox", + "avatar_url": "https://avatars.githubusercontent.com/u/118329232?v=4", + "profile": "https://gitlab.com/Aetherinox", + "contributions": ["code", "projectManagement"] + } + ], + "contributorsPerLine": 7, + "linkToUsage": false +} + diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..cdb1a82f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +.gitignore +.github +.gitattributes +READMETEMPLATE.md +README.md diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..b58e38d6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +# http://editorconfig.org + +# is top-most EditorConfig file +root = true + +# All Files +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +# Markdown Files +[*.md] +trim_trailing_whitespace = false + +# Other +[{*.nsh,*.yml,*.yaml,*.json}] +indent_style = space +indent_size = 2 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..bdb0cabc --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..77ea0e07 --- /dev/null +++ b/.gitignore @@ -0,0 +1,64 @@ +# # +# Windows image file caches +# # + +Thumbs.db +ehthumbs.db + +# # +# Folder config file +# # + +Desktop.ini + +# # +# Recycle Bin used on file shares +# # + +$RECYCLE.BIN/ + +# # +# Windows Installer files +# # + +*.cab +*.msi +*.msm +*.msp + +# # +# Windows shortcuts +# # + +*.lnk + +# # +# Operating System Files +# # + +.DS_Store +.AppleDouble +.LSOverride + +# # +# Thumbnails +# # + +._* + +# # +# Other +# # + +.Spotlight-V100 +.Trashes + +# # +# Directories potentially created on remote AFP share +# # + +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..30936b85 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,116 @@ +# syntax=docker/dockerfile:1 + +# # +# Base Image +# This container uses a modified version of the Linux server alpine image +# # + +FROM ghcr.io/linuxserver/baseimage-alpine:3.20 + +# # +# Set Args +# # + +ARG BUILD_DATE +ARG VERSION +ARG NGINX_VERSION +ARG REFRESH +ENV REFRESH="0/15 * * * *" + +ENV URL_XML="https://raw.githubusercontent.com/dtankdempse/thetvapp-m3u/refs/heads/main/guide/epg.xml" +ENV URL_XML_GZ="https://raw.githubusercontent.com/dtankdempse/thetvapp-m3u/refs/heads/main/guide/epg.xml.gz" +ENV URL_M3U="https://thetvapp-m3u.data-search.workers.dev/playlist" +ENV FILE_NAME="thetvapp" + +ENV PORT_HTTP=80 +ENV PORT_HTTPS=443 + +# # +# Set Labels +# # + +LABEL maintainer="Aetherinox" + +# # +# Install +# # + +RUN \ + if [ -z ${NGINX_VERSION+x} ]; then \ + NGINX_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \ + && awk '/^P:nginx$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \ + fi && \ + apk add --no-cache \ + wget \ + logrotate \ + openssl \ + apache2-utils \ + nginx \ + php83 \ + php83-fileinfo \ + php83-fpm \ + php83-mbstring \ + nginx==${NGINX_VERSION} \ + nginx-mod-http-fancyindex==${NGINX_VERSION} && \ + echo "**** Install Build Packages ****" && \ + echo "**** Configure Nginx ****" && \ + echo 'fastcgi_param HTTP_PROXY ""; # https://httpoxy.org/' >> \ + /etc/nginx/fastcgi_params && \ + echo 'fastcgi_param PATH_INFO $fastcgi_path_info; # http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_split_path_info' >> \ + /etc/nginx/fastcgi_params && \ + echo 'fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/#connecting-nginx-to-php-fpm' >> \ + /etc/nginx/fastcgi_params && \ + echo 'fastcgi_param SERVER_NAME $host; # Send HTTP_HOST as SERVER_NAME. If HTTP_HOST is blank, send the value of server_name from nginx (default is `_`)' >> \ + /etc/nginx/fastcgi_params && \ + rm -f /etc/nginx/http.d/default.conf && \ + rm -f /etc/nginx/conf.d/stream.conf && \ + rm -f /config/www/index.html && \ + echo "**** Check PHP version and symlink ****" && \ + if [ "$(readlink /usr/bin/php)" != "php83" ]; then \ + rm -rf /usr/bin/php && \ + ln -s /usr/bin/php83 /usr/bin/php; \ + fi && \ + echo "**** Configure PHP ****" && \ + sed -i "s#;error_log = log/php83/error.log.*#error_log = /config/log/php/error.log#g" \ + /etc/php83/php-fpm.conf && \ + sed -i "s#user = nobody.*#user = abc#g" \ + /etc/php83/php-fpm.d/www.conf && \ + sed -i "s#group = nobody.*#group = abc#g" \ + /etc/php83/php-fpm.d/www.conf && \ + echo "**** Setup Logrotate ****" && \ + sed -i "s#/var/log/messages {}.*# #g" \ + /etc/logrotate.conf && \ + sed -i 's#/usr/sbin/logrotate /etc/logrotate.conf#/usr/sbin/logrotate /etc/logrotate.conf -s /config/log/logrotate.status#g' \ + /etc/periodic/daily/logrotate + +# # +# Set work directory +# # + +WORKDIR /config/www + +# # +# add local files +# # + +COPY root/ / + +# # +# ports and volumes +# # + +EXPOSE ${PORT_HTTP} ${PORT_HTTPS} + +# # +# Add Cron Task Files +# # + +ADD run.sh / +ADD download.sh / + +# # +# In case user sets up the cron for a longer duration, do a first run +# and then keep the container running. Hacky, but whatever. +# # + +CMD ["sh", "-c", "/run.sh ; /download.sh ; tail -f /dev/null"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..db4ed882 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Gistr - Copyright (c) 2025 Aetherinox + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index f9bd9f82..e69de29b 100644 --- a/README.md +++ b/README.md @@ -1 +0,0 @@ -# thetvapp-docker diff --git a/download.sh b/download.sh new file mode 100644 index 00000000..63ce40f4 --- /dev/null +++ b/download.sh @@ -0,0 +1,25 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +DATE=$(date '+%m-%d-%Y %H:%M:%S') + +# # +# Run Download +# # + +echo -e +echo -e " Start : Downloading latest ${FILE_NAME} m3u + xml" + +# Download .xml +wget -q -O /config/www/${FILE_NAME}.xml ${URL_XML} +echo -e " Getting ${FILE_NAME}.xml › ${URL_XML}" + +# Download .xml.gz +wget -q -O /config/www/${FILE_NAME}.xml.gz ${URL_XML_GZ} +echo -e " Getting ${FILE_NAME}.xml.gz › ${URL_XML_GZ}" + +# Download .m3u8 +wget -q -O /config/www/${FILE_NAME}.m3u8 ${URL_M3U} +echo -e " Getting ${FILE_NAME}.m3u8 › ${URL_M3U}" + +echo -e " End : Finished update at ${DATE}" diff --git a/root/defaults/nginx/dhparams.pem b/root/defaults/nginx/dhparams.pem new file mode 100644 index 00000000..eed4c41e --- /dev/null +++ b/root/defaults/nginx/dhparams.pem @@ -0,0 +1,13 @@ +-----BEGIN DH PARAMETERS----- +MIICCAKCAgEA//////////+t+FRYortKmq/cViAnPTzx2LnFg84tNpWp4TZBFGQz ++8yTnc4kmz75fS/jY2MMddj2gbICrsRhetPfHtXV/WVhJDP1H18GbtCFY2VVPe0a +87VXE15/V8k1mE8McODmi3fipona8+/och3xWKE2rec1MKzKT0g6eXq8CrGCsyT7 +YdEIqUuyyOP7uWrat2DX9GgdT0Kj3jlN9K5W7edjcrsZCwenyO4KbXCeAvzhzffi +7MA0BM0oNC9hkXL+nOmFg/+OTxIy7vKBg8P+OxtMb61zO7X8vC7CIAXFjvGDfRaD +ssbzSibBsu/6iGtCOGEfz9zeNVs7ZRkDW7w09N75nAI4YbRvydbmyQd62R0mkff3 +7lmMsPrBhtkcrv4TCYUTknC0EwyTvEN5RPT9RFLi103TZPLiHnH1S/9croKrnJ32 +nuhtK8UiNjoNq8Uhl5sN6todv5pC1cRITgq80Gv6U93vPBsg7j/VnXwl5B0rZp4e +8W5vUsMWTfT7eTDp5OWIV7asfV9C1p9tGHdjzx1VA0AEh/VbpX4xzHpxNciG77Qx +iu1qHgEtnmgyqQdgCpGBMMRtx3j5ca0AOAkpmaMzy4t6Gh25PXFAADwqTs6p+Y0K +zAqCkc3OyX3Pjsm1Wn+IpGtNtahR9EGC4caKAH5eZV9q//////////8CAQI= +-----END DH PARAMETERS----- \ No newline at end of file diff --git a/root/defaults/nginx/nginx.conf.sample b/root/defaults/nginx/nginx.conf.sample new file mode 100644 index 00000000..34187582 --- /dev/null +++ b/root/defaults/nginx/nginx.conf.sample @@ -0,0 +1,90 @@ +# # +# @project thetvapp-docker +# @about Nginx site-configs default configuration file +# @file /root/defaults/nginx/nginx.conf.sample +# @repo https://github.com/Aetherinox/thetvapp-docker +# @generated 2024-11-30 +# # + +user abc; + +# Set number of worker processes automatically based on number of CPU cores. +include /config/nginx/worker_processes.conf; + +# Enables the use of JIT for regular expressions to speed-up their processing. +pcre_jit on; + +# Configures default error logger. +error_log /config/log/nginx/error.log; + +# Includes files with directives to load dynamic modules. +include /etc/nginx/modules/*.conf; + +# Include files with config snippets into the root context. +include /etc/nginx/conf.d/*.conf; + +events +{ + # The maximum number of simultaneous connections that can be opened by + # a worker process. + worker_connections 1024; +} + +http +{ + # Includes mapping of file name extensions to MIME types of responses + # and defines the default type. + include /etc/nginx/mime.types; + default_type application/octet-stream; + + # Name servers used to resolve names of upstream servers into addresses. + # It's also needed when using tcpsocket and udpsocket in Lua modules. + #resolver 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001; + include /config/nginx/resolver.conf; + + # Don't tell nginx version to the clients. Default is 'on'. + server_tokens off; + + # Specifies the maximum accepted body size of a client request, as + # indicated by the request header Content-Length. If the stated content + # length is greater than this size, then the client receives the HTTP + # error code 413. Set to 0 to disable. Default is '1m'. + client_max_body_size 0; + + # Sendfile copies data between one FD and other from within the kernel, + # which is more efficient than read() + write(). Default is off. + sendfile on; + + # Causes nginx to attempt to send its HTTP response head in one packet, + # instead of using partial frames. Default is 'off'. + tcp_nopush on; + + # all ssl related config moved to ssl.conf + # included in server blocks where listen 443 is defined + + # Enable gzipping of responses. + #gzip on; + + # Set the Vary HTTP header as defined in the RFC 2616. Default is 'off'. + gzip_vary on; + + # Helper variable for proxying websockets. + map $http_upgrade $connection_upgrade + { + default upgrade; + '' close; + } + + # Enable http2 by default for all servers + http2 on; + + # Sets the path, format, and configuration for a buffered log write. + access_log /config/log/nginx/access.log; + + # Includes virtual hosts configs. + include /etc/nginx/http.d/*.conf; + include /config/nginx/site-confs/*.conf; +} + +daemon off; +pid /run/nginx.pid; diff --git a/root/defaults/nginx/site-confs/default.conf.sample b/root/defaults/nginx/site-confs/default.conf.sample new file mode 100644 index 00000000..a4005060 --- /dev/null +++ b/root/defaults/nginx/site-confs/default.conf.sample @@ -0,0 +1,81 @@ +# # +# @project thetvapp-docker +# @about Nginx site-configs default configuration file +# @file /root/defaults/nginx/site-confs/default.conf +# @repo https://github.com/Aetherinox/thetvapp-docker +# @generated 2024-11-30 +# # + +server +{ + listen 80 default_server; + listen [::]:80 default_server; + listen 443 ssl default_server; + listen [::]:443 ssl default_server; + + server_name _; + + include /config/nginx/ssl.conf; + + set $root /app/www/public; + if (!-d /app/www/public) + { + set $root /config/www; + } + + root $root; + index index.html index.htm index.php; + + location / + { + # enable for basic auth + #auth_basic "Restricted"; + #auth_basic_user_file /config/nginx/.htpasswd; + + # index > fancy + fancyindex on; + fancyindex_header "/theme/header.html"; + fancyindex_footer "/theme/footer.html"; + fancyindex_ignore "theme"; + fancyindex_time_format "%m-%d-%Y %T"; + fancyindex_name_length 255; + fancyindex_show_dotfiles off; + fancyindex_hide_symlinks on; + fancyindex_default_sort name; + + # index > auto + autoindex_exact_size off; + autoindex_format html; + autoindex_localtime on; + + gzip on; + gzip_vary on; + gzip_types text/css text/javascript text/xml application/atom+xml application/rss+xml text/markdown text/mathml text/plain text/vnd.sun.j2me.app-descriptor text/vnd.wap.wml text/x-component application/json application/xhtml+xml application/xspf+xml font/woff font/woff2 image/avif image/bmp image/png image/svg+xml image/tiff image/vnd.wap.wbmp image/webp image/x-icon image/x-jng audio/midi audio/mpeg audio/ogg audio/x-m4a audio/x-realaudio; + gzip_proxied any; + gzip_comp_level 1; + gzip_http_version 1.0; + gunzip on; + gzip_static on; + + try_files $uri $uri/ /index.html /index.htm /index.php$is_args$args; + } + + location ~ ^(.+\.php)(.*)$ + { + # enable the next two lines for http auth + #auth_basic "Restricted"; + #auth_basic_user_file /config/nginx/.htpasswd; + + fastcgi_split_path_info ^(.+\.php)(.*)$; + if (!-f $document_root$fastcgi_script_name) { return 404; } + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + include /etc/nginx/fastcgi_params; + } + + # deny access to .htaccess/.htpasswd files + location ~ /\.ht + { + deny all; + } +} diff --git a/root/defaults/nginx/ssl.conf.sample b/root/defaults/nginx/ssl.conf.sample new file mode 100644 index 00000000..6f9b6d61 --- /dev/null +++ b/root/defaults/nginx/ssl.conf.sample @@ -0,0 +1,45 @@ +# # +# @project thetvapp-docker +# @about Nginx site-configs default configuration file +# @file /root/defaults/nginx/ssl.conf.sample +# @repo https://github.com/Aetherinox/thetvapp-docker +# @generated 2024-11-30 +# # + +### Mozilla Recommendations +# generated 2023-06-25, Mozilla Guideline v5.7, nginx 1.24.0, OpenSSL 3.1.1, intermediate configuration +# https://ssl-config.mozilla.org/#server=nginx&version=1.24.0&config=intermediate&openssl=3.1.1&guideline=5.7 + +ssl_certificate /config/keys/cert.crt; +ssl_certificate_key /config/keys/cert.key; +ssl_session_timeout 1d; +ssl_session_cache shared:MozSSL:10m; # about 40000 sessions +ssl_session_tickets off; + +# curl https://ssl-config.mozilla.org/ffdhe2048.txt > /path/to/dhparam +ssl_dhparam /config/nginx/dhparams.pem; + +# intermediate configuration +ssl_protocols TLSv1.2 TLSv1.3; +ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305; +ssl_prefer_server_ciphers off; + +# HSTS (ngx_http_headers_module is required) (63072000 seconds) +#add_header Strict-Transport-Security "max-age=63072000" always; + +# OCSP stapling +#ssl_stapling on; +#ssl_stapling_verify on; + +# verify chain of trust of OCSP response using Root CA and Intermediate certs +#ssl_trusted_certificate /config/keys/cert.crt; + +# Optional additional headers +#add_header Cache-Control "no-transform" always; +#add_header Content-Security-Policy "upgrade-insecure-requests; frame-ancestors 'self'" always; +#add_header Permissions-Policy "interest-cohort=()" always; +#add_header Referrer-Policy "same-origin" always; +#add_header X-Content-Type-Options "nosniff" always; +#add_header X-Frame-Options "SAMEORIGIN" always; +#add_header X-UA-Compatible "IE=Edge" always; +#add_header X-XSS-Protection "1; mode=block" always; diff --git a/root/defaults/www/index.html b/root/defaults/www/index.html new file mode 100644 index 00000000..8351def0 --- /dev/null +++ b/root/defaults/www/index.html @@ -0,0 +1,34 @@ + + + Welcome to our server + + + +
+

Welcome to our server

+

The website is currently being setup under this address.

+

For help and support, please contact: me@example.com

+
+ + diff --git a/root/defaults/www/theme/footer.html b/root/defaults/www/theme/footer.html new file mode 100644 index 00000000..fd0fed53 --- /dev/null +++ b/root/defaults/www/theme/footer.html @@ -0,0 +1,22 @@ + + + + + + + + + + + diff --git a/root/defaults/www/theme/header.html b/root/defaults/www/theme/header.html new file mode 100644 index 00000000..c0d2234e --- /dev/null +++ b/root/defaults/www/theme/header.html @@ -0,0 +1,35 @@ + + + + + + + + File Browser + + + + + + + + + + + +
+ +
+ +
+ + +
+
diff --git a/root/defaults/www/theme/js/breadcrumbs.js b/root/defaults/www/theme/js/breadcrumbs.js new file mode 100644 index 00000000..785d3f56 --- /dev/null +++ b/root/defaults/www/theme/js/breadcrumbs.js @@ -0,0 +1,9 @@ +/*! + * + * This file is part of the nginx-fancyindex-flat-theme, licensed under the GNU + * General Public License. See the LICENSE file for details. + * + * Copyright (C) + * 2018-2024 Alexander Haase + */ +function generateBreadcrumbs(){for(var e,a,n,r=window.location.pathname.replace(/\/$/,"").split("/"),t="",c="",o=0;o'+(n?"":'')+e+(n?"":""));document.getElementById("breadcrumbs").innerHTML=t} diff --git a/root/defaults/www/theme/js/list.js b/root/defaults/www/theme/js/list.js new file mode 100644 index 00000000..8b4d2771 --- /dev/null +++ b/root/defaults/www/theme/js/list.js @@ -0,0 +1,9 @@ +/*! + * + * This file is part of the nginx-fancyindex-flat-theme, licensed under the GNU + * General Public License. See the LICENSE file for details. + * + * Copyright (C) + * 2018-2024 Alexander Haase + */ +function generateList(){function e(e){return''}var a=document.getElementById("list");a.removeAttribute("cellpadding"),a.removeAttribute("cellspacing"),a.classList.add("table","table-sm","table-hover","text-nowrap"),a.tHead.children[0].classList.add("d-none","d-md-table-row"),"/"!=window.location.pathname&&a.deleteRow(1);for(var s,c=0;s=a.rows[c];c++)filetype=function(e){if(e.endsWith("/"))return"folder";switch(e.split(".").pop().toLowerCase()){case"txt":return"text";case"pdf":return"pdf";case"bmp":case"gif":case"jpeg":case"jpg":case"png":case"tif":case"tiff":return"image";case"aac":case"aiff":case"m4a":case"mp3":case"ogg":case"opus":case"wav":return"audio";case"amv":case"avi":case"flv":case"m4v":case"mkv":case"mov":case"mp4":case"m4p":case"mpeg":case"mpg":case"ogv":case"vob":case"webm":case"wmv":return"video";case"7z":case"a":case"apk":case"ar":case"bin":case"bz2":case"cab":case"dmg":case"gz":case"iso":case"jar":case"lz":case"lzma":case"lzo":case"pak":case"partimg":case"rar":case"s7z":case"tar":case"tbz2":case"tgz":case"tlz":case"txz":case"xz":case"zip":return"archive";case"doc":case"docx":case"odt":case"rtf":return"word";case"csv":case"ods":case"xls":case"xlsx":return"excel";case"odp":case"ppt":case"pptx":return"powerpoint";case"c":case"class":case"cpp":case"cs":case"h":case"hpp":case"hxx":case"java":case"py":case"sh":case"swift":case"vb":return"code"}}(s.cells[0].children[0].innerHTML),s.insertCell(0).innerHTML=0 + * + * See the LICENSE file for details. + */body{background-color:#f8f9fa;padding-bottom:20px}@media (prefers-color-scheme:dark){body{background-color:#343a40;color:#fff}}.breadcrumb{background-color:transparent;padding-left:35px}.breadcrumb .breadcrumb-item a{color:#4caf50}html{position:relative;min-height:100%}.footer{position:absolute;bottom:0;width:100%;margin-bottom:0}.footer a,.footer a:focus,.footer a:hover{color:#4caf50}.header{background-color:#4caf50;color:#fff;min-height:24px}.header .navbar-brand{padding:0 8px;font-size:16px;line-height:24px;height:24px}#list a,#list a:focus,#list a:hover{color:#000}#list colgroup{display:none}#list .filename{word-break:break-all;white-space:normal}@media (prefers-color-scheme:dark){#list a,#list a:focus,#list a:hover{color:#fff}} \ No newline at end of file diff --git a/root/etc/logrotate.d/nginx b/root/etc/logrotate.d/nginx new file mode 100644 index 00000000..c553d30b --- /dev/null +++ b/root/etc/logrotate.d/nginx @@ -0,0 +1,14 @@ +/config/log/nginx/*.log { + weekly + rotate 14 + compress + delaycompress + nodateext + notifempty + missingok + sharedscripts + postrotate + s6-svc -1 /run/service/svc-nginx + endscript + su abc abc +} diff --git a/root/etc/logrotate.d/php-fpm b/root/etc/logrotate.d/php-fpm new file mode 100644 index 00000000..196b32ed --- /dev/null +++ b/root/etc/logrotate.d/php-fpm @@ -0,0 +1,14 @@ +/config/log/php/*.log { + rotate 7 + weekly + missingok + notifempty + delaycompress + compress + nodateext + sharedscripts + postrotate + s6-svc -t /run/service/svc-php-fpm + endscript + su abc abc +} diff --git a/root/etc/nginx/nginx.conf b/root/etc/nginx/nginx.conf new file mode 100644 index 00000000..76d93e00 --- /dev/null +++ b/root/etc/nginx/nginx.conf @@ -0,0 +1 @@ +include /config/nginx/nginx.conf; diff --git a/root/etc/s6-overlay/s6-rc.d/ci-service-check/dependencies.d/legacy-services b/root/etc/s6-overlay/s6-rc.d/ci-service-check/dependencies.d/legacy-services new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/ci-service-check/type b/root/etc/s6-overlay/s6-rc.d/ci-service-check/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/ci-service-check/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/ci-service-check/up b/root/etc/s6-overlay/s6-rc.d/ci-service-check/up new file mode 100644 index 00000000..b5a14787 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/ci-service-check/up @@ -0,0 +1 @@ +echo -e " Core : Completed loading container" diff --git a/root/etc/s6-overlay/s6-rc.d/init-adduser/branding b/root/etc/s6-overlay/s6-rc.d/init-adduser/branding new file mode 100644 index 00000000..b208319b --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-adduser/branding @@ -0,0 +1,9 @@ +─────────────────────────────────────────────────────────────── + TheTvApp Docker Container +─────────────────────────────────────────────────────────────── + This container automatically downloads the m3u8 and xml + guide data from + - https://github.com/dtankdempse/thetvapp-m3u + + Once the data is downloaded, you can access the files from + the container's webserver. diff --git a/root/etc/s6-overlay/s6-rc.d/init-adduser/dependencies.d/init-migrations b/root/etc/s6-overlay/s6-rc.d/init-adduser/dependencies.d/init-migrations new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-adduser/run b/root/etc/s6-overlay/s6-rc.d/init-adduser/run new file mode 100644 index 00000000..9151d7ce --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-adduser/run @@ -0,0 +1,37 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +PUID=${PUID:-911} +PGID=${PGID:-911} + +if [[ -z ${AETHERX_READ_ONLY_FS} ]] && [[ -z ${AETHERX_NON_ROOT_USER} ]]; then + groupmod -o -g "$PGID" abc + usermod -o -u "$PUID" abc +fi + +if { [[ -z ${AETHERX_READ_ONLY_FS} ]] && [[ -z ${AETHERX_NON_ROOT_USER} ]]; } || [[ ! ${LSIO_FIRST_PARTY} = "true" ]]; then + cat /etc/s6-overlay/s6-rc.d/init-adduser/branding +else + cat /run/branding +fi + +if [[ -z ${AETHERX_NON_ROOT_USER} ]]; then +echo " + User ID ........... $(id -u abc) + Group ID .......... $(id -g abc)" +else +echo " + User ID ........... $(stat /run -c %u) + Group ID .......... $(stat /run -c %g)" +fi +echo " + Port HTTP ......... $(echo $PORT_HTTP) + Port HTTPS ........ $(echo $PORT_HTTPS)" + +echo '───────────────────────────────────────────────────────────────' + +if [[ -z ${AETHERX_READ_ONLY_FS} ]] && [[ -z ${AETHERX_NON_ROOT_USER} ]]; then + lsiown abc:abc /app + lsiown abc:abc /config + lsiown abc:abc /defaults +fi diff --git a/root/etc/s6-overlay/s6-rc.d/init-adduser/type b/root/etc/s6-overlay/s6-rc.d/init-adduser/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-adduser/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-adduser/up b/root/etc/s6-overlay/s6-rc.d/init-adduser/up new file mode 100644 index 00000000..b8522da3 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-adduser/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-adduser/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-config-end/dependencies.d/init-config b/root/etc/s6-overlay/s6-rc.d/init-config-end/dependencies.d/init-config new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-config-end/type b/root/etc/s6-overlay/s6-rc.d/init-config-end/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-config-end/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-config-end/up b/root/etc/s6-overlay/s6-rc.d/init-config-end/up new file mode 100644 index 00000000..c329423e --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-config-end/up @@ -0,0 +1 @@ +# This file doesn't do anything, it's just the end of the downstream image init process diff --git a/root/etc/s6-overlay/s6-rc.d/init-config/dependencies.d/init-nginx-end b/root/etc/s6-overlay/s6-rc.d/init-config/dependencies.d/init-nginx-end new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-crontab-config/dependencies.d/init-os-end b/root/etc/s6-overlay/s6-rc.d/init-crontab-config/dependencies.d/init-os-end new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-crontab-config/run b/root/etc/s6-overlay/s6-rc.d/init-crontab-config/run new file mode 100644 index 00000000..5660df55 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-crontab-config/run @@ -0,0 +1,44 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +for cron_user in abc root; do + if [[ -z ${AETHERX_READ_ONLY_FS} ]] && [[ -z ${AETHERX_NON_ROOT_USER} ]]; then + if [[ -f "/etc/crontabs/${cron_user}" ]]; then + lsiown "${cron_user}":"${cron_user}" "/etc/crontabs/${cron_user}" + crontab -u "${cron_user}" "/etc/crontabs/${cron_user}" + fi + fi + + if [[ -f "/defaults/crontabs/${cron_user}" ]]; then + mkdir -p /config/crontabs + + # # + # if crontabs do not exist in config + # # + + if [[ ! -f "/config/crontabs/${cron_user}" ]]; then + + # # + # copy crontab from system + # # + + if crontab -l -u "${cron_user}" >/dev/null 2>&1; then + crontab -l -u "${cron_user}" >"/config/crontabs/${cron_user}" + fi + + # # + # if crontabs still do not exist in config (were not copied from system) + # copy crontab from image defaults (using -n, do not overwrite an existing file) + # # + + cp -n "/defaults/crontabs/${cron_user}" /config/crontabs/ + fi + + # # + # set perms and import user crontabs + # # + + lsiown "${cron_user}":"${cron_user}" "/config/crontabs/${cron_user}" + crontab -u "${cron_user}" "/config/crontabs/${cron_user}" + fi +done diff --git a/root/etc/s6-overlay/s6-rc.d/init-crontab-config/type b/root/etc/s6-overlay/s6-rc.d/init-crontab-config/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-crontab-config/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-crontab-config/up b/root/etc/s6-overlay/s6-rc.d/init-crontab-config/up new file mode 100644 index 00000000..d3541118 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-crontab-config/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-crontab-config/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-custom-files/dependencies.d/init-mods-end b/root/etc/s6-overlay/s6-rc.d/init-custom-files/dependencies.d/init-mods-end new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-custom-files/run b/root/etc/s6-overlay/s6-rc.d/init-custom-files/run new file mode 100644 index 00000000..7cbd2cf7 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-custom-files/run @@ -0,0 +1,22 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +# Directories +SCRIPTS_DIR="/custom-cont-init.d" + +# Make sure custom init directory exists and has files in it +if [[ -e "${SCRIPTS_DIR}" ]] && [[ -n "$(/bin/ls -A ${SCRIPTS_DIR} 2>/dev/null)" ]]; then + echo -e " Loader : Custom files found, loading them ..." + for SCRIPT in "${SCRIPTS_DIR}"/*; do + NAME="$(basename "${SCRIPT}")" + if [[ -f "${SCRIPT}" ]]; then + echo -e " Loader : Executing ..." + /bin/bash "${SCRIPT}" + echo -e " Loader : ${NAME}: Exited $?" + elif [[ ! -f "${SCRIPT}" ]]; then + echo -e " Loader : ${NAME}: Not a valid file" + fi + done +else + echo -e " Loader : No custom files found, skipping..." +fi diff --git a/root/etc/s6-overlay/s6-rc.d/init-custom-files/type b/root/etc/s6-overlay/s6-rc.d/init-custom-files/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-custom-files/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-custom-files/up b/root/etc/s6-overlay/s6-rc.d/init-custom-files/up new file mode 100644 index 00000000..28bf3185 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-custom-files/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-custom-files/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-envfile/run b/root/etc/s6-overlay/s6-rc.d/init-envfile/run new file mode 100644 index 00000000..592df527 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-envfile/run @@ -0,0 +1,19 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +if find /run/s6/container_environment/FILE__* -maxdepth 1 > /dev/null 2>&1; then + for FILENAME in /run/s6/container_environment/FILE__*; do + SECRETFILE=$(cat "${FILENAME}") + if [[ -f ${SECRETFILE} ]]; then + FILESTRIP=${FILENAME//FILE__/} + if [[ $(tail -n1 "${SECRETFILE}" | wc -l) != 0 ]]; then + echo "[env-init] Your secret: ${FILENAME##*/}" + echo " contains a trailing newline and may not work as expected" + fi + cat "${SECRETFILE}" >"${FILESTRIP}" + echo "[env-init] ${FILESTRIP##*/} set from ${FILENAME##*/}" + else + echo "[env-init] cannot find secret in ${FILENAME##*/}" + fi + done +fi diff --git a/root/etc/s6-overlay/s6-rc.d/init-envfile/type b/root/etc/s6-overlay/s6-rc.d/init-envfile/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-envfile/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-envfile/up b/root/etc/s6-overlay/s6-rc.d/init-envfile/up new file mode 100644 index 00000000..b2b4fb8c --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-envfile/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-envfile/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-folders/dependencies.d/init-os-end b/root/etc/s6-overlay/s6-rc.d/init-folders/dependencies.d/init-os-end new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-folders/run b/root/etc/s6-overlay/s6-rc.d/init-folders/run new file mode 100644 index 00000000..bcdfe61a --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-folders/run @@ -0,0 +1,11 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +# make folders +mkdir -p \ + /config/{keys,php,www} \ + /config/log/{nginx,php} \ + /config/nginx/site-confs \ + /run \ + /var/lib/nginx/tmp/client_body \ + /var/tmp/nginx diff --git a/root/etc/s6-overlay/s6-rc.d/init-folders/type b/root/etc/s6-overlay/s6-rc.d/init-folders/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-folders/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-folders/up b/root/etc/s6-overlay/s6-rc.d/init-folders/up new file mode 100644 index 00000000..0fb7dc7d --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-folders/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-folders/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-keygen/dependencies.d/init-php b/root/etc/s6-overlay/s6-rc.d/init-keygen/dependencies.d/init-php new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-keygen/run b/root/etc/s6-overlay/s6-rc.d/init-keygen/run new file mode 100644 index 00000000..da0c2933 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-keygen/run @@ -0,0 +1,20 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +# # +# @project thetvapp-docker +# @about Manages self-signed ssl certificates +# @file /root/etc/s6-overlay/s6-rc.d/init-keygen/run +# @repo https://github.com/Aetherinox/thetvapp-docker +# # + +SUBJECT="/C=US/ST=CA/L=NA/O=thetvapp-docker/OU=Aetherinox TheTvApp/CN=*" +if [[ -f /config/keys/cert.key && -f /config/keys/cert.crt ]]; then + echo -e " SSL : Using existing keys found in /config/keys" +else + echo -e " SSL : Generating self-signed keys in folder/config/keys. Replace if needed." + rm -f \ + /config/keys/cert.key \ + /config/keys/cert.crt || true + openssl req -new -x509 -days 3650 -nodes -out /config/keys/cert.crt -keyout /config/keys/cert.key -subj "$SUBJECT" +fi diff --git a/root/etc/s6-overlay/s6-rc.d/init-keygen/type b/root/etc/s6-overlay/s6-rc.d/init-keygen/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-keygen/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-keygen/up b/root/etc/s6-overlay/s6-rc.d/init-keygen/up new file mode 100644 index 00000000..cacd3ec7 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-keygen/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-keygen/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-migrations/run b/root/etc/s6-overlay/s6-rc.d/init-migrations/run new file mode 100644 index 00000000..c4679265 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-migrations/run @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +MIGRATIONS_DIR="/migrations" +MIGRATIONS_HISTORY="/config/.migrations" + +echo -e " Migrations : Started" + +if [[ ! -d ${MIGRATIONS_DIR} ]]; then + echo -e " Migrations : No migrations found" + exit +fi + +for MIGRATION in $(find ${MIGRATIONS_DIR}/* | sort -n); do + NAME="$(basename "${MIGRATION}")" + if [[ -f ${MIGRATIONS_HISTORY} ]] && grep -Fxq "${NAME}" ${MIGRATIONS_HISTORY}; then + echo -e " Migrations : ${NAME} › Skipped" + continue + fi + + echo -e " Migrations : ${NAME} › Executing" + chmod +x "${MIGRATION}" + + # # + # Execute migration script in a subshell to prevent it from modifying the current environment + # # + + ("${MIGRATION}") + EXIT_CODE=$? + if [[ ${EXIT_CODE} -ne 0 ]]; then + echo -e " Migrations : ${NAME} › Failed with exit code ${EXIT_CODE}" + exit "${EXIT_CODE}" + fi + + echo "${NAME}" >>${MIGRATIONS_HISTORY} + echo -e " Migrations : ${NAME} › Success" +done + +echo -e " Migrations : Complete" diff --git a/root/etc/s6-overlay/s6-rc.d/init-migrations/type b/root/etc/s6-overlay/s6-rc.d/init-migrations/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-migrations/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-migrations/up b/root/etc/s6-overlay/s6-rc.d/init-migrations/up new file mode 100644 index 00000000..7c4cbcf6 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-migrations/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-migrations/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mods b/root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mods new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mods-package-install b/root/etc/s6-overlay/s6-rc.d/init-mods-end/dependencies.d/init-mods-package-install new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-end/type b/root/etc/s6-overlay/s6-rc.d/init-mods-end/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mods-end/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-end/up b/root/etc/s6-overlay/s6-rc.d/init-mods-end/up new file mode 100644 index 00000000..092149d5 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mods-end/up @@ -0,0 +1 @@ +# This file doesn't do anything, it's just the end of the mod init process diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mods b/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mods new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/type b/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/up b/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/up new file mode 100644 index 00000000..fb633014 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-mods-package-install/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods/dependencies.d/init-version-checks b/root/etc/s6-overlay/s6-rc.d/init-mods/dependencies.d/init-version-checks new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-nginx-end/dependencies.d/init-permissions b/root/etc/s6-overlay/s6-rc.d/init-nginx-end/dependencies.d/init-permissions new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-nginx-end/type b/root/etc/s6-overlay/s6-rc.d/init-nginx-end/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-nginx-end/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-nginx-end/up b/root/etc/s6-overlay/s6-rc.d/init-nginx-end/up new file mode 100644 index 00000000..4357f0df --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-nginx-end/up @@ -0,0 +1 @@ +# This file doesn't do anything, it's just the end of the nginx base init process diff --git a/root/etc/s6-overlay/s6-rc.d/init-nginx/dependencies.d/init-samples b/root/etc/s6-overlay/s6-rc.d/init-nginx/dependencies.d/init-samples new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-nginx/run b/root/etc/s6-overlay/s6-rc.d/init-nginx/run new file mode 100644 index 00000000..2271ce05 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-nginx/run @@ -0,0 +1,108 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +# # +# precreate log files +# # + +for file in /config/log/nginx/access.log /config/log/nginx/error.log; do + if [[ ! -f "${file}" ]]; then + touch "${file}" + fi +done + +# # +# copy default config files if they don't exist +# # + +if [[ ! -f /config/nginx/nginx.conf ]]; then + cp /defaults/nginx/nginx.conf.sample /config/nginx/nginx.conf +fi + +if [[ ! -f /config/nginx/ssl.conf ]]; then + cp /defaults/nginx/ssl.conf.sample /config/nginx/ssl.conf +fi + +if [[ ! -f /config/nginx/site-confs/default.conf ]]; then + cp /defaults/nginx/site-confs/default.conf.sample /config/nginx/site-confs/default.conf +fi + +# # +# force nginx.conf to include site-confs/*.conf instead of site-confs/* +# # + +sed -i -E "s#^(\s*)include /config/nginx/site-confs/\*;#\1include /config/nginx/site-confs/\*.conf;#" /config/nginx/nginx.conf + +# # +# copy index.html if no index file exists +# # + +INDEX_EXISTS=false +for file in /config/www/index.*; do + if [[ -e "${file}" ]]; then + INDEX_EXISTS=true + break + fi +done + +THEME_EXISTS=false +for file in /config/www/theme/*; do + if [[ -e "${file}" ]]; then + THEME_EXISTS=true + break + fi +done + +# dont add an index, we want fancy indexing +# if [[ ${INDEX_EXISTS} == false ]] && grep -Eq '^\s*index[^#]*index\.html' /config/nginx/**/*.conf; then +# cp /defaults/www/index.html /config/www/index.html +# fi + +if [[ ${THEME_EXISTS} == false ]]; then + cp -r /defaults/www/theme /config/www/ +fi + +# # +# copy pre-generated dhparams or generate if needed +# # + +if [[ ! -f /config/nginx/dhparams.pem ]]; then + cp /defaults/nginx/dhparams.pem /config/nginx/dhparams.pem +fi + +if ! grep -q 'PARAMETERS' "/config/nginx/dhparams.pem"; then + curl -o /config/nginx/dhparams.pem -L "https://ssl-config.mozilla.org/ffdhe4096.txt" +fi + +# # +# Set resolver, ignore ipv6 addresses +# # + +touch /config/nginx/resolver.conf +if ! grep -q 'resolver' /config/nginx/resolver.conf; then + RESOLVERRAW=$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print $2}' /etc/resolv.conf) + for i in ${RESOLVERRAW}; do + if [[ "$(awk -F ':' '{print NF-1}' <<<"${i}")" -le 2 ]]; then + RESOLVER="${RESOLVER} ${i}" + fi + done + + if [[ -z "${RESOLVER}" ]]; then + RESOLVER="127.0.0.11" + fi + + echo "[ Resolver ]: Setting to ${RESOLVER}" + RESOLVEROUTPUT="# This file is auto-generated only on first start, based on the container's /etc/resolv.conf file. Feel free to modify it as you wish.\n\nresolver ${RESOLVER} valid=30s;" + echo -e "${RESOLVEROUTPUT}" >/config/nginx/resolver.conf +fi + +# # +# Set worker_processes +# # + +touch /config/nginx/worker_processes.conf +if ! grep -q 'worker_processes' /config/nginx/worker_processes.conf; then + WORKER_PROCESSES=$(nproc) + echo "[ Worker ]: Setting worker_processes to ${WORKER_PROCESSES}" + echo -e "# This file is auto-generated only on first start, based on the cpu cores detected. Feel free to change it to any other number or to auto to let nginx handle it automatically.\n\nworker_processes ${WORKER_PROCESSES};" >/config/nginx/worker_processes.conf +fi diff --git a/root/etc/s6-overlay/s6-rc.d/init-nginx/type b/root/etc/s6-overlay/s6-rc.d/init-nginx/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-nginx/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-nginx/up b/root/etc/s6-overlay/s6-rc.d/init-nginx/up new file mode 100644 index 00000000..b3b5b494 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-nginx/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-nginx/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-os-end/dependencies.d/base b/root/etc/s6-overlay/s6-rc.d/init-os-end/dependencies.d/base new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-os-end/dependencies.d/init-adduser b/root/etc/s6-overlay/s6-rc.d/init-os-end/dependencies.d/init-adduser new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-os-end/dependencies.d/init-envfile b/root/etc/s6-overlay/s6-rc.d/init-os-end/dependencies.d/init-envfile new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-os-end/dependencies.d/init-migrations b/root/etc/s6-overlay/s6-rc.d/init-os-end/dependencies.d/init-migrations new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-os-end/type b/root/etc/s6-overlay/s6-rc.d/init-os-end/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-os-end/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-os-end/up b/root/etc/s6-overlay/s6-rc.d/init-os-end/up new file mode 100644 index 00000000..092149d5 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-os-end/up @@ -0,0 +1 @@ +# This file doesn't do anything, it's just the end of the mod init process diff --git a/root/etc/s6-overlay/s6-rc.d/init-permissions/dependencies.d/init-keygen b/root/etc/s6-overlay/s6-rc.d/init-permissions/dependencies.d/init-keygen new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-permissions/run b/root/etc/s6-overlay/s6-rc.d/init-permissions/run new file mode 100644 index 00000000..7c9019d1 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-permissions/run @@ -0,0 +1,25 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +# permissions +lsiown -R abc:abc \ + /var/lib/nginx \ + /var/tmp/nginx + +lsiown -R abc:abc \ + /config/keys \ + /config/log \ + /config/nginx \ + /config/php + +lsiown abc:abc \ + /config/www + +chmod -R g+w \ + /config/nginx + +chmod -R 644 /etc/logrotate.d + +if [[ -f "/config/log/logrotate.status" ]]; then + chmod 600 /config/log/logrotate.status +fi diff --git a/root/etc/s6-overlay/s6-rc.d/init-permissions/type b/root/etc/s6-overlay/s6-rc.d/init-permissions/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-permissions/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-permissions/up b/root/etc/s6-overlay/s6-rc.d/init-permissions/up new file mode 100644 index 00000000..81bfce3a --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-permissions/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-permissions/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-php/dependencies.d/init-nginx b/root/etc/s6-overlay/s6-rc.d/init-php/dependencies.d/init-nginx new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-php/run b/root/etc/s6-overlay/s6-rc.d/init-php/run new file mode 100644 index 00000000..c2894742 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-php/run @@ -0,0 +1,28 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +# precreate log files +if [[ ! -f /config/log/php/error.log ]]; then + touch /config/log/php/error.log +fi + +# set default timezone +printf "date.timezone = %s\\n" "${TZ:-UTC}" >/etc/php83/conf.d/30_timezone.ini + +# create local php.ini if it doesn't exist, set local timezone +if [[ ! -f /config/php/php-local.ini ]]; then + printf "; Edit this file to override php.ini directives\\n\\n" >/config/php/php-local.ini +fi + +# symlink user php-local.ini to image +rm -rf /etc/php83/conf.d/php-local.ini +rm -rf /etc/php83/conf.d/zzz_php-local.ini +ln -s /config/php/php-local.ini /etc/php83/conf.d/zzz_php-local.ini + +# create override for www.conf if it doesn't exist +if [[ ! -f /config/php/www2.conf ]]; then + printf "; Edit this file to override www.conf and php-fpm.conf directives and restart the container\\n\\n; Pool name\\n[www]\\n\\n" >/config/php/www2.conf +fi + +# copy user www2.conf to image +cp /config/php/www2.conf /etc/php83/php-fpm.d/www2.conf diff --git a/root/etc/s6-overlay/s6-rc.d/init-php/type b/root/etc/s6-overlay/s6-rc.d/init-php/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-php/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-php/up b/root/etc/s6-overlay/s6-rc.d/init-php/up new file mode 100644 index 00000000..80fb24e5 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-php/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-php/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-samples/dependencies.d/init-folders b/root/etc/s6-overlay/s6-rc.d/init-samples/dependencies.d/init-folders new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-samples/run b/root/etc/s6-overlay/s6-rc.d/init-samples/run new file mode 100644 index 00000000..b54aefcc --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-samples/run @@ -0,0 +1,28 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +# # +# @project thetvapp-docker +# @about Manages sample files such as nginx +# @file /root/etc/s6-overlay/s6-rc.d/init-samples/run +# @repo https://github.com/Aetherinox/thetvapp-docker +# # + +# remove old samples +find /config/nginx/ \ + -name "*.conf.sample" \ + -type f \ + -delete + +# copy new samples +find /defaults/nginx/ \ + -maxdepth 3 \ + -name "*.conf.sample" \ + -type f \ + -exec cp "{}" /config/nginx/ \; + +find /defaults/nginx/site-confs/ \ + -maxdepth 1 \ + -name "*.conf.sample" \ + -type f \ + -exec cp "{}" /config/nginx/site-confs/ \; diff --git a/root/etc/s6-overlay/s6-rc.d/init-samples/type b/root/etc/s6-overlay/s6-rc.d/init-samples/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-samples/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-samples/up b/root/etc/s6-overlay/s6-rc.d/init-samples/up new file mode 100644 index 00000000..05ae8e5f --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-samples/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-samples/run diff --git a/root/etc/s6-overlay/s6-rc.d/init-services/dependencies.d/init-custom-files b/root/etc/s6-overlay/s6-rc.d/init-services/dependencies.d/init-custom-files new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-services/dependencies.d/init-mods-end b/root/etc/s6-overlay/s6-rc.d/init-services/dependencies.d/init-mods-end new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-services/type b/root/etc/s6-overlay/s6-rc.d/init-services/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-services/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-services/up b/root/etc/s6-overlay/s6-rc.d/init-services/up new file mode 100644 index 00000000..a7c3905b --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-services/up @@ -0,0 +1 @@ +# This file doesn't do anything, it just signals that services can start diff --git a/root/etc/s6-overlay/s6-rc.d/init-version-checks/dependencies.d/init-config-end b/root/etc/s6-overlay/s6-rc.d/init-version-checks/dependencies.d/init-config-end new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-version-checks/run b/root/etc/s6-overlay/s6-rc.d/init-version-checks/run new file mode 100644 index 00000000..ad47f134 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-version-checks/run @@ -0,0 +1,36 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +# detect nginx configs with dates not matching the provided sample files +active_confs=$(find /config/nginx/ -name "*.conf" -type f 2>/dev/null) + +for i in ${active_confs}; do + if [ -f "${i}.sample" ]; then + if [ "$(sed -nE 's|^## Version ([0-9]{4}\/[0-9]{2}\/[0-9]{2}).*|\1|p' "${i}")" != "$(sed -nE 's|^## Version ([0-9]{4}\/[0-9]{2}\/[0-9]{2}).*|\1|p' "${i}.sample")" ]; then + active_confs_changed="│ $(printf '%10s' "$(sed -nE 's|^## Version ([0-9]{4}\/[0-9]{2}\/[0-9]{2}).*|\1|p' "${i}" | tr / -)") │ $(printf '%10s' "$(sed -nE 's|^## Version ([0-9]{4}\/[0-9]{2}\/[0-9]{2}).*|\1|p' "${i}.sample" | tr / -)") │ $(printf '%-70s' "${i}") │\n${active_confs_changed}" + fi + fi +done + +if [ -n "${active_confs_changed}" ]; then + echo "**** The following active confs have different version dates than the samples that are shipped. ****" + echo "**** This may be due to user customization or an update to the samples. ****" + echo "**** You should compare the following files to the samples in the same folder and update them. ****" + echo "**** Use the link at the top of the file to view the changelog. ****" + echo "┌────────────┬────────────┬────────────────────────────────────────────────────────────────────────┐" + echo "│ old date │ new date │ path │" + echo "├────────────┼────────────┼────────────────────────────────────────────────────────────────────────┤" + echo -e "${active_confs_changed%%\\n}" + echo "└────────────┴────────────┴────────────────────────────────────────────────────────────────────────┘" +fi + +# detect site-confs with wrong extension +site_confs_wrong_ext=$(find /config/nginx/site-confs/ -type f -not -name "*.conf" -not -name "*.conf.sample" 2>/dev/null) + +if [ -n "${site_confs_wrong_ext}" ]; then + echo "**** The following site-confs have extensions other than .conf ****" + echo "**** This may be due to user customization. ****" + echo "**** You should review the files and rename them to use the .conf extension or remove them. ****" + echo "**** nginx.conf will only include site-confs with the .conf extension. ****" + echo -e "${site_confs_wrong_ext}" +fi diff --git a/root/etc/s6-overlay/s6-rc.d/init-version-checks/type b/root/etc/s6-overlay/s6-rc.d/init-version-checks/type new file mode 100644 index 00000000..bdd22a18 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-version-checks/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/init-version-checks/up b/root/etc/s6-overlay/s6-rc.d/init-version-checks/up new file mode 100644 index 00000000..2b7c0e6e --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-version-checks/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-version-checks/run diff --git a/root/etc/s6-overlay/s6-rc.d/svc-cron/dependencies.d/init-services b/root/etc/s6-overlay/s6-rc.d/svc-cron/dependencies.d/init-services new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/svc-cron/run b/root/etc/s6-overlay/s6-rc.d/svc-cron/run new file mode 100644 index 00000000..87e4fdb4 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-cron/run @@ -0,0 +1,15 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +if builtin command -v crontab >/dev/null 2>&1 && [[ -n "$(crontab -l -u abc 2>/dev/null || true)" || -n "$(crontab -l -u root 2>/dev/null || true)" ]]; then + if builtin command -v busybox >/dev/null 2>&1 && [[ $(busybox || true) =~ [[:space:]](crond)([,]|$) ]]; then + exec busybox crond -f -S -l 5 + elif [[ -f /usr/bin/apt ]] && [[ -f /usr/sbin/cron ]]; then + exec /usr/sbin/cron -f -L 5 + else + echo "**** cron not found ****" + sleep infinity + fi +else + sleep infinity +fi diff --git a/root/etc/s6-overlay/s6-rc.d/svc-cron/type b/root/etc/s6-overlay/s6-rc.d/svc-cron/type new file mode 100644 index 00000000..5883cff0 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-cron/type @@ -0,0 +1 @@ +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/svc-nginx/dependencies.d/init-services b/root/etc/s6-overlay/s6-rc.d/svc-nginx/dependencies.d/init-services new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/svc-nginx/run b/root/etc/s6-overlay/s6-rc.d/svc-nginx/run new file mode 100644 index 00000000..067f0314 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-nginx/run @@ -0,0 +1,16 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +if pgrep -f "[n]ginx:" >/dev/null; then + echo "Zombie nginx processes detected, sending SIGTERM" + pkill -ef [n]ginx: + sleep 1 +fi + +if pgrep -f "[n]ginx:" >/dev/null; then + echo "Zombie nginx processes still active, sending SIGKILL" + pkill -9 -ef [n]ginx: + sleep 1 +fi + +exec /usr/sbin/nginx diff --git a/root/etc/s6-overlay/s6-rc.d/svc-nginx/type b/root/etc/s6-overlay/s6-rc.d/svc-nginx/type new file mode 100644 index 00000000..5883cff0 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-nginx/type @@ -0,0 +1 @@ +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/svc-php-fpm/dependencies.d/init-services b/root/etc/s6-overlay/s6-rc.d/svc-php-fpm/dependencies.d/init-services new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/svc-php-fpm/run b/root/etc/s6-overlay/s6-rc.d/svc-php-fpm/run new file mode 100644 index 00000000..8d372b04 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-php-fpm/run @@ -0,0 +1,4 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +exec /usr/sbin/php-fpm83 -F diff --git a/root/etc/s6-overlay/s6-rc.d/svc-php-fpm/type b/root/etc/s6-overlay/s6-rc.d/svc-php-fpm/type new file mode 100644 index 00000000..5883cff0 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/svc-php-fpm/type @@ -0,0 +1 @@ +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-folders b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-folders new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-keygen b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-keygen new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-nginx b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-nginx new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-nginx-end b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-nginx-end new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-permissions b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-permissions new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-php b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-php new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-samples b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-samples new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-version-checks b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-version-checks new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-nginx b/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-nginx new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-php-fpm b/root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-php-fpm new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/user2/contents.d/ci-service-check b/root/etc/s6-overlay/s6-rc.d/user2/contents.d/ci-service-check new file mode 100644 index 00000000..e69de29b diff --git a/root/migrations/01-nginx-site-confs-default b/root/migrations/01-nginx-site-confs-default new file mode 100644 index 00000000..c6d41242 --- /dev/null +++ b/root/migrations/01-nginx-site-confs-default @@ -0,0 +1,20 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +migrate() { + local OLD_LOCATION="${1}" + local NEW_LOCATION="${2}" + + if [[ -f ${OLD_LOCATION} ]]; then + echo "found ${OLD_LOCATION}" + if [[ ! -f ${NEW_LOCATION} ]]; then + echo "moving to ${NEW_LOCATION}" + mv "${OLD_LOCATION}" "${NEW_LOCATION}" + else + echo "new file location already exists ${NEW_LOCATION}" + fi + fi +} + +# rename default to default.conf +migrate "/config/nginx/site-confs/default" "/config/nginx/site-confs/default.conf" diff --git a/run.sh b/run.sh new file mode 100644 index 00000000..10daaebc --- /dev/null +++ b/run.sh @@ -0,0 +1,31 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash + +# # +# Disable, otherwise cron asterisks will be converted to file paths. +# # + +set -f + +# # +# For details see man crontabs +# Example of job definition: +# .---------------- minute (0 - 59) +# | .------------- hour (0 - 23) +# | | .---------- day of month (1 - 31) +# | | | .------- month (1 - 12) OR jan,feb,mar,apr ... +# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat +# | | | | | +# * * * * * +# # + +ARG_CRON_TIME=$(echo ${REFRESH}) + +if [ -z "${ARG_CRON_TIME}" ]; then + ARG_CRON_TIME="0/60 * * * *" +fi + +echo -e " Config : Setting task to run ${ARG_CRON_TIME}" +echo "${ARG_CRON_TIME} sh /download.sh" > /crontab.conf +crontab /crontab.conf +set +f