forked from RPi-Distro/pi-gen
-
Notifications
You must be signed in to change notification settings - Fork 0
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
8 changed files
with
88 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
IMG_NAME="rasppi-os" | ||
STAGE_LIST=${STAGE_LIST:-"stage0 stage1 stage2 stage99-sth"} | ||
|
||
WORK_PARTITION_SIZE=16384 | ||
DEPLOY_PARTITION_SIZE=8192 | ||
WORK_PARTITION_SIZE=8192 | ||
DEPLOY_PARTITION_SIZE=1024 | ||
|
||
DEPLOY_COMPRESSION=none |
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
|
||
on_chroot << EOF | ||
npm i -g @scramjet/sth | ||
pip install pyee==9.0.4 scramjet-framework-py | ||
EOF |
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 |
---|---|---|
@@ -1,18 +1,78 @@ | ||
#!/bin/bash | ||
|
||
DEPLOY_PATH=/opt/sth/deploy | ||
WORK_PATH=/srv/sth | ||
CONFIG_LOCATION=/etc/sth/sth-config.json | ||
DEPLOY_CONFIG_LOCATION="${DEPLOY_PATH}/conf/sth-config.json" | ||
RUNTIME_CONFIG_LOCATION="${WORK_PATH}/sth-config.json" | ||
|
||
if [[ -e "${DEPLOY_CONFIG_LOCATION}" ]]; then | ||
jq -s '.[0] * .[1]' "${CONFIG_LOCATION}" "${DEPLOY_CONFIG_LOCATION}" | ||
else | ||
cp "${CONFIG_LOCATION}" "${RUNTIME_CONFIG_LOCATION}" | ||
. /etc/sth/sth-config | ||
|
||
shopt -s extglob | ||
|
||
findfirstconf () { | ||
TARGET=$1 | ||
for FILE in "${TARGET%%/}".{json,yaml,yml}; do | ||
[[ -e "$FILE" ]] && echo $FILE && break; | ||
done | ||
} | ||
|
||
findsequences() { | ||
TARGET=$1 | ||
for FILE in "${TARGET%%/}"/*.{tgz,tar.gz}; do | ||
[[ -e "$FILE" ]] && echo $FILE | ||
done | ||
} | ||
|
||
settargetname () { | ||
BASE=$(basename "$1") | ||
TARGET=$2 | ||
|
||
echo ${TARGET%%/}/$BASE | ||
} | ||
|
||
DEPLOY_CONFIG_LOCATION=$(findfirstconf "${DEPLOY_PATH}/conf/sth-config") | ||
HAS_SEQUENCES=0 | ||
EXTRA_OPTS=("--no-colors" "-D" "$WORK_PATH/sequences") | ||
|
||
if [[ -n "${DEPLOY_CONFIG_LOCATION}" ]]; then | ||
RUNTIME_CONFIG_LOCATION=$(settargetname "$DEPLOY_CONFIG_LOCATION" "$WORK_PATH") | ||
cp "${DEPLOY_CONFIG_LOCATION}" "${RUNTIME_CONFIG_LOCATION}" | ||
EXTRA_OPTS+=("--config=${RUNTIME_CONFIG_LOCATION}") | ||
|
||
echo "Using STH config from ${DEPLOY_CONFIG_LOCATION}" | logger -e | ||
fi | ||
|
||
if [[ -e "${DEPLOY_PATH}/conf/purge.txt" ]]; then | ||
echo "Purging all sequences" | logger -e | ||
rm -rf "$WORK_PATH/sequences" | ||
mkdir "$WORK_PATH/sequences" | ||
fi | ||
|
||
SEQUENCES="$(findsequences ${DEPLOY_PATH}/sequences/)" | ||
if [[ -n "$SEQUENCES" ]]; then | ||
function unpack() { | ||
PACKAGE=$1 | ||
TARGET=$2 | ||
|
||
mkdir -p "$TARGET" | ||
tar -C "$TARGET" -zxf "$PACKAGE" | ||
} | ||
|
||
STARTUP_CONFIG=$(findfirstconf "${DEPLOY_PATH}/conf/startup-config") | ||
if [[ -n "${STARTUP_CONFIG}" ]]; then | ||
RUNTIME_CONFIG_LOCATION=$(settargetname "$STARTUP_CONFIG" "$WORK_PATH") | ||
cp "${STARTUP_CONFIG}" "${RUNTIME_CONFIG_LOCATION}" | ||
EXTRA_OPTS+=("--startup-config=${RUNTIME_CONFIG_LOCATION}") | ||
|
||
echo "Using startup config from ${DEPLOY_CONFIG_LOCATION}" | logger -e | ||
fi | ||
|
||
sth --config="${RUNTIME_CONFIG_LOCATION}" 2>&1 | logger -e | ||
|
||
for SEQ_FILE in "$(findsequences ${DEPLOY_PATH}/sequences/)"; do | ||
BASENAME=`basename "${SEQ_FILE}"` | ||
TARGET="${BASENAME%.@(tar.gz|tgz)}" | ||
|
||
echo "Unpacking sequence '${BASENAME}' to '$WORK_PATH/sequences/$TARGET'" | logger -e | ||
unpack "$SEQ_FILE" "$WORK_PATH/sequences/$TARGET" | ||
|
||
EXTRA_OPTS+=("-E") | ||
done | ||
fi | ||
|
||
echo Running STH with opts: "${EXTRA_OPTS[@]}" | ||
sth "${EXTRA_OPTS[@]}" 2>&1 | logger -e |
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,4 @@ | ||
LOGCOLORS="--no-colors" | ||
SEQUENCES_ROOT="/srv/sth/sequences" | ||
DEPLOY_PATH=/opt/sth/deploy | ||
WORK_PATH=/srv/sth |
3 changes: 3 additions & 0 deletions
3
...etup-systemd/files/sth-deploy-config.json → ...etup-systemd/files/sth-config-deploy.json
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"host": { | ||
"id": "mini-pi-1" | ||
}, | ||
"safeOperationLimit": 64, | ||
"instanceRequirements": { | ||
"freeMem": 128 | ||
|
This file was deleted.
Oops, something went wrong.