Merge branch 'feat/quick-updates' into feat/quick-updates-c-ln

This commit is contained in:
AaronDewes 2022-07-12 05:36:07 +00:00
commit d907bd63c6
9 changed files with 66 additions and 28 deletions

View File

@ -3,9 +3,9 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# A collection of fully FLOSS app definitions and FLOSS apps for Citadel.
https://github.com/runcitadel/apps v3-stable
https://github.com/runcitadel/apps v4-dev
# Some apps modified version of Umbrel apps, and their app definitions aren't FLOSS yet.
# Include them anyway, but as a separate repo.
# Add a # to the line below to disable the repo and only use FLOSS apps.
https://github.com/runcitadel/apps-nonfree v3-stable
https://github.com/runcitadel/apps-nonfree v3-beta

View File

@ -123,8 +123,8 @@ def getAppYml(name):
print("Warning: App {} is not in the source map".format(name), file=sys.stderr)
sourceMap = {
name: {
"githubRepo": "runcitadel/core",
"branch": "c-lightning-v3"
"githubRepo": "runcitadel/apps",
"branch": "v4-dev"
}
}
url = 'https://raw.githubusercontent.com/{}/{}/apps/{}/app.yml'.format(sourceMap[name]["githubRepo"], sourceMap[name]["branch"], name)
@ -144,6 +144,7 @@ def update(verbose: bool = False):
json.dump(registry["ports"], f, sort_keys=True)
print("Wrote registry to registry.json")
os.system("docker pull {}".format(dependencies['app-cli']))
threads = list()
# Loop through the apps and generate valid compose files from them, then put these into the app dir
for app in apps:
@ -187,22 +188,29 @@ def getUserData():
userData = json.load(f)
return userData
def checkUpdateAvailable(name: str) -> bool:
def checkUpdateAvailable(name: str):
latestAppYml = yaml.safe_load(getAppYml(name))
with open(os.path.join(appsDir, name, "app.yml"), "r") as f:
originalAppYml = yaml.safe_load(f)
if not "metadata" in latestAppYml or not "version" in latestAppYml["metadata"] or not "metadata" in originalAppYml or not "version" in originalAppYml["metadata"]:
print("App {} is not valid".format(name), file=sys.stderr)
return False
return semver.compare(latestAppYml["metadata"]["version"], originalAppYml["metadata"]["version"]) > 0
if semver.compare(latestAppYml["metadata"]["version"], originalAppYml["metadata"]["version"]) > 0:
return {
"updateFrom": originalAppYml["metadata"]["version"],
"updateTo": latestAppYml["metadata"]["version"]
}
else:
return False
def getAvailableUpdates():
availableUpdates = []
availableUpdates = {}
apps = findAndValidateApps(appsDir)
for app in apps:
try:
if checkUpdateAvailable(app):
availableUpdates.append(app)
checkResult = checkUpdateAvailable(app)
if checkResult:
availableUpdates[app] = checkResult
except Exception:
print("Warning: Can't check app {} yet".format(app), file=sys.stderr)
return availableUpdates
@ -256,6 +264,7 @@ def getApp(app, appId: str):
print("Warning: App {} uses version 2 of the app.yml format, which is scheduled for removal in Citadel 0.2.0".format(appId))
return createComposeConfigFromV2(app, nodeRoot)
elif 'version' in app and str(app['version']) == "3":
print("Warning: App {} uses version 3 of the app.yml format, which is scheduled for removal in Citadel 0.3.0".format(appId))
return createComposeConfigFromV3(app, nodeRoot)
else:
raise Exception("Error: Unsupported version of app.yml")

View File

@ -64,14 +64,17 @@ def findApps(dir: str):
def findAndValidateApps(dir: str):
apps = []
app_data = {}
for root, dirs, files in os.walk(dir, topdown=False):
for name in dirs:
app_dir = os.path.join(root, name)
if os.path.isfile(os.path.join(app_dir, "app.yml")):
apps.append(name)
# Read the app.yml and append it to app_data
with open(os.path.join(app_dir, "app.yml"), 'r') as f:
app_data[name] = yaml.safe_load(f)
for subdir in os.scandir(dir):
if not subdir.is_dir():
continue
app_dir = subdir.path
if os.path.isfile(os.path.join(app_dir, "app.yml")):
apps.append(subdir.name)
# Read the app.yml and append it to app_data
with open(os.path.join(app_dir, "app.yml"), 'r') as f:
app_data[subdir.name] = yaml.safe_load(f)
else:
print("App {} has no app.yml".format(subdir.name))
# Now validate all the apps using the validateAppFile function by passing the app.yml as an argument to it, if an app is invalid, remove it from the list
for app in apps:
appyml = app_data[app]

View File

@ -1,7 +1,5 @@
compose: v2.6.0
bitcoin: 22.0
lnd: 0.14.3
dashboard: ghcr.io/runcitadel/dashboard:v0.0.15@sha256:a2cf5ad79367fb083db0f61e5a296aafee655c99af0c228680644c248ec674a5
manager: ghcr.io/runcitadel/manager:v0.0.15@sha256:9fb5a86d9e40a04f93d5b6110d43a0f9a5c4ad6311a843b5442290013196a5ce
dashboard: ghcr.io/runcitadel/dashboard:fix-small-issues-and-translations@sha256:82059a11e50d77eec8edb20a8c0e1f821988ea176b928944738df1a93304c26e
manager: ghcr.io/runcitadel/manager:v0.0.16@sha256:9de3acad76e957811ff7f81cdba8b9a280a79762d24e1bcd16a4517e5643dfca
middleware: ghcr.io/runcitadel/middleware:v0.0.11@sha256:e472da8cbfa67d9a9dbf321334fe65cdf20a0f9b6d6bab33fdf07210f54e7002
app-cli: ghcr.io/runcitadel/app-cli:main@sha256:f532923eac28cfac03579cbb440397bcf16c8730f291b39eeada8278331f7054

