-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
240 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
RUN_ID=$1 | ||
|
||
if [ -z "$RUN_ID" ]; then | ||
>&2 echo usage: $0 '<run-id>' | ||
exit 1 | ||
fi | ||
|
||
TMP_DIR=/var/tmp/action-run-results/$RUN_ID | ||
|
||
rm -rf $TMP_DIR | ||
mkdir -p $TMP_DIR | ||
|
||
cd $TMP_DIR | ||
|
||
for arch in x86_64 x86_64-nonfree aarch64 aarch64-nonfree raspberrypi; do | ||
gh run download -R Start9Labs/start-os $RUN_ID -n $arch.squashfs | ||
done | ||
|
||
VERSION= | ||
HASH= | ||
for file in $(ls *.squashfs); do | ||
if [[ $file =~ ^startos-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)-([a-f0-9]{7}(~[a-z-]+)?|unknown)_([a-z0-9_-]+).squashfs$ ]]; then | ||
if [ -n "$VERSION" ] && [ "$VERSION" != "${BASH_REMATCH[1]}" ]; then | ||
>&2 echo "VERSION MISMATCH: expected $VERSION got ${BASH_REMATCH[1]}" | ||
exit 2 | ||
fi | ||
if [ -n "$HASH" ] && [ "$HASH" != "${BASH_REMATCH[3]}" ]; then | ||
>&2 echo "HASH MISMATCH: expected $HASH got ${BASH_REMATCH[3]}" | ||
exit 3 | ||
fi | ||
VERSION="${BASH_REMATCH[1]}" | ||
HASH="${BASH_REMATCH[3]}" | ||
fi | ||
done | ||
|
||
mkdir -p /root/resources/eos/$VERSION | ||
rm -rf /root/resources/eos/$VERSION/$HASH | ||
mv $TMP_DIR /root/resources/eos/$VERSION/$HASH | ||
|
||
cd /root/resources/eos/$VERSION | ||
setOsCommitHash $HASH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
declare -A params | ||
while IFS='=' read -r -d '&' key value && [[ -n "$key" ]]; do | ||
params["$key"]=$value | ||
done <<<"${QUERY_STRING}&" | ||
|
||
index_key="${params['key']}" | ||
if [ -z "$index_key" ] || [ "$index_key" != "$(cat /var/www/index_key.txt)" ]; then | ||
echo "HTTP/1.1 401 UNAUTHORIZED" | ||
echo "Content-Type: text/html" | ||
echo | ||
echo "UNAUTHORIZED" | ||
exit | ||
fi | ||
|
||
touch /tmp/resync | ||
|
||
echo "HTTP/1.1 200 OK" | ||
echo "Content-Type: text/html" | ||
echo | ||
echo "OK: Upload successful" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# Get the current directory | ||
PWD=$(pwd) | ||
HASH=$1 | ||
|
||
if [ -z "$HASH" ]; then | ||
>&2 echo "usage: setOsCommitHash <hash>" | ||
exit 1 | ||
fi | ||
|
||
# Define the expected pattern for the directory | ||
pattern="/root/resources/eos/" | ||
|
||
# Check if the current directory matches the pattern | ||
if [[ $PWD =~ ^$pattern([0-9.]+)$ ]]; then | ||
# Extract the version number from the directory path | ||
version="${BASH_REMATCH[1]}" | ||
else | ||
>&2 echo "MUST BE IN OS VERSION DIRECTORY" | ||
exit 1 | ||
fi | ||
|
||
if ! [ -d "$HASH" ]; then | ||
>&2 echo "$HASH: No such directory" | ||
exit 1 | ||
fi | ||
|
||
for file in $(ls $HASH/startos-$version-${HASH}_*.squashfs); do | ||
if [[ $file =~ ^$HASH/startos-$version-${HASH}_([a-z0-9_-]+).squashfs$ ]]; then | ||
arch="${BASH_REMATCH[1]}" | ||
echo "Found arch $arch" | ||
umount /srv/rsync/$version/$arch | ||
rm eos.$arch.squashfs | ||
ln -s $file eos.$arch.squashfs | ||
fi | ||
done | ||
|
||
resyncRsyncRegistry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
declare -A params | ||
while IFS='=' read -r -d '&' key value && [[ -n "$key" ]]; do | ||
params["$key"]=$value | ||
done <<<"${QUERY_STRING}&" | ||
|
||
index_key="${params['key']}" | ||
if [ -z "$index_key" ] || [ "$index_key" != "$(cat /var/www/index_key.txt)" ]; then | ||
echo "HTTP/1.1 401 UNAUTHORIZED" | ||
echo "Content-Type: text/html" | ||
echo | ||
echo "UNAUTHORIZED" | ||
exit | ||
fi | ||
|
||
git_hash="${params['gitHash']}" | ||
version="${params['version']}" | ||
platform="${params['platform']}" | ||
shasum="${params['shasum']}" | ||
if [ -z "$git_hash" ] || [ -z "$version" ] || [ -z "$platform" ] || [ -z "$shasum" ]; then | ||
echo "HTTP/1.1 400 BAD REQUEST" | ||
echo "Content-Type: text/html" | ||
echo | ||
echo "BAD REQUEST: missing param" | ||
exit | ||
fi | ||
|
||
tmp_file=$(mktemp /var/tmp/tmp.XXXXXXXXXX.squashfs) | ||
cat > $tmp_file | ||
|
||
if ! sha256sum $tmp_file | grep "$shasum"; then | ||
rm $tmp_file | ||
echo "HTTP/1.1 400 BAD REQUEST" | ||
echo "Content-Type: text/html" | ||
echo | ||
echo "BAD REQUEST: shasum mismatch" | ||
fi | ||
|
||
mkdir -p /var/www/resources/eos/${version}/${git_hash} | ||
mv $tmp_file /var/www/resources/eos/${version}/${git_hash}/startos-${version}-${git_hash}_${platform}.squashfs | ||
rm /var/www/resources/eos/${version}/eos.${platform}.squashfs | ||
ln -rs /var/www/resources/eos/${version}/${git_hash}/startos-${version}-${git_hash}_${platform}.squashfs /var/www/resources/eos/${version}/eos.${platform}.squashfs | ||
|
||
echo "HTTP/1.1 200 OK" | ||
echo "Content-Type: text/html" | ||
echo | ||
echo "OK: Upload successful" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
cd "$(dirname "${BASH_SOURCE[0]}")" | ||
|
||
if [ -z "$TARGET" ]; then | ||
>&2 echo "TARGET is required" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$KEY" ]; then | ||
>&2 echo "KEY is required" | ||
exit 1 | ||
fi | ||
|
||
PLATFORM="$(cat ./PLATFORM.txt)" | ||
VERSION="$(cat ./VERSION.txt)" | ||
GIT_HASH="$(cat ./GIT_HASH.txt)" | ||
if [[ "$GIT_HASH" =~ ^@ ]]; then | ||
GIT_HASH=unknown | ||
else | ||
GIT_HASH="$(echo -n "$GIT_HASH" | head -c 7)" | ||
fi | ||
STARTOS_ENV="$(cat ./ENVIRONMENT.txt)" | ||
if [ -n "$STARTOS_ENV" ]; then | ||
GIT_HASH="$GIT_HASH~${STARTOS_ENV}" | ||
fi | ||
|
||
BASENAME="startos-${VERSION}-${GIT_HASH}_${PLATFORM}" | ||
|
||
SHASUM=$(sha256sum results/$BASENAME.squashfs | awk '{print $1}') | ||
|
||
curl -T results/$(BASENAME).squashfs "https://${TARGET}:8443/upload.cgi?key=${KEY}&gitHash=${GIT_HASH}&version=${VERSION}&platform=${PLATFORM}&shasum=${SHASUM}" |