From e7b0921314a886277c1c69e54496331ff6065154 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Wed, 23 Nov 2022 17:39:22 +0800 Subject: [PATCH] Fix shebangs and bits for tangled scripts --- .../error-handling.sh | 2 +- .../challenges.exercism.bash/hello-world.sh | 2 +- .../assets/challenges.exercism.bash/leap.sh | 2 +- .../raindrops-improved.sh | 2 +- .../challenges.exercism.bash/raindrops.sh | 2 +- .../reverse-string.sh | 2 +- .../challenges.exercism.bash/two-fer.sh | 2 +- .../assets/cli.podman/fzf-podman-container-rm | 5 ++++ .../assets/cli.podman/fzf-podman-image-pull | 5 ++++ .../assets/cli.podman/fzf-podman-image-rm | 5 ++++ notebook/assets/cli.podman/podman-quickstart | 18 +++++++++++++ notebook/challenges.exercism.bash.org | 4 +-- notebook/cli.podman.org | 25 +++++++++++++++---- 13 files changed, 62 insertions(+), 14 deletions(-) create mode 100755 notebook/assets/cli.podman/fzf-podman-container-rm create mode 100755 notebook/assets/cli.podman/fzf-podman-image-pull create mode 100755 notebook/assets/cli.podman/fzf-podman-image-rm create mode 100755 notebook/assets/cli.podman/podman-quickstart diff --git a/notebook/assets/challenges.exercism.bash/error-handling.sh b/notebook/assets/challenges.exercism.bash/error-handling.sh index 2b6c32d..76a47a0 100755 --- a/notebook/assets/challenges.exercism.bash/error-handling.sh +++ b/notebook/assets/challenges.exercism.bash/error-handling.sh @@ -1,4 +1,4 @@ -#/usr/bin/env bash +#!/usr/bin/env bash function help() { echo "Usage: error_handling.sh " } diff --git a/notebook/assets/challenges.exercism.bash/hello-world.sh b/notebook/assets/challenges.exercism.bash/hello-world.sh index b7a663a..b216b49 100755 --- a/notebook/assets/challenges.exercism.bash/hello-world.sh +++ b/notebook/assets/challenges.exercism.bash/hello-world.sh @@ -1,4 +1,4 @@ -#/usr/bin/env bash +#!/usr/bin/env bash main() { echo "Hello, World!" } diff --git a/notebook/assets/challenges.exercism.bash/leap.sh b/notebook/assets/challenges.exercism.bash/leap.sh index fffb05a..6512ace 100755 --- a/notebook/assets/challenges.exercism.bash/leap.sh +++ b/notebook/assets/challenges.exercism.bash/leap.sh @@ -1,4 +1,4 @@ -#/usr/bin/env bash +#!/usr/bin/env bash set -eo pipefail function help() { diff --git a/notebook/assets/challenges.exercism.bash/raindrops-improved.sh b/notebook/assets/challenges.exercism.bash/raindrops-improved.sh index 38e85e4..cebac29 100755 --- a/notebook/assets/challenges.exercism.bash/raindrops-improved.sh +++ b/notebook/assets/challenges.exercism.bash/raindrops-improved.sh @@ -1,4 +1,4 @@ -#/usr/bin/env bash +#!/usr/bin/env bash n=$1 valid=0 function is_factor { diff --git a/notebook/assets/challenges.exercism.bash/raindrops.sh b/notebook/assets/challenges.exercism.bash/raindrops.sh index 4120e20..c948401 100755 --- a/notebook/assets/challenges.exercism.bash/raindrops.sh +++ b/notebook/assets/challenges.exercism.bash/raindrops.sh @@ -1,4 +1,4 @@ -#/usr/bin/env bash +#!/usr/bin/env bash n=$1 valid=0 function is_factor { diff --git a/notebook/assets/challenges.exercism.bash/reverse-string.sh b/notebook/assets/challenges.exercism.bash/reverse-string.sh index e161efc..0f560d1 100755 --- a/notebook/assets/challenges.exercism.bash/reverse-string.sh +++ b/notebook/assets/challenges.exercism.bash/reverse-string.sh @@ -1,2 +1,2 @@ -#/usr/bin/env bash +#!/usr/bin/env bash echo "$@" | rev diff --git a/notebook/assets/challenges.exercism.bash/two-fer.sh b/notebook/assets/challenges.exercism.bash/two-fer.sh index eae1711..8b6311c 100755 --- a/notebook/assets/challenges.exercism.bash/two-fer.sh +++ b/notebook/assets/challenges.exercism.bash/two-fer.sh @@ -1,2 +1,2 @@ -#/usr/bin/env bash +#!/usr/bin/env bash echo "One for ${1:-"you"}, one for me." diff --git a/notebook/assets/cli.podman/fzf-podman-container-rm b/notebook/assets/cli.podman/fzf-podman-container-rm new file mode 100755 index 0000000..f749f50 --- /dev/null +++ b/notebook/assets/cli.podman/fzf-podman-container-rm @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +podman container list --format "{{.ID}} {{.Names}}" \ + | fzf --multi --prompt "Choose containers to remove > " \ + | awk '{print $1}' \ + | xargs podman container rm diff --git a/notebook/assets/cli.podman/fzf-podman-image-pull b/notebook/assets/cli.podman/fzf-podman-image-pull new file mode 100755 index 0000000..78a29d8 --- /dev/null +++ b/notebook/assets/cli.podman/fzf-podman-image-pull @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +podman image search --format "{{.Index}} {{.Name}}" alpine \ + | fzf --multi --prompt "Choose images to install > " \ + | awk '{print $2}' \ + | xargs podman image pull diff --git a/notebook/assets/cli.podman/fzf-podman-image-rm b/notebook/assets/cli.podman/fzf-podman-image-rm new file mode 100755 index 0000000..ea3508b --- /dev/null +++ b/notebook/assets/cli.podman/fzf-podman-image-rm @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +podman image list --format "{{.ID}} {{.Repository}} {{.Tag}}" \ + | fzf --multi --prompt "Choose images to remove > " \ + | awk '{print $1}' \ + | xargs podman image rm diff --git a/notebook/assets/cli.podman/podman-quickstart b/notebook/assets/cli.podman/podman-quickstart new file mode 100755 index 0000000..8a77ed5 --- /dev/null +++ b/notebook/assets/cli.podman/podman-quickstart @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# Builds an image from the Dockerfile of the current directory. +podman build --tag todo-list-web-app . + +# List the images to see if our app image has been built. +podman image list + +# Assuming the app creates an HTTP server at port 5000, we'll expose it to the host, making it accessible from there. +podman run -d -p 5111:5000 todo-list-web-app + +# See if we did run a containerized version of our app. +podman container list + +# Tag the image with the convention seen in Docker registry. +podman tag foodogsquared/python-helloworld:v1.0.0 + +# Push the image to the Docker registry (assuming you've already logged in to Docker registry). +podman push foodogsquared/python-helloworld diff --git a/notebook/challenges.exercism.bash.org b/notebook/challenges.exercism.bash.org index 6b22340..62c8dab 100644 --- a/notebook/challenges.exercism.bash.org +++ b/notebook/challenges.exercism.bash.org @@ -3,7 +3,7 @@ :END: #+title: Exercism track: Bash #+date: "2021-05-11 15:06:43 +08:00" -#+date_modified: "2021-06-22 17:50:43 +08:00" +#+date_modified: "2022-09-04 22:17:41 +08:00" #+language: en #+source: https://exercism.io/my/tracks/bash #+property: header-args :cache yes @@ -43,7 +43,7 @@ main() { main #+end_src -#+results[9110ed5ee1cd74dc35880e0e285e44fc1f04e858]: +#+results[98aae568f58e5e1b2267b6c21e9efbb8c8a555b3]: : Hello, World! diff --git a/notebook/cli.podman.org b/notebook/cli.podman.org index 9c0511c..6da7ffe 100644 --- a/notebook/cli.podman.org +++ b/notebook/cli.podman.org @@ -3,9 +3,10 @@ :END: #+title: Command line: Podman #+date: "2021-06-10 11:51:26 +08:00" -#+date_modified: "2021-07-20 23:31:29 +08:00" +#+date_modified: "2022-11-23 17:48:46 +08:00" #+language: en #+property: header-args :eval no +#+property: header-args:bash :shebang "#!/usr/bin/env bash" Podman is a daemonless container engine. @@ -38,17 +39,19 @@ Podman has Git-style command-line interface with subcommands and exclusive optio + =-t, --tag [NAME]= attaches a tag to the image. + =-f, --file [FILE]= sets the name of the Dockerfile to be built from. -- =run= will create a container from an image. +- =run= creates a container from an image quickly with the given subcommand. + =-d, --detach= will make the process run in the background. + =-it= will make an interactive shell. + =-p, --publish= exposes the port of the image to the host. -- =tag= will tag an existing image. +- =tag= tags an existing image. Useful for correcting tags for pushing into a remote registry. - =image= is anything about interaction with images. In fact, a lot of the subcommands presented so far are aliases with =image= being the original — e.g., =image tag= vs =tag=, =image pull= vs =pull=, =image rm= vs =rmi=. +- =commit= creates a new image from a container, allowing to easily create one with all the changes you always have to apply previously. + @@ -61,7 +64,7 @@ Podman is a big tool so it needs a big list of examples. As with big tools, comes with a big quickstart. -#+begin_src shell +#+begin_src bash :tangle (my/concat-assets-folder "podman-quickstart") # Builds an image from the Dockerfile of the current directory. podman build --tag todo-list-web-app . @@ -98,9 +101,21 @@ podman image list --format "{{.ID}} {{.Repository}} {{.Tag}}" \ Yes, another one with fzf... -#+begin_src bash +#+begin_src bash :tangle (my/concat-assets-folder "fzf-podman-image-pull") podman image search --format "{{.Index}} {{.Name}}" alpine \ | fzf --multi --prompt "Choose images to install > " \ | awk '{print $2}' \ | xargs podman image pull #+end_src + + +** Interactive container removal + +Basically, the previous scripts except for containers. + +#+begin_src bash :tangle (my/concat-assets-folder "fzf-podman-container-rm") +podman container list --format "{{.ID}} {{.Names}}" \ + | fzf --multi --prompt "Choose containers to remove > " \ + | awk '{print $1}' \ + | xargs podman container rm +#+end_src