View File

@ -2,7 +2,7 @@ version: '3.8'
services:
tor:
container_name: tor
image: lncm/tor:0.4.7.7@sha256:3c4ae833d2fefbea7d960f833a1e89fc9b2069a6e5f360109b5ddc9334ac0227
image: lncm/tor:0.4.7.8@sha256:aab30ebb496aa25934d6096951d8b200347c3c3ce5db3493695229efa2601f7b
user: toruser
restart: on-failure
volumes:
@ -15,7 +15,7 @@ services:
ipv4_address: $TOR_PROXY_IP
app-tor:
container_name: app-tor
image: lncm/tor:0.4.7.7@sha256:3c4ae833d2fefbea7d960f833a1e89fc9b2069a6e5f360109b5ddc9334ac0227
image: lncm/tor:0.4.7.8@sha256:aab30ebb496aa25934d6096951d8b200347c3c3ce5db3493695229efa2601f7b
user: toruser
restart: on-failure
volumes:
@ -26,7 +26,7 @@ services:
ipv4_address: $APPS_TOR_IP
app-2-tor:
container_name: app-2-tor
image: lncm/tor:0.4.7.7@sha256:3c4ae833d2fefbea7d960f833a1e89fc9b2069a6e5f360109b5ddc9334ac0227
image: lncm/tor:0.4.7.8@sha256:aab30ebb496aa25934d6096951d8b200347c3c3ce5db3493695229efa2601f7b
user: toruser
restart: on-failure
volumes:
@ -37,7 +37,7 @@ services:
ipv4_address: $APPS_2_TOR_IP
app-3-tor:
container_name: app-3-tor
image: lncm/tor:0.4.7.7@sha256:3c4ae833d2fefbea7d960f833a1e89fc9b2069a6e5f360109b5ddc9334ac0227
image: lncm/tor:0.4.7.8@sha256:aab30ebb496aa25934d6096951d8b200347c3c3ce5db3493695229efa2601f7b
user: toruser
restart: on-failure
volumes:
@ -100,7 +100,7 @@ services:
ipv4_address: $LND_IP
dashboard:
container_name: dashboard
image: ghcr.io/runcitadel/dashboard:v0.0.15@sha256:a2cf5ad79367fb083db0f61e5a296aafee655c99af0c228680644c248ec674a5
image: ghcr.io/runcitadel/dashboard:fix-small-issues-and-translations@sha256:82059a11e50d77eec8edb20a8c0e1f821988ea176b928944738df1a93304c26e
restart: on-failure
stop_grace_period: 1m30s
networks:
@ -108,7 +108,7 @@ services:
ipv4_address: $DASHBOARD_IP
manager:
container_name: manager
image: ghcr.io/runcitadel/manager:v0.0.15@sha256:9fb5a86d9e40a04f93d5b6110d43a0f9a5c4ad6311a843b5442290013196a5ce
image: ghcr.io/runcitadel/manager:v0.0.16@sha256:9de3acad76e957811ff7f81cdba8b9a280a79762d24e1bcd16a4517e5643dfca
depends_on:
- tor
- redis
@ -241,6 +241,7 @@ services:
ipv4_address: $C_LIGHTNING_IP
redis:
container_name: redis
user: 1000:1000
image: redis:7.0.0-bullseye@sha256:ad0705f2e2344c4b642449e658ef4669753d6eb70228d46267685045bf932303
working_dir: /data
volumes:

25
events/triggers/quick-update Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2021-2022 Citadel and contributors
#
# SPDX-License-Identifier: GPL-3.0-or-later
CITADEL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/../..)"
RELEASE=$(cat "$CITADEL_ROOT"/statuses/update-status.json | jq .updateTo -r)
cat <<EOF > "$CITADEL_ROOT"/statuses/update-status.json
{"state": "installing", "progress": 30, "description": "Starting update", "updateTo": "$RELEASE"}
EOF
curl "https://raw.githubusercontent.com/runcitadel/core/${RELEASE}/db/dependencies.yml" > "$CITADEL_ROOT"/db/dependencies
cat <<EOF > "$CITADEL_ROOT"/statuses/update-status.json
{"state": "installing", "progress": 70, "description": "Starting new containers", "updateTo": "$RELEASE"}
EOF
"${CITADEL_ROOT}/scripts/start"
cat <<EOF > "$CITADEL_ROOT"/statuses/update-status.json
{"state": "success", "progress": 100, "description": "Successfully installed Citadel $RELEASE", "updateTo": ""}
EOF

View File

@ -7,3 +7,4 @@
CITADEL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/../..)"
"${CITADEL_ROOT}/scripts/set-update-channel" "${1}"
"${CITADEL_ROOT}/scripts/start"

View File

@ -2,5 +2,6 @@
"version": "0.0.5",
"name": "Citadel 0.0.5",
"requires": ">=0.0.1",
"isQuickUpdate": false,
"notes": "This update fixes a few bugs in the 0.0.4 release that were preventing some apps from working correctly."
}

View File

@ -10,7 +10,7 @@ NODE_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)"
# If $1 is not given, fail
if [ -z "$1" ]; then
echo "Usage: $0 <channel>"
echo "Channel can currently either be 'stable' or 'beta'"
echo "Channel can currently either be 'stable', 'beta' or 'c-lightning'"
exit 1
fi
sed -i "s/UPDATE_CHANNEL=.*/UPDATE_CHANNEL=${1}/" "${NODE_ROOT}/.env"