mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-15 22:52:37 +00:00
Compare commits
5 Commits
358b9719f1
...
c667bfb8ee
| Author | SHA1 | Date | |
|---|---|---|---|
|
c667bfb8ee
|
|||
|
2ed9208e6a
|
|||
|
0be8bcd1a2
|
|||
|
dcb186393e
|
|||
|
b7ce95dc66
|
7
env/.config/hpa/config.toml
vendored
7
env/.config/hpa/config.toml
vendored
@@ -44,8 +44,8 @@ useVaultArgs = true
|
||||
# instead of the provided / default playbook.
|
||||
|
||||
[playbook]
|
||||
directory = '~/.local/share/hpa/playbook'
|
||||
inventory = '~/.local/share/hpa/playbook/inventory.ini'
|
||||
directory = '/root/.local/share/hpa/playbook'
|
||||
inventory = '/root/.local/share/hpa/playbook/inventory.ini'
|
||||
version = 'main'
|
||||
|
||||
# NOTE:
|
||||
@@ -53,7 +53,8 @@ version = 'main'
|
||||
# a remote git repository.
|
||||
[template]
|
||||
# The directory path on your local system to the template files.
|
||||
directory = '~/.local/share/hpa/template'
|
||||
directory = '/root/.local/share/hpa/template'
|
||||
vars = 'repo_vars'
|
||||
|
||||
# The url to a git repository that contains your template files.
|
||||
# url = 'https://git.example.com/consult-template.git'
|
||||
|
||||
1
env/.config/zsh/.zshrc
vendored
1
env/.config/zsh/.zshrc
vendored
@@ -177,6 +177,7 @@ alias reload='exec zsh -l' # reload the shell, useful when making c
|
||||
alias s='swift' # shorthand to access swift commands
|
||||
alias st='swift test' # swift test
|
||||
alias sb='swift build' # swift build
|
||||
alias syu='yay -Syu' # Update packages.
|
||||
alias t='tmux' # access tmux quickly
|
||||
alias tka='tmux kill-server' # kill tmux server and all sessions.
|
||||
alias ts='$SCRIPTS/tmux-sessionator' # create new tmux session, fuzzy finding common locations.
|
||||
|
||||
68
env/.local/scripts/backup-logger
vendored
Executable file
68
env/.local/scripts/backup-logger
vendored
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
LOG_LABEL=$(basename "$THIS_FILE")
|
||||
THIS=${THIS:-$LOG_LABEL}
|
||||
LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"}
|
||||
LOG_DIR="/tmp/logs"
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
|
||||
Utility for logging backup runs.
|
||||
|
||||
USAGE:
|
||||
$ $THIS <flags> <msg...>
|
||||
|
||||
FLAGS:
|
||||
-h | --help: Show this help page.
|
||||
-s | --show: Show the log messages.
|
||||
--rm: Remove the log file
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# Logging utility function, use in place of echo.
|
||||
log() {
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
show() {
|
||||
[[ ! -f "$LOG_DIR/$LOG_FILE" ]] &&
|
||||
log --warning "Empty log file." &&
|
||||
exit 0
|
||||
|
||||
bat "$LOG_DIR/$LOG_FILE"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# MAIN
|
||||
################################################################################
|
||||
|
||||
declare -a msg
|
||||
|
||||
# Setup logging file and label.
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||
usage && exit 0
|
||||
elif [[ $1 == "-s" ]] || [[ $1 == "--show" ]]; then
|
||||
show && exit 0
|
||||
elif [[ $1 == "--rm" ]]; then
|
||||
rm "$LOG_DIR/$LOG_FILE" && exit 0
|
||||
else
|
||||
msg+=("$1")
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
[[ -z "${msg[*]}" ]] && log --error "No message passed to log." && exit 1
|
||||
|
||||
log "${msg[@]}"
|
||||
17
env/.local/scripts/hpa
vendored
17
env/.local/scripts/hpa
vendored
@@ -10,16 +10,12 @@ set -o pipefail
|
||||
# Make sure to run 'hpa-init' first on this machine to setup
|
||||
# dependencies, if you have not done so already.
|
||||
#
|
||||
# This will mount my home directory inside the container, so
|
||||
# it should somewhat mirror like commands are run on the host os.
|
||||
#
|
||||
# To attach to a shell inside the container run:
|
||||
# `hpa bash`
|
||||
#
|
||||
# To run ansible vault commands inside the container run:
|
||||
# `hpa ansible-vault ...`
|
||||
#
|
||||
#
|
||||
|
||||
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||
. "$SCRIPTS/utils/hpa/hpa.env"
|
||||
@@ -28,16 +24,19 @@ SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
||||
|
||||
last_pull="0"
|
||||
if [[ -f "$HPA_CONFIG_DIR/.lastpull" ]]; then
|
||||
last_pull=$(cat "$HPA_CONFIG_DIR/.lastpull")
|
||||
last_pull=$(cat "$HPA_CONFIG_DIR/.lastpull")
|
||||
fi
|
||||
curr=$(date +%s)
|
||||
diff=$((curr - last_pull))
|
||||
|
||||
if [[ $HPA_AUTO_PULL == "1" ]] && [[ $diff -gt "$HPA_AUTO_PULL_INTERVAL" ]]; then
|
||||
. "$SCRIPTS/hpa-pull" "$HPA_AUTO_PULL_OPTS"
|
||||
. "$SCRIPTS/hpa-pull" "$HPA_AUTO_PULL_OPTS"
|
||||
fi
|
||||
|
||||
podman run --rm --interactive --tty \
|
||||
--volume "$HOME":/root \
|
||||
--secret "$HPA_VAULT_SECRET_KEY" \
|
||||
"$HPA_DOCKER_IMAGE:$HPA_DOCKER_TAG" "$@"
|
||||
--volume "$HPA_CONFIG_DIR":/root/.config/hpa:ro \
|
||||
--volume "$HPA_DATA_DIR":/root/.local/share/hpa:ro \
|
||||
--volume "$HPA_CONSULTS_DIR":/consults \
|
||||
--volume "$PWD":/root/project \
|
||||
--secret "$HPA_VAULT_SECRET_KEY" \
|
||||
"$HPA_DOCKER_IMAGE:$HPA_DOCKER_TAG" "$@"
|
||||
|
||||
107
env/.local/scripts/utils/hpa/hpa-create
vendored
107
env/.local/scripts/utils/hpa/hpa-create
vendored
@@ -23,7 +23,7 @@ no_push_flag="0"
|
||||
date_opt=$(date '+%Y.%m.%d')
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
cat <<EOF
|
||||
|
||||
A utility script to generate a new home performance assessment project.
|
||||
|
||||
@@ -47,7 +47,7 @@ FLAGS:
|
||||
-p | --no-push: Do not push project to remote repository.
|
||||
|
||||
ENVIRONMENT:
|
||||
CONSULTS_DIR: Sets the location of new porjects
|
||||
CONSULTS_DIR: Sets the location of new projects
|
||||
(default: ~/work/consults)
|
||||
|
||||
CONSULT_ORIGIN_BASE_URL: Sets the base url for the project git origin.
|
||||
@@ -58,59 +58,62 @@ EOF
|
||||
|
||||
# Logging utility function, use in place of echo.
|
||||
log() {
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
create() {
|
||||
local customer container_dir
|
||||
customer=${1:-""}
|
||||
local customer container_dir
|
||||
customer=${1:-""}
|
||||
|
||||
[[ -z $customer ]] &&
|
||||
log --error "Must supply a customer name for the project" &&
|
||||
exit 1
|
||||
[[ -z $customer ]] &&
|
||||
log --error "Must supply a customer name for the project" &&
|
||||
exit 1
|
||||
|
||||
[[ ! -f $SCRIPTS/hpa ]] &&
|
||||
log --error "Unable to find the 'hpa' script." &&
|
||||
exit 1
|
||||
[[ ! -f $SCRIPTS/hpa ]] &&
|
||||
log --error "Unable to find the 'hpa' script." &&
|
||||
exit 1
|
||||
|
||||
log "Generating project for: '$customer'"
|
||||
log "Generating project for: '$customer'"
|
||||
|
||||
container_dir=$(
|
||||
"$SCRIPTS/hpa" create --quiet "/consults/$date_opt.$customer"
|
||||
)
|
||||
echo "$HPA_CONSULTS_DIR/$(basename "$container_dir")"
|
||||
container_dir=$(
|
||||
"$SCRIPTS/hpa" create --quiet "/consults/$date_opt.$customer"
|
||||
)
|
||||
echo "$HPA_CONSULTS_DIR/$(basename "$container_dir")"
|
||||
}
|
||||
|
||||
initialize-git() {
|
||||
local dir
|
||||
read -r dir
|
||||
local dir
|
||||
read -r dir
|
||||
|
||||
dir=$(echo "$dir" | tr -d '\r' | head -1)
|
||||
dir=$(echo "$dir" | tr -d '\r' | head -1)
|
||||
|
||||
if [[ $no_git_flag == "0" ]]; then
|
||||
if [[ $no_git_flag == "0" ]]; then
|
||||
|
||||
[[ ! -d $dir ]] &&
|
||||
log --error "Could not initialize git directory not found: '$dir'" &&
|
||||
exit 1
|
||||
[[ ! -d $dir ]] &&
|
||||
log --error "Could not initialize git directory not found: '$dir'" &&
|
||||
exit 1
|
||||
|
||||
log "Initializing git repository"
|
||||
log "Initializing git repository"
|
||||
|
||||
pushd "$dir" &>/dev/null || exit 1
|
||||
(
|
||||
git init
|
||||
git add .
|
||||
git commit --all --message="Initial commit"
|
||||
git remote add origin "$HPA_CONSULT_ORIGIN_BASE_URL/$(basename "$dir")"
|
||||
if [[ $no_push_flag == "0" ]]; then
|
||||
git push --set-upstream origin main
|
||||
fi
|
||||
) &>/dev/null
|
||||
popd &>/dev/null
|
||||
else
|
||||
log "Skipping git initialization"
|
||||
fi
|
||||
pushd "$dir" &>/dev/null || exit 1
|
||||
(
|
||||
git init
|
||||
git lfs install
|
||||
git lfs track '*.png'
|
||||
git lfs track '*.pdf'
|
||||
git add .
|
||||
git commit --all --message="Initial commit"
|
||||
git remote add origin "$HPA_CONSULT_ORIGIN_BASE_URL/$(basename "$dir")"
|
||||
if [[ $no_push_flag == "0" ]]; then
|
||||
git push --set-upstream origin main
|
||||
fi
|
||||
) &>/dev/null
|
||||
popd &>/dev/null
|
||||
else
|
||||
log "Skipping git initialization"
|
||||
fi
|
||||
|
||||
echo "$dir"
|
||||
echo "$dir"
|
||||
}
|
||||
|
||||
################################################################################
|
||||
@@ -124,19 +127,19 @@ setup-logging "$LOG_FILE" "$LOG_LABEL"
|
||||
declare customer output
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||
usage && exit 0
|
||||
elif [[ $1 == "-d" ]] || [[ $1 == "--date" ]]; then
|
||||
shift
|
||||
date_opt="$1"
|
||||
elif [[ $1 == "-g" ]] || [[ $1 == "--no-git" ]]; then
|
||||
no_git_flag="1"
|
||||
elif [[ $1 == "-p" ]] || [[ $1 == "--no-push" ]]; then
|
||||
no_push_flag="1"
|
||||
else
|
||||
customer=$1
|
||||
fi
|
||||
shift
|
||||
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||
usage && exit 0
|
||||
elif [[ $1 == "-d" ]] || [[ $1 == "--date" ]]; then
|
||||
shift
|
||||
date_opt="$1"
|
||||
elif [[ $1 == "-g" ]] || [[ $1 == "--no-git" ]]; then
|
||||
no_git_flag="1"
|
||||
elif [[ $1 == "-p" ]] || [[ $1 == "--no-push" ]]; then
|
||||
no_push_flag="1"
|
||||
else
|
||||
customer=$1
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
output=$(create "$customer" | initialize-git)
|
||||
|
||||
@@ -8,5 +8,10 @@ install() {
|
||||
xdg-mime default org.pwmt.zathura.desktop application/pdf
|
||||
}
|
||||
|
||||
uninstall() {
|
||||
xdg-mime default brave-browser.desktop application/pdf
|
||||
}
|
||||
|
||||
arg=${1:-""}
|
||||
[[ $arg == "install" ]] && install
|
||||
[[ $arg == "uninstall" ]] && uninstall
|
||||
|
||||
2
runs/pika-backup
Normal file
2
runs/pika-backup
Normal file
@@ -0,0 +1,2 @@
|
||||
# Packages to be installed with this run.
|
||||
pika-backup
|
||||
Reference in New Issue
Block a user