successfull deployment on test system

pull/86/head
Moritz Kempe 2023-06-25 21:41:18 +02:00
parent 79d8daf77c
commit f594a82881
2 changed files with 27 additions and 11 deletions

View File

@ -16,8 +16,6 @@ BRANCH=${BRANCH="main"}
HUGO_CMD=${HUGO_CMD="hugo"}
WWWDIR=${WWWDIR="/var/www/www"}
SPACEAPI_SCRIPT=${SPACEAPI_SCRIPT="python3" "$CLONE_DIR""/spaceapi.py" "$CLONE_DIR"}
# bugs ahead
# delete repo if it is already there
@ -93,7 +91,7 @@ latest_remote_sha () {
# do the build
build_page() {
# sync logo with spaceapi
"$SPACEAPI_SCRIPT"
"python3" "$CLONE_DIR""/spaceapi.py" "$CLONE_DIR"
TMPDIR=$(mktemp -d -t hugo_build_XXXXX)

34
spaceapi.py Normal file → Executable file
View File

@ -9,20 +9,36 @@ import sys
path: str = sys.argv[1]
api: str = "https://api.dezentrale.cloud/spaceapi/v14"
space_open: str = path + "/logo_open"
space_closed: str = path + "/logo_closed"
space_unknown: str = path + "/logo_unknown"
space_logo: str = path + "/logo"
space_open: str = path + "/assets/logo_open"
space_closed: str = path + "/assets/logo_closed"
space_unknown: str = path + "/assets/logo_unknown"
space_logo: str = path + "/assets/logo"
extensions: list[str] = [".png", ".svg"]
# every extension needs to be linked
def link(src: str, dest: str):
for ext in extensions:
os.symlink(src + ext, dest + ext)
try:
os.symlink(src + ext, dest + ext)
print("linked " + dest + ext + " to " + src + ext)
except:
print("cannot link " + dest + ext + " to " + src + ext)
def delete(file: str):
for ext in extensions:
try:
os.remove(file + ext)
print("deleted " + file + ext)
except:
try:
os.unlink(file + ext)
print("unlinked "+ file + ext)
except:
print(file + ext + " is already deleted and unlinked")
if __name__ == "__main__":
os.remove(space_logo)
delete(space_logo)
try:
resp: requests.Response = requests.get(api)
resp_dict: dict = resp.json()
@ -35,6 +51,8 @@ if __name__ == "__main__":
path = space_open
else:
path = space_closed
os.symlink(space_logo, path)
# the linking seems to be the wrong way around, but it links correct
# the link is pointing from dest to src (https://docs.python.org/3/library/os.html)
link(path, space_logo)
except:
os.symlink(space_logo, space_unknown)
link(space_unknown, space_logo)