Compare commits

...

6 Commits

Author SHA1 Message Date
buanet
c0ea8c2808 first test of gui for maintenance script 2023-12-14 17:17:49 +01:00
buanet
d1bbbfff58 add js-controller version check to restore 2023-12-14 17:16:19 +01:00
André Germann
11e30fa638 Merge pull request #409 from buanet/dependabot/github_actions/beta/docker/build-push-action-5.1.0
Bump docker/build-push-action from 5.0.0 to 5.1.0
2023-11-24 12:44:47 +01:00
André Germann
e5956c6faf Merge pull request #410 from buanet/dependabot/github_actions/beta/actions/github-script-7.0.1
Bump actions/github-script from 6.4.1 to 7.0.1
2023-11-24 12:44:31 +01:00
dependabot[bot]
feb02a7a33 Bump actions/github-script from 6.4.1 to 7.0.1
Bumps [actions/github-script](https://github.com/actions/github-script) from 6.4.1 to 7.0.1.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v6.4.1...v7.0.1)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-24 10:00:42 +00:00
dependabot[bot]
3f3cfdb077 Bump docker/build-push-action from 5.0.0 to 5.1.0
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5.0.0 to 5.1.0.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v5.0.0...v5.1.0)

---
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-11-24 10:00:35 +00:00
5 changed files with 106 additions and 15 deletions

View File

@@ -70,7 +70,7 @@ jobs:
password: ${{ secrets.PACKAGES_PASS }}
- name: Build and push Docker image
uses: docker/build-push-action@v5.0.0
uses: docker/build-push-action@v5.1.0
with:
context: ./debian12
file: ./debian12/Dockerfile
@@ -142,7 +142,7 @@ jobs:
password: ${{ secrets.PACKAGES_PASS }}
- name: Build and push Docker image
uses: docker/build-push-action@v5.0.0
uses: docker/build-push-action@v5.1.0
with:
context: ./debian12
file: ./debian12/Dockerfile
@@ -166,7 +166,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Delete images
uses: actions/github-script@v6.4.1
uses: actions/github-script@v7.0.1
with:
github-token: ${{ secrets.PACKAGES_PASS }}
script: |

View File

@@ -64,7 +64,7 @@ jobs:
password: ${{ secrets.PACKAGES_PASS }}
- name: Build and push Docker image
uses: docker/build-push-action@v5.0.0
uses: docker/build-push-action@v5.1.0
with:
context: ./debian12
file: ./debian12/Dockerfile
@@ -130,7 +130,7 @@ jobs:
password: ${{ secrets.PACKAGES_PASS }}
- name: Build and push Docker image
uses: docker/build-push-action@v5.0.0
uses: docker/build-push-action@v5.1.0
with:
context: ./debian12
file: ./debian12/Dockerfile
@@ -150,7 +150,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Delete images
uses: actions/github-script@v6.4.1
uses: actions/github-script@v7.0.1
with:
github-token: ${{ secrets.PACKAGES_PASS }}
script: |

View File

@@ -64,7 +64,7 @@ jobs:
password: ${{ secrets.PACKAGES_PASS }}
- name: Build and push Docker image
uses: docker/build-push-action@v5.0.0
uses: docker/build-push-action@v5.1.0
with:
context: ./debian12
file: ./debian12/Dockerfile
@@ -133,7 +133,7 @@ jobs:
password: ${{ secrets.DOCKER_PASS_IOB }}
- name: Build and push Docker image
uses: docker/build-push-action@v5.0.0
uses: docker/build-push-action@v5.1.0
with:
context: ./debian12
file: ./debian12/Dockerfile
@@ -156,7 +156,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Delete images
uses: actions/github-script@v6.4.1
uses: actions/github-script@v7.0.1
with:
github-token: ${{ secrets.PACKAGES_PASS }}
script: |

View File

