Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions scripts/beamup-entry
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,19 @@ then

if [ "$1" = "logs" ];
then
# Pass all arguments after $2 to be parsed and sanitized later
shift 2
ARGS="$@"

# Validate that ARGS only contains allowed characters
if [[ "$ARGS" =~ [^a-zA-Z0-9-=\s] ]]; then
send_git_error "Invalid arguments: $ARGS"
exit 1
fi

case "$APP_NAME" in
${GITHUB_USER_HASHED}-*) ssh -T -i /home/dokku/.ssh/id_ed25519_sync beamup@stremio-beamup-swarm-0 $1 $APP_NAME;;
*) exit 1 ;;
${GITHUB_USER_HASHED}-*) ssh -T -i /home/dokku/.ssh/id_ed25519_sync beamup@stremio-beamup-swarm-0 $1 $APP_NAME $ARGS;;
*) exit 1 ;;
esac
else
case "$APP_NAME" in
Expand Down
42 changes: 41 additions & 1 deletion scripts/beamup-swarm-entry
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,47 @@ set -e

case "$1" in
logs)
docker service logs -n 100 -t --no-task-ids --no-resolve beamup_"$2" | awk '{$2=""; print $0}'
for i in "$@"; do
case $i in
-f*|--follow*)
FOLLOW=YES
shift # past argument with no value
;;
-n=*|--tail=*)
TAIL="${i#*=}"
shift # past argument=value
;;
-t*|--timestamps*)
TIMESTAMPS=YES
shift
;;
--since=*)
SINCE="${i#*=}"
shift
;;
--until=*)
UNTIL="${i#*=}"
shift
;;
-*|--*)
echo "Unknown option $i"
exit 1
;;
*)
;;
esac
done
PARAM=""
if [ -n "$TAIL" ]; then
PARAM="$PARAM --tail=$TAIL"
else
PARAM="$PARAM --tail=100"
fi
[ "$FOLLOW" = "YES" ] && PARAM="$PARAM -f"
[ "$TIMESTAMPS" = "YES" ] && PARAM="$PARAM -t"
[ -n "$SINCE" ] && PARAM="$PARAM --since=$SINCE"
[ -n "$UNTIL" ] && PARAM="$PARAM --until=$UNTIL"
docker service logs $PARAM --no-task-ids --no-resolve beamup_"$2" | awk '{$2=""; print $0}'
;;
sync)
/home/beamup/beamup-sync-swarm.sh
Expand Down
1 change: 1 addition & 0 deletions scripts/beamup-sync-keys
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async function getNewAuthKeysContent() {

getNewAuthKeysContent()
.then(content => writeFile(AUTH_KEYS_PATH, content))
.then(() => {console.log(`Updated SSH keys for GitHub user ${GITHUB_USER}`)})
.catch(e => {
console.error(`Encountered error, quitting`)
console.error(e)
Expand Down