WSL Changes #1
29
README.md
29
README.md
|
@ -1,9 +1,24 @@
|
||||||
# Installation
|
# dotfiles
|
||||||
|
|
||||||
## Linux Bionic/Tara distributions
|
These are my dotfiles, useful for my own shell configuration and not much else. Installation is easy, just paste this into your terminal.
|
||||||
|
|
||||||
sudo apt-get install git python3 ansible ansible-lint && curl -sL https://git.penguincoder.org/penguincoder/dotfiles/raw/branch/master/bin/install-dotfiles.sh | bash && ansible-playbook -i localdev-inventory.yaml linux-bionic-playbook.yaml
|
#!/bin/sh
|
||||||
|
#Initialization script sourced from Atlassian: https://developer.atlassian.com/blog/2016/02/best-way-to-store-dotfiles-git-bare-repo/
|
||||||
## Just the configuration files and shell scripts
|
git clone --bare ssh://git@git.penguincoder.org:2222/penguincoder/dotfiles.git
|
||||||
|
function config {
|
||||||
curl -sL https://git.penguincoder.org/penguincoder/dotfiles/raw/branch/master/bin/install-dotfiles.sh | bash
|
/usr/bin/git --git-dir=$HOME/dotfiles.git/ --work-tree=$HOME $@
|
||||||
|
}
|
||||||
|
mkdir -p .config-backup
|
||||||
|
config checkout
|
||||||
|
if [ $? = 0 ]; then
|
||||||
|
echo "Checked out config.";
|
||||||
|
else
|
||||||
|
echo "Backing up pre-existing dot files.";
|
||||||
|
config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} .config-backup/{}
|
||||||
|
fi;
|
||||||
|
config checkout
|
||||||
|
config config status.showUntrackedFiles no
|
||||||
|
config push --set-upstream origin master
|
||||||
|
config submodule init
|
||||||
|
config submodule update
|
||||||
|
which fc-cache 2>/dev/null && fc-cache -f -v ~/.fonts || true
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
for i in 0 1 2 3 4 5 6 7 ; do
|
|
||||||
echo -n "cpu${i} " && cat /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_cur_freq
|
|
||||||
done
|
|
|
@ -1,83 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# bash_completion for kerl
|
|
||||||
|
|
||||||
_kerl()
|
|
||||||
{
|
|
||||||
local cur prev
|
|
||||||
if type _get_comp_words_by_ref &>/dev/null ; then
|
|
||||||
_get_comp_words_by_ref cur prev
|
|
||||||
else
|
|
||||||
cur=$2 prev=$3
|
|
||||||
fi
|
|
||||||
|
|
||||||
case $prev in
|
|
||||||
kerl)
|
|
||||||
mapfile -t COMPREPLY < <( compgen -W 'build install update list delete active path status' -- "$cur" )
|
|
||||||
;;
|
|
||||||
list)
|
|
||||||
mapfile -t COMPREPLY < <( compgen -W 'releases builds installations' -- "$cur" )
|
|
||||||
;;
|
|
||||||
build)
|
|
||||||
if [ "$COMP_CWORD" -eq 2 ]; then
|
|
||||||
if [ -f "$HOME"/.kerl/otp_releases ]; then
|
|
||||||
RELEASES=$(cat "$HOME"/.kerl/otp_releases)
|
|
||||||
fi
|
|
||||||
mapfile -t COMPREPLY < <( compgen -W "git $RELEASES" -- "$cur")
|
|
||||||
else
|
|
||||||
if [ -f "$HOME"/.kerl/otp_builds ]; then
|
|
||||||
BUILDS=$(cut -d ',' -f 2 "$HOME"/.kerl/otp_builds)
|
|
||||||
fi
|
|
||||||
mapfile -t COMPREPLY < <( compgen -W "$BUILDS" -- "$cur")
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
installation)
|
|
||||||
if [ -f "$HOME"/.kerl/otp_installations ]; then
|
|
||||||
PATHS=$(cut -d ' ' -f 2 "$HOME"/.kerl/otp_installations)
|
|
||||||
fi
|
|
||||||
mapfile -t COMPREPLY < <( compgen -W "$PATHS" -- "$cur")
|
|
||||||
;;
|
|
||||||
install)
|
|
||||||
if [ -f "$HOME"/.kerl/otp_builds ]; then
|
|
||||||
BUILDS=$(cut -d ',' -f 2 "$HOME"/.kerl/otp_builds)
|
|
||||||
fi
|
|
||||||
mapfile -t COMPREPLY < <( compgen -W "$BUILDS" -- "$cur")
|
|
||||||
;;
|
|
||||||
path)
|
|
||||||
INSTALL_LIST="$HOME"/.kerl/otp_installations
|
|
||||||
if [ -f "$INSTALL_LIST" ]; then
|
|
||||||
NAMES=$(cut -d ' ' -f 2 "$INSTALL_LIST" | xargs basename)
|
|
||||||
fi
|
|
||||||
mapfile -t COMPREPLY < <( compgen -W "$NAMES" -- "$cur")
|
|
||||||
;;
|
|
||||||
deploy)
|
|
||||||
if [ "$COMP_CWORD" -eq 3 ]; then
|
|
||||||
if [ -f "$HOME"/.kerl/otp_installations ]; then
|
|
||||||
PATHS=$(cut -d ' ' -f 2 "$HOME"/.kerl/otp_installations)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
mapfile -t COMPREPLY < <( compgen -W "$PATHS" -- "$cur")
|
|
||||||
;;
|
|
||||||
delete)
|
|
||||||
mapfile -t COMPREPLY < <( compgen -W 'build installation' -- "$cur")
|
|
||||||
;;
|
|
||||||
update)
|
|
||||||
mapfile -t COMPREPLY < <( compgen -W 'releases' -- "$cur")
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [ "$COMP_CWORD" -eq 3 ]; then
|
|
||||||
if [ -f "$HOME"/.kerl/otp_builds ]; then
|
|
||||||
BUILDS=$(cut -d ',' -f 2 "$HOME"/.kerl/otp_builds)
|
|
||||||
fi
|
|
||||||
if [ -n "$BUILDS" ]; then
|
|
||||||
for b in $BUILDS; do
|
|
||||||
if [ "$prev" = "$b" ]; then
|
|
||||||
_filedir
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
complete -F _kerl kerl
|
|
|
@ -1,15 +0,0 @@
|
||||||
|
|
||||||
_kitty_completions() {
|
|
||||||
local src
|
|
||||||
local limit
|
|
||||||
# Send all words up to the word the cursor is currently on
|
|
||||||
let limit=1+$COMP_CWORD
|
|
||||||
src=$(printf "%s
|
|
||||||
" "${COMP_WORDS[@]: 0:$limit}" | kitty +complete bash)
|
|
||||||
if [[ $? == 0 ]]; then
|
|
||||||
eval ${src}
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
complete -o nospace -F _kitty_completions kitty
|
|
||||||
|
|
227
bin/kubectx
227
bin/kubectx
|
@ -1,227 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# kubectx(1) is a utility to manage and switch between kubectl contexts.
|
|
||||||
|
|
||||||
# Copyright 2017 Google Inc.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
[[ -n $DEBUG ]] && set -x
|
|
||||||
|
|
||||||
set -eou pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
|
|
||||||
SELF_CMD="$0"
|
|
||||||
KUBECTX="${XDG_CACHE_HOME:-$HOME/.kube}/kubectx"
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
cat <<"EOF"
|
|
||||||
USAGE:
|
|
||||||
kubectx : list the contexts
|
|
||||||
kubectx <NAME> : switch to context <NAME>
|
|
||||||
kubectx - : switch to the previous context
|
|
||||||
kubectx <NEW_NAME>=<NAME> : rename context <NAME> to <NEW_NAME>
|
|
||||||
kubectx <NEW_NAME>=. : rename current-context to <NEW_NAME>
|
|
||||||
kubectx -d <NAME> [<NAME...>] : delete context <NAME> ('.' for current-context)
|
|
||||||
(this command won't delete the user/cluster entry
|
|
||||||
that is used by the context)
|
|
||||||
|
|
||||||
kubectx -h,--help : show this message
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
exit_err() {
|
|
||||||
echo >&2 "${1}"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
current_context() {
|
|
||||||
$KUBECTL config view -o=jsonpath='{.current-context}'
|
|
||||||
}
|
|
||||||
|
|
||||||
get_contexts() {
|
|
||||||
$KUBECTL config get-contexts -o=name | sort -n
|
|
||||||
}
|
|
||||||
|
|
||||||
list_contexts() {
|
|
||||||
set -u pipefail
|
|
||||||
local cur ctx_list
|
|
||||||
cur="$(current_context)" || exit_err "error getting current context"
|
|
||||||
ctx_list=$(get_contexts) || exit_err "error getting context list"
|
|
||||||
|
|
||||||
local yellow darkbg normal
|
|
||||||
yellow=$(tput setaf 3 || true)
|
|
||||||
darkbg=$(tput setab 0 || true)
|
|
||||||
normal=$(tput sgr0 || true)
|
|
||||||
|
|
||||||
local cur_ctx_fg cur_ctx_bg
|
|
||||||
cur_ctx_fg=${KUBECTX_CURRENT_FGCOLOR:-$yellow}
|
|
||||||
cur_ctx_bg=${KUBECTX_CURRENT_BGCOLOR:-$darkbg}
|
|
||||||
|
|
||||||
for c in $ctx_list; do
|
|
||||||
if [[ -n "${_KUBECTX_FORCE_COLOR:-}" || \
|
|
||||||
-t 1 && -z "${NO_COLOR:-}" ]]; then
|
|
||||||
# colored output mode
|
|
||||||
if [[ "${c}" = "${cur}" ]]; then
|
|
||||||
echo "${cur_ctx_bg}${cur_ctx_fg}${c}${normal}"
|
|
||||||
else
|
|
||||||
echo "${c}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "${c}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
read_context() {
|
|
||||||
if [[ -f "${KUBECTX}" ]]; then
|
|
||||||
cat "${KUBECTX}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
save_context() {
|
|
||||||
local saved
|
|
||||||
saved="$(read_context)"
|
|
||||||
|
|
||||||
if [[ "${saved}" != "${1}" ]]; then
|
|
||||||
printf %s "${1}" > "${KUBECTX}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_context() {
|
|
||||||
$KUBECTL config use-context "${1}"
|
|
||||||
}
|
|
||||||
|
|
||||||
choose_context_interactive() {
|
|
||||||
local choice
|
|
||||||
choice="$(_KUBECTX_FORCE_COLOR=1 \
|
|
||||||
FZF_DEFAULT_COMMAND="${SELF_CMD}" \
|
|
||||||
fzf --ansi || true)"
|
|
||||||
if [[ -z "${choice}" ]]; then
|
|
||||||
echo 2>&1 "error: you did not choose any of the options"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
set_context "${choice}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
set_context() {
|
|
||||||
local prev
|
|
||||||
prev="$(current_context)" || exit_err "error getting current context"
|
|
||||||
|
|
||||||
switch_context "${1}"
|
|
||||||
|
|
||||||
if [[ "${prev}" != "${1}" ]]; then
|
|
||||||
save_context "${prev}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
swap_context() {
|
|
||||||
local ctx
|
|
||||||
ctx="$(read_context)"
|
|
||||||
if [[ -z "${ctx}" ]]; then
|
|
||||||
echo "error: No previous context found." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
set_context "${ctx}"
|
|
||||||
}
|
|
||||||
|
|
||||||
context_exists() {
|
|
||||||
grep -q ^"${1}"\$ <($KUBECTL config get-contexts -o=name)
|
|
||||||
}
|
|
||||||
|
|
||||||
rename_context() {
|
|
||||||
local old_name="${1}"
|
|
||||||
local new_name="${2}"
|
|
||||||
|
|
||||||
if [[ "${old_name}" == "." ]]; then
|
|
||||||
old_name="$(current_context)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! context_exists "${old_name}"; then
|
|
||||||
echo "error: Context \"${old_name}\" not found, can't rename it." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if context_exists "${new_name}"; then
|
|
||||||
echo "Context \"${new_name}\" exists, deleting..." >&2
|
|
||||||
$KUBECTL config delete-context "${new_name}" 1>/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
$KUBECTL config rename-context "${old_name}" "${new_name}"
|
|
||||||
}
|
|
||||||
|
|
||||||
delete_contexts() {
|
|
||||||
for i in "${@}"; do
|
|
||||||
delete_context "${i}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
delete_context() {
|
|
||||||
local ctx
|
|
||||||
ctx="${1}"
|
|
||||||
if [[ "${ctx}" == "." ]]; then
|
|
||||||
ctx="$(current_context)" || exit_err "error getting current context"
|
|
||||||
fi
|
|
||||||
echo "Deleting context \"${ctx}\"..." >&2
|
|
||||||
$KUBECTL config delete-context "${ctx}"
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
if hash kubectl 2>/dev/null; then
|
|
||||||
KUBECTL=kubectl
|
|
||||||
elif hash kubectl.exe 2>/dev/null; then
|
|
||||||
KUBECTL=kubectl.exe
|
|
||||||
else
|
|
||||||
echo >&2 "kubectl is not installed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$#" -eq 0 ]]; then
|
|
||||||
if [[ -t 1 && -z "${KUBECTX_IGNORE_FZF:-}" && "$(type fzf &>/dev/null; echo $?)" -eq 0 ]]; then
|
|
||||||
choose_context_interactive
|
|
||||||
else
|
|
||||||
list_contexts
|
|
||||||
fi
|
|
||||||
elif [[ "${1}" == "-d" ]]; then
|
|
||||||
if [[ "$#" -lt 2 ]]; then
|
|
||||||
echo "error: missing context NAME" >&2
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
delete_contexts "${@:2}"
|
|
||||||
elif [[ "$#" -gt 1 ]]; then
|
|
||||||
echo "error: too many arguments" >&2
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
elif [[ "$#" -eq 1 ]]; then
|
|
||||||
if [[ "${1}" == "-" ]]; then
|
|
||||||
swap_context
|
|
||||||
elif [[ "${1}" == '-h' || "${1}" == '--help' ]]; then
|
|
||||||
usage
|
|
||||||
elif [[ "${1}" =~ ^-(.*) ]]; then
|
|
||||||
echo "error: unrecognized flag \"${1}\"" >&2
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
elif [[ "${1}" =~ (.+)=(.+) ]]; then
|
|
||||||
rename_context "${BASH_REMATCH[2]}" "${BASH_REMATCH[1]}"
|
|
||||||
else
|
|
||||||
set_context "${1}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
214
bin/kubens
214
bin/kubens
|
@ -1,214 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# kubens(1) is a utility to switch between Kubernetes namespaces.
|
|
||||||
|
|
||||||
# Copyright 2017 Google Inc.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
[[ -n $DEBUG ]] && set -x
|
|
||||||
|
|
||||||
set -eou pipefail
|
|
||||||
IFS=$'\n\t'
|
|
||||||
|
|
||||||
SELF_CMD="$0"
|
|
||||||
KUBENS_DIR="${XDG_CACHE_HOME:-$HOME/.kube}/kubens"
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
cat <<"EOF"
|
|
||||||
USAGE:
|
|
||||||
kubens : list the namespaces in the current context
|
|
||||||
kubens <NAME> : change the active namespace of current context
|
|
||||||
kubens - : switch to the previous namespace in this context
|
|
||||||
kubens -h,--help : show this message
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
exit_err() {
|
|
||||||
echo >&2 "${1}"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
current_namespace() {
|
|
||||||
local cur_ctx
|
|
||||||
|
|
||||||
cur_ctx="$(current_context)" || exit_err "error getting current context"
|
|
||||||
ns="$($KUBECTL config view -o=jsonpath="{.contexts[?(@.name==\"${cur_ctx}\")].context.namespace}")" \
|
|
||||||
|| exit_err "error getting current namespace"
|
|
||||||
|
|
||||||
if [[ -z "${ns}" ]]; then
|
|
||||||
echo "default"
|
|
||||||
else
|
|
||||||
echo "${ns}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
current_context() {
|
|
||||||
$KUBECTL config current-context
|
|
||||||
}
|
|
||||||
|
|
||||||
get_namespaces() {
|
|
||||||
$KUBECTL get namespaces -o=jsonpath='{range .items[*].metadata.name}{@}{"\n"}{end}'
|
|
||||||
}
|
|
||||||
|
|
||||||
escape_context_name() {
|
|
||||||
echo "${1//\//-}"
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace_file() {
|
|
||||||
local ctx="$(escape_context_name "${1}")"
|
|
||||||
echo "${KUBENS_DIR}/${ctx}"
|
|
||||||
}
|
|
||||||
|
|
||||||
read_namespace() {
|
|
||||||
local f
|
|
||||||
f="$(namespace_file "${1}")"
|
|
||||||
[[ -f "${f}" ]] && cat "${f}"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
save_namespace() {
|
|
||||||
mkdir -p "${KUBENS_DIR}"
|
|
||||||
local f saved
|
|
||||||
f="$(namespace_file "${1}")"
|
|
||||||
saved="$(read_namespace "${1}")"
|
|
||||||
|
|
||||||
if [[ "${saved}" != "${2}" ]]; then
|
|
||||||
printf %s "${2}" > "${f}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_namespace() {
|
|
||||||
local ctx="${1}"
|
|
||||||
$KUBECTL config set-context "${ctx}" --namespace="${2}"
|
|
||||||
echo "Active namespace is \"${2}\".">&2
|
|
||||||
}
|
|
||||||
|
|
||||||
choose_namespace_interactive() {
|
|
||||||
# directly calling kubens via fzf might fail with a cryptic error like
|
|
||||||
# "$FZF_DEFAULT_COMMAND failed", so try to see if we can list namespaces
|
|
||||||
# locally first
|
|
||||||
if [[ -z "$(list_namespaces)" ]]; then
|
|
||||||
echo >&2 "error: could not list namespaces (is the cluster accessible?)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local choice
|
|
||||||
choice="$(_KUBECTX_FORCE_COLOR=1 \
|
|
||||||
FZF_DEFAULT_COMMAND="${SELF_CMD}" \
|
|
||||||
fzf --ansi || true)"
|
|
||||||
if [[ -z "${choice}" ]]; then
|
|
||||||
echo 2>&1 "error: you did not choose any of the options"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
set_namespace "${choice}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
set_namespace() {
|
|
||||||
local ctx prev
|
|
||||||
ctx="$(current_context)" || exit_err "error getting current context"
|
|
||||||
prev="$(current_namespace)" || exit_error "error getting current namespace"
|
|
||||||
|
|
||||||
if grep -q ^"${1}"\$ <(get_namespaces); then
|
|
||||||
switch_namespace "${ctx}" "${1}"
|
|
||||||
|
|
||||||
if [[ "${prev}" != "${1}" ]]; then
|
|
||||||
save_namespace "${ctx}" "${prev}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "error: no namespace exists with name \"${1}\".">&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
list_namespaces() {
|
|
||||||
local yellow darkbg normal
|
|
||||||
yellow=$(tput setaf 3 || true)
|
|
||||||
darkbg=$(tput setab 0 || true)
|
|
||||||
normal=$(tput sgr0 || true)
|
|
||||||
|
|
||||||
local cur_ctx_fg cur_ctx_bg
|
|
||||||
cur_ctx_fg=${KUBECTX_CURRENT_FGCOLOR:-$yellow}
|
|
||||||
cur_ctx_bg=${KUBECTX_CURRENT_BGCOLOR:-$darkbg}
|
|
||||||
|
|
||||||
local cur ns_list
|
|
||||||
cur="$(current_namespace)" || exit_err "error getting current namespace"
|
|
||||||
ns_list=$(get_namespaces) || exit_err "error getting namespace list"
|
|
||||||
|
|
||||||
for c in $ns_list; do
|
|
||||||
if [[ -n "${_KUBECTX_FORCE_COLOR:-}" || \
|
|
||||||
-t 1 && -z "${NO_COLOR:-}" ]]; then
|
|
||||||
# colored output mode
|
|
||||||
if [[ "${c}" = "${cur}" ]]; then
|
|
||||||
echo "${cur_ctx_bg}${cur_ctx_fg}${c}${normal}"
|
|
||||||
else
|
|
||||||
echo "${c}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "${c}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
swap_namespace() {
|
|
||||||
local ctx ns
|
|
||||||
ctx="$(current_context)" || exit_err "error getting current context"
|
|
||||||
ns="$(read_namespace "${ctx}")"
|
|
||||||
if [[ -z "${ns}" ]]; then
|
|
||||||
echo "error: No previous namespace found for current context." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
set_namespace "${ns}"
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
if [[ -z "${KUBECTL:-}" ]]; then
|
|
||||||
if hash kubectl 2>/dev/null; then
|
|
||||||
KUBECTL=kubectl
|
|
||||||
elif hash kubectl.exe 2>/dev/null; then
|
|
||||||
KUBECTL=kubectl.exe
|
|
||||||
else
|
|
||||||
echo >&2 "kubectl is not installed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$#" -eq 0 ]]; then
|
|
||||||
if [[ -t 1 && -z ${KUBECTX_IGNORE_FZF:-} && "$(type fzf &>/dev/null; echo $?)" -eq 0 ]]; then
|
|
||||||
choose_namespace_interactive
|
|
||||||
else
|
|
||||||
list_namespaces
|
|
||||||
fi
|
|
||||||
elif [[ "$#" -eq 1 ]]; then
|
|
||||||
if [[ "${1}" == '-h' || "${1}" == '--help' ]]; then
|
|
||||||
usage
|
|
||||||
elif [[ "${1}" == "-" ]]; then
|
|
||||||
swap_namespace
|
|
||||||
elif [[ "${1}" =~ ^-(.*) ]]; then
|
|
||||||
echo "error: unrecognized flag \"${1}\"" >&2
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
elif [[ "${1}" =~ (.+)=(.+) ]]; then
|
|
||||||
alias_context "${BASH_REMATCH[2]}" "${BASH_REMATCH[1]}"
|
|
||||||
else
|
|
||||||
set_namespace "${1}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "error: too many flags" >&2
|
|
||||||
usage
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
|
@ -1,2 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
ffmpeg -i "concat:$(ls -1 *.mp3 | paste -sd "|" -)" -c:a aac -b:a 64k -f mp4 o.mp4
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +0,0 @@
|
||||||
export MINIKUBE_MEMORY=4096
|
|
||||||
export MINIKUBE_WANTUPDATENOTIFICATION=true
|
|
||||||
export MINIKUBE_WANTREPORTERRORPROMPT=false
|
|
||||||
export MINIKUBE_WANTKUBECTLDOWNLOADMSG=false
|
|
||||||
export MINIKUBE_HOME=$HOME
|
|
||||||
export MINIKUBE_DRIVER=kvm2
|
|
||||||
export CHANGE_MINIKUBE_NONE_USER=true
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,21 +0,0 @@
|
||||||
---
|
|
||||||
- name: linux desktop setup
|
|
||||||
hosts: all
|
|
||||||
become: yes
|
|
||||||
become_user: root
|
|
||||||
become_method: sudo
|
|
||||||
gather_facts: False
|
|
||||||
vars:
|
|
||||||
ansible_connection: local
|
|
||||||
ansible_python_interpreter: /usr/bin/python3
|
|
||||||
tasks:
|
|
||||||
- include_role:
|
|
||||||
name: dev-tools
|
|
||||||
- include_role:
|
|
||||||
name: docker
|
|
||||||
- include_role:
|
|
||||||
name: k8s
|
|
||||||
- include_role:
|
|
||||||
name: linux-desktop
|
|
||||||
- include_role:
|
|
||||||
name: libvirt
|
|
|
@ -1 +0,0 @@
|
||||||
default ansible_connection=local
|
|
|
@ -1,51 +0,0 @@
|
||||||
---
|
|
||||||
- name: install apt applications
|
|
||||||
apt:
|
|
||||||
name: jq,vim,emacs,curl,htop,tmux,git,openvpn,build-essential,libssl-dev,libncurses5-dev
|
|
||||||
state: present
|
|
||||||
- name: install micro
|
|
||||||
shell: curl -sLo /tmp/micro.tar.gz https://github.com/zyedidia/micro/releases/download/v1.4.1/micro-1.4.1-linux64.tar.gz && mkdir -p /tmp/micro && tar xzf /tmp/micro.tar.gz -C /tmp/micro && install -m 755 /tmp/micro/micro-1.4.1/micro /usr/local/bin/micro-1.4.1 && rm -rf /tmp/micro* && ln -sf /usr/local/bin/micro-1.4.1 /usr/local/bin/micro
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: /usr/local/bin/micro-1.4.1
|
|
||||||
- name: install powerline-go
|
|
||||||
shell: curl -sLo /tmp/powerline-go https://github.com/justjanne/powerline-go/releases/download/v1.12.1/powerline-go-linux-amd64 && install -m 755 /tmp/powerline-go /usr/local/bin/powerline-go-1.12.1 && rm -f /tmp/powerline-go && ln -sf /usr/local/bin/powerline-go-1.12.1 /usr/local/bin/powerline-go
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: /usr/local/bin/powerline-go-1.12.1
|
|
||||||
- name: install rustup
|
|
||||||
become: no
|
|
||||||
shell: curl -o t.sh https://sh.rustup.rs -sSf && chmod 700 t.sh && ./t.sh --no-modify-path --verbose -y --default-toolchain stable && rm -f t.sh
|
|
||||||
args:
|
|
||||||
creates: ~/.cargo/bin/rustup
|
|
||||||
- name: install kerl
|
|
||||||
shell: curl -O https://raw.githubusercontent.com/kerl/kerl/master/kerl && install -m 755 kerl /usr/local/bin/kerl && rm -f kerl
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: /usr/local/bin/kerl
|
|
||||||
- name: update kerl releases
|
|
||||||
become: no
|
|
||||||
shell: kerl update releases
|
|
||||||
args:
|
|
||||||
creates: ~/.kerl/otp_releases
|
|
||||||
- name: build erlang 22.0
|
|
||||||
become: no
|
|
||||||
shell: kerl build 22.0 22.0
|
|
||||||
args:
|
|
||||||
creates: ~/.kerl/builds/22.0
|
|
||||||
- name: install erlang 22.0
|
|
||||||
become: no
|
|
||||||
shell: kerl install 22.0
|
|
||||||
args:
|
|
||||||
creates: ~/.kerl/installs/22.0
|
|
||||||
- name: install kiex
|
|
||||||
become: no
|
|
||||||
shell: curl -sSL https://raw.githubusercontent.com/taylor/kiex/master/install | bash -s
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: ~/.kiex/bin/kiex
|
|
||||||
- name: install elixir
|
|
||||||
become: no
|
|
||||||
shell: . ~/bin/kerl.setup.bash && kiex install 1.9.0
|
|
||||||
args:
|
|
||||||
creates: ~/.kiex/elixirs/elixir-1.9.0
|
|
|
@ -1,15 +0,0 @@
|
||||||
---
|
|
||||||
- name: add docker-ce pubkey
|
|
||||||
shell: curl -sL "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x7EA0A9C3F273FCD8" | sudo apt-key add
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
- name: add docker-ce repo
|
|
||||||
apt_repository:
|
|
||||||
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
|
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
- name: install docker-compose
|
|
||||||
shell: curl -sLo /tmp/docker-compose https://github.com/docker/compose/releases/download/1.24.0/docker-compose-Linux-x86_64 && install -m 755 /tmp/docker-compose /usr/local/bin/docker-compose-1.24.0 && rm -f /tmp/docker-compose && ln -sf /usr/local/bin/docker-compose-1.24.0 /usr/local/bin/docker-compose
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: /usr/local/bin/docker-compose-1.24.0
|
|
|
@ -1,64 +0,0 @@
|
||||||
---
|
|
||||||
- name: configure static hostfile entry for starbase4.consolo.lan
|
|
||||||
lineinfile:
|
|
||||||
path: /etc/hosts
|
|
||||||
line: "10.4.21.100 starbase4 starbase4.consolo.lan"
|
|
||||||
- name: configure static hostfile entry for errbit.consolo.lan
|
|
||||||
lineinfile:
|
|
||||||
path: /etc/hosts
|
|
||||||
line: "10.4.21.136 errbit.consolo.lan"
|
|
||||||
- name: configure static hostfile entry for api-doc.consolo.lan
|
|
||||||
lineinfile:
|
|
||||||
path: /etc/hosts
|
|
||||||
line: "10.4.21.100 api-docs.consolo.lan"
|
|
||||||
- name: configure static hostfile entry for lxd.consolo.lan
|
|
||||||
lineinfile:
|
|
||||||
path: /etc/hosts
|
|
||||||
line: "10.4.21.253 lxd.consolo.lan mattermost.lxd.consolo.lan"
|
|
||||||
- name: configure static hostfile entry for git.lxd.consolo.lan
|
|
||||||
lineinfile:
|
|
||||||
path: /etc/hosts
|
|
||||||
line: "10.4.21.230 git.lxd.consolo.lan"
|
|
||||||
- name: install apt applications
|
|
||||||
apt:
|
|
||||||
name: python3-pip,python3-setuptools,python3-yaml,python3-wheel,socat,vpnc
|
|
||||||
state: present
|
|
||||||
- name: install pip applications
|
|
||||||
pip:
|
|
||||||
name: awscli,saws
|
|
||||||
state: present
|
|
||||||
- name: install kubectl
|
|
||||||
shell: curl -sLo /tmp/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.15.0/bin/linux/amd64/kubectl && install -m 755 /tmp/kubectl /usr/local/bin/kubectl-1.15.0 && rm -f /tmp/kubectl && ln -sf /usr/local/bin/kubectl-1.15.0 /usr/local/bin/kubectl
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: /usr/local/bin/kubectl-1.15.0
|
|
||||||
- name: install kops
|
|
||||||
shell: curl -sLo /tmp/kops -L https://github.com/kubernetes/kops/releases/download/1.10.0/kops-linux-amd64 && install -m 755 /tmp/kops /usr/local/bin/kops-1.10.0 && rm -f /tmp/kops && ln -sf /usr/local/bin/kops-1.10.0 /usr/local/bin/kops
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: /usr/local/bin/kops-1.12.2
|
|
||||||
- name: install minikube
|
|
||||||
shell: curl -sLo /tmp/minikube https://storage.googleapis.com/minikube/releases/v1.12.2/minikube-linux-amd64 && install -m 755 /tmp/minikube /usr/local/bin/minikube-1.12.2 && rm -f /tmp/minikube && ln -sf /usr/local/bin/minikube-1.12.2 /usr/local/bin/minikube
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: /usr/local/bin/minikube-1.12.2
|
|
||||||
- name: install helm
|
|
||||||
shell: curl -sLo /tmp/helm.tar.gz https://storage.googleapis.com/kubernetes-helm/helm-v2.13.1-linux-amd64.tar.gz && mkdir -p /tmp/helm && tar xzf /tmp/helm.tar.gz -C /tmp/helm && install -m 755 /tmp/helm/linux-amd64/helm /usr/local/bin/helm-2.13.1 && rm -rf /tmp/helm* && ln -sf /usr/local/bin/helm-2.13.1 /usr/local/bin/helm
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: /usr/local/bin/helm-2.13.1
|
|
||||||
- name: install k9s
|
|
||||||
shell: curl -sLo /tmp/k9s.tar.gz https://github.com/derailed/k9s/releases/download/0.7.11/k9s_0.7.11_Linux_x86_64.tar.gz && tar xzf /tmp/k9s.tar.gz -C /tmp && install -m 755 /tmp/k9s /usr/local/bin/k9s-0.7.11 && rm -f /tmp/k9s* && ln -sf /usr/local/bin/k9s-0.7.11 /usr/local/bin/k9s
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: /usr/local/bin/k9s-0.7.11
|
|
||||||
- name: install popeye
|
|
||||||
shell: curl -sLo /tmp/popeye.tar.gz https://github.com/derailed/popeye/releases/download/v0.3.12/popeye_0.3.12_Linux_x86_64.tar.gz && tar xzf /tmp/popeye.tar.gz -C /tmp && install -m 755 /tmp/popeye /usr/local/bin/popeye-0.3.12 && rm -f /tmp/popeye* && ln -sf /usr/local/bin/popeye-0.3.12 /usr/local/bin/popeye
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: /usr/local/bin/popeye-0.3.12
|
|
||||||
- name: install stern
|
|
||||||
shell: curl -sLo /tmp/stern_linux_amd64 https://github.com/wercker/stern/releases/download/1.10.0/stern_linux_amd64 && install -m 755 /tmp/stern_linux_amd64 /usr/local/bin/stern-1.10.0 && rm -f /tmp/stern_linux_amd64 && ln -sf /usr/local/bin/stern-1.10.0 /usr/local/bin/stern
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: /usr/local/bin/stern-1.10.0
|
|
|
@ -1,15 +0,0 @@
|
||||||
---
|
|
||||||
- name: install apt applications
|
|
||||||
apt:
|
|
||||||
name: libvirt-clients,libvirt-daemon-system,qemu-kvm,virt-manager,virt-top,virt-goodies,vagrant,vagrant-libvirt,vagrant-mutate,xsltproc,fop,docker-ce
|
|
||||||
state: present
|
|
||||||
- name: install docker-machine
|
|
||||||
shell: curl -sLo docker-machine https://github.com/docker/machine/releases/download/v0.16.0/docker-machine-linux-x86_64 && install -m 755 docker-machine /usr/local/bin/docker-machine-0.16.0 && rm -f docker-machine && ln -sf /usr/local/bin/docker-machine-0.16.0 /usr/local/bin/docker-machine
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: /usr/local/bin/docker-machine-0.16.0
|
|
||||||
- name: install docker-machine-driver-kvm2
|
|
||||||
shell: curl -sLo docker-machine-driver-kvm2 https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2 && install -m 755 docker-machine-driver-kvm2 /usr/local/bin/docker-machine-driver-kvm2 && rm -f docker-machine-driver-kvm2
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: /usr/local/bin/docker-machine-driver-kvm2
|
|
|
@ -1,30 +0,0 @@
|
||||||
---
|
|
||||||
- name: add nextcloud pubkey
|
|
||||||
shell: curl -sL "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x60EE47FBAD3DD469" | sudo apt-key add
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
- name: add nextcloud repo
|
|
||||||
apt_repository:
|
|
||||||
repo: "deb http://ppa.launchpad.net/nextcloud-devs/client/ubuntu bionic main"
|
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
- name: add openrazer repo
|
|
||||||
apt_repository:
|
|
||||||
repo: "deb http://ppa.launchpad.net/openrazer/stable/ubuntu bionic main"
|
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
- name: add polychromatic repo
|
|
||||||
apt_repository:
|
|
||||||
repo: "deb http://ppa.launchpad.net/openrazer/stable/ubuntu bionic main"
|
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
- name: install apt applications
|
|
||||||
apt:
|
|
||||||
name: openvpn,nextcloud-client,openrazer-meta,polychromatic
|
|
||||||
state: present
|
|
||||||
- name: install kitty terminal emulator
|
|
||||||
become: no
|
|
||||||
shell: curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin launch=n && ln -s ~/.local/kitty.app/bin/kitty ~/bin/ && mkdir -p ~/.local/share/applications && cp ~/.local/kitty.app/share/applications/kitty.desktop ~/.local/share/applications && sed -i "s/Icon\=kitty/Icon\=\/home\/$USER\/.local\/kitty.app\/share\/icons\/hicolor\/256x256\/apps\/kitty.png/g" ~/.local/share/applications/kitty.desktop
|
|
||||||
args:
|
|
||||||
warn: False
|
|
||||||
creates: ~/bin/kitty
|
|
|
@ -1,17 +0,0 @@
|
||||||
---
|
|
||||||
- name: wsl setup
|
|
||||||
hosts: all
|
|
||||||
become: yes
|
|
||||||
become_user: root
|
|
||||||
become_method: sudo
|
|
||||||
gather_facts: False
|
|
||||||
vars:
|
|
||||||
ansible_connection: local
|
|
||||||
ansible_python_interpreter: /usr/bin/python3
|
|
||||||
tasks:
|
|
||||||
- include_role:
|
|
||||||
name: dev-tools
|
|
||||||
- include_role:
|
|
||||||
name: docker
|
|
||||||
- include_role:
|
|
||||||
name: k8s
|
|
Reference in New Issue