install.fairie/home/dot_config/docker/cli-plugins/executable_docker-clip
Brian Zalewski 72dc4e03d9 Update 252 files
- /home/private_dot_config/Google Assistant/config.json.tmpl
- /home/private_dot_config/Google Assistant/encrypted_client-secret.json
- /home/private_dot_config/Google Assistant/encrypted_tokens.json
- /home/private_dot_config/Kvantum/kvantum.config
- /home/private_dot_config/VirtualBox/VirtualBox.xml.tmpl
- /home/private_dot_config/alacritty/alacritty.yml
- /home/private_dot_config/asdf/asdfrc.tmpl
- /home/private_dot_config/asdf/default-cargo-pkgs
- /home/private_dot_config/asdf/default-golang-pkgs
- /home/private_dot_config/asdf/default-npm-packages
- /home/private_dot_config/asdf/default-python-pkgs
- /home/private_dot_config/asdf/default-ruby-pkgs
- /home/private_dot_config/bashtop/bashtop.cfg
- /home/private_dot_config/bat/config
- /home/private_dot_config/brew/Brewfile.tmpl
- /home/private_dot_config/brew/whalebrew
- /home/private_dot_config/chromium-flags.conf
- /home/private_dot_config/crontab/config
- /home/private_dot_config/dconf/settings/org.gnome.desktop.app-folders
- /home/private_dot_config/dconf/settings/org.gnome.desktop.background
- /home/private_dot_config/dconf/settings/org.gnome.desktop.calendar
- /home/private_dot_config/dconf/settings/org.gnome.desktop.interface
- /home/private_dot_config/dconf/settings/org.gnome.desktop.privacy
- /home/private_dot_config/dconf/settings/org.gnome.desktop.screensaver
- /home/private_dot_config/dconf/settings/org.gnome.desktop.session
- /home/private_dot_config/dconf/settings/org.gnome.desktop.sound
- /home/private_dot_config/dconf/settings/org.gnome.desktop.wm.preferences
- /home/private_dot_config/dconf/settings/org.gnome.nautilus
- /home/private_dot_config/dconf/settings/org.gnome.settings-daemon.plugins.power
- /home/private_dot_config/dconf/settings/org.gnome.shell
- /home/private_dot_config/dconf/settings/org.gnome.terminal
- /home/private_dot_config/dconf/settings/org.gtk.settings.debug
- /home/private_dot_config/dconf/settings/org.gtk.settings.file-chooser
- /home/private_dot_config/dconf/settings/system.proxy
- /home/private_dot_config/direnv/direnv.toml
- /home/private_dot_config/docker/cli-plugins/executable_docker-clip
- /home/private_dot_config/docker/daemon.json
- /home/private_dot_config/fd/ignore
- /home/private_dot_config/firejail/bitwarden.local
- /home/private_dot_config/firejail/chromium.local
- /home/private_dot_config/firejail/code.local
- /home/private_dot_config/firejail/gcloud.local
- /home/private_dot_config/firejail/google-chrome-stable.local
- /home/private_dot_config/firejail/slack.local
- /home/private_dot_config/firejail/thunderbird.local
- /home/private_dot_config/fontconfig/fonts.conf
- /home/private_dot_config/ghorg/conf.yaml.tmpl
- /home/private_dot_config/git/attributes
- /home/private_dot_config/git/commit-template
- /home/private_dot_config/git/config.tmpl
- /home/private_dot_config/git/ignore
- /home/private_dot_config/git/template/branches/remove_dot_gitkeep
- /home/private_dot_config/git/template/description
- /home/private_dot_config/git/template/hooks/symlink_commit-msg.tmpl
- /home/private_dot_config/git/template/hooks/symlink_post-checkout.tmpl
- /home/private_dot_config/git/template/hooks/symlink_post-commit.tmpl
- /home/private_dot_config/git/template/hooks/symlink_post-merge.tmpl
- /home/private_dot_config/git/template/hooks/symlink_post-rewrite.tmpl
- /home/private_dot_config/git/template/hooks/symlink_pre-commit.tmpl
- /home/private_dot_config/git/template/hooks/symlink_pre-push.tmpl
- /home/private_dot_config/git/template/hooks/symlink_prepare-commit-msg.tmpl
- /home/private_dot_config/git/template/info/exclude
- /home/private_dot_config/gtk-1.0/.gitkeep
- /home/private_dot_config/gtk-2.0/gtkrc
- /home/private_dot_config/gtk-3.0/settings.ini
- /home/private_dot_config/gtkrc
- /home/private_dot_config/heroku/deploy.yml.tmpl
- /home/private_dot_config/himalaya/config.toml
- /home/private_dot_config/k9s/plugin.yml
- /home/private_dot_config/kcminputrc
- /home/private_dot_config/kdeglobals
- /home/private_dot_config/kitty/Betelgeuse-dark.conf
- /home/private_dot_config/kitty/Betelgeuse-light.conf
- /home/private_dot_config/kitty/kitty.conf
- /home/private_dot_config/konsolerc
- /home/private_dot_config/ksplashrc
- /home/private_dot_config/ktimezonedrc
- /home/private_dot_config/kwinrc
- /home/private_dot_config/libvirt/libvirtd.conf
- /home/private_dot_config/mimeapps.list
- /home/private_dot_config/ngrok/ngrok.yml.tmpl
- /home/private_dot_config/npm/config/npm-init.js
- /home/private_dot_config/npm/npmrc.tmpl
- /home/private_dot_config/nvim-custom/init.lua
- /home/private_dot_config/nvim-custom/run_onchanges_after_symlink-custom.tmpl
- /home/private_dot_config/oh-my-posh/Betelgeuse-minimal.omp.json
- /home/private_dot_config/oh-my-posh/Betelgeuse.omp.json
- /home/private_dot_config/pg/.gitkeep
- /home/private_dot_config/pgcli/config
- /home/private_dot_config/plasma-localerc
- /home/private_dot_config/plasma/plasmoids.yml
- /home/private_dot_config/plasmarc
- /home/private_dot_config/powershell/profile.ps1
- /home/private_dot_config/private_Code/User/extensions.json
- /home/private_dot_config/private_Code/User/extensions/theme-betelgeuse-vscode/README.md
- /home/private_dot_config/private_Code/User/extensions/theme-betelgeuse-vscode/icon.svg
- /home/private_dot_config/private_Code/User/extensions/theme-betelgeuse-vscode/package.json
- /home/private_dot_config/private_Code/User/extensions/theme-betelgeuse-vscode/themes/themer-dark-color-theme.json
- /home/private_dot_config/private_Code/User/extensions/theme-betelgeuse-vscode/themes/themer-light-color-theme.json
- /home/private_dot_config/private_Code/User/keybindings.json
- /home/private_dot_config/private_Code/User/settings.json
- /home/private_dot_config/putty/.gitkeep
- /home/private_dot_config/rclone/merge_rclone.conf
- /home/private_dot_config/readline/inputrc
- /home/private_dot_config/ripgrep/config
- /home/private_dot_config/rofi-user/config.rasi.tmpl
- /home/private_dot_config/shell/aliases.sh.tmpl
- /home/private_dot_config/shell/exports.sh.tmpl
- /home/private_dot_config/shell/functions.sh
- /home/private_dot_config/shell/motd.sh
- /home/private_dot_config/shell/private_private.sh
- /home/private_dot_config/shell/profile.sh
- /home/private_dot_config/slack-term/config.tmpl
- /home/private_dot_config/tabby/encrypted-fallback_config.yaml
- /home/private_dot_config/tabby/encrypted_config.yaml
- /home/private_dot_config/tabby/plugins/package.json
- /home/private_dot_config/tabby/plugins/run_onchange_after_install-tabby-plugins.tmpl
- /home/private_dot_config/terminator/config
- /home/private_dot_config/tmux/remove_dot_gitkeep
- /home/private_dot_config/vim/vimrc
- /home/private_dot_config/wget/wgetrc
- /home/private_dot_config/xfce4/terminal/terminalrc
- /home/private_dot_config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml
- /home/private_dot_config/xsettingsd/xsettingsd.conf
- /home/private_dot_config/youtube-dl/config
- /home/private_dot_config/zap/v2/config.ini.tmpl
- /home/dot_config/Google Assistant/config.json.tmpl
- /home/dot_config/Google Assistant/encrypted_client-secret.json
- /home/dot_config/Google Assistant/encrypted_tokens.json
- /home/dot_config/Kvantum/kvantum.config
- /home/dot_config/VirtualBox/VirtualBox.xml.tmpl
- /home/dot_config/alacritty/alacritty.yml
- /home/dot_config/asdf/default-python-pkgs
- /home/dot_config/asdf/default-golang-pkgs
- /home/dot_config/asdf/asdfrc.tmpl
- /home/dot_config/asdf/default-ruby-pkgs
- /home/dot_config/asdf/default-cargo-pkgs
- /home/dot_config/asdf/default-npm-packages
- /home/dot_config/bashtop/bashtop.cfg
- /home/dot_config/bat/config
- /home/dot_config/brew/whalebrew
- /home/dot_config/brew/Brewfile.tmpl
- /home/dot_config/crontab/config
- /home/dot_config/dconf/settings/org.gnome.desktop.sound
- /home/dot_config/dconf/settings/org.gnome.desktop.screensaver
- /home/dot_config/dconf/settings/org.gnome.desktop.session
- /home/dot_config/dconf/settings/org.gnome.desktop.wm.preferences
- /home/dot_config/dconf/settings/org.gnome.desktop.privacy
- /home/dot_config/dconf/settings/org.gnome.shell
- /home/dot_config/dconf/settings/org.gnome.terminal
- /home/dot_config/dconf/settings/org.gtk.settings.debug
- /home/dot_config/dconf/settings/org.gnome.nautilus
- /home/dot_config/dconf/settings/org.gnome.desktop.app-folders
- /home/dot_config/dconf/settings/org.gnome.settings-daemon.plugins.power
- /home/dot_config/dconf/settings/org.gnome.desktop.background
- /home/dot_config/dconf/settings/org.gnome.desktop.interface
- /home/dot_config/dconf/settings/org.gtk.settings.file-chooser
- /home/dot_config/dconf/settings/system.proxy
- /home/dot_config/dconf/settings/org.gnome.desktop.calendar
- /home/dot_config/direnv/direnv.toml
- /home/dot_config/docker/cli-plugins/executable_docker-clip
- /home/dot_config/docker/daemon.json
- /home/dot_config/fd/ignore
- /home/dot_config/firejail/bitwarden.local
- /home/dot_config/firejail/thunderbird.local
- /home/dot_config/firejail/chromium.local
- /home/dot_config/firejail/code.local
- /home/dot_config/firejail/gcloud.local
- /home/dot_config/firejail/slack.local
- /home/dot_config/firejail/google-chrome-stable.local
- /home/dot_config/fontconfig/fonts.conf
- /home/dot_config/ghorg/conf.yaml.tmpl
- /home/dot_config/git/template/branches/remove_dot_gitkeep
- /home/dot_config/git/template/hooks/symlink_prepare-commit-msg.tmpl
- /home/dot_config/git/template/hooks/symlink_post-merge.tmpl
- /home/dot_config/git/template/hooks/symlink_post-checkout.tmpl
- /home/dot_config/git/template/hooks/symlink_post-commit.tmpl
- /home/dot_config/git/template/hooks/symlink_commit-msg.tmpl
- /home/dot_config/git/template/hooks/symlink_post-rewrite.tmpl
- /home/dot_config/git/template/hooks/symlink_pre-commit.tmpl
- /home/dot_config/git/template/hooks/symlink_pre-push.tmpl
- /home/dot_config/git/template/info/exclude
- /home/dot_config/git/template/description
- /home/dot_config/git/config.tmpl
- /home/dot_config/git/ignore
- /home/dot_config/git/attributes
- /home/dot_config/git/commit-template
- /home/dot_config/gtk-1.0/.gitkeep
- /home/dot_config/gtk-2.0/gtkrc
- /home/dot_config/gtk-3.0/settings.ini
- /home/dot_config/heroku/deploy.yml.tmpl
- /home/dot_config/himalaya/config.toml
- /home/dot_config/k9s/plugin.yml
- /home/dot_config/kitty/kitty.conf
- /home/dot_config/kitty/Betelgeuse-dark.conf
- /home/dot_config/kitty/Betelgeuse-light.conf
- /home/dot_config/libvirt/libvirtd.conf
- /home/dot_config/ngrok/ngrok.yml.tmpl
- /home/dot_config/npm/config/npm-init.js
- /home/dot_config/npm/npmrc.tmpl
- /home/dot_config/nvim-custom/init.lua
- /home/dot_config/nvim-custom/run_onchanges_after_symlink-custom.tmpl
- /home/dot_config/oh-my-posh/Betelgeuse-minimal.omp.json
- /home/dot_config/oh-my-posh/Betelgeuse.omp.json
- /home/dot_config/pg/.gitkeep
- /home/dot_config/pgcli/config
- /home/dot_config/plasma/plasmoids.yml
- /home/dot_config/powershell/profile.ps1
- /home/dot_config/putty/.gitkeep
- /home/dot_config/rclone/merge_rclone.conf
- /home/dot_config/readline/inputrc
- /home/dot_config/ripgrep/config
- /home/dot_config/rofi-user/config.rasi.tmpl
- /home/dot_config/shell/aliases.sh.tmpl
- /home/dot_config/shell/exports.sh.tmpl
- /home/dot_config/shell/private_private.sh
- /home/dot_config/shell/functions.sh
- /home/dot_config/shell/profile.sh
- /home/dot_config/shell/motd.sh
- /home/dot_config/slack-term/config.tmpl
- /home/dot_config/tabby/plugins/package.json
- /home/dot_config/tabby/plugins/run_onchange_after_install-tabby-plugins.tmpl
- /home/dot_config/tabby/encrypted-fallback_config.yaml
- /home/dot_config/tabby/encrypted_config.yaml
- /home/dot_config/terminator/config
- /home/dot_config/tmux/remove_dot_gitkeep
- /home/dot_config/vim/vimrc
- /home/dot_config/wget/wgetrc
- /home/dot_config/xfce4/terminal/terminalrc
- /home/dot_config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml
- /home/dot_config/xsettingsd/xsettingsd.conf
- /home/dot_config/youtube-dl/config
- /home/dot_config/zap/v2/config.ini.tmpl
- /home/dot_config/ktimezonedrc
- /home/dot_config/plasma-localerc
- /home/dot_config/kcminputrc
- /home/dot_config/kwinrc
- /home/dot_config/mimeapps.list
- /home/dot_config/ksplashrc
- /home/dot_config/gtkrc
- /home/dot_config/kdeglobals
- /home/dot_config/plasmarc
- /home/dot_config/konsolerc
- /home/dot_config/chromium-flags.conf
- /home/dot_config/Code/User/extensions.json
- /home/dot_config/Code/User/extensions/theme-betelgeuse-vscode/themes/themer-dark-color-theme.json
- /home/dot_config/Code/User/extensions/theme-betelgeuse-vscode/themes/themer-light-color-theme.json
- /home/dot_config/Code/User/extensions/theme-betelgeuse-vscode/package.json
- /home/dot_config/Code/User/extensions/theme-betelgeuse-vscode/README.md
- /home/dot_config/Code/User/extensions/theme-betelgeuse-vscode/icon.svg
- /home/dot_config/Code/User/settings.json
- /home/dot_config/Code/User/keybindings.json
2023-01-25 00:20:21 +00:00

