From bf91a66fec9b624458eb959bd95ea60b472b59f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Fri, 22 Dec 2023 10:03:05 -0300 Subject: [PATCH] core: tools: scripts: red-pill: Add option to select user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- core/tools/scripts/red-pill | 41 ++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/core/tools/scripts/red-pill b/core/tools/scripts/red-pill index 997bd2996e..3097f29866 100755 --- a/core/tools/scripts/red-pill +++ b/core/tools/scripts/red-pill @@ -1,5 +1,44 @@ +#!/bin/bash + +usage() { + echo "Usage: $0 [-h] [-u user]" + echo + echo " -h, Show this help message" + echo " -u, Define a user (default: pi)" + exit 1 +} + +# Default values +user="pi" + +while getopts ":hu:" opt; do + case ${opt} in + h ) + usage + ;; + u ) + user=$OPTARG + ;; + \? ) + echo "Invalid Option: -$OPTARG" 1>&2 + usage + ;; + : ) + echo "Invalid Option: -$OPTARG requires an argument" 1>&2 + usage + ;; + esac +done +shift $((OPTIND -1)) + +# Don't simply ignore additional arguments +if [ $# -gt 0 ]; then + echo "Invalid Argument: $1" 1>&2 + usage +fi + echo "You took the red pill." echo "You stay in Wonderland, and I show you how deep the rabbit hole goes." echo "Remember, all I'm offering is the truth. Nothing more." echo "Exiting from docker, welcome to the real world." -ssh -i /root/.config/.ssh/id_rsa -o StrictHostKeyChecking=no pi@localhost +ssh -i /root/.config/.ssh/id_rsa -o StrictHostKeyChecking=no $user@localhost