Docker Shortcuts (#43)

* Shrink toolbar icons to 28 from 32.

* Add shortcut commands for Docker administration.

* Add more docker commands. General improvements.
This commit is contained in:
Hyperling 2023-07-22 18:27:13 +00:00 committed by GitHub
parent 84844715a6
commit a9d20be8e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 78 additions and 48 deletions

View File

@ -17,7 +17,7 @@
create: no
state: present
when: ansible_distribution == "Archlinux"
#- name: General | Account Management | Users | Use ZSH (Arch+Manjaro)
# set_fact:
# user_shell: "{{ zsh_exec.stdout }}"
@ -62,7 +62,7 @@
user:
name: "{{ user }}"
comment: "{{ user_desc }}"
groups:
groups:
- sudo
- video
- render
@ -82,7 +82,7 @@
## Folders ##
- name: General | Account Management | Users | Folders | Root | Create bin, Downloads, TRASH
file:
file:
path: "{{ item }}"
state: directory
mode: '0755'
@ -93,7 +93,7 @@
when: user_root.home != ""
- name: General | Account Management | Users | Folders | Hyperling | Create bin, LBRY, TRASH
file:
file:
path: "{{ item }}"
state: directory
mode: '0755'
@ -119,7 +119,7 @@
alias_rm: alias rm='echo "Use mv ~/TRASH/ instead!"'
alias_clean_dir: alias clean-dir='mv * ~/TRASH/'
alias_clean_trash: alias clean-trash='sh -c "rm -rfv ~/TRASH/*"'
path_additions: export PATH="~/bin:$PATH"
export_path_additions: export PATH="~/bin:$PATH"
function_wttr: |
function weather() {
# 20210301 - Someone showed me an awesome weather API! Had to implement it!
@ -137,13 +137,13 @@
fi
curl "https://wttr.in/${1//\ /+}"
}
PS1: export PS1='[\u@\h \w]\$ '
remount: alias remount='sudo umount /mnt/*; sudo umount /mnt/*/*; sudo mount -a; echo -e "\nRemount completed!"; mount | grep /mnt'
update: |
export_PS1: export PS1='[\u@\h \w]\$ '
alias_remount: alias remount='sudo umount /mnt/*; sudo umount /mnt/*/*; sudo mount -a; echo -e "\nRemount completed!"; mount | grep /mnt'
function_update: |
function update() {
PROG=$FUNCNAME
usage="Usage: $PROG [-y]
$PROG is used to run all the system's package manager commands
$PROG is used to run all the system's package manager commands
in one swoop. Flow stops if any command returns a failure code.
The hope is to run something as easy as 'pacman -Syyu'.
-y : Assume yes to any prompts."
@ -153,11 +153,11 @@
while getopts ":hy" opt; do
case $opt in
h) echo -e "$usage"
return 0 ;;
return 0 ;;
y) accept="-y" ;;
*) echo "ERROR: -$OPTARG is not a recognized option."
echo -e "$usage"
return 1 ;;
*) echo "ERROR: -$OPTARG is not a recognized option." >&2
echo -e "$usage"
return 1 ;;
esac
done
@ -165,30 +165,30 @@
{{ update_flatpak }}
return 0
echo "ERROR: $PROG experienced a problem and has aborted."
echo "ERROR: $PROG experienced a problem and has aborted." >&2
return 1
}
sync: alias sync='date && echo "Syncing!" && sync && date'
editor: export EDITOR='vi'
alias_sync: alias sync='date && echo "Syncing!" && sync && date'
export_editor: export EDITOR='vi'
init_aliases: |
alias init-video='mkdir -v raw; mkdir -v exports; cp ~/Templates/*video* ./'
alias init-video='mkdir -v raw; mkdir -v exports; cp ~/Templates/*video* ./'
alias init-vid=init-video
alias init-program='echo -e "#!/bin/bash\n# `date +%Y-%m-%d` by Hyperling\n# REASON\n\nexit 0\n"'
alias init-prog=init-program
bye: |
bye_aliases: |
alias bye="{{ shutdown_command }}"
alias goodbye="update -y && bye"
metasploit: |
metasploit_aliases: |
alias metasploit="msfconsole"
alias hax="metasploit"
show_config: |
show_config_aliases: |
alias show-config-gen="cat {{ gen_file }}"
alias show-config-wrk="cat {{ wrk_file }}"
alias show-config-mnr="cat {{ mnr_file }}"
alias show-config-srv="cat {{ srv_file }}"
alias show-config-all="show-config-gen && echo '' && show-config-wrk && echo '' && show-config-mnr && echo '' && show-config-srv"
alias show-config="show-config-all"
edit_config: |
edit_config_aliases: |
alias edit-config-gen="sudo $EDITOR {{ gen_file }}"
alias edit-config-wrk="sudo $EDITOR {{ wrk_file }}"
alias edit-config-mnr="sudo $EDITOR {{ mnr_file }}"
@ -200,13 +200,17 @@
unset network
while (( $# > 0 )); do
case $1 in
-c | -y | --clean ) clean="Y" ;;
-n | -net | --network ) network="Y" ;;
* ) echo "
ERROR: Option '$1' with value '$2' not recognized.
$PROG [-c|-clean|--clean|-y] [-n|-net|--network]
"
return 1
-c | -y | --clean )
clean="Y" ;;
-n | -net | --network )
network="Y" ;;
* )
echo "
ERROR: Option '$1' with value '$2' not recognized.
$PROG [-c|-clean|--clean|-y] [-n|-net|--network]
" >&2
return 1
;;
esac
shift
done
@ -218,9 +222,9 @@
echo "/root"
echo "/home"
}
dirs_to_check | while read dir; do
dirs_to_check | while read dir; do
echo "Checking $dir..."
sudo find $dir -name TRASH | while read trash; do
sudo find $dir -name TRASH | while read trash; do
if [[ "$trash" != "" && `sudo ls $trash` ]]; then
echo "Found $trash with contents:"
sudo ls -lh $trash
@ -229,15 +233,15 @@
sudo sh -c "rm -rfv $trash/*"
fi
fi
done
done
done
if [[ "$network" == "Y" ]]; then
function network_to_check {
find /mnt -maxdepth 1 -mindepth 1
find /mnt -maxdepth 1 -mindepth 1
}
network_to_check | while read dir; do
network_to_check | while read dir; do
echo "Checking $dir..."
sudo find $dir -name TRASH | while read trash; do
sudo find $dir -name TRASH | while read trash; do
if [[ "$trash" != "" && `sudo ls $trash` ]]; then
echo "Found $trash with contents:"
sudo ls -lh $trash
@ -246,7 +250,7 @@
sudo sh -c "rm -rfv $trash/*"
fi
fi
done
done
done
fi
echo "Checking but not cleaning /var/mail..."
@ -276,37 +280,63 @@
flatpak repair &&
echo "Finished purging all Flatpak apps. Executable may still need uninstalled." &&
return
echo "ERROR: Something went wrong while removing Flatpak apps!"
echo "ERROR: Something went wrong while removing Flatpak apps!" >&2
}
alias_vim: alias vi=vim
alias_here: alias here='ls -lh `pwd`/*'
alias_here: alias here='ls -alh `pwd`/*'
alias_docker_reload: alias docker-reload='docker compose down && docker compose build && docker compose up -d'
alias_docker_update: alias docker-update='docker compose down && docker compose pull && docker compose build && docker compose up -d'
function_docker_upgrade: |
# Wrapper for a full-scale upgrade of a container.
function docker-upgrade() {
container=$1
if [[ -z $container ]]; then
echo "ERROR: Container name or ID is required." >&2
return;
fi
if [[ -s $2 ]]; then
echo "ERROR: A second parameter is not expected, aborting." >&2
return;
fi
docker compose down &&
docker compose pull &&
docker compose build &&
docker compose up -d &&
echo "Following log." &&
docker logs -f $container
}
alias_docker_restart: alias docker-reload='docker compose down && docker compose up -d'
- name: General | Account Management | Users | Files | Common Variable
set_fact:
rc_common: |
{{ path_additions }}
{{ export_path_additions }}
{{ alias_cp }}
{{ alias_mv }}
{{ alias_rm }}
{{ alias_clean_dir }}
{{ alias_clean_trash }}
{{ function_wttr }}
{{ PS1 }}
{{ remount }}
{{ update }}
{{ sync }}
{{ editor }}
{{ export_PS1 }}
{{ alias_remount }}
{{ function_update }}
{{ alias_sync }}
{{ export_editor }}
{{ init_aliases }}
{{ bye }}
{{ metasploit }}
{{ show_config }}
{{ edit_config }}
{{ bye_aliases }}
{{ metasploit_aliases }}
{{ show_config_aliases }}
{{ edit_config_aliases }}
{{ function_check_trash }}
{{ function_clean }}
{{ function_flatpak_usage }}
{{ function_flatpak_purge }}
{{ alias_vim }}
{{ alias_here }}
{{ alias_docker_reload }}
{{ alias_docker_update }}
{{ function_docker_upgrade }}
{{ alias_docker_restart }}
- name: General | Account Management | Users | Files | .bashrc
blockinfile:

View File

@ -158,7 +158,7 @@
- name: Workstation | Account Management | GNOME | Dash To Dock | Icon Size
dconf:
key: /org/gnome/shell/extensions/dash-to-dock/dash-max-icon-size
value: "32"
value: "28"
state: present
become_user: "{{ user }}"