mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-05 19:49:31 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a708085dda | ||
|
|
7921e079da | ||
|
|
2369eae0ef |
@@ -17,13 +17,13 @@ indent_size = 2
|
|||||||
indent_size = 2
|
indent_size = 2
|
||||||
tab_width = 2
|
tab_width = 2
|
||||||
|
|
||||||
shell_variant = posix # like -ln=posix
|
shell_variant = bash # like -ln=posix
|
||||||
binary_next_line = true # like -bn
|
binary_next_line = true # like -bn
|
||||||
switch_case_indent = true # like -ci
|
switch_case_indent = true # like -ci
|
||||||
space_redirects = true # like -sr
|
space_redirects = true # like -sr
|
||||||
keep_padding = false # like -kp
|
keep_padding = false # like -kp
|
||||||
function_next_line = true # like -fn
|
function_next_line = true # like -fn
|
||||||
never_split = true # like -ns
|
never_split = false # like -ns
|
||||||
|
|
||||||
[local/bin/antigen.zsh]
|
[local/bin/antigen.zsh]
|
||||||
ignore = true
|
ignore = true
|
||||||
|
|||||||
2
Brewfile
2
Brewfile
@@ -79,6 +79,8 @@ brew "unbound"
|
|||||||
brew "gnutls"
|
brew "gnutls"
|
||||||
# GNU Pretty Good Privacy (PGP) package
|
# GNU Pretty Good Privacy (PGP) package
|
||||||
brew "gnupg"
|
brew "gnupg"
|
||||||
|
# Open source programming language to build simple/reliable/efficient software
|
||||||
|
brew "go"
|
||||||
# Image manipulation
|
# Image manipulation
|
||||||
brew "netpbm"
|
brew "netpbm"
|
||||||
# OpenType text shaping engine
|
# OpenType text shaping engine
|
||||||
|
|||||||
78
README.md
78
README.md
@@ -1,6 +1,11 @@
|
|||||||
# .dotfiles
|
# .dotfiles
|
||||||
|
|
||||||
The folder structure follows [XDG Base Directory Specification][xdg] where possible.
|
Welcome to [ivuorinen](https://github.com/ivuorinen)'s .dotfiles repository. It's a hodgepodge of scripts
|
||||||
|
and configurations, tests and mistakes I'm not aware of yet. As I find more interesting tools, configs and
|
||||||
|
other stuff, this repository will live accordingly.
|
||||||
|
|
||||||
|
Please for the love of everything good do not use these 1:1 as your own dotfiles,
|
||||||
|
fork or download the repo as a zip and go from there with your own configs.
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
@@ -11,14 +16,42 @@ The folder structure follows [XDG Base Directory Specification][xdg] where possi
|
|||||||
3. ???
|
3. ???
|
||||||
4. Profit
|
4. Profit
|
||||||
|
|
||||||
Note: there's a bit chicken/egg situation, because settler assumes you don't have git, and you need git to clone the repo.
|
Note: there's a bit chicken/egg situation, because settler assumes you don't have git,
|
||||||
|
and you need git to clone the repo. This will change soon™.
|
||||||
|
|
||||||
|
## Interesting files and locations
|
||||||
|
|
||||||
|
### Special folders
|
||||||
|
|
||||||
|
| Path | Description |
|
||||||
|
|--------------------|-------------------------------------------------------------------------------------|
|
||||||
|
| `.github` | GitHub Repository configuration files. Not part of the dotfiles per se. |
|
||||||
|
| `host-{hostname}/` | Host specific dotfiles. Configurations that should apply to that host only. |
|
||||||
|
| `local/bin` | Helper scripts that I've collected or wrote to make life easier. |
|
||||||
|
| `scripts` | Setup scripts. Some can be run many times, some are meant only for the first round. |
|
||||||
|
|
||||||
|
### dotfile folders
|
||||||
|
|
||||||
|
| Repo | Destination | Description |
|
||||||
|
|-----------|-------------|------------------------------------------------------------------|
|
||||||
|
| `config/` | `.config/` | Configurations for applications. |
|
||||||
|
| `local/` | `.local/` | XDG Base folder, contains `bin`, `share` and `state` for example |
|
||||||
|
| `ssh/` | `.ssh/` | SSH Configurations. |
|
||||||
|
|
||||||
### dfm - the dotfiles manager
|
### dfm - the dotfiles manager
|
||||||
|
|
||||||
`dfm` is a shellscript that has some tools that help with dotfiles management.
|
`.local/bin/dfm` is a shell script that has some tools that help with dotfiles management.
|
||||||
|
|
||||||
|
### `scripts/install.sh` - dotfiles linker
|
||||||
|
|
||||||
|
The `scripts/install.sh` is a `rcm` generated shell script that does all the necessary linking.
|
||||||
|
|
||||||
|
To refresh the file, you can run `dfm dotfiles update`
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
The folder structure follows [XDG Base Directory Specification][xdg] where possible.
|
||||||
|
|
||||||
### XDG Variables
|
### XDG Variables
|
||||||
|
|
||||||
| Var | Default |
|
| Var | Default |
|
||||||
@@ -28,13 +61,36 @@ Note: there's a bit chicken/egg situation, because settler assumes you don't hav
|
|||||||
| `$XDG_STATE_HOME` | `$HOME/.local/state` |
|
| `$XDG_STATE_HOME` | `$HOME/.local/state` |
|
||||||
| `$XDG_CONFIG_HOME` | `$HOME/.config` |
|
| `$XDG_CONFIG_HOME` | `$HOME/.config` |
|
||||||
|
|
||||||
- `$XDG_DATA_HOME` defines the base directory relative to which user-specific data files should be stored. If `$XDG_DATA_HOME` is either not set or empty, a default equal to `$HOME/.local/share` should be used.
|
- `$XDG_DATA_HOME` defines the base directory relative to which user-specific data
|
||||||
- `$XDG_CONFIG_HOME` defines the base directory relative to which user-specific configuration files should be stored. If `$XDG_CONFIG_HOME` is either not set or empty, a default equal to `$HOME/.config` should be used.
|
files should be stored. If `$XDG_DATA_HOME` is either not set or empty,
|
||||||
- `$XDG_STATE_HOME` defines the base directory relative to which user-specific state files should be stored. If `$XDG_STATE_HOME` is either not set or empty, a default equal to `$HOME/.local/state` should be used.
|
a default equal to `$HOME/.local/share` should be used.
|
||||||
- The `$XDG_STATE_HOME` contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in `$XDG_DATA_HOME`. It may contain:
|
- `$XDG_CONFIG_HOME` defines the base directory relative to which user-specific configuration
|
||||||
- actions history (logs, history, recently used files, …)
|
files should be stored. If `$XDG_CONFIG_HOME` is either not set or empty,
|
||||||
- current state of the application that can be reused on a restart (view, layout, open files, undo history, …)
|
a default equal to `$HOME/.config` should be used.
|
||||||
- User-specific executable files may be stored in `$HOME/.local/bin`. Distributions should ensure this directory shows up in the UNIX `$PATH` environment variable, at an appropriate place.
|
- `$XDG_STATE_HOME` defines the base directory relative to which user-specific state files should be stored.
|
||||||
- `$XDG_DATA_DIRS` defines the preference-ordered set of base directories to search for data files in addition to the `$XDG_DATA_HOME` base directory. The directories in `$XDG_DATA_DIRS` should be seperated with a colon ':'.
|
If `$XDG_STATE_HOME` is either not set or empty, a default equal to `$HOME/.local/state` should be used.
|
||||||
|
- The `$XDG_STATE_HOME` contains state data that should persist between (application) restarts,
|
||||||
|
but that is not important or portable enough to the user that it should be stored in `$XDG_DATA_HOME`.
|
||||||
|
It may contain:
|
||||||
|
- actions history (logs, history, recently used files, …)
|
||||||
|
- current state of the application that can be reused on a restart (view, layout, open files, undo history, …)
|
||||||
|
- User-specific executable files may be stored in `$HOME/.local/bin`. Distributions should ensure this
|
||||||
|
directory shows up in the UNIX `$PATH` environment variable, at an appropriate place.
|
||||||
|
- `$XDG_DATA_DIRS` defines the preference-ordered set of base directories to search for data files in addition
|
||||||
|
to the `$XDG_DATA_HOME` base directory. The directories in `$XDG_DATA_DIRS` should be seperated with a colon ':'.
|
||||||
|
|
||||||
[xdg]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
[xdg]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||||
|
|
||||||
|
## Interesting links
|
||||||
|
|
||||||
|
### Interesting dotfiles repos
|
||||||
|
|
||||||
|
- https://dotfiles.github.io/inspiration/
|
||||||
|
- https://github.com/frdmn/dotfiles - Ansible-based dotfile setup for macOS
|
||||||
|
- https://github.com/mvdan/dotfiles - Here be dragons
|
||||||
|
- https://github.com/vsouza/dotfiles - 🏡 My dotfiles
|
||||||
|
- https://github.com/freekmurze/dotfiles - My personal dotfiles
|
||||||
|
|
||||||
|
### Interesting dotfiles tools
|
||||||
|
|
||||||
|
- https://github.com/zero-sh/zero.sh - Radically simple personal bootstrapping tool for macOS.
|
||||||
|
|||||||
33
local/bin/README.md
Normal file
33
local/bin/README.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Scripts
|
||||||
|
|
||||||
|
All scripts have been normalized to same code standard using `shfmt`.
|
||||||
|
Some problematic code has been fixed per `shellcheck` suggestions.
|
||||||
|
|
||||||
|
## Homegrown
|
||||||
|
|
||||||
|
- dfm
|
||||||
|
- x-backup-mysql-with-prefix
|
||||||
|
- x-check-git-attributes
|
||||||
|
- x-open-ports
|
||||||
|
|
||||||
|
## Sourced
|
||||||
|
|
||||||
|
| Script | Source |
|
||||||
|
|-------------------------|-------------------|
|
||||||
|
| `x-dupes` | skx/sysadmin-util |
|
||||||
|
| `x-foreach` | mvdan/dotfiles |
|
||||||
|
| `x-multi-ping` | skx/sysadmin-util |
|
||||||
|
| `x-ssl-expiry-date` | skx/sysadmin-util |
|
||||||
|
| `x-until-error` | skx/sysadmin-util |
|
||||||
|
| `x-until-success` | skx/sysadmin-util |
|
||||||
|
| `x-validate-sha256-sum` | onnimonni |
|
||||||
|
| `x-when-down` | skx/sysadmin-util |
|
||||||
|
| `x-when-up` | skx/sysadmin-util |
|
||||||
|
|
||||||
|
- Sources:
|
||||||
|
- [skx/sysadmin-utils](https://github.com/skx/sysadmin-util/)
|
||||||
|
- Tools for Linux/Unix sysadmins.
|
||||||
|
- [Licence](https://github.com/skx/sysadmin-util/blob/master/LICENSE)
|
||||||
|
- onnimonni
|
||||||
|
- https://gist.github.com/onnimonni/b49779ebc96216771a6be3de46449fa1
|
||||||
|
- [mvdan/dotfiles](https://github.com/mvdan/dotfiles)
|
||||||
@@ -14,35 +14,42 @@
|
|||||||
|
|
||||||
SCRIPT=$(basename "$0")
|
SCRIPT=$(basename "$0")
|
||||||
|
|
||||||
|
source "$HOME/.dotfiles/scripts/shared.sh"
|
||||||
|
|
||||||
function section_install
|
function section_install
|
||||||
{
|
{
|
||||||
USAGE_PREFIX="-> $SCRIPT install"
|
USAGE_PREFIX="$SCRIPT install"
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
all)
|
all)
|
||||||
bash "$DOTFILES/scripts/settler.sh" && echo "🎉 Done!"
|
bash "$DOTFILES/scripts/settler.sh" && msg_done "🎉 Done!"
|
||||||
;;
|
;;
|
||||||
antigen)
|
antigen)
|
||||||
curl -L git.io/antigen > "$DOTFILES/local/bin/antigen.zsh" && echo "🎉 Done!"
|
curl -L git.io/antigen > "$DOTFILES/local/bin/antigen.zsh" && msg_done "🎉 Done!"
|
||||||
;;
|
;;
|
||||||
defaults)
|
defaults)
|
||||||
bash "$DOTFILES/scripts/set-defaults.sh" && echo "🎉 Done!"
|
bash "$DOTFILES/scripts/set-defaults.sh" && msg_done "🎉 Done!"
|
||||||
;;
|
;;
|
||||||
gh-extensions)
|
ext_go)
|
||||||
bash "$DOTFILES/scripts/gh-extensions.sh" && echo "🎉 Done!"
|
bash "$DOTFILES/scripts/install-go-packages" && msg_done "🎉 Done!"
|
||||||
|
;;
|
||||||
|
ext_gh)
|
||||||
|
bash "$DOTFILES/scripts/install-gh-extensions" && msg_done "🎉 Done!"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "$USAGE_PREFIX [antigen | defaults | gh-extensions]"
|
menu_section "$USAGE_PREFIX" "all | antigen | defaults | ext_go | ext_gh"
|
||||||
echo " * antigen: Updates the antigen.zsh file"
|
menu_item "all" "Runs the WIP settler.sh"
|
||||||
echo " * defaults: Setup nice macOS defaults"
|
menu_item "antigen" "Updates the antigen.zsh file"
|
||||||
echo " * gh-extensions: Install GitHub CLI Extensions"
|
menu_item "defaults" "Setup nice macOS defaults"
|
||||||
|
menu_item "ext_go" "Install Go Packages"
|
||||||
|
menu_item "ext_gh" "Install GitHub CLI Extensions"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function section_brew
|
function section_brew
|
||||||
{
|
{
|
||||||
USAGE_PREFIX="-> $SCRIPT brew"
|
USAGE_PREFIX="$SCRIPT brew"
|
||||||
|
|
||||||
if ! command -v brew &> /dev/null; then
|
if ! command -v brew &> /dev/null; then
|
||||||
echo "brew could not be found, please install it first"
|
echo "brew could not be found, please install it first"
|
||||||
@@ -60,36 +67,39 @@ function section_brew
|
|||||||
;;
|
;;
|
||||||
updatebundle)
|
updatebundle)
|
||||||
# Updates .dotfiles/Brewfile with descriptions
|
# Updates .dotfiles/Brewfile with descriptions
|
||||||
brew bundle dump --force --file="$BREWFILE" --describe && echo "🎉 Done!"
|
brew bundle dump \
|
||||||
|
--force \
|
||||||
|
--file="$BREWFILE" \
|
||||||
|
--describe && msg_ok "🎉 Done!"
|
||||||
;;
|
;;
|
||||||
autoupdate)
|
autoupdate)
|
||||||
brew autoupdate start 43200 --upgrade --cleanup --immediate
|
brew autoupdate start 43200 --upgrade --cleanup --immediate
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "$USAGE_PREFIX [install | update | updatebundle]"
|
menu_section "$USAGE_PREFIX" "install | update | updatebundle | autoupdate"
|
||||||
echo " * install: Installs items defined in Brewfile"
|
menu_item "install" "Installs items defined in Brewfile"
|
||||||
echo " * update: Updates and upgrades brew packages"
|
menu_item "update" "Updates and upgrades brew packages"
|
||||||
echo " * updatebundle: Updates Brewfile with descriptions"
|
menu_item "updatebundle" "Updates Brewfile with descriptions"
|
||||||
echo " * autoupdate: Setups brew auto-update and runs it immediately"
|
menu_item "autoupdate" "Setups brew auto-update and runs it immediately"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function section_dotfiles
|
function section_dotfiles
|
||||||
{
|
{
|
||||||
USAGE_PREFIX="-> $SCRIPT dotfiles"
|
USAGE_PREFIX="$SCRIPT dotfiles"
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
link)
|
link)
|
||||||
rcup -B "$HOSTNAME" -v && echo "🎉 Done!"
|
rcup -B "$HOSTNAME" -f -v && echo "🎉 Done!"
|
||||||
;;
|
;;
|
||||||
update)
|
update)
|
||||||
# Updates .dotfiles/scripts/install.sh and formats it
|
# Updates .dotfiles/scripts/install.sh and formats it
|
||||||
rcup -B 0 -g \
|
rcup -B 0 -g \
|
||||||
| tee "$INSTALL_SCRIPT" 1> /dev/null \
|
| tee "$INSTALL_SCRIPT" 1> /dev/null \
|
||||||
&& shfmt -w -l "$INSTALL_SCRIPT" \
|
&& sed -i '' "s|$HOME|\$HOME|g" "$INSTALL_SCRIPT"
|
||||||
&& sed -i '' "s|$HOME|\$HOME|g" "$INSTALL_SCRIPT" \
|
$0 dotfiles shfmt
|
||||||
&& echo "🎉 Done!"
|
echo "🎉 Done!"
|
||||||
;;
|
;;
|
||||||
shfmt)
|
shfmt)
|
||||||
# Format shell scripts according to following rules.
|
# Format shell scripts according to following rules.
|
||||||
@@ -108,18 +118,44 @@ function section_dotfiles
|
|||||||
"$DOTFILES"
|
"$DOTFILES"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "$USAGE_PREFIX [link | update | shfmt]"
|
menu_section "$USAGE_PREFIX" "link | update | shfmt"
|
||||||
echo " * link: Use rcrc to update dotfile links"
|
menu_item "link" "Use rcrc to update dotfile links"
|
||||||
echo " * update: Updates dotfile links, installs host specific overrides automatically"
|
menu_item "update" "Updates dotfile links, installs host specific overrides automatically"
|
||||||
echo " * shfmt: Run shfmt to all dotfiles"
|
menu_item "shfmt" "Run shfmt to all dotfiles"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Secret menu for visual tests
|
||||||
|
function section_tests
|
||||||
|
{
|
||||||
|
USAGE_PREFIX="$SCRIPT tests"
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
msg)
|
||||||
|
msg "msg"
|
||||||
|
msg_done "msg_done"
|
||||||
|
msg_prompt "msg_prompt"
|
||||||
|
msg_prompt_done "msg_prompt_done"
|
||||||
|
msg_nested "msg_nested"
|
||||||
|
msg_nested_done "msg_nested_done"
|
||||||
|
msg_run "msg_run" "second_param"
|
||||||
|
msg_ok "msg_ok"
|
||||||
|
msg_warn "msg_warn"
|
||||||
|
msg_err "msg_err"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
menu_section "$USAGE_PREFIX" "msg"
|
||||||
|
menu_item "msg" "List all log functions from shared.sh"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function usage
|
function usage
|
||||||
{
|
{
|
||||||
echo $"Usage: $SCRIPT [install | brew | dotfiles]"
|
echo ""
|
||||||
echo $" All commands have their own subcommands."
|
menu_section "Usage: $SCRIPT" "install | brew | dotfiles"
|
||||||
|
echo $" All commands have their own subcommands."
|
||||||
echo ""
|
echo ""
|
||||||
section_install
|
section_install
|
||||||
echo ""
|
echo ""
|
||||||
@@ -133,5 +169,6 @@ case "$1" in
|
|||||||
install) section_install "$2" ;;
|
install) section_install "$2" ;;
|
||||||
brew) section_brew "$2" ;;
|
brew) section_brew "$2" ;;
|
||||||
dotfiles) section_dotfiles "$2" ;;
|
dotfiles) section_dotfiles "$2" ;;
|
||||||
|
tests) section_tests "$2" ;;
|
||||||
*) usage && exit 1 ;;
|
*) usage && exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
208
local/bin/x-dupes
Executable file
208
local/bin/x-dupes
Executable file
@@ -0,0 +1,208 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
dupes - Report on files with duplicate contents, via SHA1 hash.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
dupes [options] directory
|
||||||
|
|
||||||
|
General Options:
|
||||||
|
|
||||||
|
--help Show the help information for this script.
|
||||||
|
--verbose Show useful debugging information.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
|
||||||
|
=head1 ABOUT
|
||||||
|
|
||||||
|
dupes is a simple script to report upon files that are identical,
|
||||||
|
recursively.
|
||||||
|
|
||||||
|
The process involves calculating the SHA1 hash of the file contents
|
||||||
|
and reporting on anything collisions we see.
|
||||||
|
|
||||||
|
Note that a collision might be caused by a symbolic link, or hardlink,
|
||||||
|
so blindly deleting duplicates without investigation is almost certainly
|
||||||
|
a mistake.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
Steve
|
||||||
|
--
|
||||||
|
http://www.steve.org.uk/
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
|
||||||
|
=head1 LICENSE
|
||||||
|
|
||||||
|
Copyright (c) 2013 by Steve Kemp. All rights reserved.
|
||||||
|
|
||||||
|
This script is free software;you can redistribute it and/or modify it under
|
||||||
|
the same terms as Perl itself.
|
||||||
|
|
||||||
|
The LICENSE file contains the full text of the license.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use File::Find;
|
||||||
|
use Getopt::Long;
|
||||||
|
use Pod::Usage;
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Parse the arguments
|
||||||
|
#
|
||||||
|
my %config = parsedOptions();
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# The path to examine.
|
||||||
|
#
|
||||||
|
my $path = $ARGV[0] || '.';
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Get the hashing object, dynamically.
|
||||||
|
#
|
||||||
|
my $ctx = getHashObject();
|
||||||
|
my %digest;
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Find files and store the hash of their contents.
|
||||||
|
#
|
||||||
|
find( {
|
||||||
|
'wanted' => sub {
|
||||||
|
if ( -f $_ )
|
||||||
|
{
|
||||||
|
lstat;
|
||||||
|
if ( ( -r _ ) && ( !-l _ ) )
|
||||||
|
{
|
||||||
|
$ctx->reset;
|
||||||
|
$ctx->addfile($_);
|
||||||
|
my $md5 = $ctx->hexdigest;
|
||||||
|
if ( exists $digest{ $md5 } )
|
||||||
|
{
|
||||||
|
push @{ $digest{ $md5 }->{ 'dupes' } }, $_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$digest{ $md5 } = { 'file' => $_,
|
||||||
|
'dupes' => [] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$config{ 'verbose' } && print "Entering $_\n";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'no_chdir' => 1
|
||||||
|
},
|
||||||
|
$path
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Report upon collisions.
|
||||||
|
#
|
||||||
|
foreach my $hash ( keys %digest )
|
||||||
|
{
|
||||||
|
my $dupes = $digest{ $hash }->{ 'dupes' };
|
||||||
|
my $src = $digest{ $hash }->{ 'file' };
|
||||||
|
|
||||||
|
if (@$dupes)
|
||||||
|
{
|
||||||
|
print $src . "\n";
|
||||||
|
foreach my $dupe (@$dupes)
|
||||||
|
{
|
||||||
|
print "\t$dupe\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# All done.
|
||||||
|
#
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
|
||||||
|
=begin doc
|
||||||
|
|
||||||
|
Load one of M<Digest::SHA> and M<Digest::SHA1>, depending on what is available.
|
||||||
|
|
||||||
|
=end doc
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub getHashObject
|
||||||
|
{
|
||||||
|
my $hash = undef;
|
||||||
|
|
||||||
|
foreach my $module (qw! Digest::SHA Digest::SHA1 !)
|
||||||
|
{
|
||||||
|
|
||||||
|
# If we succeeded in calculating the hash we're done.
|
||||||
|
next if ( defined($hash) );
|
||||||
|
|
||||||
|
# Attempt to load the module
|
||||||
|
my $eval = "use $module;";
|
||||||
|
|
||||||
|
## no critic (Eval)
|
||||||
|
eval($eval);
|
||||||
|
## use critic
|
||||||
|
|
||||||
|
if ( !$@ )
|
||||||
|
{
|
||||||
|
$hash = $module->new;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($hash)
|
||||||
|
{
|
||||||
|
return ($hash);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "Failed to load either DIgest::SHA or Digest::SHA1\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
=begin doc
|
||||||
|
|
||||||
|
Parse the options and return suitable values.
|
||||||
|
|
||||||
|
=end doc
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub parsedOptions
|
||||||
|
{
|
||||||
|
my %vars;
|
||||||
|
|
||||||
|
exit
|
||||||
|
if (
|
||||||
|
!GetOptions( "help" => \$vars{ 'help' },
|
||||||
|
"verbose" => \$vars{ 'verbose' } ) );
|
||||||
|
|
||||||
|
pod2usage(1) if ( $vars{ 'help' } );
|
||||||
|
|
||||||
|
return (%vars);
|
||||||
|
|
||||||
|
}
|
||||||
16
local/bin/x-foreach
Executable file
16
local/bin/x-foreach
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# foreach <folder> <commands that should be run to each file>
|
||||||
|
#
|
||||||
|
# Source: https://github.com/mvdan/dotfiles/blob/master/.bin/foreach
|
||||||
|
|
||||||
|
cmd=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
for dir in $($cmd); do
|
||||||
|
(
|
||||||
|
echo "$dir"
|
||||||
|
cd "$dir" || exit 1
|
||||||
|
eval "$@" # allow multiple commands like "foo && bar"
|
||||||
|
)
|
||||||
|
done
|
||||||
228
local/bin/x-multi-ping
Executable file
228
local/bin/x-multi-ping
Executable file
@@ -0,0 +1,228 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
multi-ping - Multi-protocol ping wrapper
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
multi-ping [--loop|--forever] [--sleep=N] hostname1 hostname2 .. hostnameN
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
This wrapper script will invoke one of 'ping' or 'ping6', as appropriate,
|
||||||
|
to test the connectivity of a remote host and your route to it.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
|
||||||
|
Steve
|
||||||
|
--
|
||||||
|
http://www.steve.org.uk/
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
=head1 LICENSE
|
||||||
|
|
||||||
|
Copyright (c) 2013-2014 by Steve Kemp. All rights reserved.
|
||||||
|
|
||||||
|
This script is free software; you can redistribute it and/or modify it under
|
||||||
|
the same terms as Perl itself.
|
||||||
|
|
||||||
|
The LICENSE file contains the full text of the license.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use Getopt::Long;
|
||||||
|
use Pod::Usage;
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check the dependencies.
|
||||||
|
#
|
||||||
|
checkSystem();
|
||||||
|
|
||||||
|
#
|
||||||
|
# Parse the command-line.
|
||||||
|
#
|
||||||
|
my %config = parsedOptions();
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# We could parse arguments here, for the moment we will hard-wire
|
||||||
|
# a timeout of five seconds.
|
||||||
|
#
|
||||||
|
my $timeout = 5;
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# If we didn't get any arguments then we should complain.
|
||||||
|
#
|
||||||
|
if ( scalar @ARGV < 1 )
|
||||||
|
{
|
||||||
|
print "Usage: multi-ping hostname1 hostname2 .. hostnameN\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Process each hostname specified upon the command-line.
|
||||||
|
#
|
||||||
|
# Looping if applicable.
|
||||||
|
#
|
||||||
|
do
|
||||||
|
{
|
||||||
|
foreach my $host (@ARGV)
|
||||||
|
{
|
||||||
|
pingHost($host);
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep( $config{ 'sleep' } );
|
||||||
|
|
||||||
|
} until ( !$config{ 'loop' } );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=begin doc
|
||||||
|
|
||||||
|
Given a hostname lookup both the AAAA & A records. For each result
|
||||||
|
perform the appropriate ping request.
|
||||||
|
|
||||||
|
=end doc
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub pingHost
|
||||||
|
{
|
||||||
|
my ($hostname) = (@_);
|
||||||
|
|
||||||
|
#
|
||||||
|
# If we've been given an URI then we'll remove the leading-scheme
|
||||||
|
# and use the hostname only.
|
||||||
|
#
|
||||||
|
if ( $hostname =~ m!^([a-z]+:\/\/)([^/]+)/?!i )
|
||||||
|
{
|
||||||
|
$hostname = $2;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Port might be specified too, drop that if present.
|
||||||
|
#
|
||||||
|
if ( $hostname =~ /^(.*):([0-9]+)$/ )
|
||||||
|
{
|
||||||
|
$hostname = $1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Lookup the IP for the name specified
|
||||||
|
#
|
||||||
|
my $res = Net::DNS::Resolver->new;
|
||||||
|
|
||||||
|
#
|
||||||
|
# The two types we'll lookup.
|
||||||
|
#
|
||||||
|
# NOTE: This shouldn't be required but my laptop resolver seems to
|
||||||
|
# struggle with lookups of the type "ANY". Sigh.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
foreach my $type (qw! A AAAA !)
|
||||||
|
{
|
||||||
|
my $query = $res->query( $hostname, $type );
|
||||||
|
|
||||||
|
if ($query)
|
||||||
|
{
|
||||||
|
foreach my $rr ( $query->answer )
|
||||||
|
{
|
||||||
|
my $ping_binary =
|
||||||
|
$rr->type eq "A" ? "ping" :
|
||||||
|
$rr->type eq "AAAA" ? "ping6" :
|
||||||
|
"";
|
||||||
|
if ($ping_binary)
|
||||||
|
{
|
||||||
|
my $result = system(
|
||||||
|
"$ping_binary -c1 -w$timeout -W$timeout $hostname >/dev/null 2>/dev/null"
|
||||||
|
);
|
||||||
|
|
||||||
|
print "Host $hostname - " . $rr->address() .
|
||||||
|
( ( $result == 0 ) ? " - alive" : " - FAILED" ) . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "WARNING: Failed to resolve $hostname [$type]\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=begin doc
|
||||||
|
|
||||||
|
Test that we have the required perl dependencies present.
|
||||||
|
|
||||||
|
=end doc
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub checkSystem
|
||||||
|
{
|
||||||
|
my $eval = "use Net::DNS;";
|
||||||
|
|
||||||
|
## no critic (Eval)
|
||||||
|
eval($eval);
|
||||||
|
## use critic
|
||||||
|
|
||||||
|
#
|
||||||
|
# If we don't have Net::DNS we're out of luck.
|
||||||
|
#
|
||||||
|
if ($@)
|
||||||
|
{
|
||||||
|
print "The required Net::DNS module is missing. Aborting.\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
=begin doc
|
||||||
|
|
||||||
|
Parse the options and return suitable values.
|
||||||
|
|
||||||
|
=end doc
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub parsedOptions
|
||||||
|
{
|
||||||
|
my %vars;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Defaults
|
||||||
|
#
|
||||||
|
$vars{ 'loop' } = 0;
|
||||||
|
$vars{ 'sleep' } = 1;
|
||||||
|
|
||||||
|
exit
|
||||||
|
if (
|
||||||
|
!GetOptions( "help" => \$vars{ 'help' },
|
||||||
|
"verbose" => \$vars{ 'verbose' },
|
||||||
|
"forever" => \$vars{ 'loop' },
|
||||||
|
"loop" => \$vars{ 'loop' },
|
||||||
|
"sleep=i" => \$vars{ 'sleep' },
|
||||||
|
) );
|
||||||
|
|
||||||
|
pod2usage(1) if ( $vars{ 'help' } );
|
||||||
|
|
||||||
|
return (%vars);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,14 +6,15 @@
|
|||||||
# Originally from: https://www.commandlinefu.com/commands/view/8951
|
# Originally from: https://www.commandlinefu.com/commands/view/8951
|
||||||
# Original author: https://www.commandlinefu.com/commands/by/wickedcpj
|
# Original author: https://www.commandlinefu.com/commands/by/wickedcpj
|
||||||
#
|
#
|
||||||
echo 'User: Command: Port:'
|
echo 'User: Command: PID: Port:'
|
||||||
echo '====================================================='
|
echo '========================================================='
|
||||||
|
|
||||||
lsof -i 4 -P -n +c 0 \
|
lsof -i 4 -P -n +c 0 \
|
||||||
| grep -i 'listen' \
|
| grep -i 'listen' \
|
||||||
| awk '{print $3, $1, $9}' \
|
| awk '{print $3, $1, $2, $9}' \
|
||||||
| sed 's/ [a-z0-9\.\*]*:/ /' \
|
| sed 's/ [a-z0-9\.\*]*:/ /' \
|
||||||
| sort -k 3 -n \
|
| sort -k 3 -n \
|
||||||
| xargs printf '%-20s %-25s %-5s\n' | uniq
|
| xargs printf '%-15s %-25s %-8s %-5s\n' \
|
||||||
|
| uniq
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
133
local/bin/x-ssl-expiry-date
Executable file
133
local/bin/x-ssl-expiry-date
Executable file
@@ -0,0 +1,133 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# About
|
||||||
|
# -----
|
||||||
|
# Check the expiry date of the SSL certificate on the given host.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# License
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013-2015 by Steve Kemp. All rights reserved.
|
||||||
|
#
|
||||||
|
# This script is free software; you can redistribute it and/or modify it under
|
||||||
|
# the same terms as Perl itself.
|
||||||
|
#
|
||||||
|
# The LICENSE file contains the full text of the license.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Simple function to show usage information, and exit.
|
||||||
|
#
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [-d] [-p 443] domain1.org domain2.com .. domainN"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Default settings for flags set by the command-line arguments
|
||||||
|
#
|
||||||
|
days=0
|
||||||
|
port=443
|
||||||
|
|
||||||
|
#
|
||||||
|
# Parse the argument(s) - i.e. look for "-d" / "-p 443".
|
||||||
|
#
|
||||||
|
while getopts "h?dp:" opt; do
|
||||||
|
case $opt in
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
d)
|
||||||
|
days=1
|
||||||
|
;;
|
||||||
|
p)
|
||||||
|
port=$OPTARG
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
|
#
|
||||||
|
# Ensure we have some arguments
|
||||||
|
#
|
||||||
|
if [ "$#" = "0" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# For each domain-name on the command-line.
|
||||||
|
#
|
||||||
|
for name in "$@"; do
|
||||||
|
|
||||||
|
#
|
||||||
|
# Make a temporary file
|
||||||
|
#
|
||||||
|
# Test if we have BSD or GNU version of mktemp
|
||||||
|
if ( strings "$(which mktemp)" | grep -q GNU); then
|
||||||
|
# We have the GNU version
|
||||||
|
tmp=$(mktemp)
|
||||||
|
else
|
||||||
|
# We have the BSD version
|
||||||
|
tmp=$(mktemp -t tmp)
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Download the certificate
|
||||||
|
#
|
||||||
|
if ( ! echo "" | openssl s_client -connect $name:$port > $tmp 2> /dev/null); then
|
||||||
|
echo "Failed to get cert from https://$name:$port/"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# Get the expiry date
|
||||||
|
#
|
||||||
|
date=$(openssl x509 -in "$tmp" -noout -enddate | awk -F= '{print $2}')
|
||||||
|
|
||||||
|
#
|
||||||
|
# Remove the temporary file
|
||||||
|
#
|
||||||
|
rm -f "$tmp"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Convert the expiry date + todays date to seconds-past epoch
|
||||||
|
#
|
||||||
|
# Check if we have the BSD or the GNU version of date
|
||||||
|
if (strings "$(which date)" | grep -q GNU); then
|
||||||
|
# We have GNU this is easy
|
||||||
|
then=$(date --date "$date" +%s)
|
||||||
|
else
|
||||||
|
# We have BSD now it is getting complicated
|
||||||
|
year=$(echo "$date" | awk '{print $4}')
|
||||||
|
month=$(echo "$date" | awk '{print $1}')
|
||||||
|
day=$(echo "$date" | awk '{print $2}')
|
||||||
|
hour=$(echo "$date" | awk '{print $3}' | awk -F: '{print $1}')
|
||||||
|
minute=$(echo "$date" | awk '{print $3}' | awk -F: '{print $2}')
|
||||||
|
second=$(echo "$date" | awk '{print $3}' | awk -F: '{print $3}')
|
||||||
|
then=$(date -v${year}y -v${month} -v${day}d -v${hour}H -v${minute}M -v${second}S -u +%s)
|
||||||
|
fi
|
||||||
|
|
||||||
|
now=$(date +%s)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Day diff
|
||||||
|
#
|
||||||
|
diff=$(("$then" - "$now"))
|
||||||
|
diff=$($diff / 86400)
|
||||||
|
|
||||||
|
#
|
||||||
|
# All done
|
||||||
|
#
|
||||||
|
if [ "$days" = "1" ]; then
|
||||||
|
echo "${name}: ${diff}"
|
||||||
|
else
|
||||||
|
echo "$name"
|
||||||
|
echo " Expires: ${date}"
|
||||||
|
echo " Days: ${diff}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
15
local/bin/x-until-error
Executable file
15
local/bin/x-until-error
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# About
|
||||||
|
# -----
|
||||||
|
# Repeat the command until it fails - always run at least once.
|
||||||
|
#
|
||||||
|
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
#
|
||||||
|
# If the status code was zero then repeat.
|
||||||
|
#
|
||||||
|
while [ $? -eq 0 ]; do
|
||||||
|
"$@"
|
||||||
|
done
|
||||||
30
local/bin/x-until-success
Executable file
30
local/bin/x-until-success
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# About
|
||||||
|
# -----
|
||||||
|
# Repeat the command until it succeeds - always run at least once.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# License
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013 by Steve Kemp. All rights reserved.
|
||||||
|
#
|
||||||
|
# This script is free software; you can redistribute it and/or modify it under
|
||||||
|
# the same terms as Perl itself.
|
||||||
|
#
|
||||||
|
# The LICENSE file contains the full text of the license.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Run the first time.
|
||||||
|
#
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
#
|
||||||
|
# If the status code was not zero then repeat.
|
||||||
|
#
|
||||||
|
while [ $? -ne 0 ]; do
|
||||||
|
"$@"
|
||||||
|
done
|
||||||
0
local/bin/x-validate-sha256sum.sh
Normal file → Executable file
0
local/bin/x-validate-sha256sum.sh
Normal file → Executable file
32
local/bin/x-when-down
Executable file
32
local/bin/x-when-down
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Wait until a given host is down (determined by ping) then execute the
|
||||||
|
# given command
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# ./when-down HOST COMMAND...
|
||||||
|
#
|
||||||
|
# Example
|
||||||
|
# ./when-down 1.2.3.4 ssh 1.2.3.4
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Ensure we received the correct number of arguments.
|
||||||
|
#
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
|
echo "Usage: $0 HOST COMMAND..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
HOST=$1
|
||||||
|
|
||||||
|
echo "Waiting for $HOST to get down..."
|
||||||
|
|
||||||
|
true
|
||||||
|
while [ $? -ne 1 ]; do
|
||||||
|
ping -c 1 -W 1 $HOST > /dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
shift
|
||||||
|
|
||||||
|
"$@"
|
||||||
45
local/bin/x-when-up
Executable file
45
local/bin/x-when-up
Executable file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Wait until a given host is online (determined by ping) then execute the
|
||||||
|
# given command
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# ./when-up HOST COMMAND...
|
||||||
|
#
|
||||||
|
# Example
|
||||||
|
# ./when-up 1.2.3.4 ssh 1.2.3.4
|
||||||
|
#
|
||||||
|
# Special case:
|
||||||
|
# when using when-up to ssh to a host, this host does not need to be given twice
|
||||||
|
# ./when-up ssh 1.2.3.4
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Ensure we received the correct number of arguments.
|
||||||
|
#
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
|
echo "Usage: $0 HOST COMMAND..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $1 = "ssh" ]; then
|
||||||
|
HOST=$2
|
||||||
|
else
|
||||||
|
HOST=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Waiting for $HOST to come online..."
|
||||||
|
|
||||||
|
ping -c 1 -W 1 $HOST > /dev/null
|
||||||
|
while [ $? -ne 0 ]; do
|
||||||
|
sleep 1
|
||||||
|
ping -c 1 -W 1 $HOST > /dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
# By the time we reach here the ping-command has completed successfully
|
||||||
|
# so we can launch the command we were given - along with any arguments.
|
||||||
|
if [ $1 != "ssh" ]; then
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$@"
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Install GitHub CLI extensions
|
# Install GitHub CLI extensions
|
||||||
|
|
||||||
|
source "$HOME/.dotfiles/scripts/shared.sh"
|
||||||
|
|
||||||
if ! command -v gh &> /dev/null; then
|
if ! command -v gh &> /dev/null; then
|
||||||
echo "gh (GitHub Client) could not be found, please install it first"
|
msg_run "gh (GitHub Client) could not be found, please install it first"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -35,10 +37,17 @@ extensions=(
|
|||||||
stoe/gh-report
|
stoe/gh-report
|
||||||
)
|
)
|
||||||
|
|
||||||
|
msg "Starting to install GitHub CLI extensions..."
|
||||||
|
|
||||||
for ext in "${extensions[@]}"; do
|
for ext in "${extensions[@]}"; do
|
||||||
|
# Trim spaces
|
||||||
|
ext=${ext// /}
|
||||||
# Skip comments
|
# Skip comments
|
||||||
if [[ ${ext:0:1} == "#" ]]; then continue; fi
|
if [[ ${ext:0:1} == "#" ]]; then continue; fi
|
||||||
|
|
||||||
echo "-> Installing $ext"
|
msg_run "Installing $ext"
|
||||||
gh extensions install "$ext"
|
gh extensions install "$ext"
|
||||||
|
echo ""
|
||||||
done
|
done
|
||||||
|
|
||||||
|
msg_ok "Done"
|
||||||
27
scripts/install-go-packages.sh
Normal file
27
scripts/install-go-packages.sh
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# Install Go packages
|
||||||
|
|
||||||
|
source "$HOME/.dotfiles/scripts/shared.sh"
|
||||||
|
|
||||||
|
if ! command -v go &> /dev/null; then
|
||||||
|
msg "go hasn't been installed yet."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
packages=(
|
||||||
|
# sysadmin/scripting utilities, distributed as a single binary
|
||||||
|
github.com/skx/sysbox@latest
|
||||||
|
)
|
||||||
|
|
||||||
|
for pkg in "${packages[@]}"; do
|
||||||
|
# Trim spaces
|
||||||
|
pkg=${pkg// /}
|
||||||
|
# Skip comments
|
||||||
|
if [[ ${pkg:0:1} == "#" ]]; then continue; fi
|
||||||
|
|
||||||
|
msg_run "Installing go package:" "$pkg"
|
||||||
|
go install "$pkg"
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
|
msg_ok "Done"
|
||||||
@@ -80,7 +80,15 @@ handle_file_ln "$HOME/.dotfiles/huskyrc" "$HOME/.huskyrc"
|
|||||||
handle_file_ln "$HOME/.dotfiles/local/bin/antigen.zsh" "$HOME/.local/bin/antigen.zsh"
|
handle_file_ln "$HOME/.dotfiles/local/bin/antigen.zsh" "$HOME/.local/bin/antigen.zsh"
|
||||||
handle_file_ln "$HOME/.dotfiles/local/bin/dfm" "$HOME/.local/bin/dfm"
|
handle_file_ln "$HOME/.dotfiles/local/bin/dfm" "$HOME/.local/bin/dfm"
|
||||||
handle_file_ln "$HOME/.dotfiles/local/bin/x-check-git-attributes" "$HOME/.local/bin/x-check-git-attributes"
|
handle_file_ln "$HOME/.dotfiles/local/bin/x-check-git-attributes" "$HOME/.local/bin/x-check-git-attributes"
|
||||||
|
handle_file_ln "$HOME/.dotfiles/local/bin/x-dupes" "$HOME/.local/bin/x-dupes"
|
||||||
|
handle_file_ln "$HOME/.dotfiles/local/bin/x-foreach" "$HOME/.local/bin/x-foreach"
|
||||||
|
handle_file_ln "$HOME/.dotfiles/local/bin/x-multi-ping" "$HOME/.local/bin/x-multi-ping"
|
||||||
handle_file_ln "$HOME/.dotfiles/local/bin/x-open-ports" "$HOME/.local/bin/x-open-ports"
|
handle_file_ln "$HOME/.dotfiles/local/bin/x-open-ports" "$HOME/.local/bin/x-open-ports"
|
||||||
|
handle_file_ln "$HOME/.dotfiles/local/bin/x-ssl-expiry-date" "$HOME/.local/bin/x-ssl-expiry-date"
|
||||||
|
handle_file_ln "$HOME/.dotfiles/local/bin/x-until-error" "$HOME/.local/bin/x-until-error"
|
||||||
|
handle_file_ln "$HOME/.dotfiles/local/bin/x-until-success" "$HOME/.local/bin/x-until-success"
|
||||||
|
handle_file_ln "$HOME/.dotfiles/local/bin/x-when-down" "$HOME/.local/bin/x-when-down"
|
||||||
|
handle_file_ln "$HOME/.dotfiles/local/bin/x-when-up" "$HOME/.local/bin/x-when-up"
|
||||||
handle_file_ln "$HOME/.dotfiles/rcrc" "$HOME/.rcrc"
|
handle_file_ln "$HOME/.dotfiles/rcrc" "$HOME/.rcrc"
|
||||||
handle_file_ln "$HOME/.dotfiles/ssh/allowed_signers" "$HOME/.ssh/allowed_signers"
|
handle_file_ln "$HOME/.dotfiles/ssh/allowed_signers" "$HOME/.ssh/allowed_signers"
|
||||||
handle_file_ln "$HOME/.dotfiles/ssh/config" "$HOME/.ssh/config"
|
handle_file_ln "$HOME/.dotfiles/ssh/config" "$HOME/.ssh/config"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# set-defaults.sh - Sets macOS Defaults that I like
|
# set-macos-defaults.sh - Sets macOS Defaults that I like
|
||||||
#
|
#
|
||||||
# This script contains large portions from following scripts:
|
# This script contains large portions from following scripts:
|
||||||
# - https://github.com/freekmurze/dotfiles/blob/main/macos/set-defaults.sh
|
# - https://github.com/freekmurze/dotfiles/blob/main/macos/set-defaults.sh
|
||||||
88
scripts/shared.sh
Normal file
88
scripts/shared.sh
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Shared bash functions and helpers
|
||||||
|
# that can be sourced to other scripts.
|
||||||
|
#
|
||||||
|
|
||||||
|
# -- Colors -- #
|
||||||
|
CLR_RED="\033[1;31m"
|
||||||
|
CLR_YELLOW='\033[1;33m'
|
||||||
|
CLR_GREEN="\033[1;32m"
|
||||||
|
CLR_BLUE='\033[1;34m'
|
||||||
|
CLR_RESET="\033[0m"
|
||||||
|
|
||||||
|
# -- Helpers -- #
|
||||||
|
function __log_marker() {
|
||||||
|
echo -e "${CLR_BLUE}➜${CLR_RESET}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function __log_marker_ok() {
|
||||||
|
echo -e "${CLR_GREEN}✔${CLR_RESET}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function __log_marker_ok_blue() {
|
||||||
|
echo -e "${CLR_BLUE}✔${CLR_RESET}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function __log_marker_warn() {
|
||||||
|
echo -e "${CLR_YELLOW}⁕${CLR_RESET}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function __log_marker_err() {
|
||||||
|
echo -e "${CLR_RED}⛌${CLR_RESET}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function __log_indent() {
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
|
||||||
|
# -- Log -- #
|
||||||
|
function msg() {
|
||||||
|
echo -e "$(__log_marker) $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function msg_done() {
|
||||||
|
echo -e "$(__log_marker) $1 ...$(__log_marker_ok)"
|
||||||
|
}
|
||||||
|
|
||||||
|
function msg_prompt() {
|
||||||
|
echo -e "$(__log_marker) $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function msg_prompt_done() {
|
||||||
|
echo -e "$(__log_marker) $1 ...$(__log_marker_ok)"
|
||||||
|
}
|
||||||
|
|
||||||
|
function msg_nested() {
|
||||||
|
echo -e "$(__log_indent)$(__log_marker) $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function msg_nested_done() {
|
||||||
|
echo -e "$(__log_indent)$(__log_marker) $1 ...$(__log_marker_ok)"
|
||||||
|
}
|
||||||
|
|
||||||
|
function msg_run() {
|
||||||
|
echo -e "${CLR_GREEN}➜ $1${CLR_RESET} $2"
|
||||||
|
}
|
||||||
|
|
||||||
|
function msg_ok() {
|
||||||
|
echo -e "$(__log_marker_ok) $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function msg_warn() {
|
||||||
|
echo -e "$(__log_marker_warn) $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function msg_err() {
|
||||||
|
echo -e "$(__log_marker_err) $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
# -- Menu builder -- #
|
||||||
|
function menu_section() {
|
||||||
|
LINE=$(printf '%-18s [ %-15s ]\n' "$1" "$2")
|
||||||
|
echo -e " $(__log_marker) $LINE"
|
||||||
|
}
|
||||||
|
function menu_item() {
|
||||||
|
LINE=$(printf '%-15s %-30s\n' "$1" "$2")
|
||||||
|
echo -e "$(__log_indent)$(__log_marker) $LINE"
|
||||||
|
}
|
||||||
11
zshrc
11
zshrc
@@ -2,6 +2,9 @@
|
|||||||
[[ -f "$HOME/.fig/shell/zshrc.pre.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.pre.zsh"
|
[[ -f "$HOME/.fig/shell/zshrc.pre.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.pre.zsh"
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
|
autoload -U colors zsh/terminfo
|
||||||
|
colors
|
||||||
|
|
||||||
export PATH="/opt/homebrew/bin:/usr/local/sbin:$PATH"
|
export PATH="/opt/homebrew/bin:/usr/local/sbin:$PATH"
|
||||||
|
|
||||||
if [ command -v brew &> /dev/null ]; then
|
if [ command -v brew &> /dev/null ]; then
|
||||||
@@ -16,6 +19,14 @@ if [ command -v brew &> /dev/null ]; then
|
|||||||
export PATH="$BREW_PYTHON:$GNUBIN_DIR:$BREW_GEMS:$BREW_RUBY:$BREW_BIN:$BREW_SBIN:$PATH"
|
export PATH="$BREW_PYTHON:$GNUBIN_DIR:$BREW_GEMS:$BREW_RUBY:$BREW_BIN:$BREW_SBIN:$PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If we have go packages, include them to the PATH
|
||||||
|
if command -v go &> /dev/null; then
|
||||||
|
export GOPATH=$(go env GOPATH);
|
||||||
|
if [ -d "$GOPATH/bin" ]; then
|
||||||
|
export PATH="$GOPATH/bin:$PATH"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
LOCAL_BIN="$HOME/.local/bin"
|
LOCAL_BIN="$HOME/.local/bin"
|
||||||
COMPOSER_DIR="$HOME/.composer/vendor/bin"
|
COMPOSER_DIR="$HOME/.composer/vendor/bin"
|
||||||
export PATH="$LOCAL_BIN:$COMPOSER_DIR:$PATH"
|
export PATH="$LOCAL_BIN:$COMPOSER_DIR:$PATH"
|
||||||
|
|||||||
Reference in New Issue
Block a user