2 Commits

Author SHA1 Message Date
4682664bf0 Update URL to GitHub raw content and bump version to 2.0.3
Replaced API URLs with GitHub raw content URLs for installation and updates to ensure reliability and consistency. Incremented the program version from 2.0.2 to 2.0.3 to reflect the changes.
2025-03-24 09:58:03 +02:00
1afeb7c5fa Update version to 2.0.2 and improve repository token handling
Bump the program version from 2.0.1 to 2.0.2. Enhance the repository token and API handling by allowing repository-specific [.api] and [.token] values to override global settings, with a fallback mechanism for global values. Added more comprehensive comments to clarify the override logic.
2024-10-07 18:18:11 +02:00
2 changed files with 16 additions and 9 deletions

View File

@ -8,7 +8,7 @@ With this script we can easily package multiple power classes in an automated wa
---
# Install
```shell
$ sudo curl -L "https://git.vdm.dev/api/v1/repos/octoleo/octopower/raw/src/octopower" -o /usr/local/bin/octopower
$ sudo curl -L "https://raw.githubusercontent.com/octoleo/octopower/refs/heads/master/src/octopower" -o /usr/local/bin/octopower
$ sudo chmod +x /usr/local/bin/octopower
```
---

View File

@ -3,7 +3,7 @@
# Program name
PROGRAM_NAME="OctoPower"
PROGRAM_CODE="octopower"
PROGRAM_VERSION="2.0.1"
PROGRAM_VERSION="2.0.3"
PROGRAM_V="2.0"
PROGRAM_URL="https://git.vdm.dev/octoleo/${PROGRAM_CODE}"
@ -710,12 +710,19 @@ command -v sed >/dev/null 2>&1 || {
setValueFromJson 'VDM_BRANCH' '.branch' "${repository}" || VDM_BRANCH="default"
setValueFromJson 'VDM_API_NAME' '.api_name' "${repository}" || VDM_API_NAME="VDM_GLOBAL_API"
setValueFromJson 'VDM_TOKEN_NAME' '.token_name' "${repository}" || VDM_TOKEN_NAME="VDM_GLOBAL_TOKEN"
# Now check if the repository has its own `.api` and `.token` values
# If present, override the global values
if setValueFromJson 'VDM_API' '.api' "${repository}"; then
setValueFromJson 'VDM_TOKEN' '.token' "${repository}" || VDM_TOKEN=''
else
# set the package (api/toke)
tmp_api=${!VDM_API_NAME}
tmp_token=${!VDM_TOKEN_NAME}
# allow direct overriding (api/toke)
# allow direct overriding (api)
getConfigValue 'VDM_API' '.repository.api' false || VDM_API="${tmp_api}"
# allow direct overriding (toke)
getConfigValue 'VDM_TOKEN' '.repository.token' false || VDM_TOKEN="${tmp_token}"
fi
# check if we have some errors already
if $has_error; then
clearFileEnv
@ -1778,7 +1785,7 @@ command -v sed >/dev/null 2>&1 || {
sudo mv "/usr/local/bin/${PROGRAM_CODE}" "/usr/local/bin/${PROGRAM_CODE}.bak"
fi
# pull the latest version. Master is always the latest
if sudo curl --fail -L "https://git.vdm.dev/api/v1/repos/octoleo/${PROGRAM_CODE}/raw/src/${PROGRAM_CODE}?ref=${branch:-master}" -o "/usr/local/bin/${PROGRAM_CODE}" 2>/dev/null; then
if sudo curl --fail -L "https://raw.githubusercontent.com/octoleo/${PROGRAM_CODE}/refs/heads/${branch:-master}/src/${PROGRAM_CODE}" -o "/usr/local/bin/${PROGRAM_CODE}" 2>/dev/null; then
# give success message
echo "[success] Update was successful."
# do we have a backup