Compare commits

..

32 Commits

Author SHA1 Message Date
buanet
4fe9c10771 fix permission issue 2023-07-06 00:24:02 +02:00
buanet
3d83c7fa21 v8.1.0-beta.3 2023-07-05 21:44:47 +02:00
André Germann
f225536852 Merge pull request #346 from buanet/dependabot/github_actions/main/docker/login-action-2.2.0
Bump docker/login-action from 2.1.0 to 2.2.0
2023-07-02 21:57:42 +02:00
André Germann
18b0f863bd Merge pull request #350 from buanet/dependabot/github_actions/main/docker/build-push-action-4.1.1
Bump docker/build-push-action from 4.0.0 to 4.1.1
2023-07-02 21:56:58 +02:00
André Germann
ff6535a896 Merge branch 'beta' into dependabot/github_actions/main/docker/build-push-action-4.1.1 2023-07-02 21:56:14 +02:00
André Germann
3543b10c90 Merge pull request #351 from buanet/dependabot/github_actions/main/docker/setup-buildx-action-2.8.0
Bump docker/setup-buildx-action from 2.5.0 to 2.8.0
2023-07-02 21:19:10 +02:00
André Germann
b3870bdcb7 Merge pull request #345 from buanet/dependabot/github_actions/main/docker/setup-qemu-action-2.2.0
Bump docker/setup-qemu-action from 2.1.0 to 2.2.0
2023-07-02 21:16:41 +02:00
dependabot[bot]
9f016f5363 Bump docker/setup-buildx-action from 2.5.0 to 2.8.0
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2.5.0 to 2.8.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/v2.5.0...v2.8.0)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-29 09:42:27 +00:00
buanet
800e95a5c2 new ioBroker versions 2023-06-19 23:45:06 +00:00
dependabot[bot]
0f3b59fe98 Bump docker/build-push-action from 4.0.0 to 4.1.1
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4.0.0 to 4.1.1.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v4.0.0...v4.1.1)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-14 09:58:25 +00:00
dependabot[bot]
8f7f9656d8 Bump docker/login-action from 2.1.0 to 2.2.0
Bumps [docker/login-action](https://github.com/docker/login-action) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v2.1.0...v2.2.0)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-08 09:58:10 +00:00
dependabot[bot]
7e291f98ea Bump docker/setup-qemu-action from 2.1.0 to 2.2.0
Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/docker/setup-qemu-action/releases)
- [Commits](https://github.com/docker/setup-qemu-action/compare/v2.1.0...v2.2.0)

---
updated-dependencies:
- dependency-name: docker/setup-qemu-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-08 09:58:06 +00:00
buanet
a46e29fac1 fix changelog 2023-04-27 09:41:08 +02:00
buanet
8294f8cf51 new ioBroker versions 2023-04-26 23:45:29 +00:00
buanet
5c7dfb3d3c update workflows for node 20 2023-04-26 22:06:57 +02:00
André Germann
721c108742 Merge pull request #340 from buanet/feature/issue-329/add-influx-repo
Feature/issue 329/add influx repo
2023-04-26 21:48:06 +02:00
buanet
7a455952dd enhance maintenance script 2023-04-25 22:30:15 +02:00
André Germann
a04f210190 Merge pull request #339 from buanet/beta
update feature branch
2023-04-25 21:29:05 +02:00
André Germann
0f59839695 Merge pull request #338 from buanet/temp_main
moving hotfix to beta
2023-04-25 21:22:24 +02:00
André Germann
4f15a4df23 Merge branch 'beta' into temp_main 2023-04-25 21:22:05 +02:00
buanet
686b391119 docu 2023-04-25 21:15:29 +02:00
buanet
d5a6596070 update version 2023-04-25 21:07:38 +02:00
buanet
8c9279b867 enhance output 2023-04-16 23:03:23 +02:00
buanet
065d0cb4df syntax change 2023-04-16 22:14:03 +02:00
buanet
acad72922e testing 2023-04-16 21:55:23 +02:00
buanet
8fe4d775f5 testing 2023-04-16 15:16:37 +02:00
buanet
e283d25710 small fixes 2023-04-16 14:57:10 +02:00
buanet
893908f29d fix typo 2023-04-16 13:44:18 +02:00
buanet
16e30c392d fix typo 2023-04-16 01:10:05 +02:00
buanet
a954b51223 small fixes 2023-04-16 00:54:15 +02:00
buanet
6a55923669 add check for package validity 2023-04-16 00:08:10 +02:00
buanet
bbac132f28 testing influx repo integration 2023-04-15 22:30:19 +02:00
13 changed files with 283 additions and 123 deletions

View File

@@ -1 +1 @@
v8.0.1 v8.1.0-beta.3

View File

@@ -1 +1 @@
2.6.16 2.6.23

View File

@@ -39,37 +39,42 @@ jobs:
mv -f ./debian/node20/Dockerfile.tmp ./debian/node20/Dockerfile mv -f ./debian/node20/Dockerfile.tmp ./debian/node20/Dockerfile
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2.1.0 uses: docker/setup-qemu-action@v2.2.0
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v2.5.0 uses: docker/setup-buildx-action@v2.8.0
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@v2.1.0 uses: docker/login-action@v2.2.0
with: with:
username: ${{ secrets.DOCKER_USER }} username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }} password: ${{ secrets.DOCKER_PASS }}
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v2.1.0 uses: docker/login-action@v2.2.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ secrets.PACKAGES_USER }} username: ${{ secrets.PACKAGES_USER }}
password: ${{ secrets.PACKAGES_PASS }} password: ${{ secrets.PACKAGES_PASS }}
- name: Build Docker image (node20) - name: Build Docker image (node20)
uses: docker/build-push-action@v4.0.0 uses: docker/build-push-action@v4.1.1
with: with:
context: ./debian context: ./debian
file: ./debian/node20/Dockerfile file: ./debian/node20/Dockerfile
push: true push: true
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8 platforms: |
linux/amd64
linux/arm/v7
linux/arm64/v8
tags: | tags: |
buanet/iobroker:beta-node20, buanet/iobroker:beta-node20,
buanet/iobroker:${{ env.version }}-node20, buanet/iobroker:${{ env.version }}-node20,
ghcr.io/buanet/iobroker:beta-node20, ghcr.io/buanet/iobroker:beta-node20,
ghcr.io/buanet/iobroker:${{ env.version }}-node20 ghcr.io/buanet/iobroker:${{ env.version }}-node20
provenance: false
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Official Docker image for ioBroker smarthome software (https://www.iobroker.net)
- name: Delete untagged images from GitHub packages - name: Delete untagged images from GitHub packages
uses: actions/github-script@v6 uses: actions/github-script@v6

View File

@@ -39,27 +39,27 @@ jobs:
mv -f ./debian/node18/Dockerfile.tmp ./debian/node18/Dockerfile mv -f ./debian/node18/Dockerfile.tmp ./debian/node18/Dockerfile
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2.1.0 uses: docker/setup-qemu-action@v2.2.0
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v2.5.0 uses: docker/setup-buildx-action@v2.8.0
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@v2.1.0 uses: docker/login-action@v2.2.0
with: with:
username: ${{ secrets.DOCKER_USER }} username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }} password: ${{ secrets.DOCKER_PASS }}
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v2.1.0 uses: docker/login-action@v2.2.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ secrets.PACKAGES_USER }} username: ${{ secrets.PACKAGES_USER }}
password: ${{ secrets.PACKAGES_PASS }} password: ${{ secrets.PACKAGES_PASS }}
- name: Build Docker image - name: Build Docker image
uses: docker/build-push-action@v4.0.0 uses: docker/build-push-action@v4.1.1
with: with:
context: ./debian context: ./debian
file: ./debian/node18/Dockerfile file: ./debian/node18/Dockerfile