@@ -223,7 +223,6 @@ restore_iobroker() {
# check autoconfirm
if [[ "$autoconfirm" != yes ]]; then
local reply
read -rp 'Do you want to continue [yes/no]? ' reply
if [[ "$reply" != y && "$reply" != Y && "$reply" != yes ]]; then
return 1
@@ -255,10 +254,11 @@ restore_iobroker() {
return 1
elif [[ $backup_count -eq 1 ]]; then
selected_backup=$(basename "${backup_files[0]}")
echo "There is one backup file in $backup_dir."
echo "Selected backup file is \"$selected_backup\"."
else
# more than one backup file found, ask user to select
echo "There is more than one backup file in $backup_dir."
echo "There are more than one backup file in \"$backup_dir\"."
echo ' '
echo "Please select file for restore:"
for ((i=0; i<$backup_count; i++)); do
echo "$i: $(basename "${backup_files[$i]}")"
@@ -267,10 +267,69 @@ restore_iobroker() {
read -rp "Enter the number of the backup to restore (0-$((backup_count - 1))): " selected_number
selected_backup=$(basename "${backup_files[$selected_number]}")
echo ' '
echo "Selected backup file is \"$selected_backup\"."
echo ' '
fi
# restoe backup
echo -n "Restoring ioBroker from $selected_backup... "
# extract backup.json from backup
tar -xvzf $backup_dir/$selected_backup -C $backup_dir --strip-components=1 "backup/backup.json" > /dev/null 2>&1
# write js-controller versions from backup.json into array
jq_output=$(jq --arg TITLE "JS controller" -r '.objects[] | select(.value.common.title == $TITLE)' $backup_dir/backup.json)
# remove backup.json
rm $backup_dir/backup.json
result=()
while read -r line; do
entry=$(echo "$line" | jq -r '.value.common.installedVersion')
result+=("$entry")
done <<< "$(echo "$jq_output" | jq -c '.')"
# check for empty array
if [[ "${#result[@]}" -eq 0 ]]; then
echo "There was a problem detecting the js-controller version in the seclected backup file."
return 1
else
# check if all found js-controller versions are equal (for multihost systems!)
first_version=${result[0]}
all_versions_equal=true
for i in "${result[@]}"; do
version=$i
if [[ "$version" != "$first_version" ]]; then
all_versions_equal=false
break
fi
done
if [[ "$all_versions_equal" != true ]]; then
echo "Detected different js-controller versions in the selected backup file."
return 1
fi
fi
# compare installed js-controller version with version from backup file
echo -n "Checking js-controller versions... "
installed_version=$(iob version js-controller)
echo "Done."
echo ' '
echo "Installed js-controller version: $installed_version"
echo "Backup js-controller version: $first_version"
echo ' '
if [[ "$first_version" != "$installed_version" ]]; then
echo "The installed js-controller version is different from the version in the selected backup file."
echo "If you continue, the script will use the \"--force\" option to restore your backup."
echo "Although this is normally safe with small version differences, you should know,"
echo "that the recommended way is to first install the same js-controller version before restoring the backup file."
local reply
read -rp 'Do you want to continue [yes/no]? ' reply
if [[ "$reply" != y && "$reply" != Y && "$reply" != yes ]]; then
return 1
fi
fi
echo -n "Restoring ioBroker from \"$selected_backup\"... "
set +e
bash iobroker restore "$selected_backup" --force > /opt/iobroker/log/restore.log 2>&1
return_value=$?

View File

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
welcome () {
whiptail --title "ioBroker Docker Container Maintenance Script" --ok-button "OK" --msgbox " \
╔═══════════════════════════════════════════════════════════════════════╗\
\n ║ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ███████╗ ██████╗ ║\
\n ║ ██║ ██╔═══██╗ ██╔══██╗ ██╔══██╗ ██╔═══██╗ ██║ ██╔╝ ██╔════╝ ██╔══██╗ ║\
\n ║ ██║ ██║ ██║ ██████╔╝ ██████╔╝ ██║ ██║ █████╔╝ █████╗ ██████╔╝ ║\
\n ║ ██║ ██║ ██║ ██╔══██╗ ██╔══██╗ ██║ ██║ ██╔═██╗ ██╔══╝ ██╔══██╗ ║\
\n ║ ██║ ╚██████╔╝ ██████╔╝ ██║ ██║ ╚██████╔╝ ██║ ██╗ ███████╗ ██║ ██║ ║\
\n ║ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ║\
\n ╚═══════════════════════════════════════════════════════════════════════╝\
\n This script will help you to maintain your ioBroker Docker container!\
\n" 19 79
}
if welcome; then
TO_RUN=$(whiptail --title "ioBroker Docker Container Maintenance Script" --menu "What do you want to do?" 25 78 5 \
"maintenance" "Turn Maintenance Mode on or off" \
"upgrade" "Upgrade js-controller" \
"restore" "Restore ioBroker from backup" 3>&1 1>&2 2>&3)
else
exit 0
fi
if [[ $TO_RUN = "maintenance" ]]; then
echo "You selected maintenance"
elif [[ $TO_RUN = "upgrade" ]]; then
echo "You selected upgrade"
elif [[ $TO_RUN = "restore" ]]; then
echo "You selected restore"
fi