Skip to content

Commit

Permalink
add useful scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Akira25 committed Oct 21, 2021
1 parent 3cff630 commit 4986706
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
5 changes: 5 additions & 0 deletions IMPORTANT_README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The files in this directory aren't in git and shouldn't be added to
it. They are symbolic links to their counterparts in the www/-dir.

In that way, we can preserve campability with the upstream repo, but
deploy falter-selector at its normal web-address.
62 changes: 62 additions & 0 deletions get_profiles_local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#! /usr/bin/python3

"""Fetch the profiles from buildbot-unstable-dir
and feed them into the firmware-selector """

import requests
import shutil
import time
import sys
import os
import re


def find_subdirs(url, regex):
r = requests.get(url)
subdirs = re.findall(regex, r.text)
return subdirs

try:
print("fetching data from " + sys.argv[2])
except:
print("Usage:\n\t./get_profiles_from [URL]\n\nPlease give an URL to the buildbot-dir.")
print("Example:\n\t./get_profiles_from http://buildbot.berlin.freifunk.net/buildbot/unstable/2020-12-19/")
exit(1)

image_types = find_subdirs(sys.argv[1], "\"(\w*\/)\"")
#print(image_types)

profiles_root = sys.argv[1].split(sep='/')[-2]
try:
os.mkdir(profiles_root)
except:
shutil.rmtree(profiles_root)
os.mkdir(profiles_root)

for itype in image_types:
link = sys.argv[1] + itype

# write stuff into own directory
try:
os.mkdir(itype)
except:
shutil.rmtree(itype)
os.mkdir(itype)

os.mkdir(itype+"www/")
os.system("touch "+itype+"www/config.js")

command = "./misc/collect.py --image-url '"+link+"{target}' "+sys.argv[2]+" "+itype+"www/"
os.system(command)

src_dir = [f.path for f in os.scandir(itype+"www/data/") if f.is_dir()][0]
dirs_to_move = [f.path for f in os.scandir(src_dir)]


# move dirs to first hirachy-step
for fd in dirs_to_move:
shutil.move(fd, itype)
shutil.rmtree(itype+"www/")

shutil.move(itype, profiles_root)

10 changes: 10 additions & 0 deletions get_profiles_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This script regularily updates the overview-files for the firmware-selector by pulling
# the snapshot images from the buildbor-dir. It gets called by a cronjob.

REALPATH_SCRIPT=$(realpath "$0")
SCRIPT_DIR=$(dirname "$REALPATH_SCRIPT")
cd $SCRIPT_DIR

for DIR in $(ls /usr/local/src/www/htdocs/buildbot/unstable/ | grep snapshot); do
./get_profiles_local.py "https://firmware.berlin.freifunk.net/unstable/$DIR/" /usr/local/src/www/htdocs/buildbot/unstable/$DIR/
done
7 changes: 7 additions & 0 deletions link_www.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# link every file in www-folder to this folder

for FILE in $(ls www/); do
ln -s www/$FILE $FILE
done

0 comments on commit 4986706

Please sign in to comment.