init
This commit is contained in:
commit
6d87ac8ba1
139 changed files with 7604 additions and 0 deletions
942
local-bin/.local/bin/betterlockscreen
Executable file
942
local-bin/.local/bin/betterlockscreen
Executable file
|
@ -0,0 +1,942 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Author : Copyright (c) 2017-2023 Pavan Jadhaw, and others (https://github.com/betterlockscreen/betterlockscreen/graphs/contributors)
|
||||
# Project Repository : https://github.com/betterlockscreen/betterlockscreen
|
||||
|
||||
cmd_exists () {
|
||||
command -v "$1" >/dev/null
|
||||
}
|
||||
|
||||
init_config () {
|
||||
# default options
|
||||
display_on=0
|
||||
span_image=false
|
||||
lock_timeout=300
|
||||
fx_list=(dim blur dimblur pixel dimpixel color)
|
||||
dim_level=40
|
||||
blur_level=1
|
||||
pixel_scale=10,1000
|
||||
solid_color=333333
|
||||
description=""
|
||||
quiet=false
|
||||
i3lockcolor_bin="i3lock-color"
|
||||
suspend_command="systemctl suspend"
|
||||
convert_command="magick"
|
||||
composite_command="magick composite"
|
||||
|
||||
if ! cmd_exists "$i3lockcolor_bin" && cmd_exists "i3lock"; then
|
||||
i3lockcolor_bin="i3lock"
|
||||
fi
|
||||
|
||||
if ! cmd_exists "magick"; then
|
||||
convert_command="convert"
|
||||
composite_command="composite"
|
||||
fi
|
||||
|
||||
# default theme
|
||||
loginbox=00000066
|
||||
loginshadow=00000000
|
||||
locktext="Type password to unlock..."
|
||||
font="sans-serif"
|
||||
ringcolor=ffffffff
|
||||
insidecolor=00000000
|
||||
separatorcolor=00000000
|
||||
ringvercolor=ffffffff
|
||||
insidevercolor=00000000
|
||||
ringwrongcolor=ffffffff
|
||||
insidewrongcolor=d23c3dff
|
||||
timecolor=ffffffff
|
||||
time_format="%H:%M:%S"
|
||||
greetercolor=ffffffff
|
||||
layoutcolor=ffffffff
|
||||
keyhlcolor=d23c3dff
|
||||
bshlcolor=d23c3dff
|
||||
veriftext="Verifying..."
|
||||
verifcolor=ffffffff
|
||||
wrongtext="Failure!"
|
||||
wrongcolor=d23c3dff
|
||||
modifcolor=d23c3dff
|
||||
bgcolor=000000ff
|
||||
wallpaper_cmd="feh --bg-fill"
|
||||
|
||||
# read user config
|
||||
USER_CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
USER_CONF="$USER_CONF_DIR/betterlockscreenrc"
|
||||
SYS_CONF="/etc/betterlockscreenrc"
|
||||
XDG_USER_CONF_DIR="$USER_CONF_DIR/betterlockscreen"
|
||||
XDG_USER_CONF="$XDG_USER_CONF_DIR/betterlockscreenrc"
|
||||
|
||||
if [ -e "$SYS_CONF" ]; then
|
||||
# shellcheck source=/dev/null
|
||||
source "$SYS_CONF"
|
||||
fi
|
||||
|
||||
if [ -e "$USER_CONF" ]; then
|
||||
echof error "Please, migrate your config $USER_CONF to $XDG_USER_CONF. Old location will soon be deprecated."
|
||||
echof info "mkdir -p ~/.config/betterlockscreen/ && mv $USER_CONF $XDG_USER_CONF"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
source "$USER_CONF"
|
||||
fi
|
||||
|
||||
if [ -e "$XDG_USER_CONF" ]; then
|
||||
# shellcheck source=/dev/null
|
||||
source "$XDG_USER_CONF"
|
||||
fi
|
||||
|
||||
if ! cmd_exists "$i3lockcolor_bin"; then
|
||||
echof error "Unable to find i3lock-color binary under detected/configured name: '$i3lockcolor_bin'!"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Please make sure to adjust this before release!
|
||||
VERSION="4.3.0"
|
||||
|
||||
# paths
|
||||
CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/betterlockscreen"
|
||||
CUR_DIR="$CACHE_DIR/current"
|
||||
|
||||
# wallpaper
|
||||
CUR_W_RESIZE="$CUR_DIR/wall_resize.png"
|
||||
CUR_W_DIM="$CUR_DIR/wall_dim.png"
|
||||
CUR_W_BLUR="$CUR_DIR/wall_blur.png"
|
||||
CUR_W_DIMBLUR="$CUR_DIR/wall_dimblur.png"
|
||||
CUR_W_PIXEL="$CUR_DIR/wall_pixel.png"
|
||||
CUR_W_DIMPIXEL="$CUR_DIR/wall_dimpixel.png"
|
||||
CUR_W_COLOR="$CUR_DIR/wall_color.png"
|
||||
|
||||
# lockscreen
|
||||
CUR_L_RESIZE="$CUR_DIR/lock_resize.png"
|
||||
CUR_L_DIM="$CUR_DIR/lock_dim.png"
|
||||
CUR_L_BLUR="$CUR_DIR/lock_blur.png"
|
||||
CUR_L_DIMBLUR="$CUR_DIR/lock_dimblur.png"
|
||||
CUR_L_PIXEL="$CUR_DIR/lock_pixel.png"
|
||||
CUR_L_DIMPIXEL="$CUR_DIR/lock_dimpixel.png"
|
||||
CUR_L_COLOR="$CUR_DIR/lock_color.png"
|
||||
|
||||
# Original DPMS timeout
|
||||
DEFAULT_TIMEOUT=$(cut -d ' ' -f4 <<< "$(xset q | sed -n '25p')")
|
||||
# Original DPMS status
|
||||
DEFAULT_DPMS=$(xset q | awk '/^[[:blank:]]*DPMS is/ {print $(NF)}')
|
||||
|
||||
# Dunst
|
||||
DUNST_INSTALLED=false && [[ -e "$(command -v dunstctl)" ]] && DUNST_INSTALLED=true
|
||||
DUNST_IS_RUNNING=false && [[ "$DUNST_INSTALLED" == "true" ]] && [[ "$(pgrep -c dunst)" -gt 0 ]] && DUNST_IS_RUNNING=true
|
||||
DUNST_IS_PAUSED=false && [[ "$DUNST_IS_RUNNING" == "true" ]] && DUNST_IS_PAUSED=$(dunstctl is-paused)
|
||||
|
||||
# Feh
|
||||
FEH_INSTALLED=false && [[ -e "$(command -v feh)" ]] && FEH_INSTALLED=true
|
||||
}
|
||||
|
||||
# called before screen is locked
|
||||
prelock() {
|
||||
# set dpms timeout
|
||||
if [ "$DEFAULT_DPMS" == "Enabled" ]; then
|
||||
xset dpms "$lock_timeout"
|
||||
fi
|
||||
|
||||
# If dusnt is already paused don't pause it again
|
||||
if [[ "$DUNST_IS_RUNNING" == "true" && "$DUNST_IS_PAUSED" == "false" ]]; then
|
||||
dunstctl set-paused true
|
||||
fi
|
||||
|
||||
if [ -e "$XDG_USER_CONF_DIR/custom-pre.sh" ]; then
|
||||
# shellcheck source=/dev/null
|
||||
source "$XDG_USER_CONF_DIR/custom-pre.sh"
|
||||
fi
|
||||
}
|
||||
|
||||
# lock screen with specified image
|
||||
lock() {
|
||||
local image="$1"
|
||||
local fontlg=32
|
||||
local fontmd=16
|
||||
local fontsm=12
|
||||
|
||||
if [ -f "$image" ]; then
|
||||
echof act "Locking screen..."
|
||||
else
|
||||
echof act "Locking screen... (FAILSAFE MODE)"
|
||||
fi
|
||||
|
||||
$i3lockcolor_bin \
|
||||
${image:+-i "$image"} \
|
||||
--color "$bgcolor" \
|
||||
${display_on:+-S "$display_on"} \
|
||||
--ind-pos="x+310:y+h-80" \
|
||||
--radius=25 \
|
||||
--ring-width=5 \
|
||||
--inside-color="$insidecolor" \
|
||||
--ring-color="$ringcolor" \
|
||||
--separator-color=$separatorcolor \
|
||||
--insidever-color="$insidevercolor" \
|
||||
--insidewrong-color="$insidewrongcolor" \
|
||||
--ringver-color="$ringvercolor" \
|
||||
--ringwrong-color="$ringwrongcolor" \
|
||||
--line-uses-inside \
|
||||
--keyhl-color="$keyhlcolor" \
|
||||
--bshl-color="$bshlcolor" \
|
||||
--clock --force-clock \
|
||||
--time-pos="ix-265:iy-10" \
|
||||
--time-align 1 \
|
||||
--time-str "$time_format" \
|
||||
--time-color="$timecolor" \
|
||||
--time-font="$font" \
|
||||
--time-size="$fontlg" \
|
||||
--date-str "" \
|
||||
--greeter-pos="ix-265:iy+12" \
|
||||
--greeter-align 1 \
|
||||
--greeter-text "$locktext" \
|
||||
--greeter-color="$greetercolor" \
|
||||
--greeter-font="$font" \
|
||||
--greeter-size="$fontmd" \
|
||||
--layout-pos="ix-265:iy+32" \
|
||||
--layout-align 1 \
|
||||
--layout-color="$layoutcolor" \
|
||||
--layout-font="$font" \
|
||||
--layout-size="$fontsm" \
|
||||
--verif-pos="ix+35:iy-34" \
|
||||
--verif-align 2 \
|
||||
--verif-text="$veriftext" \
|
||||
--verif-color="$verifcolor" \
|
||||
--verif-font="$font" \
|
||||
--verif-size="$fontsm" \
|
||||
--wrong-pos="ix+24:iy-34" \
|
||||
--wrong-align 2 \
|
||||
--wrong-text="$wrongtext" \
|
||||
--wrong-color="$wrongcolor" \
|
||||
--wrong-font="$font" \
|
||||
--wrong-size="$fontsm" \
|
||||
--modif-pos="ix+45:iy+43" \
|
||||
--modif-align 2 \
|
||||
--modif-size="$fontsm" \
|
||||
--modif-color="$modifcolor" \
|
||||
--noinput-text="" \
|
||||
--pass-media-keys \
|
||||
--pass-screen-keys \
|
||||
--pass-volume-keys \
|
||||
--pass-power-keys \
|
||||
"${lockargs[@]}"
|
||||
}
|
||||
|
||||
# called after screen is unlocked
|
||||
postlock() {
|
||||
# restore default dpms timeout
|
||||
if [ "$DEFAULT_DPMS" == "Enabled" ]; then
|
||||
xset dpms "$DEFAULT_TIMEOUT"
|
||||
fi
|
||||
|
||||
# If dunst already paused before locking don't unpause dunst
|
||||
if [[ "$DUNST_IS_RUNNING" == "true" && "$DUNST_IS_PAUSED" == "false" ]]; then
|
||||
dunstctl set-paused false
|
||||
fi
|
||||
|
||||
if [ -e "$XDG_USER_CONF_DIR/custom-post.sh" ]; then
|
||||
# shellcheck source=/dev/null
|
||||
source "$XDG_USER_CONF_DIR/custom-post.sh"
|
||||
fi
|
||||
}
|
||||
|
||||
# select effect and lock screen
|
||||
lockinit() {
|
||||
if pgrep -u "$USER" "$i3lockcolor_bin"; then
|
||||
echof error "i3lock already running"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echof act "Running prelock..."
|
||||
prelock
|
||||
|
||||
if [[ $runsuspend ]]; then
|
||||
lockselect "$@" &
|
||||
$suspend_command
|
||||
wait $!
|
||||
else
|
||||
lockselect "$@"
|
||||
fi
|
||||
|
||||
echof act "Running postlock..."
|
||||
postlock
|
||||
}
|
||||
|
||||
lockselect() {
|
||||
case "$1" in
|
||||
dim) lock "$CUR_L_DIM" ;;
|
||||
blur) lock "$CUR_L_BLUR" ;;
|
||||
dimblur) lock "$CUR_L_DIMBLUR" ;;
|
||||
pixel) lock "$CUR_L_PIXEL" ;;
|
||||
dimpixel) lock "$CUR_L_DIMPIXEL" ;;
|
||||
color) lock "$CUR_L_COLOR" ;;
|
||||
*) lock "$CUR_L_RESIZE" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# calculate adjustments for hidpi displays
|
||||
logical_px() {
|
||||
# $1: number of pixels to convert
|
||||
# $2: 1 for width. 2 for height
|
||||
local pixels="$1"
|
||||
local direction="$2"
|
||||
local dpi
|
||||
|
||||
# use DPI set by user in .Xresources
|
||||
dpi=$(xrdb -q | grep -oP '^\s*Xft.dpi:\s*\K\d+' | bc)
|
||||
|
||||
# or get dpi value from xdpyinfo
|
||||
if [ -z "$dpi" ]; then
|
||||
dpi=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$direction/p" | head -n1)
|
||||
fi
|
||||
|
||||
# adjust scaling
|
||||
if [ -n "$dpi" ]; then
|
||||
local scale
|
||||
scale=$(echo "scale=3; $dpi / 96.0" | bc)
|
||||
echo "$scale * $pixels / 1" | bc
|
||||
else
|
||||
# return the default value if no DPI is set
|
||||
echo "$pixels"
|
||||
fi
|
||||
}
|
||||
|
||||
# get total resolution, sets $TOTAL_SIZE
|
||||
get_total_size () {
|
||||
TOTAL_SIZE=$(xdpyinfo | grep -w "dimensions" | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/')
|
||||
}
|
||||
|
||||
# get list of displays, sets $DISPLAY_LIST
|
||||
get_display_list () {
|
||||
local count=0
|
||||
mapfile -t displays < <(xrandr --listactivemonitors)
|
||||
for display in "${displays[@]:1}"; do
|
||||
((count++))
|
||||
display="$(echo "$display" | sed -r 's/\/[0-9]*//g')"
|
||||
IFS=' ' read -r -a info <<< "$display"
|
||||
DISPLAY_LIST+=("$count ${info[3]} ${info[2]}")
|
||||
done
|
||||
}
|
||||
|
||||
# populate $WALL_LIST depending on number of displays and images passed
|
||||
get_wall_list() {
|
||||
local paths=("$@")
|
||||
declare -ga WALL_LIST
|
||||
|
||||
# multiple images and spanning conflict, bail out
|
||||
if [ "${#paths[@]}" -gt 1 ] && [ "$span_image" = true ]; then
|
||||
echof err "Can't use --span with multiple images!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if spanning return 1 image
|
||||
if [ "$span_image" = true ]; then
|
||||
get_image "${paths[0]}"
|
||||
|
||||
# if # paths is 1
|
||||
elif [ "${#paths[@]}" -eq 1 ]; then
|
||||
for ((i=0; i<${#DISPLAY_LIST[@]}; i++)); do
|
||||
# add same image to $WALL_LIST for each display
|
||||
get_image "${paths[0]}"
|
||||
done
|
||||
|
||||
# if # of paths equals # of displays
|
||||
elif [ ${#paths[@]} -eq "${#DISPLAY_LIST[@]}" ]; then
|
||||
for ((i=0; i<${#DISPLAY_LIST[@]}; i++)); do
|
||||
# add each image to $WALL_LIST
|
||||
get_image "${paths[$i]}"
|
||||
done
|
||||
|
||||
# if # of paths differ from # of display, bail out
|
||||
else
|
||||
echof err "${#paths[@]} images provided for ${#DISPLAY_LIST[@]} displays!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# get image path, append to $WALL_LIST
|
||||
get_image() {
|
||||
local path="$1"
|
||||
|
||||
# we have a file
|
||||
if [ -f "$path" ]; then
|
||||
WALL_LIST+=("$path")
|
||||
return
|
||||
# we have a directory
|
||||
elif [ -d "$path" ]; then
|
||||
dir=("$path"/*)
|
||||
rdir="${dir[RANDOM % ${#dir[@]}]}"
|
||||
get_image "$rdir" # <-- calls itself
|
||||
# not file or directory, bail out
|
||||
else
|
||||
echof err "invalid path: $path"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# scale base image and generate effects
|
||||
resize_and_render () {
|
||||
local base="$1"
|
||||
local path="$2"
|
||||
local resolution="$3"
|
||||
|
||||
# resource paths
|
||||
RES_RESIZE="$path/resize.png"
|
||||
RES_DIM="$path/dim.png"
|
||||
RES_BLUR="$path/blur.png"
|
||||
RES_DIMBLUR="$path/dimblur.png"
|
||||
RES_PIXEL="$path/pixel.png"
|
||||
RES_DIMPIXEL="$path/dimpixel.png"
|
||||
RES_COLOR="$path/color.png"
|
||||
|
||||
# resize
|
||||
base_resize "$base" "$RES_RESIZE" "$resolution"
|
||||
|
||||
# effects
|
||||
for effect in "${fx_list[@]}"; do
|
||||
case $effect in
|
||||
dim) fx_dim "$RES_RESIZE" "$RES_DIM";;
|
||||
blur) fx_blur "$RES_RESIZE" "$RES_BLUR" "$resolution";;
|
||||
dimblur) fx_dimblur "$RES_RESIZE" "$RES_DIMBLUR" "$resolution";;
|
||||
pixel) fx_pixel "$RES_RESIZE" "$RES_PIXEL";;
|
||||
dimpixel) fx_dimpixel "$RES_RESIZE" "$RES_DIMPIXEL";;
|
||||
color) fx_color "$RES_COLOR" "$resolution";;
|
||||
esac
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
# apply resize
|
||||
base_resize() {
|
||||
local input="$1"
|
||||
local output="$2"
|
||||
local size="$3"
|
||||
|
||||
echof act "Resizing base image..."
|
||||
eval $convert_command "$input" \
|
||||
-resize "$size""^" \
|
||||
-gravity center \
|
||||
-extent "$size" \
|
||||
"$output"
|
||||
}
|
||||
|
||||
# apply dim
|
||||
fx_dim() {
|
||||
local input="$1"
|
||||
local output="$2"
|
||||
|
||||
echof act "Rendering 'dim' effect..."
|
||||
eval $convert_command "$input" \
|
||||
-fill black -colorize "$dim_level"% \
|
||||
"$output"
|
||||
}
|
||||
|
||||
# apply blur
|
||||
fx_blur() {
|
||||
local input="$1"
|
||||
local output="$2"
|
||||
local size="$3"
|
||||
|
||||
echof act "Rendering 'blur' effect..."
|
||||
blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc)
|
||||
blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc)
|
||||
eval $convert_command "$input" \
|
||||
-filter Gaussian \
|
||||
-resize "$blur_shrink%" \
|
||||
-define "filter:sigma=$blur_sigma" \
|
||||
-resize "$size^" -gravity center -extent "$size" \
|
||||
"$output"
|
||||
}
|
||||
|
||||
# apply dimblur
|
||||
fx_dimblur() {
|
||||
local input="$1"
|
||||
local output="$2"
|
||||
local size="$3"
|
||||
|
||||
echof act "Rendering 'dimblur' effect..."
|
||||
blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc)
|
||||
blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc)
|
||||
eval $convert_command "$input" \
|
||||
-fill black -colorize "$dim_level"% \
|
||||
-filter Gaussian \
|
||||
-resize "$blur_shrink%" \
|
||||
-define "filter:sigma=$blur_sigma" \
|
||||
-resize "$size^" -gravity center -extent "$size" \
|
||||
"$output"
|
||||
}
|
||||
|
||||
# pixelate
|
||||
fx_pixel() {
|
||||
local input="$1"
|
||||
local output="$2"
|
||||
|
||||
echof act "Rendering 'pixel' effect..."
|
||||
IFS=',' read -ra range <<< "$pixel_scale"
|
||||
eval $convert_command "$input" \
|
||||
-scale "${range[0]}"% -scale "${range[1]}"% \
|
||||
"$output"
|
||||
}
|
||||
|
||||
# apply dimpixel
|
||||
fx_dimpixel() {
|
||||
local input="$1"
|
||||
local output="$2"
|
||||
|
||||
echof act "Rendering 'dimpixel' effect..."
|
||||
IFS=',' read -ra range <<< "$pixel_scale"
|
||||
eval $convert_command "$input" \
|
||||
-fill black -colorize "$dim_level"% \
|
||||
-scale "${range[0]}"% -scale "${range[1]}"% \
|
||||
"$output"
|
||||
}
|
||||
|
||||
# create solid color
|
||||
fx_color() {
|
||||
local output="$1"
|
||||
local size="$2"
|
||||
|
||||
echof act "Rendering 'color' effect..."
|
||||
eval $convert_command -size "$size" canvas:\#"$solid_color" "$RES_COLOR"
|
||||
}
|
||||
|
||||
# create loginbox rectangle, set "$RECTANGLE"
|
||||
create_loginbox () {
|
||||
RECTANGLE="$CUR_DIR/rectangle.png"
|
||||
local shadow="$CUR_DIR/shadow.png"
|
||||
local width height
|
||||
width=$(logical_px 340 1)
|
||||
height=$(logical_px 100 2)
|
||||
$convert_command -size "$width"x"$height" xc:\#"$loginbox" -fill none "$RECTANGLE"
|
||||
$convert_command "$RECTANGLE" \
|
||||
\( -clone 0 -background \#"$loginshadow" -shadow 100x5+0+0 \) +swap \
|
||||
-background none -layers merge +repage "$shadow"
|
||||
$composite_command -compose Dst_Out -gravity center \
|
||||
"$RECTANGLE" "$shadow" -alpha Set "$shadow"
|
||||
$convert_command "$shadow" "$RECTANGLE" -geometry +10+10 -composite "$RECTANGLE"
|
||||
[[ "$shadow" ]] && rm "$shadow"
|
||||
}
|
||||
|
||||
# create rectangle with description, set "$DESCRECT"
|
||||
create_description () {
|
||||
DESCRECT="$CUR_DIR/description.png"
|
||||
local shadow="$CUR_DIR/shadow.png"
|
||||
$convert_command -background none -family "$(fc-match "$font" family)" -style Normal -pointsize 14 -fill \#"$greetercolor" label:"\ $description\ " -bordercolor \#"$loginbox" -border 10 "$DESCRECT"
|
||||
$convert_command "$DESCRECT" \
|
||||
\( -clone 0 -background \#"$loginshadow" -shadow 100x5+0+0 \) +swap \
|
||||
-background none -layers merge +repage "$shadow"
|
||||
$composite_command -compose Dst_Out -gravity center \
|
||||
"$DESCRECT" "$shadow" -alpha Set "$shadow"
|
||||
$convert_command "$shadow" "$DESCRECT" -geometry +10+10 -composite "$DESCRECT"
|
||||
[[ "$shadow" ]] && rm "$shadow"
|
||||
}
|
||||
|
||||
# delete and recreate directory
|
||||
purge_cache () {
|
||||
if [[ -d "$1" ]]; then
|
||||
rm -r "$1"
|
||||
fi
|
||||
mkdir -p "$1"
|
||||
}
|
||||
|
||||
# update lockscreen and wallpaper images
|
||||
update () {
|
||||
local images=("$@")
|
||||
|
||||
echof act "Updating image cache..."
|
||||
mkdir -p "$CACHE_DIR" &>/dev/null
|
||||
|
||||
get_display_list # DISPLAY_LIST
|
||||
get_total_size # TOTAL_SIZE
|
||||
echof info "Detected ${#DISPLAY_LIST[@]} display(s) @ $TOTAL_SIZE total resolution"
|
||||
|
||||
get_wall_list "${images[@]}" # WALL_LIST
|
||||
echof info "Original image(s): ${WALL_LIST[*]##*/}"
|
||||
|
||||
# Prepare description box to obtain width for positioning
|
||||
local descwidth
|
||||
local descheight
|
||||
if [ -z "$description" ]; then
|
||||
descwidth=0
|
||||
descheight=0
|
||||
else
|
||||
create_description
|
||||
descwidth=$(identify -format "%[fx:w]" "$DESCRECT")
|
||||
descheight=$(identify -format "%[fx:h]" "$DESCRECT")
|
||||
fi
|
||||
|
||||
for ((i=0; i<${#DISPLAY_LIST[@]}; i++)); do
|
||||
display="${DISPLAY_LIST[$i]}"
|
||||
USER_WALL="${WALL_LIST[$i]}"
|
||||
|
||||
# escape spaces for IM
|
||||
if echo "$USER_WALL" | grep -E -q "[[:space:]]"; then
|
||||
USER_WALL="${USER_WALL// /\\ }"
|
||||
fi
|
||||
|
||||
IFS=' ' read -r -a dinfo <<< "$display"
|
||||
local id="${dinfo[0]}"
|
||||
local device="${dinfo[1]}"
|
||||
local geometry="${dinfo[2]}"
|
||||
|
||||
read -r -a cols <<< "${geometry//[x+-]/ }"
|
||||
local position="${geometry#*"${cols[1]}"}"
|
||||
local resolution="${geometry%"${position}"*}"
|
||||
|
||||
if [[ $id -eq "$display_on" ]] || [[ "$display_on" -eq 0 ]]; then
|
||||
|
||||
IFS='x' read -r -a dimension <<< "$resolution"
|
||||
res_x="${dimension[0]}"
|
||||
res_y="${dimension[1]}"
|
||||
read -r -a val <<< "${position//[+-]/ }"
|
||||
read -r -a sym <<< "${position//[0-9]/ }"
|
||||
pos_x="${sym[0]}${val[0]}"
|
||||
pos_y="${sym[1]}${val[1]}"
|
||||
|
||||
rect_x=$((pos_x + $(logical_px 15 1)))
|
||||
rect_y=$((pos_y + res_y - $(logical_px 140 2)))
|
||||
positions+=("+$((rect_x))+$((rect_y))")
|
||||
|
||||
descrect_x=$((pos_x + res_x - descwidth - $(logical_px 15 1)))
|
||||
descrect_y=$((pos_y + res_y - descheight - $(logical_px 20 2)))
|
||||
positions_desc+=("+$((descrect_x))+$((descrect_y))")
|
||||
fi
|
||||
|
||||
local path="$CACHE_DIR/$id-$device"
|
||||
purge_cache "$path"
|
||||
|
||||
if [ "$span_image" = true ]; then
|
||||
if [ "$id" -gt 1 ]; then
|
||||
continue
|
||||
else
|
||||
device="[span]"
|
||||
id="*"
|
||||
resolution="$TOTAL_SIZE"
|
||||
fi
|
||||
fi
|
||||
|
||||
echof info "Processing display: $device ($id)"
|
||||
echof info "Resolution: $resolution"
|
||||
|
||||
if [ "$span_image" = true ]; then
|
||||
resize_and_render "$USER_WALL" "$path" "$resolution"
|
||||
else
|
||||
resize_and_render "$USER_WALL" "$path" "$resolution"
|
||||
|
||||
PARAM_RESIZE="$PARAM_RESIZE $RES_RESIZE -geometry $position -composite "
|
||||
PARAM_DIM="$PARAM_DIM $RES_DIM -geometry $position -composite "
|
||||
PARAM_BLUR="$PARAM_BLUR $RES_BLUR -geometry $position -composite "
|
||||
PARAM_DIMBLUR="$PARAM_DIMBLUR $RES_DIMBLUR -geometry $position -composite "
|
||||
PARAM_PIXEL="$PARAM_PIXEL $RES_PIXEL -geometry $position -composite "
|
||||
PARAM_DIMPIXEL="$PARAM_DIMPIXEL $RES_DIMPIXEL -geometry $position -composite "
|
||||
PARAM_COLOR="$PARAM_COLOR $RES_COLOR -geometry $position -composite "
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
purge_cache "$CUR_DIR"
|
||||
|
||||
if [ "$span_image" = true ] || [ ${#DISPLAY_LIST[@]} -lt 2 ]; then
|
||||
echof act "Rendering final wallpaper images..."
|
||||
[[ -f "$RES_RESIZE" ]] && eval "cp $RES_RESIZE $CUR_W_RESIZE"
|
||||
[[ -f "$RES_DIM" ]] && eval "cp $RES_DIM $CUR_W_DIM"
|
||||
[[ -f "$RES_BLUR" ]] && eval "cp $RES_BLUR $CUR_W_BLUR"
|
||||
[[ -f "$RES_DIMBLUR" ]] && eval "cp $RES_DIMBLUR $CUR_W_DIMBLUR"
|
||||
[[ -f "$RES_PIXEL" ]] && eval "cp $RES_PIXEL $CUR_W_PIXEL"
|
||||
[[ -f "$RES_DIMPIXEL" ]] && eval "cp $RES_DIMPIXEL $CUR_W_DIMPIXEL"
|
||||
[[ -f "$RES_COLOR" ]] && eval "cp $RES_COLOR $CUR_W_COLOR"
|
||||
else
|
||||
echof act "Creating canvas: $TOTAL_SIZE"
|
||||
[[ -f "$RES_RESIZE" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_RESIZE"
|
||||
[[ -f "$RES_DIM" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIM"
|
||||
[[ -f "$RES_BLUR" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_BLUR"
|
||||
[[ -f "$RES_DIMBLUR" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIMBLUR"
|
||||
[[ -f "$RES_PIXEL" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_PIXEL"
|
||||
[[ -f "$RES_DIMPIXEL" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIMPIXEL"
|
||||
[[ -f "$RES_COLOR" ]] && eval "$convert_command -size $TOTAL_SIZE 'xc:blue' $CUR_W_COLOR"
|
||||
|
||||
echof act "Rendering final wallpaper images..."
|
||||
[[ -f "$CUR_W_RESIZE" ]] && eval "$convert_command $CUR_W_RESIZE $PARAM_RESIZE $CUR_W_RESIZE"
|
||||
[[ -f "$CUR_W_DIM" ]] && eval "$convert_command $CUR_W_DIM $PARAM_DIM $CUR_W_DIM"
|
||||
[[ -f "$CUR_W_BLUR" ]] && eval "$convert_command $CUR_W_BLUR $PARAM_BLUR $CUR_W_BLUR"
|
||||
[[ -f "$CUR_W_DIMBLUR" ]] && eval "$convert_command $CUR_W_DIMBLUR $PARAM_DIMBLUR $CUR_W_DIMBLUR"
|
||||
[[ -f "$CUR_W_PIXEL" ]] && eval "$convert_command $CUR_W_PIXEL $PARAM_PIXEL $CUR_W_PIXEL"
|
||||
[[ -f "$CUR_W_DIMPIXEL" ]] && eval "$convert_command $CUR_W_DIMPIXEL $PARAM_DIMPIXEL $CUR_W_DIMPIXEL"
|
||||
[[ -f "$CUR_W_COLOR" ]] && eval "$convert_command $CUR_W_COLOR $PARAM_COLOR $CUR_W_COLOR"
|
||||
fi
|
||||
|
||||
echof act "Rendering final lockscreen images..."
|
||||
|
||||
create_loginbox
|
||||
for pos in "${positions[@]}"; do
|
||||
PARAM_RECT="$PARAM_RECT $RECTANGLE -geometry $pos -composite "
|
||||
done
|
||||
|
||||
if [ -n "$description" ]; then
|
||||
create_description
|
||||
for descpos in "${positions_desc[@]}"; do
|
||||
PARAM_RECT="$PARAM_RECT $DESCRECT -geometry $descpos -composite "
|
||||
done
|
||||
fi
|
||||
|
||||
[[ -f "$CUR_W_RESIZE" ]] && eval "$convert_command $CUR_W_RESIZE $PARAM_RECT $CUR_L_RESIZE"
|
||||
[[ -f "$CUR_W_DIM" ]] && eval "$convert_command $CUR_W_DIM $PARAM_RECT $CUR_L_DIM"
|
||||
[[ -f "$CUR_W_BLUR" ]] && eval "$convert_command $CUR_W_BLUR $PARAM_RECT $CUR_L_BLUR"
|
||||
[[ -f "$CUR_W_DIMBLUR" ]] && eval "$convert_command $CUR_W_DIMBLUR $PARAM_RECT $CUR_L_DIMBLUR"
|
||||
[[ -f "$CUR_W_PIXEL" ]] && eval "$convert_command $CUR_W_PIXEL $PARAM_RECT $CUR_L_PIXEL"
|
||||
[[ -f "$CUR_W_DIMPIXEL" ]] && eval "$convert_command $CUR_W_DIMPIXEL $PARAM_RECT $CUR_L_DIMPIXEL"
|
||||
[[ -f "$CUR_W_COLOR" ]] && eval "$convert_command $CUR_W_COLOR $PARAM_RECT $CUR_L_COLOR"
|
||||
|
||||
[[ "$RECTANGLE" ]] && rm "$RECTANGLE"
|
||||
[[ "$DESCRECT" ]] && rm "$DESCRECT"
|
||||
|
||||
echof ok "Done"
|
||||
|
||||
}
|
||||
|
||||
# set wallpaper with effect
|
||||
wallpaper() {
|
||||
local effect="$1"
|
||||
|
||||
# make wallpaper span displays
|
||||
get_display_list
|
||||
if [ "$span_image" = true ] || [[ "${#DISPLAY_LIST[@]}" -gt 1 ]]; then
|
||||
wallpaper_cmd="$wallpaper_cmd --no-xinerama"
|
||||
fi
|
||||
|
||||
# set wallpaper
|
||||
case "$effect" in
|
||||
dim) wallpaper="$CUR_W_DIM";;
|
||||
blur) wallpaper="$CUR_W_BLUR";;
|
||||
dimblur) wallpaper="$CUR_W_DIMBLUR";;
|
||||
pixel) wallpaper="$CUR_W_PIXEL";;
|
||||
dimpixel) wallpaper="$CUR_W_DIMPIXEL";;
|
||||
color) wallpaper="$CUR_W_COLOR";;
|
||||
*) wallpaper="$CUR_W_RESIZE";;
|
||||
esac
|
||||
eval "$wallpaper_cmd $wallpaper"
|
||||
}
|
||||
|
||||
# wrap echo with fancy prefix
|
||||
echof() {
|
||||
local prefix="$1"
|
||||
local message="$2"
|
||||
|
||||
case "$prefix" in
|
||||
header) msgpfx="[\e[1;95mB\e[m]";;
|
||||
info) msgpfx="[\e[1;97m=\e[m]";;
|
||||
act) msgpfx="[\e[1;92m*\e[m]";;
|
||||
ok) msgpfx="[\e[1;93m+\e[m]";;
|
||||
error) msgpfx="[\e[1;91m!\e[m]";;
|
||||
*) msgpfx="";;
|
||||
esac
|
||||
[ "$quiet" != true ] && echo -e "$msgpfx $message"
|
||||
}
|
||||
|
||||
# help message
|
||||
usage() {
|
||||
echo
|
||||
echo "Usage: betterlockscreen [-u <PATH>] [-l <EFFECT>] [-w <EFFECT>]"
|
||||
echo
|
||||
echo " -q --quiet"
|
||||
echo " Do not produce any text output on locking"
|
||||
echo
|
||||
echo " -u --update <PATH>"
|
||||
echo " Update lock screen image"
|
||||
echo
|
||||
echo " -l --lock <EFFECT>"
|
||||
echo " Lock screen with cached image"
|
||||
echo
|
||||
echo " -w --wall <EFFECT>"
|
||||
echo " Set wallpaper with cached image"
|
||||
echo
|
||||
echo "Additional arguments:"
|
||||
echo
|
||||
echo " --display <N>"
|
||||
echo " Set display to draw loginbox"
|
||||
echo
|
||||
echo " --span"
|
||||
echo " Scale image to span multiple displays"
|
||||
echo
|
||||
echo " --off <N>"
|
||||
echo " Turn display off after N seconds"
|
||||
echo
|
||||
echo " --fx <EFFECT,EFFECT,EFFECT>"
|
||||
echo " List of effects to generate"
|
||||
echo
|
||||
echo " --desc <DESCRIPTION>"
|
||||
echo " Set a description for the new lock screen image"
|
||||
echo " (Only has an effect in combination with --update)"
|
||||
echo
|
||||
echo " --show-layout"
|
||||
echo " Show current keyboard layout"
|
||||
echo
|
||||
echo " --wallpaper-cmd <command>"
|
||||
echo " to set your custom wallpaper setter"
|
||||
echo
|
||||
echo " --time-format <format>"
|
||||
echo " to set the time format used by i3lock-color"
|
||||
echo
|
||||
echo " -- <ARGS>"
|
||||
echo " Pass additional arguments to i3lock"
|
||||
echo
|
||||
echo "Effects arguments:"
|
||||
echo
|
||||
echo " --dim <N>"
|
||||
echo " Dim image N percent (0-100)"
|
||||
echo
|
||||
echo " --blur <N>"
|
||||
echo " Blur image N amount (0.0-1.0)"
|
||||
echo
|
||||
echo " --pixel <N,N>"
|
||||
echo " Pixelate image with N shrink and N grow (unsupported)"
|
||||
echo
|
||||
echo " --color <HEX>"
|
||||
echo " Solid color background with HEX"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
lockargs=(-n)
|
||||
|
||||
init_config
|
||||
|
||||
# show usage when no arguments passed
|
||||
[[ "$1" = "" ]] && usage
|
||||
|
||||
# process arguments
|
||||
for arg in "$@"; do
|
||||
[[ "${arg:0:1}" = '-' ]] || continue
|
||||
|
||||
case "$1" in
|
||||
|
||||
-q | --quiet)
|
||||
quiet=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-u | --update)
|
||||
runupdate=true
|
||||
imagepaths+=("$2")
|
||||
shift 2
|
||||
;;
|
||||
|
||||
-s | --suspend)
|
||||
runsuspend=true
|
||||
;&
|
||||
|
||||
-l | --lock)
|
||||
runlock=true
|
||||
if [[ ${2:0:1} = '-' ]]; then
|
||||
shift 1
|
||||
else
|
||||
lockstyle="$2"; shift 2
|
||||
fi
|
||||
;;
|
||||
|
||||
-w | --wall)
|
||||
wallpaper "$2"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--wallpaper-cmd)
|
||||
wallpaper_cmd="$2"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--time-format)
|
||||
time_format="$2"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--display)
|
||||
display_on="$2"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--span)
|
||||
span_image=true
|
||||
shift 1
|
||||
;;
|
||||
|
||||
--off)
|
||||
lock_timeout="$2"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--text)
|
||||
locktext="$2"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--show-layout)
|
||||
keylayout="$2";
|
||||
lockargs+=(--keylayout "${keylayout:-0}")
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--fx)
|
||||
IFS=',' read -ra fx_list <<< "$2"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--dim)
|
||||
dim_level="$2"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--blur)
|
||||
blur_level="$2"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--pixel)
|
||||
pixel_scale="$2"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--color)
|
||||
solid_color="${2//\#/}"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
--desc)
|
||||
description="$2"
|
||||
shift 2
|
||||
;;
|
||||
|
||||
-v | --version)
|
||||
echo
|
||||
echo "Betterlockscreen: version: v$VERSION (dunst: $DUNST_INSTALLED, feh: $FEH_INSTALLED)"
|
||||
$i3lockcolor_bin --version
|
||||
$convert_command --version
|
||||
|
||||
if [[ "$DUNST_INSTALLED" == "true" ]]; then
|
||||
dunstctl debug
|
||||
fi
|
||||
|
||||
if [[ "$FEH_INSTALLED" == "true" ]]; then
|
||||
feh --version
|
||||
fi
|
||||
|
||||
break
|
||||
;;
|
||||
|
||||
--)
|
||||
lockargs+=("${@:2}")
|
||||
break
|
||||
;;
|
||||
|
||||
-h | --help | *)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echof header "Betterlockscreen"
|
||||
|
||||
# Run image generation
|
||||
[[ $runupdate ]] && update "${imagepaths[@]}"
|
||||
|
||||
# Activate lockscreen
|
||||
[[ $runlock ]] && lockinit "$lockstyle"
|
||||
|
||||
exit 0
|
53
local-bin/.local/bin/dbeaver-backup.sh
Executable file
53
local-bin/.local/bin/dbeaver-backup.sh
Executable file
|
@ -0,0 +1,53 @@
|
|||
#!/bin/bash
|
||||
|
||||
# DBeaver Profile Backup Script
|
||||
# This script creates a backup of DBeaver profiles and configurations
|
||||
|
||||
# Configuration variables - modify as needed
|
||||
BACKUP_DIR="/home/forbi/Sync/Backups"
|
||||
HOSTNAME=$(hostname)
|
||||
BACKUP_FILE="dbeaver_backup_${HOSTNAME}.tar.gz"
|
||||
LOG_FILE="$BACKUP_DIR/dbeaver_backup_log.txt"
|
||||
|
||||
# DBeaver configuration location
|
||||
DBEAVER_DATA="$HOME/.local/share/DBeaverData" # Contains drivers, workspace, and secure storage
|
||||
|
||||
# Create backup directory if it doesn't exist
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
# Start logging
|
||||
echo "===== DBeaver Backup Started at $(date) =====" >>"$LOG_FILE"
|
||||
|
||||
# Check if DBeaver configuration exists
|
||||
if [ ! -d "$DBEAVER_DATA" ]; then
|
||||
echo "Error: DBeaver configuration not found at $DBEAVER_DATA. Please make sure DBeaver is installed and has been run at least once." | tee -a "$LOG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create temporary directory for backup
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
echo "Created temporary directory: $TEMP_DIR" >>"$LOG_FILE"
|
||||
|
||||
# Copy DBeaver data to temporary directory
|
||||
echo "Copying DBeaver data from $DBEAVER_DATA..." >>"$LOG_FILE"
|
||||
cp -r "$DBEAVER_DATA" "$TEMP_DIR/"
|
||||
|
||||
# Create compressed archive
|
||||
echo "Creating backup archive..." >>"$LOG_FILE"
|
||||
tar -czf "$BACKUP_DIR/$BACKUP_FILE" -C "$TEMP_DIR" .
|
||||
BACKUP_RESULT=$?
|
||||
|
||||
# Clean up temporary directory
|
||||
echo "Cleaning up temporary files..." >>"$LOG_FILE"
|
||||
rm -rf "$TEMP_DIR"
|
||||
|
||||
# Check if backup was successful
|
||||
if [ $BACKUP_RESULT -eq 0 ]; then
|
||||
echo "Backup completed successfully: $BACKUP_DIR/$BACKUP_FILE" | tee -a "$LOG_FILE"
|
||||
echo "Backup size: $(du -h "$BACKUP_DIR/$BACKUP_FILE" | cut -f1)" | tee -a "$LOG_FILE"
|
||||
echo "Keeping only the latest backup for this PC ($HOSTNAME)" >>"$LOG_FILE"
|
||||
else
|
||||
echo "Error: Backup failed with exit code $BACKUP_RESULT" | tee -a "$LOG_FILE"
|
||||
fi
|
||||
|
||||
echo "===== DBeaver Backup Finished at $(date) =====" >>"$LOG_FILE"
|
72
local-bin/.local/bin/dbeaver-restore.sh
Executable file
72
local-bin/.local/bin/dbeaver-restore.sh
Executable file
|
@ -0,0 +1,72 @@
|
|||
#!/bin/bash
|
||||
# DBeaver Profile Restore Script
|
||||
# This script restores a DBeaver backup created with the backup script
|
||||
|
||||
# Configuration variables - modify as needed
|
||||
BACKUP_DIR="/home/forbi/Sync/Backups"
|
||||
HOSTNAME=main
|
||||
BACKUP_FILE="dbeaver_backup_${HOSTNAME}.tar.gz"
|
||||
LOG_FILE="$BACKUP_DIR/dbeaver_restore_log.txt"
|
||||
|
||||
# DBeaver configuration location
|
||||
DBEAVER_DATA="$HOME/.local/share/DBeaverData"
|
||||
|
||||
# Start logging
|
||||
echo "===== DBeaver Restore Started at $(date) =====" >>"$LOG_FILE"
|
||||
|
||||
# Check if backup file exists
|
||||
if [ ! -f "$BACKUP_DIR/$BACKUP_FILE" ]; then
|
||||
echo "Error: Backup file not found at $BACKUP_DIR/$BACKUP_FILE" | tee -a "$LOG_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if DBeaver data directory exists and create backup if it does
|
||||
if [ -d "$DBEAVER_DATA" ]; then
|
||||
echo "DBeaver data directory exists. Creating backup before restoration..." | tee -a "$LOG_FILE"
|
||||
TEMP_BACKUP="${DBEAVER_DATA}_backup_$(date +%Y%m%d_%H%M%S)"
|
||||
mv "$DBEAVER_DATA" "$TEMP_BACKUP"
|
||||
echo "Original data backed up to: $TEMP_BACKUP" | tee -a "$LOG_FILE"
|
||||
fi
|
||||
|
||||
# Create temporary directory for extraction
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
echo "Created temporary directory for extraction: $TEMP_DIR" >>"$LOG_FILE"
|
||||
|
||||
# Extract backup file
|
||||
echo "Extracting backup archive..." | tee -a "$LOG_FILE"
|
||||
tar -xzf "$BACKUP_DIR/$BACKUP_FILE" -C "$TEMP_DIR"
|
||||
EXTRACT_RESULT=$?
|
||||
|
||||
if [ $EXTRACT_RESULT -ne 0 ]; then
|
||||
echo "Error: Failed to extract backup with exit code $EXTRACT_RESULT" | tee -a "$LOG_FILE"
|
||||
rm -rf "$TEMP_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create target directory if it doesn't exist
|
||||
mkdir -p "$(dirname "$DBEAVER_DATA")"
|
||||
|
||||
# Copy extracted content to DBeaver data directory
|
||||
echo "Restoring DBeaver data to $DBEAVER_DATA..." | tee -a "$LOG_FILE"
|
||||
cp -r "$TEMP_DIR/DBeaverData" "$(dirname "$DBEAVER_DATA")/"
|
||||
RESTORE_RESULT=$?
|
||||
|
||||
# Clean up temporary directory
|
||||
echo "Cleaning up temporary files..." >>"$LOG_FILE"
|
||||
rm -rf "$TEMP_DIR"
|
||||
|
||||
# Check if restore was successful
|
||||
if [ $RESTORE_RESULT -eq 0 ]; then
|
||||
echo "Restore completed successfully to: $DBEAVER_DATA" | tee -a "$LOG_FILE"
|
||||
echo "You may need to restart DBeaver for changes to take effect." | tee -a "$LOG_FILE"
|
||||
else
|
||||
echo "Error: Restore failed with exit code $RESTORE_RESULT" | tee -a "$LOG_FILE"
|
||||
if [ -d "$TEMP_BACKUP" ]; then
|
||||
echo "Attempting to restore original data from backup..." | tee -a "$LOG_FILE"
|
||||
rm -rf "$DBEAVER_DATA"
|
||||
mv "$TEMP_BACKUP" "$DBEAVER_DATA"
|
||||
echo "Original data restored from backup." | tee -a "$LOG_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "===== DBeaver Restore Finished at $(date) =====" >>"$LOG_FILE"
|
237
local-bin/.local/bin/maintenance.sh
Executable file
237
local-bin/.local/bin/maintenance.sh
Executable file
|
@ -0,0 +1,237 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Make sure we're running as root or with sudo
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
gum style --foreground 196 --bold "This script must be run as root or with sudo"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if gum is installed
|
||||
if ! command -v gum &>/dev/null; then
|
||||
echo "This script uses gum for a nice interface."
|
||||
echo "Please install gum first: pacman -S gum"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Function to print section headers
|
||||
print_section() {
|
||||
gum style --border normal --border-foreground 39 --margin "1" --padding "0 2" --bold "$1"
|
||||
}
|
||||
|
||||
# Function to print tasks
|
||||
print_task() {
|
||||
echo "→ $1..."
|
||||
}
|
||||
|
||||
# Function to print success messages
|
||||
print_success() {
|
||||
gum style --foreground 46 "✓ $1"
|
||||
}
|
||||
|
||||
# Function to print warning messages
|
||||
print_warning() {
|
||||
gum style --foreground 226 "⚠ $1"
|
||||
}
|
||||
|
||||
# Starting message
|
||||
# Starting message
|
||||
echo "=== Arch Linux System Maintenance ==="
|
||||
|
||||
# Update the system
|
||||
print_section "Updating System"
|
||||
|
||||
# Sync package database
|
||||
print_task "Synchronizing package databases"
|
||||
pacman -Sy
|
||||
print_success "Package databases synchronized"
|
||||
|
||||
# Clean package caches
|
||||
print_section "Cleaning Package Caches"
|
||||
|
||||
# Clean pacman cache
|
||||
print_task "Cleaning pacman cache"
|
||||
pacman -Sc --noconfirm
|
||||
print_success "Pacman cache cleaned"
|
||||
|
||||
# Clean AUR cache if paru is installed
|
||||
if command -v paru &>/dev/null; then
|
||||
print_task "Cleaning paru cache"
|
||||
paru -Sc --noconfirm
|
||||
print_success "Paru cache cleaned"
|
||||
else
|
||||
print_warning "paru not found. Skipping AUR cache cleanup."
|
||||
fi
|
||||
|
||||
# Remove orphaned packages
|
||||
print_section "Removing Orphaned Packages"
|
||||
print_task "Finding orphaned packages"
|
||||
ORPHANS=$(pacman -Qtdq)
|
||||
if [ -n "$ORPHANS" ]; then
|
||||
echo "Found orphaned packages:"
|
||||
echo "$ORPHANS"
|
||||
|
||||
print_task "Removing orphaned packages"
|
||||
pacman -Rns $(pacman -Qtdq) --noconfirm
|
||||
print_success "Orphaned packages removed"
|
||||
else
|
||||
print_success "No orphaned packages found"
|
||||
fi
|
||||
|
||||
# Clean user cache directory
|
||||
print_section "Cleaning User Cache Directory"
|
||||
|
||||
# Get current user's username
|
||||
CURRENT_USER=$(logname 2>/dev/null || echo $SUDO_USER)
|
||||
|
||||
# If we still don't have a username, try to get it from /home
|
||||
if [ -z "$CURRENT_USER" ]; then
|
||||
CURRENT_USER=$(ls -la /home | grep -v "\.\." | grep -v "total" | awk '{print $9}' | head -1)
|
||||
fi
|
||||
|
||||
echo "Cleaning cache for user: $CURRENT_USER"
|
||||
|
||||
# Create a backup directory
|
||||
BACKUP_DIR="/home/$CURRENT_USER/.cache_backup_$(date +%Y%m%d)"
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
chown $CURRENT_USER:$CURRENT_USER "$BACKUP_DIR"
|
||||
|
||||
# User cache directory
|
||||
USER_CACHE="/home/$CURRENT_USER/.cache"
|
||||
|
||||
if [ -d "$USER_CACHE" ]; then
|
||||
# Firefox cache
|
||||
if [ -d "$USER_CACHE/mozilla" ]; then
|
||||
print_task "Backing up Firefox cache metadata"
|
||||
cp -r "$USER_CACHE/mozilla" "$BACKUP_DIR/"
|
||||
print_task "Cleaning Firefox cache"
|
||||
find "$USER_CACHE/mozilla" -type f -name "*.sqlite" -exec sqlite3 {} "VACUUM;" \;
|
||||
fi
|
||||
|
||||
# Chrome/Chromium cache
|
||||
for chrome_dir in "$USER_CACHE/google-chrome" "$USER_CACHE/chromium"; do
|
||||
if [ -d "$chrome_dir" ]; then
|
||||
print_task "Backing up Chrome/Chromium cache metadata"
|
||||
mkdir -p "$BACKUP_DIR/$(basename $chrome_dir)"
|
||||
cp -r "$chrome_dir/Default/Preferences" "$BACKUP_DIR/$(basename $chrome_dir)/" 2>/dev/null
|
||||
print_task "Cleaning Chrome/Chromium cache"
|
||||
rm -rf "$chrome_dir/Default/Cache" "$chrome_dir/Default/Code Cache" 2>/dev/null
|
||||
fi
|
||||
done
|
||||
|
||||
# Clean thumbnail cache
|
||||
if [ -d "$USER_CACHE/thumbnails" ]; then
|
||||
print_task "Cleaning thumbnail cache"
|
||||
rm -rf "$USER_CACHE/thumbnails/*" 2>/dev/null
|
||||
fi
|
||||
|
||||
# General cache cleanup (but preserve important files)
|
||||
print_task "Cleaning general cache files"
|
||||
find "$USER_CACHE" -type f -atime +30 -not -path "*/mozilla/*" -not -path "*/chromium/*" -not -path "*/google-chrome/*" -delete 2>/dev/null
|
||||
|
||||
print_success "Cache cleaned for user $CURRENT_USER"
|
||||
else
|
||||
print_warning "Cache directory not found for user $CURRENT_USER"
|
||||
fi
|
||||
|
||||
# Clean system journals
|
||||
print_section "Cleaning System Journals"
|
||||
print_task "Rotating and cleaning journal logs"
|
||||
journalctl --vacuum-time=2weeks
|
||||
print_success "Journal logs cleaned (kept last 2 weeks)"
|
||||
|
||||
# Reset failed services
|
||||
print_section "Resetting Failed Systemd Units"
|
||||
print_task "Checking for failed systemd units"
|
||||
FAILED_UNITS=$(systemctl --failed --no-legend | awk '{print $1}')
|
||||
if [ -n "$FAILED_UNITS" ]; then
|
||||
echo "Failed units found:"
|
||||
echo "$FAILED_UNITS"
|
||||
fi
|
||||
print_task "Clearing failed systemd units"
|
||||
systemctl reset-failed
|
||||
print_success "Failed systemd units cleared"
|
||||
|
||||
# Clean temporary files
|
||||
print_section "Cleaning Temporary Files"
|
||||
print_task "Removing temporary files"
|
||||
rm -rf /tmp/* /var/tmp/* 2>/dev/null
|
||||
print_success "Temporary files removed"
|
||||
|
||||
# Update file database
|
||||
print_section "Updating File Database"
|
||||
if command -v updatedb &>/dev/null; then
|
||||
print_task "Updating file database for locate command"
|
||||
updatedb
|
||||
print_success "File database updated"
|
||||
else
|
||||
print_warning "updatedb not found. Skipping file database update."
|
||||
fi
|
||||
|
||||
# Check for and install security updates
|
||||
print_section "Security Updates Check"
|
||||
print_task "Checking for security updates"
|
||||
SECURITY_UPDATES=$(pacman -Qu | grep -i "security")
|
||||
if [ -n "$SECURITY_UPDATES" ]; then
|
||||
echo "Security updates available:"
|
||||
echo "$SECURITY_UPDATES"
|
||||
|
||||
print_task "Installing security updates"
|
||||
pacman -S --needed $(echo "$SECURITY_UPDATES" | awk '{print $1}') --noconfirm
|
||||
print_success "Security updates installed"
|
||||
else
|
||||
print_success "No security updates needed"
|
||||
fi
|
||||
|
||||
# Check for pacman database errors
|
||||
print_section "Checking Pacman Database"
|
||||
print_task "Verifying package database integrity"
|
||||
if command -v paccheck &>/dev/null; then
|
||||
paccheck --md5sum --quiet
|
||||
print_success "Pacman database check complete"
|
||||
else
|
||||
print_warning "paccheck not found. Consider installing pacutils package."
|
||||
fi
|
||||
|
||||
# Cleanup pacnew/pacsave files
|
||||
print_section "Configuration File Management"
|
||||
print_task "Checking for .pacnew and .pacsave files"
|
||||
PACFILES=$(find /etc -name "*.pacnew" -o -name "*.pacsave" 2>/dev/null)
|
||||
if [ -n "$PACFILES" ]; then
|
||||
echo "Found the following .pacnew/.pacsave files:"
|
||||
echo "$PACFILES"
|
||||
|
||||
print_warning "You may want to merge these configuration files"
|
||||
echo "Use 'pacdiff' to help manage these files (install pacdiff from pacman-contrib)"
|
||||
else
|
||||
print_success "No .pacnew or .pacsave files found"
|
||||
fi
|
||||
|
||||
# System status
|
||||
print_section "System Status"
|
||||
|
||||
# Disk usage with duf
|
||||
print_task "Checking disk usage"
|
||||
if command -v duf &>/dev/null; then
|
||||
duf --only local
|
||||
else
|
||||
print_warning "duf not found. Using df instead. Consider installing duf for better disk usage display."
|
||||
df -h | grep -v "tmpfs" | grep -v "udev"
|
||||
fi
|
||||
|
||||
# Memory usage
|
||||
echo "Memory usage:"
|
||||
free -h
|
||||
|
||||
# Find large files
|
||||
echo "Large files (>100MB) in your home directory:"
|
||||
find /home/$(logname 2>/dev/null || echo $SUDO_USER) -type f -size +100M -exec ls -lh {} \; 2>/dev/null | sort -k5hr | head -n 10
|
||||
|
||||
# Final summary
|
||||
print_section "Maintenance Complete"
|
||||
echo "System maintenance tasks completed successfully"
|
||||
echo "Remember to periodically run additional manual maintenance tasks:"
|
||||
echo "- Check for broken symlinks: find /usr /etc -xtype l -print"
|
||||
echo "- Run a SMART disk check: smartctl -a /dev/sdX (install smartmontools)"
|
||||
echo "- Check systemd boot time: systemd-analyze"
|
||||
|
||||
exit 0
|
25
local-bin/.local/bin/rmq-passwd
Executable file
25
local-bin/.local/bin/rmq-passwd
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/sh
|
||||
|
||||
PREFIX="oc-"
|
||||
SUFFIX="-eks-cluster"
|
||||
FINAL=""
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
context="$PREFIX$1$SUFFIX"
|
||||
current_context=$(kubectl config current-context)
|
||||
|
||||
kubectl config use-context $context >/dev/null
|
||||
kubectl config set-context --current --namespace=oc-app >/dev/null
|
||||
|
||||
# is second argument provided then silent exit
|
||||
password=$(kubectl get secret oc-secrets -o jsonpath="{.data.rabbit_passwd}" | base64 --decode)
|
||||
|
||||
printf "$password" | wl-copy
|
||||
# printf "$password" | xsel --clipboard
|
||||
|
||||
# reset context
|
||||
kubectl config use-context $current_context >/dev/null
|
||||
kubectl config set-context --current --namespace=oc-app >/dev/null
|
279
local-bin/.local/bin/run-on-pod
Executable file
279
local-bin/.local/bin/run-on-pod
Executable file
|
@ -0,0 +1,279 @@
|
|||
#!/bin/env bash
|
||||
|
||||
# ARG_OPTIONAL_BOOLEAN([confirm],[c],[Wether to confirm the action or not],[on])
|
||||
# ARG_OPTIONAL_SINGLE([runner],[r],[Specify the runner],[])
|
||||
# ARG_TYPE_GROUP_SET([commands],[COMMAND],[runner],[node, sh],[index])
|
||||
# ARG_POSITIONAL_SINGLE([context],[The Kubernetes context])
|
||||
# ARG_POSITIONAL_SINGLE([script],[The script to run])
|
||||
# ARG_POSITIONAL_SINGLE([pod_name],[The pod name])
|
||||
# ARG_HELP([Prints this help message])
|
||||
# ARG_VERSION([1.0])
|
||||
# ARG_DEFAULTS_POS([])
|
||||
# ARGBASH_GO()
|
||||
# needed because of Argbash --> m4_ignore([
|
||||
### START OF CODE GENERATED BY Argbash v2.10.0 one line above ###
|
||||
# Argbash is a bash code generator used to get arguments parsing right.
|
||||
# Argbash is FREE SOFTWARE, see https://argbash.io for more info
|
||||
|
||||
die() {
|
||||
local _ret="${2:-1}"
|
||||
test "${_PRINT_HELP:-no}" = yes && print_help >&2
|
||||
echo "$1" >&2
|
||||
exit "${_ret}"
|
||||
}
|
||||
|
||||
# validators
|
||||
|
||||
commands() {
|
||||
local _allowed=("node" "sh") _seeking="$1" _idx=0
|
||||
for element in "${_allowed[@]}"; do
|
||||
test "$element" = "$_seeking" && { test "$3" = "idx" && echo "$_idx" || echo "$element"; } && return 0
|
||||
_idx=$((_idx + 1))
|
||||
done
|
||||
die "Value '$_seeking' (of argument '$2') doesn't match the list of allowed values: 'node' and 'sh'" 4
|
||||
}
|
||||
|
||||
begins_with_short_option() {
|
||||
local first_option all_short_options='crhv'
|
||||
first_option="${1:0:1}"
|
||||
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
|
||||
}
|
||||
|
||||
# THE DEFAULTS INITIALIZATION - POSITIONALS
|
||||
_positionals=()
|
||||
_arg_context=
|
||||
_arg_script=
|
||||
_arg_pod_name=
|
||||
# THE DEFAULTS INITIALIZATION - OPTIONALS
|
||||
_arg_confirm="on"
|
||||
_arg_runner="sh"
|
||||
|
||||
print_help() {
|
||||
printf '%s\n' "Prints this help message"
|
||||
printf 'Usage: %s [-c|--(no-)confirm] [-r|--runner <COMMAND>] [-h|--help] [-v|--version] <context> <script> <pod_name>\n' "$0"
|
||||
printf '\t%s\n' "<context>: The Kubernetes context"
|
||||
printf '\t%s\n' "<script>: The script to run"
|
||||
printf '\t%s\n' "<pod_name>: The pod name"
|
||||
printf '\t%s\n' "-c, --confirm, --no-confirm: Wether to confirm the action or not (on by default)"
|
||||
printf '\t%s\n' "-r, --runner: Specify the runner. Can be one of: 'node' and 'sh' (sh)"
|
||||
printf '\t%s\n' "-h, --help: Prints help"
|
||||
printf '\t%s\n' "-v, --version: Prints version"
|
||||
}
|
||||
|
||||
parse_commandline() {
|
||||
_positionals_count=0
|
||||
while test $# -gt 0; do
|
||||
_key="$1"
|
||||
case "$_key" in
|
||||
-c | --no-confirm | --confirm)
|
||||
_arg_confirm="on"
|
||||
test "${1:0:5}" = "--no-" && _arg_confirm="off"
|
||||
;;
|
||||
-c*)
|
||||
_arg_confirm="on"
|
||||
_next="${_key##-c}"
|
||||
if test -n "$_next" -a "$_next" != "$_key"; then
|
||||
{ begins_with_short_option "$_next" && shift && set -- "-c" "-${_next}" "$@"; } || die "The short option '$_key' can't be decomposed to ${_key:0:2} and -${_key:2}, because ${_key:0:2} doesn't accept value and '-${_key:2:1}' doesn't correspond to a short option."
|
||||
fi
|
||||
;;
|
||||
-r | --runner)
|
||||
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
|
||||
_arg_runner="$(commands "$2" "runner")" || exit 1
|
||||
shift
|
||||
;;
|
||||
--runner=*)
|
||||
_arg_runner="$(commands "${_key##--runner=}" "runner")" || exit 1
|
||||
;;
|
||||
-r*)
|
||||
_arg_runner="$(commands "${_key##-r}" "runner")" || exit 1
|
||||
;;
|
||||
-h | --help)
|
||||
print_help
|
||||
exit 0
|
||||
;;
|
||||
-h*)
|
||||
print_help
|
||||
exit 0
|
||||
;;
|
||||
-v | --version)
|
||||
1.0
|
||||
exit 0
|
||||
;;
|
||||
-v*)
|
||||
1.0
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
_last_positional="$1"
|
||||
_positionals+=("$_last_positional")
|
||||
_positionals_count=$((_positionals_count + 1))
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
handle_passed_args_count() {
|
||||
local _required_args_string="'context', 'script' and 'pod_name'"
|
||||
test "${_positionals_count}" -ge 3 || _PRINT_HELP=yes die "FATAL ERROR: Not enough positional arguments - we require exactly 3 (namely: $_required_args_string), but got only ${_positionals_count}." 1
|
||||
test "${_positionals_count}" -le 3 || _PRINT_HELP=yes die "FATAL ERROR: There were spurious positional arguments --- we expect exactly 3 (namely: $_required_args_string), but got ${_positionals_count} (the last one was: '${_last_positional}')." 1
|
||||
}
|
||||
|
||||
assign_positional_args() {
|
||||
local _positional_name _shift_for=$1
|
||||
_positional_names="_arg_context _arg_script _arg_pod_name "
|
||||
|
||||
shift "$_shift_for"
|
||||
for _positional_name in ${_positional_names}; do
|
||||
test $# -gt 0 || break
|
||||
eval "$_positional_name=\${1}" || die "Error during argument parsing, possibly an Argbash bug." 1
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
parse_commandline "$@"
|
||||
handle_passed_args_count
|
||||
assign_positional_args 1 "${_positionals[@]}"
|
||||
|
||||
# OTHER STUFF GENERATED BY Argbash
|
||||
# Validation of values
|
||||
_arg_runner_index="$(commands "$_arg_runner" "runner" idx)"
|
||||
|
||||
### END OF CODE GENERATED BY Argbash (sortof) ### ])
|
||||
# [ <-- needed because of Argbash
|
||||
# ] <-- needed because of Argbash
|
||||
|
||||
# Color definitions
|
||||
PURPLE='#c462fc'
|
||||
RED='#f44336'
|
||||
GREEN='#8bc34a'
|
||||
GOLD='#ffd700'
|
||||
|
||||
# Initial settings
|
||||
ORIGINAL_CONTEXT=""
|
||||
|
||||
# Function to print a styled message using gum
|
||||
print_gum_message() {
|
||||
local color="$1"
|
||||
local message="$2"
|
||||
echo -e $(gum style --bold --foreground="$color" -- "$message")
|
||||
}
|
||||
|
||||
# Function to handle confirmation prompts
|
||||
ask_confirmation() {
|
||||
if [ "$_arg_confirm" = "on" ]; then
|
||||
echo -e "$1"
|
||||
CHOICE=$(gum choose "Yes" "No")
|
||||
[ "$CHOICE" = "Yes" ] || exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to list available Kubernetes contexts
|
||||
list_contexts() {
|
||||
kubectl config get-contexts -o name
|
||||
}
|
||||
|
||||
# Function to validate the provided context
|
||||
validate_context() {
|
||||
local context="$1"
|
||||
if ! kubectl config get-contexts -o name | grep -q "^${context}$"; then
|
||||
print_gum_message "$RED" "Invalid context: $context"
|
||||
echo "Available contexts:"
|
||||
list_contexts
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to validate the existence of the script
|
||||
validate_script_existence() {
|
||||
local script="$1"
|
||||
if [ ! -f "$script" ]; then
|
||||
print_gum_message "$RED" "Script not found: $script"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -r "$script" ]; then
|
||||
print_gum_message "$RED" "Script is not readable: $script"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to backup the current Kubernetes context
|
||||
backup_current_context() {
|
||||
ORIGINAL_CONTEXT=$(kubectl config current-context)
|
||||
if [ -z "$ORIGINAL_CONTEXT" ]; then
|
||||
echo "Failed to retrieve the current context"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to restore the original Kubernetes context
|
||||
restore_original_context() {
|
||||
kubectl config use-context "$ORIGINAL_CONTEXT"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to restore the original context"
|
||||
exit 1
|
||||
fi
|
||||
print_gum_message "$GREEN" "Restored original context: $ORIGINAL_CONTEXT"
|
||||
}
|
||||
|
||||
# Function to set Kubernetes context and namespace
|
||||
set_kubernetes_context() {
|
||||
validate_context "$_arg_context"
|
||||
|
||||
kubectl config use-context "$_arg_context" || {
|
||||
echo "Failed to set context"
|
||||
exit 1
|
||||
}
|
||||
|
||||
kubectl config set-context --current --namespace=oc-app || {
|
||||
echo "Failed to set namespace"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Function to get the running pod name
|
||||
get_running_pod() {
|
||||
kubectl get pod --field-selector=status.phase==Running --selector app.kubernetes.io/name="$_arg_pod_name" -o jsonpath='{.items[0].metadata.name}' 2>/dev/null
|
||||
}
|
||||
|
||||
# Main script logic
|
||||
main() {
|
||||
print_gum_message "$GREEN" "Using \"$_arg_runner\" runner"
|
||||
|
||||
validate_context "$_arg_context"
|
||||
|
||||
# Validate script existence
|
||||
validate_script_existence "$_arg_script"
|
||||
|
||||
if [ "$_arg_confirm" = "off" ]; then
|
||||
title=$(gum style --bold --foreground="$PURPLE" -- "Running without confirmation in 5 seconds...Press CTRL+C to cancel")
|
||||
echo -e "$title"
|
||||
sleep 5 || exit 1
|
||||
fi
|
||||
|
||||
# Backup the current Kubernetes context
|
||||
backup_current_context
|
||||
|
||||
# Ensure context will be restored on exit
|
||||
trap restore_original_context EXIT
|
||||
|
||||
ask_confirmation "Execute '\e[31m$_arg_script\e[0m' on context '\e[32m$_arg_context\e[0m' using pod '\e[32m$_arg_pod_name\e[0m'?"
|
||||
|
||||
set_kubernetes_context
|
||||
|
||||
print_gum_message "$GREEN" "Getting pod $_arg_pod_name..."
|
||||
pod=$(get_running_pod)
|
||||
if [ -z "$pod" ]; then
|
||||
print_gum_message "$RED" "Pod not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_gum_message "$GREEN" "Found pod $pod"
|
||||
ask_confirmation "Confirm execution of '\e[31m$_arg_script\e[0m' on pod '\e[32m$pod\e[0m'?"
|
||||
|
||||
print_gum_message "$GOLD" "Executing $_arg_script inside $pod..."
|
||||
|
||||
kubectl exec -i "$pod" -- "$_arg_runner" <"$_arg_script"
|
||||
}
|
||||
|
||||
main "$@"
|
Loading…
Add table
Add a link
Reference in a new issue