From 5a870a7a5c7f0aab3095f2d03b586a26a3cc1c40 Mon Sep 17 00:00:00 2001 From: STAM Date: Thu, 27 Feb 2020 15:49:33 +0300 Subject: [PATCH] init --- .github/CODE_OF_CONDUCT.md | 76 ++++++++++++++ .github/CONTRIBUTING.md | 17 +++ .github/FUNDING.yml | 13 +++ .github/ISSUE_TEMPLATE/bug_report.md | 27 +++++ .github/ISSUE_TEMPLATE/cve_report.md | 18 ++++ .github/ISSUE_TEMPLATE/feature_request.md | 21 ++++ .github/ISSUE_TEMPLATE/task_generic.md | 17 +++ .github/pull_request_template.md | 13 +++ LICENSE.md | 21 ++++ README.md | 2 + ovm/.docker-repository.yml | 1 + ovm/.dockerignore | 3 + ovm/Dockerfile | 50 +++++++++ ovm/Makefile | 4 + ovm/README.md | 30 ++++++ ovm/container.ini | 6 ++ ovm/omv-startup | 121 ++++++++++++++++++++++ ovm/openmediavault.list | 2 + 18 files changed, 442 insertions(+) create mode 100644 .github/CODE_OF_CONDUCT.md create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/cve_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/task_generic.md create mode 100644 .github/pull_request_template.md create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 ovm/.docker-repository.yml create mode 100644 ovm/.dockerignore create mode 100644 ovm/Dockerfile create mode 100644 ovm/Makefile create mode 100644 ovm/README.md create mode 100644 ovm/container.ini create mode 100644 ovm/omv-startup create mode 100644 ovm/openmediavault.list diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..477e061 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at developer@epicm.org. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..cb742ee --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,17 @@ +# Contributing + +When contributing to this repository, please first discuss the change you wish to make via issue, +email, or any other method with the owners of this repository before making a change. + +Please note we have a code of conduct, please follow it in all your interactions with the project. + +## Pull Request Process + +1. Ensure any install or build dependencies are removed before the end of the layer when doing a + build. +2. Update the README.md with details of changes to the interface, this includes new environment + variables, exposed ports, useful file locations and container parameters. +3. Increase the version numbers in any examples files and the README.md to the new version that this + Pull Request would represent. +4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you + do not have permission to do that, you may request the second reviewer to merge it for you. diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..b7e7b12 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms +patreon: epicmorg +ko_fi: epicmorg +custom: https://ko-fi.com/alexz696 + +#github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +#open_collective: # Replace with a single Open Collective username +#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +#liberapay: # Replace with a single Liberapay username +#issuehunt: # Replace with a single IssueHunt username +#otechie: # Replace with a single Otechie username +#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..d41b607 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,27 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: 'bug, Regular Priority' +assignees: 'stamepicmorg' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/cve_report.md b/.github/ISSUE_TEMPLATE/cve_report.md new file mode 100644 index 0000000..c69f58d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/cve_report.md @@ -0,0 +1,18 @@ +--- +name: CVE report +about: Create a report of some CVE +title: '[CVE] ' +labels: 'CVE, High Priority' +assignees: 'stamepicmorg' + +--- +**CVE number or URL** + +**Describe** +A clear and concise description of what the CVE is. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..982d2cd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,21 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: 'Feature request, help wanted' +assignees: 'stamepicmorg' +milestone: 'Due 2021 🙏' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/task_generic.md b/.github/ISSUE_TEMPLATE/task_generic.md new file mode 100644 index 0000000..4afb970 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/task_generic.md @@ -0,0 +1,17 @@ +--- +name: Generic task +about: Create a generic task +title: '' +labels: 'task, Regular Priority' +assignees: 'stamepicmorg' + +--- + +**Describe** +A clear and concise description of what the bug is. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..c7f8007 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,13 @@ +## Purpose +_Describe the problem or feature in addition to a link to the issues._ + +## Approach +_How does this change address the problem?_ + +#### Open Questions and Pre-Merge TODOs +- [ ] Use github checklists. When solved, check the box and explain the answer. + +## Learning +_Describe the research stage_ + +_Links to blog posts, patterns, libraries or addons used to solve this problem_ diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..25a42e6 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018-2020 EpicMorg: Main + +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 new file mode 100644 index 0000000..4ebf278 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# docker-experimental-images +Splited from https://github.com/EpicMorg/docker-scripts diff --git a/ovm/.docker-repository.yml b/ovm/.docker-repository.yml new file mode 100644 index 0000000..6bf9e26 --- /dev/null +++ b/ovm/.docker-repository.yml @@ -0,0 +1 @@ +repository: epicmorg/balancer diff --git a/ovm/.dockerignore b/ovm/.dockerignore new file mode 100644 index 0000000..f5523d4 --- /dev/null +++ b/ovm/.dockerignore @@ -0,0 +1,3 @@ +.git +scripts +.idea diff --git a/ovm/Dockerfile b/ovm/Dockerfile new file mode 100644 index 0000000..887d1ae --- /dev/null +++ b/ovm/Dockerfile @@ -0,0 +1,50 @@ +FROM debian:buster +MAINTAINER Anatoliy Zimovskiy + +ENV DEBIAN_FRONTEND noninteractive + +#editing sources list +RUN rm /etc/apt/sources.list +COPY sources.list /etc/apt/sources.list + +COPY locale.gen /etc/locale.gen + +# fix errors +RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections + +#installing utils +RUN apt-get update && apt-get install -y --allow-unauthenticated ca-certificates gnupg sudo apt-transport-https lsb-release apt-utils locales console-cyrillic wget curl htop mc tmux iftop cmatrix iputils-ping cmatrix-xfont lsof lynx fontconfig smbclient nano + + +#installing packages +RUN gpg --keyserver keyserver.ubuntu.com --recv 7E7A6C592EF35D13 +RUN gpg --keyserver keyserver.ubuntu.com --recv 24863F0C716B980B +RUN wget -qO - http://packages.openmediavault.org/public/archive.key | sudo apt-key add - +COPY openmediavault.list /etc/apt/sources.list.d/openmediavault.list +RUN apt-get update && apt-get install -y --allow-unauthenticated openmediavault-keyring postfix openmediavault + + +#After install fixes +#RUN localedef en_US.UTF-8 -i en_US -f UTF-8 +#RUN update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 +#RUN apt update +#RUN apt upgrade -y +#RUN apt dist-upgrade -y +#RUN apt-get clean autoclean +#RUN apt-get autoremove -y +#RUN rm -rf /var/lib/apt/lists/* + +#final config +# We need to make sure rrdcached uses /data for it's data +COPY defaults/rrdcached /etc/default + +# Add our startup script last because we don't want changes +# to it to require a full container rebuild +COPY omv-startup /usr/sbin/omv-startup +RUN chmod +x /usr/sbin/omv-startup + +EXPOSE 8080 8443 + +VOLUME /data + +ENTRYPOINT /usr/sbin/omv-startup diff --git a/ovm/Makefile b/ovm/Makefile new file mode 100644 index 0000000..80be0b3 --- /dev/null +++ b/ovm/Makefile @@ -0,0 +1,4 @@ +all: ovm + +ovm: + docker build --compress -t epicmorg/ovm . diff --git a/ovm/README.md b/ovm/README.md new file mode 100644 index 0000000..034784b --- /dev/null +++ b/ovm/README.md @@ -0,0 +1,30 @@ +# Compose example + +```yml +version: '3.7' +services: + balancer: + image: epicmorg/balancer + restart: unless-stopped + ports: + - "0.0.0.0:80:80" + - "0.0.0.0:443:443" + volumes: + - /etc/localtime:/etc/localtime + - /etc/timezone:/etc/timezone + - /etc/letsencrypt:/etc/letsencrypt + - nginx:/etc/nginx + - nginx-usr:/usr/share/nginx/html + - /var/lib/nginx +# extra_hosts: +# - "example.com:192.168.0.11" + depends_on: + - websites + tmpfs: + - /tmp +volumes: + nginx: + external: true + nginx-usr: + external: true +``` diff --git a/ovm/container.ini b/ovm/container.ini new file mode 100644 index 0000000..a18ed01 --- /dev/null +++ b/ovm/container.ini @@ -0,0 +1,6 @@ +[nginx] +httpPort = '8080'; +httpsPort = '8443'; + +[data] +alwaysClear = 'false'; diff --git a/ovm/omv-startup b/ovm/omv-startup new file mode 100644 index 0000000..48c7deb --- /dev/null +++ b/ovm/omv-startup @@ -0,0 +1,121 @@ +#!/bin/bash + +set -e + +# Config parser code from https://github.com/chilladx/config-parser +config_parser () { + local iniFile="$1"; + local tmpFile=$( mktemp /tmp/`basename $iniFile`.XXXXXX ); + local intLines; + local binSED=$( which sed ); + + # copy the ini file to the temporary location + cp $iniFile $tmpFile; + + # remove tabs or spaces around the = + $binSED -i -e 's/[ \t]*=[ \t]*/=/g' $tmpFile; + + # transform section labels into function declaration + $binSED -i -e 's/\[\([A-Za-z0-9_]*\)\]/config.section.\1() \{/g' $tmpFile; + $binSED -i -e 's/config\.section\./\}\'$'\nconfig\.section\./g' $tmpFile; + + # remove first line + $binSED -i -e '1d' $tmpFile; + + # add the last brace + echo -e "\n}" >> $tmpFile; + + # now load the file + source $tmpFile; + + # clean up + rm -f $tmpFile; +} + +if [ -e /data/container.ini ]; then + config_parser "/data/container.ini" +fi + +if [[ "$(type -t config.section.data)" == "function" ]]; then + config.section.data +fi + +if [ "${alwaysClear}" = "true" ]; then + echo Clearing data because config says so... + + rm -Rf /data/etc + rm -Rf /data/var +fi + +if [ ! -e /data/etc ] || [ ! -e /data/var ]; then + FIRST_RUN=true + + if [ ! -e /data/etc ]; then + echo Creating initial configuration... + + mkdir -p /data/etc + + mv /etc/openmediavault /data/etc + mv /etc/default /data/etc + mv /etc/nginx /data/etc + fi + + if [ ! -e /data/var ]; then + echo Creating persistent data directory... + + mkdir /data/var + + mv /var/log /data/var/log + fi +else + FIRST_RUN=false + + rm -Rf /etc/openmediavault + rm -Rf /etc/default + rm -Rf /etc/nginx + + rm -Rf /var/log +fi + +echo Linking in configuration and data... +ln -s /data/etc/openmediavault /etc/openmediavault +ln -s /data/etc/default /etc/default +ln -s /data/etc/nginx /etc/nginx + +ln -s /data/var/log /var/log + +if [ "${FIRST_RUN}" = "true" ]; then + echo Initializing OpenMediaVault... + sed 's/OMV_DEBUG_\(.*\)=.*/OMV_DEBUG_\1="yes"/' -i /etc/default/openmediavault + omv-initsystem $(find /usr/share/openmediavault/initsystem ! -name '*rootfs' ! -name '*sysctl' -type f -printf "%f\n" | sort | xargs) +fi + +if [[ "$(type -t config.section.nginx)" == "function" ]]; then + config.section.nginx +fi + +if [ ! -z "${httpPort}" ]; then + sed -i "s|listen \(.*\):[0-9][0-9]* \(.*\)|listen \1:${httpPort} \2|g" /etc/nginx/sites-available/openmediavault-webgui +fi + +if [ ! -z "${httpsPort}" ]; then + sed -i "s|listen \(.*\):[0-9][0-9]* \(.*\) ssl \(.*\)|:listen \1:${httpsPort} \2 ssl \3|g" /etc/nginx/sites-available/openmediavault-webgui +fi + +SERVICES="motd openmediavault php5-fpm rrdcached rsyslog sudo anacron ntp openmediavault-engined cron postfix nginx collectd rc.local monit" + +for EACH in ${SERVICES}; do + /etc/init.d/${EACH} start +done + +if [[ -e /data/startup.sh ]]; then + /data/startup.sh +fi + +if [ -t 0 ]; then + /bin/bash +else + while true; do + sleep 1000 & wait $! + done +fi diff --git a/ovm/openmediavault.list b/ovm/openmediavault.list new file mode 100644 index 0000000..297a4a8 --- /dev/null +++ b/ovm/openmediavault.list @@ -0,0 +1,2 @@ +deb http://packages.openmediavault.org/public usul main partner +deb http://packages.openmediavault.org/public usul-proposed main