View File

@@ -9,11 +9,11 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v3 uses: actions/checkout@v3.5.0
with: with:
repository: 'buanet/ioBroker.docker' repository: 'buanet/ioBroker.docker'
- name: Fetching version tag and date - name: Fetch version tag and date
id: version id: version
run: | run: |
VERSION="$(cat .VERSION)" VERSION="$(cat .VERSION)"
@@ -33,38 +33,43 @@ jobs:
mv -f ./debian/node20/Dockerfile.tmp ./debian/node20/Dockerfile mv -f ./debian/node20/Dockerfile.tmp ./debian/node20/Dockerfile
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2.1.0 uses: docker/setup-qemu-action@v2.2.0
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v2.5.0 uses: docker/setup-buildx-action@v2.8.0
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@v2.1.0 uses: docker/login-action@v2.2.0
with: with:
username: ${{ secrets.DOCKER_USER }} username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }} password: ${{ secrets.DOCKER_PASS }}
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v2.1.0 uses: docker/login-action@v2.2.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ secrets.PACKAGES_USER }} username: ${{ secrets.PACKAGES_USER }}
password: ${{ secrets.PACKAGES_PASS }} password: ${{ secrets.PACKAGES_PASS }}
- name: Build Docker image (node20) - name: Build Docker image (node20)
uses: docker/build-push-action@v4.0.0 uses: docker/build-push-action@v4.1.1
with: with:
context: ./debian context: ./debian
file: ./debian/node20/Dockerfile file: ./debian/node20/Dockerfile
push: true push: true
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8 platforms: |
linux/amd64
linux/arm/v7
linux/arm64/v8
tags: | tags: |
buanet/iobroker:dev-node20, buanet/iobroker:dev-node20,
ghcr.io/buanet/iobroker:dev-node20 ghcr.io/buanet/iobroker:dev-node20
provenance: false
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Official Docker image for ioBroker smarthome software (https://www.iobroker.net)
- name: Delete untagged images from GitHub packages - name: Delete untagged images from GitHub Container Registry
uses: actions/github-script@v6 uses: actions/github-script@v6.4.1
with: with:
github-token: ${{ secrets.PACKAGES_PASS }} github-token: ${{ secrets.PACKAGES_PASS }}
script: | script: |

View File

@@ -33,27 +33,27 @@ jobs:
mv -f ./debian/node18/Dockerfile.tmp ./debian/node18/Dockerfile mv -f ./debian/node18/Dockerfile.tmp ./debian/node18/Dockerfile
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2.1.0 uses: docker/setup-qemu-action@v2.2.0
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v2.5.0 uses: docker/setup-buildx-action@v2.8.0
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@v2.1.0 uses: docker/login-action@v2.2.0
with: with:
username: ${{ secrets.DOCKER_USER }} username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }} password: ${{ secrets.DOCKER_PASS }}
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v2.1.0 uses: docker/login-action@v2.2.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ secrets.PACKAGES_USER }} username: ${{ secrets.PACKAGES_USER }}
password: ${{ secrets.PACKAGES_PASS }} password: ${{ secrets.PACKAGES_PASS }}
- name: Build and push Docker image - name: Build and push Docker image
uses: docker/build-push-action@v4.0.0 uses: docker/build-push-action@v4.1.1
with: with:
context: ./debian context: ./debian
file: ./debian/node18/Dockerfile file: ./debian/node18/Dockerfile

