diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..3992a09 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "mads-hartmann.bash-ide-vscode", + "waderyan.gitblame", + "jgclark.vscode-todo-highlight", + "yzhang.markdown-all-in-one" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..002138f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "bashIde.shfmt.caseIndent": true, + "bashIde.shfmt.funcNextLine": false, + "bashIde.shfmt.simplifyCode": true, + "editor.formatOnSave": true, + "editor.defaultFormatter": "mads-hartmann.bash-ide-vscode", + "bashIde.shfmt.binaryNextLine": true, + "bashIde.shfmt.languageDialect": "bash", + "bashIde.shfmt.spaceRedirects": true +} \ No newline at end of file diff --git a/tools/miaou-create b/tools/miaou-create new file mode 100755 index 0000000..771d01f --- /dev/null +++ b/tools/miaou-create @@ -0,0 +1,76 @@ +#!/usr/bin/env bash + +# CONSTANTS + +BASEDIR=$(dirname "$0") +DEBIAN='images:debian/13' +CONTAINER='' + +# FUNCTIONS + +function usage { + echo "$(basename "$0") " +} + + +function parse_options { + while [[ $# -gt 0 ]]; do + case "$1" in + --help | -h) + usage && exit 0 + ;; + *) + if [[ -z $CONTAINER ]]; then + CONTAINER=$1 + else + echo >&2 "Unknown option: $1" && usage && exit 2 + fi + ;; + esac + + shift 1 # Move to the next argument + done + [[ -n $CONTAINER ]] || ( usage && exit 1 ) + +} + +function before_start { + # cold changes + incus config device add $CONTAINER MIAOU-BASH disk source=/opt/miaou-bash path=/opt/miaou-bash readonly=true | grep -q 'Device MIAOU-BASH added' + incus config set $CONTAINER environment.PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/miaou-bash/tools + cat <&2 "Unknown option: $1" && usage && exit 2 + fi + ;; + esac + + shift 1 # Move to the next argument + done + [[ -n $CONTAINER ]] && [[ -n $SCRIPT ]] || (usage && exit 1) +} + +function debug_option { + [[ $DEBUG == 'true' ]] && echo "-x" || true +} + +function recipe { + [[ ! -f $SCRIPT ]] && echo >&2 "Script not found: $SCRIPT" && exit 3 + + # hot changes + cat "$SCRIPT" | incus exec "$CONTAINER" -- bash $(debug_option) + +} + +# MAIN + +set -Eue +parse_options $* +recipe +echo "Recipe <$(basename "$SCRIPT")> successfully performed on container <$CONTAINER>"