bin housekeeping + apt personal utilities
sz-add-my-apt-repos - automate the apt repo addition sz-doctor - better output - still in the works sz-fix-apt-chmod - For TrueNAS SCALE where apt is disabled by default
This commit is contained in:
parent
786370ba94
commit
9b07d9489d
|
@ -1,42 +0,0 @@
|
||||||
#! /usr/bin/env bash
|
|
||||||
|
|
||||||
function print-result() {
|
|
||||||
printf "%-30s: %-8s %s \n" "$1" "$2" "$3"
|
|
||||||
}
|
|
||||||
function check-exist() {
|
|
||||||
_TEST_RESULT='Missing'
|
|
||||||
_TEST_NAME=$1
|
|
||||||
_TEST_PATH=${2:-$(type -fP $_TEST_NAME | head -1 2>/dev/null)}
|
|
||||||
[[ -n "$_TEST_PATH" ]] && eval "[[ ${3:--x} ${_TEST_PATH// /\\ } ]]" && _TEST_RESULT='Found'
|
|
||||||
print-result "$_TEST_NAME" "$_TEST_RESULT" "${4}"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Shell: $SHELL"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
#_ALT_EDITOR=$( update-alternatives --get-selections | grep '^editor' | sed 's:^editor\W\+\w\+\W\+/:/:' )
|
|
||||||
_ALT_EDITOR=$( update-alternatives --query editor | grep '^Value:' | cut -d: -f2 | sed 's: *\(.*\) *:\1:g' )
|
|
||||||
print-result "System prefered editor" "$_ALT_EDITOR"
|
|
||||||
( echo $_ALT_EDITOR | grep "nano$" >/dev/null ) && echo "Recommended to run: update-alternatives --set editor $(type -fP nvim vim.basic vim.tiny vi | head -1)"
|
|
||||||
echo "editors found:"
|
|
||||||
update-alternatives --query editor | grep Alternative: | cut -d: -f2
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
print-result 'Executable `apt`' $([[ -e $(type -fP apt) ]] && [[ -x $(type -fP apt | head -1) ]] && echo 'Found' || echo 'NOT found' )
|
|
||||||
|
|
||||||
check-exist "Byobu" "/usr/bin/byobu-launch"
|
|
||||||
check-exist "oh-my-posh"
|
|
||||||
check-exist "~/.poshtheme.omp.json" "~/.poshtheme.omp.json" "-r"
|
|
||||||
check-exist "tmux"
|
|
||||||
check-exist "git"
|
|
||||||
check-exist "emacs"
|
|
||||||
check-exist "terraform"
|
|
||||||
check-exist "setxkbmap"
|
|
||||||
check-exist "chezmoi"
|
|
||||||
check-exist "gcloud"
|
|
||||||
check-exist 'bash completion' '/usr/share/bash-completion/bash_completion' '-r'
|
|
||||||
check-exist 'CodeNewRoman Nerd Font' '~/.local/share/fonts/NF_CodeNewRoman' '-d'
|
|
||||||
check-exist 'FiraCode Nerd Font' '~/.local/share/fonts/NF_FiraCode' '-d'
|
|
||||||
check-exist '~/bin' "~/bin" '-d' '(Optional)'
|
|
||||||
check-exist '~/.local/bin' "~/.local/bin" '-d' '(Optional)'
|
|
||||||
echo ""
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
# sudo mkdir -p /usr/share/keyrings 2>&1 > /dev/null
|
||||||
|
|
||||||
|
# sudo apt-get install --yes --no-install-recommends \
|
||||||
|
# curl gnupg software-properties-common apt-transport-https
|
||||||
|
|
||||||
|
function add_repo() {
|
||||||
|
REPO_FQDN=$1 #'download.docker.com'
|
||||||
|
GPG_KEY_URL=${2:-https:\/\/$REPO_FQDN\/gpg}
|
||||||
|
GPG_KEY_PATH=/usr/share/keyrings/$REPO_FQDN.gpg
|
||||||
|
REPO_ARCH=${3:-$(dpkg --print-architecture)}
|
||||||
|
[[ $REPO_ARCH == '-' ]] && REPO_ARCH='' || REPO_ARCH="arch=$REPO_ARCH"
|
||||||
|
REPO_URL=${4:-https:\/\/$REPO_FQDN}
|
||||||
|
REPO_SUITE=${5:-$(lsb_release -cs)}
|
||||||
|
REPO_CMP=${6:-main}
|
||||||
|
|
||||||
|
curl -fsSL $GPG_KEY_URL | sudo gpg --dearmor -o $GPG_KEY_PATH
|
||||||
|
echo "Key created: $GPG_KEY_PATH"
|
||||||
|
echo "deb [$(echo "$REPO_ARCH signed-by=$GPG_KEY_PATH" | xargs )] $REPO_URL $REPO_SUITE $REPO_CMP" | \
|
||||||
|
sudo tee /etc/apt/sources.list.d/$REPO_FQDN.list > /dev/null
|
||||||
|
echo "APT source list added: /etc/apt/sources.list.d/$REPO_FQDN.list"
|
||||||
|
}
|
||||||
|
|
||||||
|
#Long line - 189 characters long
|
||||||
|
#add_repo REPO_FQDN/Name GPG_KEY_URL REPO_ARCH REPO_URL REPO_SUITE REPO_CMP # TBD: PIN_PRIORITY
|
||||||
|
#defaults: <required> 'https://$REPO_FQDN/gpg' $(dpkg --print-architecture) 'https://$REPO_FQDN' $(lsb_release -cs) 'main' # <optional>
|
||||||
|
# ---------------------------- ------------------------------------------------------- ---------- ------------------------------------------ ----------- ---------
|
||||||
|
add_repo 'download.docker.com' 'https://download.docker.com/linux/ubuntu/gpg' '' 'https://download.docker.com/linux/ubuntu' '' 'stable'
|
||||||
|
add_repo 'deb.anydesk.com' 'https://keys.anydesk.com/repos/DEB-GPG-KEY' '-' 'http://deb.anydesk.com/' 'all' ''
|
||||||
|
add_repo 'packages.cloud.google.com' 'https://packages.cloud.google.com/apt/doc/apt-key.gpg' '-' 'https://packages.cloud.google.com/apt' 'cloud-sdk' ''
|
||||||
|
add_repo 'packages.microsoft.com' 'https://packages.microsoft.com/keys/microsoft.asc' '' 'http://packages.microsoft.com/repos/code' 'stable' ''
|
||||||
|
add_repo 'apt.releases.hashicorp.com' 'https://apt.releases.hashicorp.com/gpg' '' 'https://apt.releases.hashicorp.com' '' ''
|
||||||
|
|
||||||
|
sudo apt-add-repository --no-update "deb [arch=amd64] http://http.us.debian.org/debian sid main non-free contrib"
|
||||||
|
# # Debian sid (unstable) as low-priority option
|
||||||
|
(echo 'Package: *'; echo 'Pin: release a=unstable'; echo 'Pin-Priority: 200') | sudo tee /etc/apt/preferences.d/unstable > /dev/null
|
||||||
|
# # pin xscreensaver to unstable
|
||||||
|
(echo 'Package: xscreenaver*'; echo 'Pin: release a=unstable'; echo 'Pin-Priority: 2000') | sudo tee /etc/apt/preferences.d/xscreensaver > /dev/null
|
||||||
|
|
||||||
|
sudo apt update
|
|
@ -0,0 +1,59 @@
|
||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
MISSING_APT_PACKAGES=()
|
||||||
|
SUGGESTED=()
|
||||||
|
|
||||||
|
function print-result() {
|
||||||
|
printf "%-30s: %-8s %s \n" "$1" "$2" "$3"
|
||||||
|
}
|
||||||
|
function check-exist() {
|
||||||
|
_RETURN_EVAL='true'
|
||||||
|
_TEST_RESULT='Missing'
|
||||||
|
_TEST_NAME=$1
|
||||||
|
_TEST_PATH=${2:-$(type -fP $_TEST_NAME | head -1 2>/dev/null)}
|
||||||
|
[[ -n "$_TEST_PATH" ]] && eval "[[ ${3:--x} ${_TEST_PATH// /\\ } ]]" && _TEST_RESULT='Found' || _RETURN_EVAL='false'
|
||||||
|
eval $_RETURN_EVAL && _TEST_NOTE="${4}" || _TEST_NOTE="${5}"
|
||||||
|
print-result "$_TEST_NAME" "$_TEST_RESULT" "$_TEST_NOTE"
|
||||||
|
eval $_RETURN_EVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Shell: $SHELL"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
#_ALT_EDITOR=$( update-alternatives --get-selections | grep '^editor' | sed 's:^editor\W\+\w\+\W\+/:/:' )
|
||||||
|
_ALT_EDITOR=$( update-alternatives --query editor | grep '^Value:' | cut -d: -f2 | sed 's: *\(.*\) *:\1:g' )
|
||||||
|
print-result "System prefered editor" "$_ALT_EDITOR"
|
||||||
|
( echo $_ALT_EDITOR | grep "nano$" >/dev/null ) && echo "Recommended to run: update-alternatives --set editor $(type -fP nvim vim.basic vim.tiny vi | head -1)"
|
||||||
|
echo "editors found:"
|
||||||
|
update-alternatives --query editor | grep Alternative: | cut -d: -f2
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
APT_OK=$([[ -e $(type -fP apt) ]] && [[ -x $(type -fP apt | head -1) ]] && echo '1')
|
||||||
|
APT_OK=""
|
||||||
|
print-result 'Executable `apt`' $([[ -n "$APT_OK" ]] && echo "Found" || echo "Missing" ) "$([[ -n "$APT_OK" ]] || printf 'repair by running:\n%-41sfix-apt.sh' '' )"
|
||||||
|
|
||||||
|
check-exist "Byobu" "/usr/bin/byobu-launch" || MISSING_APT_PACKAGES+=('byobu')
|
||||||
|
check-exist "oh-my-posh"
|
||||||
|
check-exist "~/.poshtheme.omp.json" "~/.poshtheme.omp.json" "-r"
|
||||||
|
check-exist "tmux"
|
||||||
|
check-exist "git"
|
||||||
|
check-exist "emacs"
|
||||||
|
check-exist "terraform" '' '' '' "$([[ -r /usr/share/keyrings/hashicorp.gpg ]] && MISSING_APT_PACKAGES+=('torraform') || echo \
|
||||||
|
'add apt repo by running:
|
||||||
|
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp.gpg
|
||||||
|
sudo apt-add-repository \
|
||||||
|
"deb [arch=amd64 signed-by=/usr/share/keyrings/hashicorp.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main"' \
|
||||||
|
)"
|
||||||
|
check-exist "setxkbmap"
|
||||||
|
check-exist "chezmoi"
|
||||||
|
check-exist "gcloud"
|
||||||
|
check-exist 'bash completion' '/usr/share/bash-completion/bash_completion' '-r'
|
||||||
|
check-exist 'CodeNewRoman Nerd Font' '~/.local/share/fonts/NF_CodeNewRoman' '-d'
|
||||||
|
check-exist 'FiraCode Nerd Font' '~/.local/share/fonts/NF_FiraCode' '-d'
|
||||||
|
check-exist '~/bin' "~/bin" '-d' '(Optional)'
|
||||||
|
check-exist '~/.local/bin' "~/.local/bin" '-d' '(Optional)'
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
[[ -n $SUGGESTED ]] && echo 'You might want to run the following commands:' && printf "\n%s\n" "${SUGGESTED[*]}"
|
||||||
|
|
||||||
|
[[ -n $MISSING_APT_PACKAGES ]] && printf "There are some missing APT packages, run the following command line to add them:\n\tsudo apt install ${MISSING_APT_PACKAGES[*]}\n\n"
|
Loading…
Reference in New Issue