View File

@@ -42,20 +42,20 @@ jobs:
mv -f ./debian/node18/Dockerfile.tmp ./debian/node18/Dockerfile mv -f ./debian/node18/Dockerfile.tmp ./debian/node18/Dockerfile
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2.1.0 uses: docker/setup-qemu-action@v2.2.0
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v2.5.0 uses: docker/setup-buildx-action@v2.8.0
- name: Login to DockerHub (iobroker) - name: Login to DockerHub (iobroker)
uses: docker/login-action@v2.1.0 uses: docker/login-action@v2.2.0
with: with:
username: ${{ secrets.DOCKER_USER_IOB }} username: ${{ secrets.DOCKER_USER_IOB }}
password: ${{ secrets.DOCKER_PASS_IOB }} password: ${{ secrets.DOCKER_PASS_IOB }}
- name: Build Docker image - name: Build Docker image
uses: docker/build-push-action@v4.0.0 uses: docker/build-push-action@v4.1.1
with: with:
context: ./debian context: ./debian
file: ./debian/node18/Dockerfile file: ./debian/node18/Dockerfile

View File

@@ -42,26 +42,26 @@ jobs:
mv -f ./debian/node18/Dockerfile.tmp ./debian/node18/Dockerfile mv -f ./debian/node18/Dockerfile.tmp ./debian/node18/Dockerfile
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2.1.0 uses: docker/setup-qemu-action@v2.2.0
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v2.5.0 uses: docker/setup-buildx-action@v2.8.0
- name: Login to DockerHub (buanet) - name: Login to DockerHub (buanet)
uses: docker/login-action@v2.1.0 uses: docker/login-action@v2.2.0
with: with:
username: ${{ secrets.DOCKER_USER }} username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }} password: ${{ secrets.DOCKER_PASS }}
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v2.1.0 uses: docker/login-action@v2.2.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ secrets.PACKAGES_USER }} username: ${{ secrets.PACKAGES_USER }}
password: ${{ secrets.PACKAGES_PASS }} password: ${{ secrets.PACKAGES_PASS }}
- name: Build Docker image - name: Build Docker image
uses: docker/build-push-action@v4.0.0 uses: docker/build-push-action@v4.1.1
with: with:
context: ./debian context: ./debian
file: ./debian/node18/Dockerfile file: ./debian/node18/Dockerfile