234 lines
6.6 KiB
Bash

#!/bin/bash
# Source: https://github.com/lukaszlach/clip/
# Docker Client Plugin Manager (CLIP)
#
# (c) 2019 Łukasz Lach
# llach@llach.pl
# https://lach.dev
if [[ "$1" == "docker-cli-plugin-metadata" ]]; then
cat <<CUT
{
"SchemaVersion": "0.1.0",
"Vendor": "Łukasz Lach",
"Version": "v19.06.0",
"ShortDescription": "Docker Client Plugins Manager"
}
CUT
exit
fi
USER_LOCAL_DIR="${XDG_CONFIG_HOME:-$HOME/.docker}/cli-plugins"
#
# docker clip build
#
cmd_build() {
while getopts ":t:c:" opt; do
case ${opt} in
t ) PLUGIN_TAG=$OPTARG ;;
c ) PLUGIN_COMMAND=$OPTARG ;;
\? )
echo "Invalid option: $OPTARG" 1>&2
break
;;
: )
echo "Invalid option: $OPTARG requires an argument" 1>&2
break
;;
esac
done
shift $((OPTIND -1))
PLUGIN_REPOSITORY=$(echo "$PLUGIN_TAG" | cut -d ':' -f 1)
PLUGIN_CONTEXT="$1"
if [ ! -e "$PLUGIN_CONTEXT/docker-$PLUGIN_COMMAND" ]; then
echo "Error: docker-$PLUGIN_COMMAND file does not exist in the build context"
exit 1
elif [ ! -x "$PLUGIN_CONTEXT/docker-$PLUGIN_COMMAND" ]; then
echo "Error: docker-$PLUGIN_COMMAND file is not executable"
exit 1
elif [ ! -e "$PLUGIN_CONTEXT/docker-$PLUGIN_COMMAND.json" ]; then
echo "Error: docker-$PLUGIN_COMMAND.json file does not exist in the build context"
exit 1
fi
BUILD_FILE=$(mktemp)
cat > "$BUILD_FILE" <<EOF
FROM scratch
LABEL com.docker.clip="1" \
com.docker.clip.tag="${PLUGIN_TAG}" \
com.docker.clip.repository="${PLUGIN_REPOSITORY}" \
com.docker.clip.command="${PLUGIN_COMMAND}" \
com.docker.clip.build_date="$(date +'%F %T')"
COPY . .
EOF
echo "Building $PLUGIN_TAG client plugin"
docker build -q --force-rm --no-cache -t "$PLUGIN_TAG" -f "$BUILD_FILE" "$PLUGIN_CONTEXT"
rm -f "$BUILD_FILE"
echo "Successfully built $PLUGIN_TAG client plugin"
}
#
# docker clip push
#
cmd_push() {
PLUGIN_TAG="$1"
echo "Pushing $PLUGIN_TAG client plugin"
docker push "$PLUGIN_TAG"
}
#
# docker clip add
#
cmd_add() {
PLUGIN_TAG="$1"
PLUGIN_REPOSITORY=$(echo "$PLUGIN_TAG" | cut -d ':' -f 1)
IMAGE_TAG=$(echo "$PLUGIN_TAG:" | cut -d ':' -f 2)
if [ -z "$IMAGE_TAG" ]; then PLUGIN_TAG="$PLUGIN_TAG:latest"; fi
echo "Installing client plugin from $PLUGIN_TAG"
REMOVE_PLUGIN_IMAGE=0
if ! docker images --format '{{.Repository}}:{{.Tag}}' | grep -e "^$PLUGIN_TAG$" &>/dev/null; then
docker pull "$PLUGIN_TAG"
REMOVE_PLUGIN_IMAGE=1
fi
PLUGIN_FLAG=$(docker image inspect --format '{{index .Config.Labels "com.docker.clip"}}' "$PLUGIN_TAG")
PLUGIN_COMMAND=$(docker image inspect --format '{{index .Config.Labels "com.docker.clip.command"}}' "$PLUGIN_TAG")
PLUGIN_BIN="$USER_LOCAL_DIR/docker-$PLUGIN_COMMAND"
if [ "$PLUGIN_FLAG" != "1" ]; then
echo "Error: Image $PLUGIN_TAG is not a valid plugin image"
exit 1
fi
if [ -e "$PLUGIN_BIN" ]; then
echo "Error: $PLUGIN_TAG exports '$PLUGIN_COMMAND' client command that already exists"
exit 1
fi
PLUGIN_LOCAL_DIR="$USER_LOCAL_DIR/.command/$PLUGIN_COMMAND"
rm -rf "$PLUGIN_LOCAL_DIR"
mkdir -p "$PLUGIN_LOCAL_DIR"
IMAGE_DIR=$(mktemp -d)
docker save "$PLUGIN_TAG" | tar -C "$IMAGE_DIR" -x
find "$IMAGE_DIR" -name 'layer.tar' -exec tar -C "$PLUGIN_LOCAL_DIR" -xf {} \;
rm -rf "$IMAGE_DIR"
echo "$PLUGIN_TAG" > "$PLUGIN_LOCAL_DIR/.plugin-image"
if [[ "$REMOVE_PLUGIN_IMAGE" == "1" ]]; then
docker rmi "$PLUGIN_TAG" >/dev/null
fi
# Install command
cat > "$USER_LOCAL_DIR/docker-$PLUGIN_COMMAND" <<EOF
#!/usr/bin/env bash
exec docker clip run "$PLUGIN_COMMAND" "\$@"
EOF
chmod +x "$USER_LOCAL_DIR/docker-$PLUGIN_COMMAND"
echo "Successfully installed $PLUGIN_TAG client plugin"
echo "New client command available: 'docker $PLUGIN_COMMAND'"
}
#
# docker clip update
#
cmd_update() {
PLUGIN_COMMAND="$1"
PLUGIN_LOCAL_DIR="$USER_LOCAL_DIR/.command/$PLUGIN_COMMAND"
PLUGIN_TAG=$(cat "$PLUGIN_LOCAL_DIR/.plugin-image")
echo "Updating the $PLUGIN_COMMAND client command from $PLUGIN_TAG"
cmd_rm "$PLUGIN_COMMAND"
docker rmi "$PLUGIN_TAG" >/dev/null || true
cmd_install "$PLUGIN_TAG"
echo "Successfully updated the $PLUGIN_COMMAND client command"
}
#
# docker clip rm
#
cmd_rm() {
PLUGIN_COMMAND="$1"
if [ -z "$PLUGIN_COMMAND" ]; then
echo "Error: Command name was not specified"
exit 1
fi
PLUGIN_LOCAL_DIR="$USER_LOCAL_DIR/.command/$PLUGIN_COMMAND"
if [ -d "$PLUGIN_LOCAL_DIR" ]; then
rm -rf "$PLUGIN_LOCAL_DIR"
rm -f "$USER_LOCAL_DIR/docker-$PLUGIN_COMMAND"
echo "Successfully removed '$PLUGIN_COMMAND' client command"
else
if [ -e "$USER_LOCAL_DIR/docker-$PLUGIN_COMMAND" ]; then
echo "Error: Client command '$PLUGIN_COMMAND' is not maintained by docker-clip"
exit 1
fi
echo "Error: Client command '$PLUGIN_COMMAND' is not installed"
exit 1
fi
}
#
# docker clip ls
#
cmd_ls() {
printf "%-20s %s\n" COMMAND IMAGE
while read PLUGIN_IMAGE_FILE; do
PLUGIN_TAG=$(cat "$PLUGIN_IMAGE_FILE")
PLUGIN_COMMAND=$(basename $(dirname "$PLUGIN_IMAGE_FILE"))
printf "%-20s %s\n" "$PLUGIN_COMMAND" "$PLUGIN_TAG"
done < <(find "$USER_LOCAL_DIR/.command" -name .plugin-image)
}
#
# docker clip search
#
cmd_search() {
PATTERN="$1"
printf "COMMAND IMAGE DESCRIPTION\n"
curl -sSfL https://raw.githubusercontent.com/lukaszlach/clip/master/clips/catalog | \
grep --color=always -ie "$PATTERN"
exit $?
}
#
# docker clip run
# Used internally only
#
cmd_run() {
PLUGIN_COMMAND="$1"
PLUGIN_LOCAL_DIR="$USER_LOCAL_DIR/.command/$PLUGIN_COMMAND"
shift
if [[ "$1" == "docker-cli-plugin-metadata" ]]; then
cat "$PLUGIN_LOCAL_DIR/docker-$PLUGIN_COMMAND.json"
exit 0
fi
exec "$PLUGIN_LOCAL_DIR/docker-$PLUGIN_COMMAND" "$@"
exit 0
}
usage() {
cat <<EOF
Usage: docker clip COMMAND
Commands:
add Install a new plugin by an image name
build Build a new plugin
ls List installed plugins
push Push local plugin to a Docker registry
rm Remove an installed plugin
search Search plugins from the remote catalog
update Reinstall a plugin to its latest version
EOF
}
shift
COMMAND="$1"
shift
if [ -z "$COMMAND" ] || [ "$COMMAND" == "-h" ] || [ "$COMMAND" == "--help" ]; then
usage
exit 0
fi
set -e
case "$COMMAND" in
build | push | add | update | rm | ls | search | run)
eval "cmd_${COMMAND}" "$@"
;;
esac
exit 0