feat(docker): custom docker cli plugins

This commit is contained in:
TheK4n 2023-04-04 20:33:41 +03:00
parent 5bf9f51cd3
commit ab5dd5c11a
6 changed files with 50 additions and 23 deletions

View File

@ -42,7 +42,7 @@ exec --no-startup-id dex --autostart --environment i3
# xss-lock grabs a logind suspend inhibit lock and will use i3lock to lock the # xss-lock grabs a logind suspend inhibit lock and will use i3lock to lock the
# screen before suspend. Use loginctl lock-session to lock your screen. # screen before suspend. Use loginctl lock-session to lock your screen.
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork -c 000000 -e -f
# NetworkManager is the most popular way to manage wireless networks on Linux, # NetworkManager is the most popular way to manage wireless networks on Linux,
# and nm-applet is a desktop environment-independent system tray GUI for it. # and nm-applet is a desktop environment-independent system tray GUI for it.

View File

@ -0,0 +1,25 @@
#!/bin/bash
if [[ "$1" == "docker-cli-plugin-metadata" ]]; then
cat << HERE
{
"SchemaVersion": "0.1.0",
"Vendor": "example.com",
"Version": "v0.1.0",
"ShortDescription": "Bash based Docker cli-plugin"
}
HERE
exit
fi
result="CONTAINER NAME;IMAGE;IP\n"
for container in $(docker ps -q | tr '\n' ' ')
do
IP="$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container" 2>/dev/null)"
container_name="$(docker inspect --format='{{.Name}}' "$container" 2>/dev/null)"
image_name="$(docker inspect --format='{{.Config.Image}}' "$container" 2>/dev/null)"
result+="${container_name#"/"};$image_name;$IP\n"
done
echo -e $result 2>/dev/null | column -t -s ";"

View File

@ -0,0 +1,16 @@
#!/bin/bash
if [[ "$1" == "docker-cli-plugin-metadata" ]]; then
cat << HERE
{
"SchemaVersion": "0.1.0",
"Vendor": "example.com",
"Version": "v0.1.0",
"ShortDescription": "Bash based Docker cli-plugin"
}
HERE
exit
fi
docker exec -it $2 bash

View File

@ -152,27 +152,6 @@ mcd () {
} }
# docker
# execute bash shell in running container
docker_ex() {
docker exec -it $1 ${2:-bash}
}
# ips of docker containers
docker_ips() {
local DOC IP OUT NAME PORT
for DOC in $(docker ps -q | tr '\n' ' ')
do
IP="$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$DOC" 2>/dev/null)"
PORT="$(docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}}{{(index $conf 0).HostPort}}{{end}}' "$DOC" 2>/dev/null)"
NAME="$(docker inspect --format='{{.Name}}' "$DOC" 2>/dev/null)"
OUT+="${NAME#"/"}"'\t'"$IP":"$PORT"'\n'
done
echo -e $OUT 2>/dev/null | column -t
}
# toggle wireguard vpn with interface /etc/wireguard/wg0.conf # toggle wireguard vpn with interface /etc/wireguard/wg0.conf
# to allow sudo user toggle vpn without password: # to allow sudo user toggle vpn without password:
## sudo groupadd wireguard ## sudo groupadd wireguard

View File

@ -1,4 +1,4 @@
if systemctl -q is-active graphical.target && [[ $(tty) = "/dev/tty1" ]] && [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then if systemctl -q is-active graphical.target && [[ $(tty) = "/dev/tty1" ]] && [[ -z $DISPLAY ]] && [[ $XDG_VTNR -eq 1 ]]; then
exec startx >> ~/.xlogs 2>&1 exec startx >> ~/.xlogs 2>&1
fi fi

View File

@ -18,6 +18,7 @@ declare -A TARGETS=(
["i3"]=".config/i3 .config/i3status .local/bin/i3status_wrapper .config/picom" ["i3"]=".config/i3 .config/i3status .local/bin/i3status_wrapper .config/picom"
["bat"]=".config/bat" ["bat"]=".config/bat"
["psql"]=".psqlrc" ["psql"]=".psqlrc"
["docker"]=".docker/cli-plugins"
) )
_die() { _die() {
@ -181,6 +182,11 @@ cmd_psql() {
__install_from_sandbox __install_from_sandbox
} }
cmd_docker() {
_link_files_in_sandbox ${TARGETS["docker"]}
__install_from_sandbox
}
is_target_exists() { is_target_exists() {
test " ${!TARGETS[@]} " =~ " $1 " test " ${!TARGETS[@]} " =~ " $1 "
} }
@ -219,6 +225,7 @@ cmd_install() {
termux) shift; cmd_termux "$@" ;; termux) shift; cmd_termux "$@" ;;
arch) shift; cmd_arch "$@" ;; arch) shift; cmd_arch "$@" ;;
psql) shift; cmd_psql "$@" ;; psql) shift; cmd_psql "$@" ;;
docker) shift; cmd_docker "$@" ;;
*) shift; cmd_no_target "$@" ;; *) shift; cmd_no_target "$@" ;;
esac esac
done done