View File

@@ -1,5 +1,20 @@
## Changelog ## Changelog
### v8.1.0-beta.3 (05.07.2023)
* fix permission issue for restart container as iobroker user
* fix issue with js-controller ui upgrade
* fix small issues in maintenance script
* update action workflows
* v8.1.0-beta.2 (26.04.2023)
* prohibit restore when startup script is still running
* extend time before restart after restore is done
* influx data repo will be added automatically when PACKAGES contains influxdb or influxdb2-cli package
* v8.1.0-beta.1 (14.04.2023)
* enhance github actions
* enhance log output of maintenance script on restore ([#333](https://github.com/buanet/ioBroker.docker/issues/333))
* allow iobroker admin to be disabled at startup ([#332](https://github.com/buanet/ioBroker.docker/issues/332))
* allow deletion of objects and states db password with value "none" ([#306](https://github.com/buanet/ioBroker.docker/issues/306))
### v8.0.1 (17.04.2023) ### v8.0.1 (17.04.2023)
* fix calling of "iob setup first" on slaves ([#335](https://github.com/buanet/ioBroker.docker/issues/335)) * fix calling of "iob setup first" on slaves ([#335](https://github.com/buanet/ioBroker.docker/issues/335))

102
debian/node20/Dockerfile vendored Normal file
View File

@@ -0,0 +1,102 @@
FROM debian:bullseye-slim
LABEL org.opencontainers.image.title="Official ioBroker Docker Image" \
org.opencontainers.image.description="Official Docker image for ioBroker smarthome software (https://www.iobroker.net)" \
org.opencontainers.image.documentation="https://github.com/buanet/ioBroker.docker#readme" \
org.opencontainers.image.authors="André Germann <info@buanet.de>" \
org.opencontainers.image.url="https://github.com/buanet/ioBroker.docker" \
org.opencontainers.image.source="https://github.com/buanet/ioBroker.docker" \
org.opencontainers.image.base.name="docker.io/library/debian:bullseye-slim" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.created="${DATI}"
ENV DEBIAN_FRONTEND noninteractive
# Copy scripts
COPY scripts /opt/scripts
COPY userscripts /opt/userscripts
# Install prerequisites (including node) and generating locales
RUN apt-get update && apt-get install -y \
apt-utils \
cifs-utils \
curl \
gosu \
iputils-ping \
jq \
locales \
nfs-common \
procps \
python3 \
python3-dev \
sudo \
tar \
tzdata \
udev \
wget \
# Install node
&& curl -sL https://deb.nodesource.com/setup_20.x | bash \
&& apt-get update && apt-get install -y nodejs \
# Install node-gyp
&& npm install -g node-gyp \
# Generating locales
&& sed -i 's/^# *\(de_DE.UTF-8\)/\1/' /etc/locale.gen \
&& sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \
&& locale-gen \
# Change permissions for scripts
&& chmod 777 /opt/scripts/ \
&& chmod 777 /opt/userscripts/ \
&& chmod +x /opt/scripts/*.sh \
&& chmod +x /opt/userscripts/*.sh \
# Prepare
&& mkdir -p /opt/scripts/.docker_config/ \
&& echo "starting" > /opt/scripts/.docker_config/.healthcheck \
&& echo "${VERSION}" > /opt/scripts/.docker_config/.thisisdocker \
&& echo "true" > /opt/.first_run \
# Run installer
&& curl -sL https://iobroker.net/install.sh | bash - \
# Deleting UUID from build
&& iobroker unsetup -y \
&& echo "true" > /opt/iobroker/.fresh_install \
# Backup initial ioBroker and userscript folder
&& tar -cf /opt/initial_iobroker.tar /opt/iobroker \
&& tar -cf /opt/initial_userscripts.tar /opt/userscripts \
# Setting up iobroker-user (shell, home dir and rights)
&& chsh -s /bin/bash iobroker \
&& usermod --home /opt/iobroker iobroker \
&& usermod -u 1000 iobroker \
&& groupmod -g 1000 iobroker \
&& chown root:iobroker /usr/sbin/gosu \
&& chmod +s /usr/sbin/gosu \
# Clean up installation cache
&& apt-get autoclean -y \
&& apt-get autoremove \
&& apt-get clean \
&& rm -rf /tmp/* /var/tmp/* \
&& rm -rf /root/.cache/* /root/.npm/* \
&& rm -rf /var/lib/apt/lists/*
# Setting up default ENVs
ENV DEBIAN_FRONTEND="teletype" \
LANG="de_DE.UTF-8" \
LANGUAGE="de_DE:de" \
LC_ALL="de_DE.UTF-8" \
SETGID=1000 \
SETUID=1000 \
TZ="Europe/Berlin"
# Expose default admin ui port
EXPOSE 8081
# Change work dir
WORKDIR /opt/iobroker/
# Healthcheck
HEALTHCHECK --interval=15s --timeout=5s --retries=5 \
CMD ["/bin/bash", "-c", "/opt/scripts/healthcheck.sh"]
# Volumes for persistent data
VOLUME ["/opt/iobroker"]
# Run startup-script
ENTRYPOINT ["/bin/bash", "-c", "/opt/scripts/iobroker_startup.sh"]

View File

@@ -143,9 +143,10 @@ if [[ -f /opt/.first_run ]]; then
echo "PACKAGES is set, but OFFLINE_MODE is \"true\". Skipping Linux package installation." echo "PACKAGES is set, but OFFLINE_MODE is \"true\". Skipping Linux package installation."
elif [[ "$packages" != "" ]]; then elif [[ "$packages" != "" ]]; then
echo "PACKAGES is set. Installing the following additional Linux packages: ""$packages" echo "PACKAGES is set. Installing the following additional Linux packages: ""$packages"
echo "$packages" > /opt/scripts/.docker_config/.packages # echo "$packages" > /opt/scripts/.docker_config/.packages
bash /opt/scripts/setup_packages.sh -install bash /opt/scripts/setup_packages.sh -install
fi fi
echo ' '
# Register maintenance script # Register maintenance script
echo -n 'Registering maintenance script as command... ' echo -n 'Registering maintenance script as command... '
echo "alias maintenance=\'/opt/scripts/maintenance.sh\'" >> /root/.bashrc echo "alias maintenance=\'/opt/scripts/maintenance.sh\'" >> /root/.bashrc

View File

@@ -38,6 +38,11 @@ maintenance_enabled() {
[[ -f "$healthcheck" && "$(cat "$healthcheck")" == maintenance ]] [[ -f "$healthcheck" && "$(cat "$healthcheck")" == maintenance ]]
} }
# check status starting
check_starting() {
[[ -f "$healthcheck" && "$(cat "$healthcheck")" == starting ]]
}
# display maintenance status # display maintenance status
maintenance_status() { maintenance_status() {
if maintenance_enabled; then if maintenance_enabled; then
@@ -54,40 +59,24 @@ enable_maintenance() {
return return
fi fi
if [[ "$killbyname" == yes ]]; then
# undocumented option, only for use with backitup restore scripts
# stops iobroker by terminating js-controller process by name (the old way)
echo 'This command will activate maintenance mode and stop js-controller.'
echo 'Activating maintenance mode...'
echo 'maintenance' > "$healthcheck"
sleep 1
echo 'Done.'
echo -n 'Stopping ioBroker...'
pkill -u iobroker -f iobroker.js-controller
sleep 5
echo 'Done.'
return
fi
echo 'You are now going to stop ioBroker and activate maintenance mode for this container.' echo 'You are now going to stop ioBroker and activate maintenance mode for this container.'
if [[ "$autoconfirm" != yes ]]; then if [[ "$killbyname" != yes ]]; then
local reply if [[ "$autoconfirm" != yes ]]; then
local reply
read -rp 'Do you want to continue [yes/no]? ' reply read -rp 'Do you want to continue [yes/no]? ' reply
if [[ "$reply" == y || "$reply" == Y || "$reply" == yes ]]; then if [[ "$reply" == y || "$reply" == Y || "$reply" == yes ]]; then
: # continue : # continue
else else
return 1 return 1
fi
fi fi
else
echo 'This command was already confirmed by the -y or --yes option.'
fi fi
echo 'Activating maintenance mode...' echo 'Activating maintenance mode...'
echo 'maintenance' > "$healthcheck" echo 'maintenance' > "$healthcheck"
sleep 1 sleep 1
echo 'Done.'
echo -n 'Stopping ioBroker...' echo -n 'Stopping ioBroker...'
stop_iob stop_iob
} }
@@ -111,13 +100,11 @@ disable_maintenance() {
else else
return 1 return 1
fi fi
else
echo 'This command was already confirmed by the -y or --yes option.'
fi fi
echo 'Deactivating maintenance mode and forcing container to stop or restart...' echo 'Deactivating maintenance mode and forcing container to stop or restart...'
echo 'stopping' > "$healthcheck" echo 'stopping' > "$healthcheck"
pkill -u root gosu root pkill -u root
echo 'Done.' echo 'Done.'
} }
@@ -137,8 +124,6 @@ upgrade_jscontroller() {
else else
return 1 return 1
fi fi
else
echo 'This command was already confirmed by the -y or --yes option.'
fi fi
if ! maintenance_enabled > /dev/null; then if ! maintenance_enabled > /dev/null; then
@@ -156,7 +141,7 @@ upgrade_jscontroller() {
echo 'Container will be stopped or restarted in 5 seconds...' echo 'Container will be stopped or restarted in 5 seconds...'
sleep 5 sleep 5
echo 'stopping' > "$healthcheck" echo 'stopping' > "$healthcheck"
pkill -u root gosu root pkill -u root
} }
# stop iobroker and wait until all processes stopped or pkill_timeout is reached # stop iobroker and wait until all processes stopped or pkill_timeout is reached
@@ -164,29 +149,37 @@ stop_iob() {
local status timeout local status timeout
timeout="$(date --date="now + $pkill_timeout sec" +%s)" timeout="$(date --date="now + $pkill_timeout sec" +%s)"
pkill -u iobroker -f iobroker.js-controller pkill -u iobroker -f 'iobroker.js-controller[^/]*$'
status=$? status=$?
if (( status >= 2 )); then # syntax error or fatal error if (( status >= 2 )); then # syntax error or fatal error
echo 'fatal error' #for logging
return 1 return 1
fi fi
if (( status == 1 )); then # no processes matched if (( status == 1 )); then # no processes matched
echo 'no process matched' #for logging
return return
fi fi
# pgrep exits with status 1 when there are no matches if [[ "$killbyname" != yes ]]; then
while pgrep -u iobroker > /dev/null; (( $? != 1 )); do # pgrep exits with status 1 when there are no matches
if (($(date +%s) > timeout)); then while pgrep -u iobroker > /dev/null; (( $? != 1 )); do
echo -e '\nTimeout reached. Killing remaining processes...' if (($(date +%s) > timeout)); then
pgrep --list-full -u iobroker echo -e '\nTimeout reached. Killing remaining processes...'
pkill --signal SIGKILL -u iobroker pgrep --list-full -u iobroker
echo 'Done.' pkill --signal SIGKILL -u iobroker
return echo 'Done.'
fi return
fi
echo -n '.' echo -n '.'
sleep 1 sleep 1
done done
else
for ((i=0; i<3; i++)); do
sleep 1
echo -n '.'
done
fi
echo -e '\nDone.' echo -e '\nDone.'
} }
@@ -205,22 +198,24 @@ restart_container() {
else else
return 1 return 1
fi fi
else
echo 'This command was already confirmed by the -y or --yes option.'
fi fi
echo -n 'Stopping ioBroker...' if ! maintenance_enabled > /dev/null; then
stop_iob echo -n 'Stopping ioBroker...'
stop_iob
fi
echo 'Container will be stopped or restarted in 5 seconds...' echo 'Container will be stopped or restarted in 5 seconds...'
sleep 5 sleep 5
echo 'stopping' > "$healthcheck" echo 'stopping' > "$healthcheck"
pkill -u root gosu root pkill -u root
} }
# restore iobroker # restore iobroker
restore_iobroker() { restore_iobroker() {
echo 'You are now going to perform a restore of your iobroker.' echo 'You are now going to perform a restore of your iobroker.'
echo 'During the restore process, the container will automatically switch into maintenance mode and stop ioBroker.'
echo 'Depending on the restart policy, your container will be stopped or restarted automatically after the restore.'
if [[ "$autoconfirm" != yes ]]; then if [[ "$autoconfirm" != yes ]]; then
local reply local reply
@@ -231,15 +226,19 @@ restore_iobroker() {
else else
return 1 return 1
fi fi
else
echo 'This command was already confirmed by the -y or --yes option.'
fi fi
echo -n 'Stopping ioBroker...' if check_starting > /dev/null; then
stop_iob echo "Startup script is still running."
echo "Please check container log and wait until ioBroker is sucessfully started."
echo "Then try again."
return 1
fi
# fixing permission errors during restore if ! maintenance_enabled > /dev/null; then
#chown -R $setuid:$setgid /opt/iobroker/backup autoconfirm=yes
enable_maintenance
fi
echo -n "Restoring ioBroker... " echo -n "Restoring ioBroker... "
set +e set +e
@@ -263,10 +262,10 @@ restore_iobroker() {
echo "!!!! You can view installation process by taking a look at ioBroker log. !!!!" echo "!!!! You can view installation process by taking a look at ioBroker log. !!!!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
sleep 10 sleep 10
echo 'Container will be stopped or restarted in 5 seconds...' echo 'Container will be stopped or restarted in 10 seconds...'
sleep 5 sleep 10
echo 'stopping' > "$healthcheck" echo 'stopping' > "$healthcheck"
pkill -u root gosu root pkill -u root
} }
# parsing commands and options # parsing commands and options

View File

@@ -1,36 +1,69 @@
#!/bin/bash #!/bin/bash
# bash strict mode
set -euo pipefail
# Reading ENV
set +u
packages=$PACKAGES
debug=$DEBUG
set -u
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
if [ "$1" == "-install" ] check_package_preq() {
then # check for influx packages
apt-get -q update >> /opt/scripts/setup_packages.log 2>&1 if [[ "$i" == "influxdb" || "$i" == "influxdb2-cli" ]]; then
packages=$(cat /opt/scripts/.docker_config/.packages) # add influxdata repo keys
echo ' ' wget -qO- https://repos.influxdata.com/influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
for i in $packages; do echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; apt-get -q update >> /opt/scripts/setup_packages.log 2>&1
then fi
echo -n "$i is not installed. Installing... " }
DEBIAN_FRONTEND=noninteractive apt-get -q -y install "$i" >> /opt/scripts/setup_packages.log 2>&1 check_package_validity() {
return=$? # check string for double spaces
if [[ "$return" -ne 0 ]]; then while echo "$packages" | grep -q ' '; do
echo "Failed." packages=$(echo "$packages" | sed 's/ / /g')
echo "For more details see \"/opt/scripts/setup_packages.log\"."
echo ' '
else
echo "Done."
fi
else
echo "$i is already installed."
fi
done done
elif [ "$1" == "-update" ]; then # remove packages when "influxdb" AND "influxdb2-cli"
if echo "$packages" | grep -qw "influxdb" && echo "$packages" | grep -qw "influxdb2-cli"; then
echo "PACKAGES includes influxdb AND influxdb2-cli."
echo "As installing both packages together is not possible, they will be skipped."
packages=$(echo "$packages" | sed 's/influxdb2-cli//g;s/influxdb//g')
# check string for double spaces again
while echo "$packages" | grep -q ' '; do
packages=$(echo "$packages" | sed 's/ / /g')
done
if [[ $debug == "true" ]]; then echo "[DEBUG] New list of packages: ""$packages"; fi
echo ' '
fi
}
if [[ "$1" == "-install" ]]; then
echo ' '
apt-get -q update >> /opt/scripts/setup_packages.log 2>&1
check_package_validity
for i in $packages; do
if ! dpkg -s "$i" >/dev/null 2>&1; then
echo -n "$i is not installed. Installing... "
check_package_preq >> /opt/scripts/setup_packages.log 2>&1
if ! apt-get -q -y install "$i" >> /opt/scripts/setup_packages.log 2>&1; then
echo "Failed."
echo "For more details see \"/opt/scripts/setup_packages.log\"."
else
echo "Done."
fi
else
echo "$i is already installed."
fi
done
elif [[ "$1" == "-update" ]]; then
echo -n "Updating Linux packages on first run... " echo -n "Updating Linux packages on first run... "
apt-get -q update >> /opt/scripts/setup_packages.log 2>&1 apt-get -q update >> /opt/scripts/setup_packages.log 2>&1
return=$?
apt-get -q -y upgrade >> /opt/scripts/setup_packages.log 2>&1
return1=$? return1=$?
if [[ "$return" -ne 0 || "$return1" -ne 0 ]]; then apt-get -q -y upgrade >> /opt/scripts/setup_packages.log 2>&1
return2=$?
if [[ "$return1" -ne 0 || "$return2" -ne 0 ]]; then
echo "Failed." echo "Failed."
echo "For more details see \"/opt/scripts/setup_packages.log\"." echo "For more details see \"/opt/scripts/setup_packages.log\"."
echo "Make sure the container has internet access to get the latest package updates." echo "Make sure the container has internet access to get the latest package updates."