mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-20 17:51:23 +00:00
docs(shell): add function docstring comments
This commit is contained in:
@@ -42,6 +42,7 @@ done
|
|||||||
# Mark certain repositories shallow
|
# Mark certain repositories shallow
|
||||||
git config -f .gitmodules submodule.antidote.shallow true
|
git config -f .gitmodules submodule.antidote.shallow true
|
||||||
|
|
||||||
|
# Log a message using msgr if available, else echo
|
||||||
_log() {
|
_log() {
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
if command -v msgr > /dev/null 2>&1; then
|
if command -v msgr > /dev/null 2>&1; then
|
||||||
@@ -52,6 +53,7 @@ _log() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Remove a stale git submodule and clean up references
|
||||||
remove_old_submodule() {
|
remove_old_submodule() {
|
||||||
local name="$1" path="$2"
|
local name="$1" path="$2"
|
||||||
|
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ commit()
|
|||||||
git commit -a -m "$commitMessage"
|
git commit -a -m "$commitMessage"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Run Laravel scheduler in a loop
|
||||||
scheduler()
|
scheduler()
|
||||||
{
|
{
|
||||||
while :; do
|
while :; do
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ if ! command -v sesh &>/dev/null; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Pick a sesh session using gum filter
|
||||||
pick_with_gum() {
|
pick_with_gum() {
|
||||||
sesh list -i \
|
sesh list -i \
|
||||||
| gum filter \
|
| gum filter \
|
||||||
@@ -41,16 +42,19 @@ FZF_COMMON_OPTS=(
|
|||||||
--preview 'sesh preview {}'
|
--preview 'sesh preview {}'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Pick a sesh session using fzf-tmux popup
|
||||||
pick_with_fzf_tmux() {
|
pick_with_fzf_tmux() {
|
||||||
sesh list --icons | fzf-tmux -p 80%,70% "${FZF_COMMON_OPTS[@]}"
|
sesh list --icons | fzf-tmux -p 80%,70% "${FZF_COMMON_OPTS[@]}"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Pick a sesh session using fzf inline
|
||||||
pick_with_fzf() {
|
pick_with_fzf() {
|
||||||
sesh list --icons | fzf "${FZF_COMMON_OPTS[@]}"
|
sesh list --icons | fzf "${FZF_COMMON_OPTS[@]}"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Pick a sesh session using bash select menu
|
||||||
pick_with_select() {
|
pick_with_select() {
|
||||||
local sessions
|
local sessions
|
||||||
mapfile -t sessions < <(sesh list)
|
mapfile -t sessions < <(sesh list)
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ menu_builder()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Handle install section commands
|
||||||
section_install()
|
section_install()
|
||||||
{
|
{
|
||||||
USAGE_PREFIX="$SCRIPT install <command>"
|
USAGE_PREFIX="$SCRIPT install <command>"
|
||||||
@@ -193,6 +194,7 @@ section_install()
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Handle Homebrew section commands
|
||||||
section_brew()
|
section_brew()
|
||||||
{
|
{
|
||||||
USAGE_PREFIX="$SCRIPT brew <command>"
|
USAGE_PREFIX="$SCRIPT brew <command>"
|
||||||
@@ -291,6 +293,7 @@ section_brew()
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Handle helper utility commands
|
||||||
section_helpers()
|
section_helpers()
|
||||||
{
|
{
|
||||||
USAGE_PREFIX="$SCRIPT helpers <command>"
|
USAGE_PREFIX="$SCRIPT helpers <command>"
|
||||||
@@ -367,6 +370,7 @@ section_helpers()
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Handle apt package manager commands
|
||||||
section_apt()
|
section_apt()
|
||||||
{
|
{
|
||||||
USAGE_PREFIX="$SCRIPT apt <command>"
|
USAGE_PREFIX="$SCRIPT apt <command>"
|
||||||
@@ -435,6 +439,7 @@ section_apt()
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Handle documentation generation commands
|
||||||
section_docs()
|
section_docs()
|
||||||
{
|
{
|
||||||
USAGE_PREFIX="$SCRIPT docs <command>"
|
USAGE_PREFIX="$SCRIPT docs <command>"
|
||||||
@@ -459,6 +464,7 @@ section_docs()
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Handle dotfiles formatting and reset commands
|
||||||
section_dotfiles()
|
section_dotfiles()
|
||||||
{
|
{
|
||||||
USAGE_PREFIX="$SCRIPT dotfiles <command>"
|
USAGE_PREFIX="$SCRIPT dotfiles <command>"
|
||||||
@@ -526,6 +532,7 @@ section_dotfiles()
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Handle system check commands (arch, hostname)
|
||||||
section_check()
|
section_check()
|
||||||
{
|
{
|
||||||
USAGE_PREFIX="$SCRIPT check <command>"
|
USAGE_PREFIX="$SCRIPT check <command>"
|
||||||
@@ -552,6 +559,7 @@ section_check()
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Handle install script execution
|
||||||
section_scripts()
|
section_scripts()
|
||||||
{
|
{
|
||||||
USAGE_PREFIX="$SCRIPT scripts <command>"
|
USAGE_PREFIX="$SCRIPT scripts <command>"
|
||||||
@@ -619,6 +627,7 @@ section_tests()
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Display main usage information for all sections
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
echo ""
|
echo ""
|
||||||
@@ -642,6 +651,7 @@ usage()
|
|||||||
section_helpers
|
section_helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Parse section argument and dispatch to handler
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
SECTION="${1:-}"
|
SECTION="${1:-}"
|
||||||
|
|||||||
@@ -22,32 +22,37 @@ if [ "$DEBUG" -eq 1 ]; then
|
|||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output functions
|
# Print an error message in red
|
||||||
msg_err()
|
msg_err()
|
||||||
{
|
{
|
||||||
echo -e "\e[31m$*\e[0m" >&2
|
echo -e "\e[31m$*\e[0m" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a success message in green
|
||||||
msg_success()
|
msg_success()
|
||||||
{
|
{
|
||||||
echo -e "\e[32m$*\e[0m"
|
echo -e "\e[32m$*\e[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a warning message in yellow
|
||||||
msg_warn()
|
msg_warn()
|
||||||
{
|
{
|
||||||
echo -e "\e[33m$*\e[0m" >&2
|
echo -e "\e[33m$*\e[0m" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print an info message in blue
|
||||||
msg_info()
|
msg_info()
|
||||||
{
|
{
|
||||||
echo -e "\e[36m$*\e[0m"
|
echo -e "\e[36m$*\e[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a debug message when verbose mode is on
|
||||||
msg_debug()
|
msg_debug()
|
||||||
{
|
{
|
||||||
[[ $VERBOSE -eq 1 ]] && echo -e "\e[35m$*\e[0m"
|
[[ $VERBOSE -eq 1 ]] && echo -e "\e[35m$*\e[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Display usage information and examples
|
||||||
show_help()
|
show_help()
|
||||||
{
|
{
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
|||||||
@@ -90,13 +90,14 @@ declare -A DIR_HAS_REPOS
|
|||||||
# Record start time
|
# Record start time
|
||||||
START_TIME=$(date +%s)
|
START_TIME=$(date +%s)
|
||||||
|
|
||||||
# Logging functions
|
# Log an error message
|
||||||
log_error()
|
log_error()
|
||||||
{
|
{
|
||||||
print_color "31" "ERROR:" >&2
|
print_color "31" "ERROR:" >&2
|
||||||
echo " $*" >&2
|
echo " $*" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Log an informational message
|
||||||
log_info()
|
log_info()
|
||||||
{
|
{
|
||||||
if [[ $VERBOSE -eq 1 ]]; then
|
if [[ $VERBOSE -eq 1 ]]; then
|
||||||
@@ -105,6 +106,7 @@ log_info()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Log a warning message
|
||||||
log_warn()
|
log_warn()
|
||||||
{
|
{
|
||||||
print_color "33" "WARNING:" >&2
|
print_color "33" "WARNING:" >&2
|
||||||
@@ -911,6 +913,7 @@ process_in_parallel()
|
|||||||
echo -e "\nProcessed $total repositories in $dur (Total runtime: $runtime)"
|
echo -e "\nProcessed $total repositories in $dur (Total runtime: $runtime)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check a directory for git status with progress tracking
|
||||||
check_directory_with_progress()
|
check_directory_with_progress()
|
||||||
{
|
{
|
||||||
local dir
|
local dir
|
||||||
|
|||||||
@@ -23,21 +23,25 @@ CLR_RESET="\033[0m"
|
|||||||
# │ Color functions │
|
# │ Color functions │
|
||||||
# ╰──────────────────────────────────────────────────────────╯
|
# ╰──────────────────────────────────────────────────────────╯
|
||||||
|
|
||||||
|
# Wrap text in red color
|
||||||
function __color_red()
|
function __color_red()
|
||||||
{
|
{
|
||||||
local MSG="$1"
|
local MSG="$1"
|
||||||
echo -e "${CLR_RED}${MSG}${CLR_RESET}"
|
echo -e "${CLR_RED}${MSG}${CLR_RESET}"
|
||||||
}
|
}
|
||||||
|
# Wrap text in yellow color
|
||||||
function __color_yellow()
|
function __color_yellow()
|
||||||
{
|
{
|
||||||
local MSG="$1"
|
local MSG="$1"
|
||||||
echo -e "${CLR_YELLOW}${MSG}${CLR_RESET}"
|
echo -e "${CLR_YELLOW}${MSG}${CLR_RESET}"
|
||||||
}
|
}
|
||||||
|
# Wrap text in green color
|
||||||
function __color_green()
|
function __color_green()
|
||||||
{
|
{
|
||||||
local MSG="$1"
|
local MSG="$1"
|
||||||
echo -e "${CLR_GREEN}${MSG}${CLR_RESET}"
|
echo -e "${CLR_GREEN}${MSG}${CLR_RESET}"
|
||||||
}
|
}
|
||||||
|
# Wrap text in blue color
|
||||||
function __color_blue()
|
function __color_blue()
|
||||||
{
|
{
|
||||||
local MSG="$1"
|
local MSG="$1"
|
||||||
@@ -48,36 +52,43 @@ function __color_blue()
|
|||||||
# │ Helpers │
|
# │ Helpers │
|
||||||
# ╰──────────────────────────────────────────────────────────╯
|
# ╰──────────────────────────────────────────────────────────╯
|
||||||
|
|
||||||
|
# Print blue arrow marker
|
||||||
function __log_marker()
|
function __log_marker()
|
||||||
{
|
{
|
||||||
echo -e "${CLR_BLUE}➜${CLR_RESET}"
|
echo -e "${CLR_BLUE}➜${CLR_RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print green checkmark marker
|
||||||
function __log_marker_ok()
|
function __log_marker_ok()
|
||||||
{
|
{
|
||||||
echo -e "${CLR_GREEN}✔${CLR_RESET}"
|
echo -e "${CLR_GREEN}✔${CLR_RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print blue checkmark marker
|
||||||
function __log_marker_ok_blue()
|
function __log_marker_ok_blue()
|
||||||
{
|
{
|
||||||
echo -e "${CLR_BLUE}✔${CLR_RESET}"
|
echo -e "${CLR_BLUE}✔${CLR_RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print yellow warning marker
|
||||||
function __log_marker_warn()
|
function __log_marker_warn()
|
||||||
{
|
{
|
||||||
echo -e "${CLR_YELLOW}⁕${CLR_RESET}"
|
echo -e "${CLR_YELLOW}⁕${CLR_RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print yellow question marker
|
||||||
function __log_marker_question()
|
function __log_marker_question()
|
||||||
{
|
{
|
||||||
echo -e "${CLR_YELLOW}?${CLR_RESET}"
|
echo -e "${CLR_YELLOW}?${CLR_RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print red error marker
|
||||||
function __log_marker_err()
|
function __log_marker_err()
|
||||||
{
|
{
|
||||||
echo -e "${CLR_RED}⛌${CLR_RESET}"
|
echo -e "${CLR_RED}⛌${CLR_RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print indentation spacing
|
||||||
function __log_indent()
|
function __log_indent()
|
||||||
{
|
{
|
||||||
echo " "
|
echo " "
|
||||||
@@ -87,71 +98,85 @@ function __log_indent()
|
|||||||
# │ Log functions │
|
# │ Log functions │
|
||||||
# ╰──────────────────────────────────────────────────────────╯
|
# ╰──────────────────────────────────────────────────────────╯
|
||||||
|
|
||||||
|
# Print a message with arrow marker
|
||||||
function msg()
|
function msg()
|
||||||
{
|
{
|
||||||
echo -e "$(__log_marker) $1"
|
echo -e "$(__log_marker) $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a celebration message
|
||||||
function msg_yay()
|
function msg_yay()
|
||||||
{
|
{
|
||||||
echo -e "🎉 $1"
|
echo -e "🎉 $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a celebration message with checkmark
|
||||||
function msg_yay_done()
|
function msg_yay_done()
|
||||||
{
|
{
|
||||||
echo -e "🎉 $1 ...$(__log_marker_ok)"
|
echo -e "🎉 $1 ...$(__log_marker_ok)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a message with completion checkmark
|
||||||
function msg_done()
|
function msg_done()
|
||||||
{
|
{
|
||||||
echo -e "$(__log_marker) $1 ...$(__log_marker_ok)"
|
echo -e "$(__log_marker) $1 ...$(__log_marker_ok)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a completion checkmark suffix
|
||||||
function msg_done_suffix()
|
function msg_done_suffix()
|
||||||
{
|
{
|
||||||
echo -e "$(__log_marker) ...$(__log_marker_ok)"
|
echo -e "$(__log_marker) ...$(__log_marker_ok)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a prompt-style message
|
||||||
function msg_prompt()
|
function msg_prompt()
|
||||||
{
|
{
|
||||||
echo -e "$(__log_marker_question) $1"
|
echo -e "$(__log_marker_question) $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a prompt message with checkmark
|
||||||
function msg_prompt_done()
|
function msg_prompt_done()
|
||||||
{
|
{
|
||||||
echo -e "$(__log_marker_question) $1 ...$(__log_marker_ok)"
|
echo -e "$(__log_marker_question) $1 ...$(__log_marker_ok)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print an indented message
|
||||||
function msg_nested()
|
function msg_nested()
|
||||||
{
|
{
|
||||||
echo -e "$(__log_indent)$(__log_marker) $1"
|
echo -e "$(__log_indent)$(__log_marker) $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print an indented message with checkmark
|
||||||
function msg_nested_done()
|
function msg_nested_done()
|
||||||
{
|
{
|
||||||
echo -e "$(__log_indent)$(__log_marker) $1 ...$(__log_marker_ok)"
|
echo -e "$(__log_indent)$(__log_marker) $1 ...$(__log_marker_ok)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a running-task message in green
|
||||||
function msg_run()
|
function msg_run()
|
||||||
{
|
{
|
||||||
echo -e "${CLR_GREEN}➜ $1${CLR_RESET} $2"
|
echo -e "${CLR_GREEN}➜ $1${CLR_RESET} $2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a running-task message with checkmark
|
||||||
function msg_run_done()
|
function msg_run_done()
|
||||||
{
|
{
|
||||||
echo -e "${CLR_GREEN}➜ $1${CLR_RESET} $2 ...$(__log_marker_ok)"
|
echo -e "${CLR_GREEN}➜ $1${CLR_RESET} $2 ...$(__log_marker_ok)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print an ok/success message
|
||||||
function msg_ok()
|
function msg_ok()
|
||||||
{
|
{
|
||||||
echo -e "$(__log_marker_ok) $1"
|
echo -e "$(__log_marker_ok) $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print a warning message
|
||||||
function msg_warn()
|
function msg_warn()
|
||||||
{
|
{
|
||||||
echo -e "$(__log_marker_warn) $1"
|
echo -e "$(__log_marker_warn) $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print an error message
|
||||||
function msg_err()
|
function msg_err()
|
||||||
{
|
{
|
||||||
echo -e "$(__log_marker_err) $1"
|
echo -e "$(__log_marker_err) $1"
|
||||||
@@ -174,6 +199,7 @@ ask()
|
|||||||
# If this is being sourced, no need to run the next steps.
|
# If this is being sourced, no need to run the next steps.
|
||||||
[ "$sourced" = 1 ] && return
|
[ "$sourced" = 1 ] && return
|
||||||
|
|
||||||
|
# Run visual tests for all message types
|
||||||
function __tests()
|
function __tests()
|
||||||
{
|
{
|
||||||
msg "[ msg ]"
|
msg "[ msg ]"
|
||||||
@@ -192,6 +218,7 @@ function __tests()
|
|||||||
msg_yay_done "[ yay_done ]"
|
msg_yay_done "[ yay_done ]"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Show usage information and examples
|
||||||
function usage()
|
function usage()
|
||||||
{
|
{
|
||||||
echo "usage: msgr [type] [message] [optional second message]"
|
echo "usage: msgr [type] [message] [optional second message]"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ set -euo pipefail # Add error handling
|
|||||||
LATEST_VERSION_FORMULA="php" # The formula name for latest PHP version
|
LATEST_VERSION_FORMULA="php" # The formula name for latest PHP version
|
||||||
PHP_VERSION_FILE=".php-version" # File name to look for when auto-switching
|
PHP_VERSION_FILE=".php-version" # File name to look for when auto-switching
|
||||||
|
|
||||||
# Switch brew php version
|
# Verify that Homebrew is installed
|
||||||
function check_dependencies()
|
function check_dependencies()
|
||||||
{
|
{
|
||||||
if ! command -v brew > /dev/null 2>&1; then
|
if ! command -v brew > /dev/null 2>&1; then
|
||||||
@@ -28,6 +28,7 @@ function check_dependencies()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Display help message and usage examples
|
||||||
function usage()
|
function usage()
|
||||||
{
|
{
|
||||||
echo "Brew PHP Switcher - Switch between PHP versions installed via Homebrew"
|
echo "Brew PHP Switcher - Switch between PHP versions installed via Homebrew"
|
||||||
@@ -53,6 +54,7 @@ function usage()
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# List all PHP versions installed via Homebrew
|
||||||
function list_php_versions()
|
function list_php_versions()
|
||||||
{
|
{
|
||||||
# Check Homebrew's installation path for PHP versions
|
# Check Homebrew's installation path for PHP versions
|
||||||
@@ -185,6 +187,7 @@ function list_php_versions()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Convert a version number to a Homebrew formula name
|
||||||
function get_php_formula_for_version()
|
function get_php_formula_for_version()
|
||||||
{
|
{
|
||||||
local version="$1"
|
local version="$1"
|
||||||
@@ -199,6 +202,7 @@ function get_php_formula_for_version()
|
|||||||
echo "php@$version"
|
echo "php@$version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if a Homebrew formula is installed
|
||||||
function check_formula_installed()
|
function check_formula_installed()
|
||||||
{
|
{
|
||||||
local formula="$1"
|
local formula="$1"
|
||||||
@@ -216,6 +220,7 @@ function check_formula_installed()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Unlink the currently active PHP version
|
||||||
function unlink_current_php()
|
function unlink_current_php()
|
||||||
{
|
{
|
||||||
local current_formula=""
|
local current_formula=""
|
||||||
@@ -241,6 +246,7 @@ function unlink_current_php()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Link a specific PHP formula as the active version
|
||||||
function link_php_version()
|
function link_php_version()
|
||||||
{
|
{
|
||||||
local formula="$1"
|
local formula="$1"
|
||||||
@@ -265,6 +271,7 @@ function link_php_version()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Display the currently active PHP version
|
||||||
function get_current_version()
|
function get_current_version()
|
||||||
{
|
{
|
||||||
if ! command -v php > /dev/null 2>&1; then
|
if ! command -v php > /dev/null 2>&1; then
|
||||||
@@ -300,6 +307,7 @@ function get_current_version()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Validate PHP version format (x.y or latest)
|
||||||
function validate_version()
|
function validate_version()
|
||||||
{
|
{
|
||||||
local version="$1"
|
local version="$1"
|
||||||
@@ -312,6 +320,7 @@ function validate_version()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Search for .php-version file in directory hierarchy
|
||||||
function find_php_version_file()
|
function find_php_version_file()
|
||||||
{
|
{
|
||||||
local dir="$PWD"
|
local dir="$PWD"
|
||||||
@@ -334,6 +343,7 @@ function find_php_version_file()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Auto-switch PHP based on .php-version file
|
||||||
function auto_switch_php_version()
|
function auto_switch_php_version()
|
||||||
{
|
{
|
||||||
local version_file
|
local version_file
|
||||||
@@ -360,6 +370,7 @@ function auto_switch_php_version()
|
|||||||
switch_php_version "$version"
|
switch_php_version "$version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Switch to a specific PHP version
|
||||||
function switch_php_version()
|
function switch_php_version()
|
||||||
{
|
{
|
||||||
local version="$1"
|
local version="$1"
|
||||||
@@ -398,6 +409,7 @@ function switch_php_version()
|
|||||||
echo "PHP executable: $(command -v php)"
|
echo "PHP executable: $(command -v php)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Parse arguments and dispatch to appropriate action
|
||||||
function main()
|
function main()
|
||||||
{
|
{
|
||||||
local version=""
|
local version=""
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#
|
#
|
||||||
# Modified by Ismo Vuorinen <https://github.com/ivuorinen> 2023
|
# Modified by Ismo Vuorinen <https://github.com/ivuorinen> 2023
|
||||||
|
|
||||||
|
# Display usage information for pushover
|
||||||
__pushover_usage()
|
__pushover_usage()
|
||||||
{
|
{
|
||||||
printf "pushover <options> <message>\n"
|
printf "pushover <options> <message>\n"
|
||||||
@@ -23,6 +24,7 @@ __pushover_usage()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Format an optional curl form field
|
||||||
__pushover_opt_field()
|
__pushover_opt_field()
|
||||||
{
|
{
|
||||||
field=$1
|
field=$1
|
||||||
@@ -33,6 +35,7 @@ __pushover_opt_field()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Send a pushover notification via curl
|
||||||
__pushover_send_message()
|
__pushover_send_message()
|
||||||
{
|
{
|
||||||
device="${1:-}"
|
device="${1:-}"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ VERSION="1.0.0"
|
|||||||
LANG_MAP="c:.c,.h|cpp:.cpp,.cc,.cxx,.hpp,.hxx|csharp:.cs|go:.go|java:.java|
|
LANG_MAP="c:.c,.h|cpp:.cpp,.cc,.cxx,.hpp,.hxx|csharp:.cs|go:.go|java:.java|
|
||||||
javascript:.js,.jsx,.mjs,.ts,.tsx|python:.py|ruby:.rb|swift:.swift"
|
javascript:.js,.jsx,.mjs,.ts,.tsx|python:.py|ruby:.rb|swift:.swift"
|
||||||
|
|
||||||
|
# Display usage information and options
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
cat << EOF
|
cat << EOF
|
||||||
@@ -24,22 +25,26 @@ EOF
|
|||||||
exit "${1:-0}"
|
exit "${1:-0}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Log a timestamped message to stderr
|
||||||
log()
|
log()
|
||||||
{
|
{
|
||||||
printf '[%s] %s\n' "$(date '+%H:%M:%S')" "$*" >&2
|
printf '[%s] %s\n' "$(date '+%H:%M:%S')" "$*" >&2
|
||||||
}
|
}
|
||||||
|
# Log an error message and exit
|
||||||
err()
|
err()
|
||||||
{
|
{
|
||||||
log "ERROR: $*"
|
log "ERROR: $*"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Verify codeql binary is available in PATH
|
||||||
check_codeql()
|
check_codeql()
|
||||||
{
|
{
|
||||||
command -v codeql > /dev/null 2>&1 || err "codeql binary not found in PATH"
|
command -v codeql > /dev/null 2>&1 || err "codeql binary not found in PATH"
|
||||||
log "Found codeql: $(codeql version --format=terse)"
|
log "Found codeql: $(codeql version --format=terse)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get or create the CodeQL cache directory
|
||||||
get_cache_dir()
|
get_cache_dir()
|
||||||
{
|
{
|
||||||
cache="${XDG_CACHE_HOME:-$HOME/.cache}/codeql"
|
cache="${XDG_CACHE_HOME:-$HOME/.cache}/codeql"
|
||||||
@@ -47,6 +52,7 @@ get_cache_dir()
|
|||||||
printf '%s' "$cache"
|
printf '%s' "$cache"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Detect supported programming languages in source path
|
||||||
detect_languages()
|
detect_languages()
|
||||||
{
|
{
|
||||||
src_path="$1"
|
src_path="$1"
|
||||||
@@ -85,6 +91,7 @@ detect_languages()
|
|||||||
printf '%s' "$detected" | tr ' ' '\n' | sort -u | tr '\n' ' ' | sed 's/ $//'
|
printf '%s' "$detected" | tr ' ' '\n' | sort -u | tr '\n' ' ' | sed 's/ $//'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Create a CodeQL database for a language
|
||||||
create_database()
|
create_database()
|
||||||
{
|
{
|
||||||
lang="$1"
|
lang="$1"
|
||||||
@@ -98,6 +105,7 @@ create_database()
|
|||||||
--overwrite
|
--overwrite
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Display analysis result statistics from SARIF file
|
||||||
show_results_stats()
|
show_results_stats()
|
||||||
{
|
{
|
||||||
sarif_file="$1"
|
sarif_file="$1"
|
||||||
@@ -126,6 +134,7 @@ show_results_stats()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Run CodeQL analysis for a single language
|
||||||
analyze_language()
|
analyze_language()
|
||||||
{
|
{
|
||||||
lang="$1"
|
lang="$1"
|
||||||
@@ -172,6 +181,7 @@ analyze_language()
|
|||||||
rm -rf "$db_path"
|
rm -rf "$db_path"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Parse arguments and run CodeQL analysis pipeline
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
src_path="."
|
src_path="."
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ get_custom_group()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if a key matches the skipped keys list
|
||||||
is_skipped()
|
is_skipped()
|
||||||
{
|
{
|
||||||
local key=$1
|
local key=$1
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ LOOP=0
|
|||||||
SLEEP=1
|
SLEEP=1
|
||||||
TIMEOUT=5
|
TIMEOUT=5
|
||||||
|
|
||||||
|
# Display usage information and options
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
echo "Usage: $0 [--loop|--forever] [--sleep=N] hostname1 hostname2 ..."
|
echo "Usage: $0 [--loop|--forever] [--sleep=N] hostname1 hostname2 ..."
|
||||||
|
|||||||
@@ -39,16 +39,19 @@ log_error()
|
|||||||
{
|
{
|
||||||
echo -e "${RED}ERROR:${NC} $1" >&2
|
echo -e "${RED}ERROR:${NC} $1" >&2
|
||||||
}
|
}
|
||||||
|
# Log a warning message
|
||||||
log_warn()
|
log_warn()
|
||||||
{
|
{
|
||||||
echo -e "${YELLOW}WARN:${NC} $1" >&2
|
echo -e "${YELLOW}WARN:${NC} $1" >&2
|
||||||
}
|
}
|
||||||
|
# Log an informational message
|
||||||
log_info()
|
log_info()
|
||||||
{
|
{
|
||||||
if [[ "${INFO:-0}" == "1" ]]; then
|
if [[ "${INFO:-0}" == "1" ]]; then
|
||||||
echo -e "${GREEN}INFO:${NC} $1" >&2
|
echo -e "${GREEN}INFO:${NC} $1" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
# Log a debug message
|
||||||
log_debug()
|
log_debug()
|
||||||
{
|
{
|
||||||
if [[ "${DEBUG:-0}" == "1" ]]; then
|
if [[ "${DEBUG:-0}" == "1" ]]; then
|
||||||
|
|||||||
@@ -49,16 +49,19 @@ log_error()
|
|||||||
{
|
{
|
||||||
echo -e "${RED}ERROR:${NC} $1" >&2
|
echo -e "${RED}ERROR:${NC} $1" >&2
|
||||||
}
|
}
|
||||||
|
# Log a warning message
|
||||||
log_warn()
|
log_warn()
|
||||||
{
|
{
|
||||||
echo -e "${YELLOW}WARN:${NC} $1" >&2
|
echo -e "${YELLOW}WARN:${NC} $1" >&2
|
||||||
}
|
}
|
||||||
|
# Log an informational message
|
||||||
log_info()
|
log_info()
|
||||||
{
|
{
|
||||||
if [[ "${INFO:-0}" == "1" ]]; then
|
if [[ "${INFO:-0}" == "1" ]]; then
|
||||||
echo -e "${GREEN}INFO:${NC} $1" >&2
|
echo -e "${GREEN}INFO:${NC} $1" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
# Log a debug message
|
||||||
log_debug()
|
log_debug()
|
||||||
{
|
{
|
||||||
if [[ "${DEBUG:-0}" == "1" ]]; then
|
if [[ "${DEBUG:-0}" == "1" ]]; then
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ get_state()
|
|||||||
# ERROR HANDLING AND CLEANUP
|
# ERROR HANDLING AND CLEANUP
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
# Clean up temporary files and handle exit
|
||||||
cleanup()
|
cleanup()
|
||||||
{
|
{
|
||||||
exit_code=$?
|
exit_code=$?
|
||||||
@@ -177,6 +178,7 @@ trap cleanup EXIT INT TERM
|
|||||||
# LOGGING FUNCTIONS
|
# LOGGING FUNCTIONS
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
# Create audit directories and initialize log file
|
||||||
setup_logging()
|
setup_logging()
|
||||||
{
|
{
|
||||||
# Create all necessary directories
|
# Create all necessary directories
|
||||||
@@ -197,6 +199,7 @@ setup_logging()
|
|||||||
} >> "$LOG_FILE"
|
} >> "$LOG_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Log a message with timestamp and severity level
|
||||||
log_message()
|
log_message()
|
||||||
{
|
{
|
||||||
level="$1"
|
level="$1"
|
||||||
@@ -225,6 +228,7 @@ log_message()
|
|||||||
# INPUT VALIDATION
|
# INPUT VALIDATION
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
# Validate hostname format for SSH connection
|
||||||
validate_hostname()
|
validate_hostname()
|
||||||
{
|
{
|
||||||
hostname="$1"
|
hostname="$1"
|
||||||
@@ -244,6 +248,7 @@ validate_hostname()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Validate username format for SSH connection
|
||||||
validate_username()
|
validate_username()
|
||||||
{
|
{
|
||||||
username="$1"
|
username="$1"
|
||||||
@@ -263,6 +268,7 @@ validate_username()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Parse input file into validated host entries
|
||||||
parse_host_list()
|
parse_host_list()
|
||||||
{
|
{
|
||||||
input_file="$1"
|
input_file="$1"
|
||||||
@@ -309,6 +315,7 @@ parse_host_list()
|
|||||||
# SSH CONNECTION FUNCTIONS
|
# SSH CONNECTION FUNCTIONS
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
# Execute SSH command with retry logic and key fallback
|
||||||
ssh_with_retry()
|
ssh_with_retry()
|
||||||
{
|
{
|
||||||
host="$1"
|
host="$1"
|
||||||
@@ -373,6 +380,7 @@ ssh_with_retry()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Verify SSH connectivity to a host
|
||||||
test_ssh_connectivity()
|
test_ssh_connectivity()
|
||||||
{
|
{
|
||||||
host="$1"
|
host="$1"
|
||||||
@@ -392,6 +400,7 @@ test_ssh_connectivity()
|
|||||||
# SSH SECURITY AUDIT FUNCTIONS
|
# SSH SECURITY AUDIT FUNCTIONS
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
# Audit SSH daemon configuration on a remote host
|
||||||
check_sshd_config()
|
check_sshd_config()
|
||||||
{
|
{
|
||||||
host="$1"
|
host="$1"
|
||||||
@@ -451,6 +460,7 @@ check_sshd_config()
|
|||||||
# AUTOMATED UPDATES DETECTION
|
# AUTOMATED UPDATES DETECTION
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
# Check if automated security updates are enabled
|
||||||
check_automated_updates()
|
check_automated_updates()
|
||||||
{
|
{
|
||||||
host="$1"
|
host="$1"
|
||||||
@@ -532,6 +542,7 @@ check_automated_updates()
|
|||||||
# PENDING REBOOT DETECTION
|
# PENDING REBOOT DETECTION
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
# Detect if a remote host requires a reboot
|
||||||
check_pending_reboot()
|
check_pending_reboot()
|
||||||
{
|
{
|
||||||
host="$1"
|
host="$1"
|
||||||
@@ -602,6 +613,7 @@ check_pending_reboot()
|
|||||||
# REMEDIATION FUNCTIONS
|
# REMEDIATION FUNCTIONS
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
# Create a timestamped backup of sshd_config
|
||||||
backup_sshd_config()
|
backup_sshd_config()
|
||||||
{
|
{
|
||||||
host="$1"
|
host="$1"
|
||||||
@@ -616,6 +628,7 @@ backup_sshd_config()
|
|||||||
" "$ssh_key"
|
" "$ssh_key"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Disable password authentication on a remote host
|
||||||
disable_password_auth()
|
disable_password_auth()
|
||||||
{
|
{
|
||||||
host="$1"
|
host="$1"
|
||||||
@@ -668,6 +681,7 @@ ClientAliveCountMax 2
|
|||||||
# REPORTING FUNCTIONS
|
# REPORTING FUNCTIONS
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
# Generate CSV report from audit results
|
||||||
generate_csv_report()
|
generate_csv_report()
|
||||||
{
|
{
|
||||||
report_file="$1"
|
report_file="$1"
|
||||||
@@ -693,6 +707,7 @@ generate_csv_report()
|
|||||||
done < "$HOSTS_LIST_FILE"
|
done < "$HOSTS_LIST_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Display formatted audit summary to terminal
|
||||||
display_summary()
|
display_summary()
|
||||||
{
|
{
|
||||||
printf '\n'
|
printf '\n'
|
||||||
@@ -743,6 +758,7 @@ display_summary()
|
|||||||
# MAIN AUDIT FUNCTION
|
# MAIN AUDIT FUNCTION
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
# Run all audit checks on a single host
|
||||||
audit_host()
|
audit_host()
|
||||||
{
|
{
|
||||||
host_entry="$1"
|
host_entry="$1"
|
||||||
@@ -788,6 +804,7 @@ audit_host()
|
|||||||
# MAIN EXECUTION
|
# MAIN EXECUTION
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
# Main entry point: parse args, run audits, generate report
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
input_file="${1:-}"
|
input_file="${1:-}"
|
||||||
|
|||||||
@@ -9,11 +9,13 @@
|
|||||||
# <r> <g> <b> range from 0 to 255 inclusive.
|
# <r> <g> <b> range from 0 to 255 inclusive.
|
||||||
# The escape sequence ^[0m returns output to default
|
# The escape sequence ^[0m returns output to default
|
||||||
|
|
||||||
|
# Set terminal background to an RGB color
|
||||||
setBackgroundColor()
|
setBackgroundColor()
|
||||||
{
|
{
|
||||||
echo -en "\x1b[48;2;$1;$2;$3""m"
|
echo -en "\x1b[48;2;$1;$2;$3""m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Reset terminal output formatting
|
||||||
resetOutput()
|
resetOutput()
|
||||||
{
|
{
|
||||||
echo -en "\x1b[0m\n"
|
echo -en "\x1b[0m\n"
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Display usage information and options
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
cat << EOF
|
cat << EOF
|
||||||
@@ -52,6 +53,7 @@ THUMB_SUFFIX="${THUMB_SUFFIX:-_thumb}"
|
|||||||
# List of MIME types supported by ImageMagick (adjust as needed)
|
# List of MIME types supported by ImageMagick (adjust as needed)
|
||||||
ALLOWED_MIMETYPES=("image/jpeg" "image/png" "image/gif" "image/bmp" "image/tiff" "image/webp")
|
ALLOWED_MIMETYPES=("image/jpeg" "image/png" "image/gif" "image/bmp" "image/tiff" "image/webp")
|
||||||
|
|
||||||
|
# Verify ImageMagick is available
|
||||||
check_magick_installed()
|
check_magick_installed()
|
||||||
{
|
{
|
||||||
if ! command -v magick &> /dev/null; then
|
if ! command -v magick &> /dev/null; then
|
||||||
@@ -60,6 +62,7 @@ check_magick_installed()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Verify mimetype command is available
|
||||||
check_mimetype_installed()
|
check_mimetype_installed()
|
||||||
{
|
{
|
||||||
if ! command -v mimetype &> /dev/null; then
|
if ! command -v mimetype &> /dev/null; then
|
||||||
@@ -165,6 +168,7 @@ generate_thumbnails()
|
|||||||
done < <(find "$source_dir" -type f -print0)
|
done < <(find "$source_dir" -type f -print0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Parse options, validate inputs, and generate thumbnails
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
parse_options "$@"
|
parse_options "$@"
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ if [ "$#" -lt 2 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Wait until host stops responding to ping
|
||||||
wait_for_host_down()
|
wait_for_host_down()
|
||||||
{
|
{
|
||||||
local host=$1
|
local host=$1
|
||||||
@@ -37,6 +38,7 @@ wait_for_host_down()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Wait for host to go down then execute command
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
local host=$1
|
local host=$1
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ if [ "$#" -lt 2 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Extract hostname from arguments, handling ssh shortcut
|
||||||
get_host()
|
get_host()
|
||||||
{
|
{
|
||||||
if [ "$1" = "ssh" ]; then
|
if [ "$1" = "ssh" ]; then
|
||||||
@@ -39,6 +40,7 @@ get_host()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Wait until host responds to ping
|
||||||
wait_for_host()
|
wait_for_host()
|
||||||
{
|
{
|
||||||
local host=$1
|
local host=$1
|
||||||
@@ -50,6 +52,7 @@ wait_for_host()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Wait for host to come online then execute command
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
local host
|
local host
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ set -euo pipefail
|
|||||||
source "${DOTFILES}/config/shared.sh"
|
source "${DOTFILES}/config/shared.sh"
|
||||||
DEST="$HOME/.dotfiles/docs/nvim-keybindings.md"
|
DEST="$HOME/.dotfiles/docs/nvim-keybindings.md"
|
||||||
|
|
||||||
|
# Generate Neovim keybindings documentation
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
msg "Generating Neovim keybindings documentation"
|
msg "Generating Neovim keybindings documentation"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
source "${DOTFILES}/config/shared.sh"
|
source "${DOTFILES}/config/shared.sh"
|
||||||
DEST="$HOME/.dotfiles/docs/wezterm-keybindings.md"
|
DEST="$HOME/.dotfiles/docs/wezterm-keybindings.md"
|
||||||
|
|
||||||
|
# Generate wezterm keybindings documentation
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
msg "Generating wezterm keybindings documentation"
|
msg "Generating wezterm keybindings documentation"
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ packages=(
|
|||||||
software-properties-common # add-apt-repository command
|
software-properties-common # add-apt-repository command
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Install apt packages that are not already present
|
||||||
install_packages()
|
install_packages()
|
||||||
{
|
{
|
||||||
local to_install=()
|
local to_install=()
|
||||||
@@ -67,6 +68,7 @@ install_packages()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install all apt packages and report completion
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
install_packages
|
install_packages
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ post_install_steps()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install cargo packages and run post-install steps
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
install_packages
|
install_packages
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ PBB_SYNTAX="syntax: bash"
|
|||||||
PBB_TAGS="tags: [bash]"
|
PBB_TAGS="tags: [bash]"
|
||||||
PBB_TEMP_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/cheat/pbb"
|
PBB_TEMP_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/cheat/pbb"
|
||||||
|
|
||||||
|
# Verify required tools are installed
|
||||||
check_required_tools()
|
check_required_tools()
|
||||||
{
|
{
|
||||||
for t in "${PBB_REQUIRED_TOOLS[@]}"; do
|
for t in "${PBB_REQUIRED_TOOLS[@]}"; do
|
||||||
@@ -23,6 +24,7 @@ check_required_tools()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Clone or update the pure-bash-bible repository
|
||||||
clone_or_update_repo()
|
clone_or_update_repo()
|
||||||
{
|
{
|
||||||
if [[ ! -d "$PBB_TEMP_DIR/.git" ]]; then
|
if [[ ! -d "$PBB_TEMP_DIR/.git" ]]; then
|
||||||
@@ -38,6 +40,7 @@ clone_or_update_repo()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get the cheat destination directory for pure-bash-bible
|
||||||
prepare_cheat_dest()
|
prepare_cheat_dest()
|
||||||
{
|
{
|
||||||
local cheat_dest
|
local cheat_dest
|
||||||
@@ -95,6 +98,7 @@ process_chapters()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install pure-bash-bible cheatsheets
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
check_required_tools
|
check_required_tools
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ packages=(
|
|||||||
gnupg2 # GPG encryption/signing
|
gnupg2 # GPG encryption/signing
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Install the Development Tools dnf group
|
||||||
install_dev_tools_group()
|
install_dev_tools_group()
|
||||||
{
|
{
|
||||||
if dnf group list installed 2>/dev/null | grep -q "Development Tools"; then
|
if dnf group list installed 2>/dev/null | grep -q "Development Tools"; then
|
||||||
@@ -50,6 +51,7 @@ install_dev_tools_group()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install dnf packages that are not already present
|
||||||
install_packages()
|
install_packages()
|
||||||
{
|
{
|
||||||
local to_install=()
|
local to_install=()
|
||||||
@@ -75,6 +77,7 @@ install_packages()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install all dnf packages and report completion
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
install_dev_tools_group
|
install_dev_tools_group
|
||||||
|
|||||||
@@ -52,12 +52,14 @@ install_fonts()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Remove the temporary nerd-fonts clone directory
|
||||||
remove_tmp_path()
|
remove_tmp_path()
|
||||||
{
|
{
|
||||||
rm -rf "$TMP_PATH"
|
rm -rf "$TMP_PATH"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Clone, sparse-checkout, install fonts, and clean up
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
clone_or_update_repo
|
clone_or_update_repo
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ install_extensions()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install all GitHub CLI extensions
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
install_extensions
|
install_extensions
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ clear_go_cache()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install go packages, completions, and clear cache
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
install_packages
|
install_packages
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ clean_npm_cache()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install, upgrade, and clean npm packages
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
install_packages
|
install_packages
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ install_ntfy()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Download and install ntfy
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
install_ntfy
|
install_ntfy
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ upgrade_tools()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install Python tools, libraries, and upgrade all
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
install_tools
|
install_tools
|
||||||
|
|||||||
Reference in New Issue
Block a user