Move tasks into new general role
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFi5drlM5Uli7GbTZFiKPKnG8RmOyS2eu3c6XkwwJiSk luX@smithers.codesignd.net
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOBEksH8LMO5jf1QsMH3yRdxSmY2XPk8CH9HNsWfsXVt luX@bart.codesignd.net
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIETsPbHqAta4E6j9pm/9E4lLurlPoh+p5zOWiZ9GS5ml luX@maggie.codesignd.net
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG9J5FMq9ttUcnuqWhYsiKVuols5uD2Ddv7L3Z93nD2W luX@homer.codesignd.net
|
||||
@@ -0,0 +1,60 @@
|
||||
###
|
||||
# Loader for Oh My Fish! packages
|
||||
# Loads all packages stored in ~/.config/fish/pkgs/
|
||||
#
|
||||
# Inspired by https://github.com/jorgebucaran/fisher
|
||||
###
|
||||
|
||||
set -q pkgs_path; or set -g pkgs_path ~/.config/fish/pkgs
|
||||
|
||||
# also search for functions/completions/binaries/manpages within packages
|
||||
set fish_function_path $fish_function_path[1] $pkgs_path/.functions $pkgs_path/*/functions $fish_function_path[2..-1]
|
||||
set fish_complete_path $fish_complete_path[1] $pkgs_path/*/completions $fish_complete_path[2..-1]
|
||||
set -x PATH $pkgs_path/*/bin $PATH
|
||||
set -x MANPATH $pkgs_path/*/man $MANPATH
|
||||
|
||||
# load package key bindings when needed
|
||||
if functions -q fish_user_key_bindings
|
||||
functions -c fish_user_key_bindings fish_user_key_bindings_copy
|
||||
end
|
||||
function fish_user_key_bindings
|
||||
for file in $pkgs_path/*/key_bindings.fish
|
||||
builtin source $file 2>&1 > /dev/null
|
||||
end
|
||||
if functions -q fish_user_key_bindings_copy
|
||||
fish_user_key_bindings_copy
|
||||
end
|
||||
end
|
||||
|
||||
# load custom config from packages
|
||||
for file in $pkgs_path/*/conf.d/*.fish $pkgs_path/*/init.fish
|
||||
builtin source $file 2> /dev/null
|
||||
end
|
||||
|
||||
# ensure that the prompt is loaded (doesn't autoload for some reason)
|
||||
if test -f $pkgs_path/.functions/fish_prompt.fish
|
||||
builtin source $pkgs_path/.functions/fish_prompt.fish 2> /dev/null
|
||||
end
|
||||
|
||||
# collect all functions on the top-level of packages into $pkgs_path/.functions
|
||||
# (run by Ansible after packages have been updated)
|
||||
function _pkgs_collect_functions
|
||||
# clear the functions directory as we rebuild it from scratch
|
||||
if test -d $pkgs_path/.functions
|
||||
command rm -rf $pkgs_path/.functions
|
||||
end
|
||||
command mkdir -p $pkgs_path/.functions
|
||||
|
||||
# consider all fish files in the top-level of each package
|
||||
for src in $pkgs_path/*/*.fish
|
||||
set -l package (command basename (command dirname $src))
|
||||
set -l filename (command basename $src)
|
||||
|
||||
# we don't care about uninstall.fish;
|
||||
# init.fish and key_bindings.fish are dynamically handled on runtime above
|
||||
if not contains $filename {init,key_bindings,uninstall}.fish
|
||||
# create a relative symlink
|
||||
command ln -sf ../$package/$filename $pkgs_path/.functions/$filename
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,46 @@
|
||||
# Environment variables
|
||||
# ---------------------
|
||||
|
||||
set -x PATH $HOME/bin \
|
||||
$HOME/.composer/vendor/bin \
|
||||
$HOME/.local/bin \
|
||||
$HOME/.linuxbrew/bin \
|
||||
$PATH
|
||||
|
||||
set -x MANPATH $HOME/.linuxbrew/share/man \
|
||||
$MANPATH
|
||||
|
||||
# language
|
||||
set -x LANG de_DE.UTF-8
|
||||
|
||||
# editor
|
||||
set -x VISUAL "$HOME/.config/fish/pkgs/rmate/rmate -p 64364 -w" # Visual Studio Code (wait mode)
|
||||
set -x EDITOR 'nano -w' # nano as fallback editor
|
||||
|
||||
set -x XDG_CONFIG_HOME $HOME/.config
|
||||
|
||||
# Aliases
|
||||
# -------
|
||||
|
||||
# Edit file remotely with VS Code
|
||||
alias code="$HOME/.config/fish/pkgs/rmate/rmate -p 64364"
|
||||
|
||||
# Short ls command
|
||||
alias l='ls -la'
|
||||
|
||||
# General Settings
|
||||
# ----------------
|
||||
|
||||
# enforce 24-bit color mode
|
||||
# (the requried env var is not transmitted via SSH)
|
||||
set -x COLORTERM truecolor
|
||||
set -g fish_term24bit 1
|
||||
|
||||
# settings for the bobthefish theme
|
||||
set -g fish_prompt_pwd_dir_length 0
|
||||
set -g theme_color_scheme solarized-dark
|
||||
set -g theme_date_format '+%a %d.%m.%y %H:%M:%S'
|
||||
set -g theme_display_git_master_branch yes
|
||||
set -g theme_show_exit_status yes
|
||||
set -g theme_title_use_abbreviated_path no
|
||||
set -x VIRTUAL_ENV_DISABLE_PROMPT 1
|
||||
@@ -0,0 +1,3 @@
|
||||
function fish_greeting
|
||||
welcome
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
###
|
||||
# Looks up the IPv4 address of the given hostname and tries to find the reverse record of that IP
|
||||
#
|
||||
# Globals:
|
||||
# None
|
||||
# Arguments:
|
||||
# $domain string Hostname to look up
|
||||
# Returns:
|
||||
# None
|
||||
###
|
||||
function nsreverse
|
||||
# lookup IP
|
||||
set ip (dig "$argv[1]" A +short); or return 1
|
||||
|
||||
# lookup reverse record
|
||||
set reverse (dig -x "$ip" +short); or return 1
|
||||
|
||||
# output
|
||||
echo -e "\033[1mIPv4: \033[0;34m $ip\033[0m"
|
||||
echo -e "\033[1mReverse lookup:\033[0;34m $reverse\033[0m"
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
###
|
||||
# Looks up the IPv6 address of the given hostname and tries to find the reverse record of that IP
|
||||
#
|
||||
# Globals:
|
||||
# None
|
||||
# Arguments:
|
||||
# $domain string Hostname to look up
|
||||
# Returns:
|
||||
# None
|
||||
###
|
||||
function nsreverse6
|
||||
# lookup IP
|
||||
set ip (dig "$argv[1]" AAAA +short); or return 1
|
||||
|
||||
# lookup reverse record
|
||||
set reverse (dig -x "$ip" +short); or return 1
|
||||
|
||||
# output
|
||||
echo -e "\033[1mIPv6: \033[0;34m $ip\033[0m"
|
||||
echo -e "\033[1mReverse lookup:\033[0;34m $reverse\033[0m"
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
function dateSummarizer() {
|
||||
echo -n "\033[34m"
|
||||
date
|
||||
}
|
||||
|
||||
registerSummarizer "Date" dateSummarizer
|
||||
@@ -0,0 +1,111 @@
|
||||
function uptimeSummarizer() {
|
||||
# Get the uptime in seconds depending on the kernel
|
||||
if [[ "$(uname -s)" == 'Darwin' ]]; then
|
||||
# OS X
|
||||
# kern.boottime is an absolute timestamp
|
||||
bootTime="$(sysctl -n kern.boottime | awk '{print $4}' | sed 's/,//g')"
|
||||
currentTime="$(date +%s)"
|
||||
uptime="$(($currentTime - $bootTime))"
|
||||
elif [[ -f /proc/uptime ]]; then
|
||||
# Linux
|
||||
uptime="$(cat /proc/uptime)"
|
||||
uptime="${uptime%%.*}"
|
||||
else
|
||||
# We don't have a handler for that
|
||||
# If you need one, please create an issue at
|
||||
# https://github.com/lukasbestle/my-welcome/issues
|
||||
echo "\033[31mUnsupported environment, can't get uptime. :(\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Parse into units
|
||||
seconds="$((uptime % 60))"
|
||||
minutes="$((uptime / 60 % 60))"
|
||||
hours="$(( uptime / 60 / 60 % 24))"
|
||||
days="$(( uptime / 60 / 60 / 24 % 30))"
|
||||
months="$(( uptime / 60 / 60 / 24 / 30 % 12))"
|
||||
years="$(( uptime / 60 / 60 / 24 / 30 / 12))"
|
||||
|
||||
# Output depending on the scale of the uptime
|
||||
if [[ years -ge 1 ]]; then
|
||||
outputYears=true
|
||||
outputMonths=true
|
||||
outputDays=true
|
||||
elif [[ months -ge 1 ]]; then
|
||||
outputMonths=true
|
||||
outputDays=true
|
||||
elif [[ days -ge 1 ]]; then
|
||||
outputDays=true
|
||||
outputHours=true
|
||||
outputMinutes=true
|
||||
elif [[ hours -ge 1 ]]; then
|
||||
outputHours=true
|
||||
outputMinutes=true
|
||||
elif [[ minutes -ge 1 ]]; then
|
||||
outputMinutes=true
|
||||
outputSeconds=true
|
||||
else
|
||||
outputSeconds=true
|
||||
fi
|
||||
|
||||
# Output each element
|
||||
output=''
|
||||
if [[ "$outputYears" == true ]]; then
|
||||
output+="\033[34m$years"
|
||||
if [[ "$years" == 1 ]]; then
|
||||
output+=' year\033[0m\n'
|
||||
else
|
||||
output+=' years\033[0m\n'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$outputMonths" == true ]]; then
|
||||
output+="\033[34m$months"
|
||||
if [[ "$months" == 1 ]]; then
|
||||
output+=' month\033[0m\n'
|
||||
else
|
||||
output+=' months\033[0m\n'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$outputDays" == true ]]; then
|
||||
output+="\033[34m$days"
|
||||
if [[ "$days" == 1 ]]; then
|
||||
output+=' day\033[0m\n'
|
||||
else
|
||||
output+=' days\033[0m\n'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$outputHours" == true ]]; then
|
||||
output+="\033[34m$hours"
|
||||
if [[ "$hours" == 1 ]]; then
|
||||
output+=' hour\033[0m\n'
|
||||
else
|
||||
output+=' hours\033[0m\n'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$outputMinutes" == true ]]; then
|
||||
output+="\033[34m$minutes"
|
||||
if [[ "$minutes" == 1 ]]; then
|
||||
output+=' minute\033[0m\n'
|
||||
else
|
||||
output+=' minutes\033[0m\n'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$outputSeconds" == true ]]; then
|
||||
output+="\033[34m$seconds"
|
||||
if [[ "$seconds" == 1 ]]; then
|
||||
output+=' second\033[0m\n'
|
||||
else
|
||||
output+=' seconds\033[0m\n'
|
||||
fi
|
||||
fi
|
||||
|
||||
# Replace newlines with a comma
|
||||
echo "Host up for $(echo -ne "$output" | paste -s -d ';' - | sed "s/\;/\, /g")"
|
||||
}
|
||||
|
||||
registerSummarizer "Uptime" uptimeSummarizer
|
||||
@@ -0,0 +1,12 @@
|
||||
function quotaSummarizer() {
|
||||
# Get current quota information in MB (integers) and % of total
|
||||
quota_used=$(quota -lgs | grep '/dev/' | sed 's/ \/dev\/[a-z]\+[0-9] \+\([0-9]\+\?\)M.*/\1/')
|
||||
quota_total=$(quota -lgs | grep '/dev/' | sed 's/ \/dev\/[a-z]\+[0-9] \+[0-9]\+\?M \+\([0-9]\+\?\)M.*/\1/')
|
||||
quota_free=$(( $quota_total - $quota_used ))
|
||||
quota_percentage=$(( $quota_used * 100 / $quota_total ))
|
||||
|
||||
echo "Used \033[34m$quota_used MB\033[0m of \033[34m$quota_total MB\033[0m (\033[34m$quota_percentage %\033[0m)"
|
||||
echo -n "\033[34m$quota_free MB\033[0m available"
|
||||
}
|
||||
|
||||
registerSummarizer "Quota" quotaSummarizer
|
||||
@@ -0,0 +1,8 @@
|
||||
function ramSummarizer() {
|
||||
# Get current RAM usage in MB (integer)
|
||||
ram_used=$(ps -u $USER -o rss= | awk '{rss += $1} END {printf("%0.f", rss / 1000)}')
|
||||
|
||||
echo -n "Used \033[34m$ram_used MB\033[0m"
|
||||
}
|
||||
|
||||
registerSummarizer "RAM" ramSummarizer
|
||||
@@ -0,0 +1,46 @@
|
||||
---
|
||||
- name: Set authorized SSH keys
|
||||
authorized_key:
|
||||
user: "{{ ansible_facts.user_id }}"
|
||||
state: present
|
||||
key: "{{ item }}"
|
||||
with_file: authorized_keys
|
||||
|
||||
- name: Copy dotfiles to home directory
|
||||
copy:
|
||||
src: dotfiles/
|
||||
dest: "{{ ansible_facts.env.HOME }}/"
|
||||
mode: preserve
|
||||
|
||||
- name: Copy Git config to home directory
|
||||
template:
|
||||
src: gitconfig.j2
|
||||
dest: "{{ ansible_facts.env.HOME }}/.config/git/config"
|
||||
|
||||
- name: Remove unneeded files
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "{{ ansible_facts.env.HOME }}/.bash_history"
|
||||
- "{{ ansible_facts.env.HOME }}/.zcompdump"
|
||||
|
||||
- name: Disable cron MAILTO
|
||||
cronvar:
|
||||
name: MAILTO
|
||||
value: ""
|
||||
|
||||
- name: Set up host-specific cronjobs
|
||||
cron: "{{ item }}"
|
||||
loop: "{{ cronjobs.get(ansible_facts.user_id, []) }}"
|
||||
|
||||
- name: Add host domain to Uberspace config
|
||||
import_role:
|
||||
name: snapstromegon.uberspace_web_domain
|
||||
vars:
|
||||
domain: kodos-{{ ansible_facts.user_id }}.codesignd.net
|
||||
|
||||
- name: Set up host site
|
||||
template:
|
||||
src: index.html.j2
|
||||
dest: /var/www/virtual/{{ ansible_facts.user_id }}/html/index.html
|
||||
@@ -0,0 +1,20 @@
|
||||
; user settings
|
||||
[user]
|
||||
name = kodos-{{ ansible_facts.user_id }}.codesignd.net
|
||||
email = hostmaster@codesignd.net
|
||||
|
||||
; core settings
|
||||
[advice]
|
||||
detachedHead = false
|
||||
[branch]
|
||||
autoSetupRebase = always
|
||||
[core]
|
||||
editor = code -w
|
||||
quotepath = false
|
||||
commitGraph = true
|
||||
[help]
|
||||
autocorrect = 10
|
||||
[push]
|
||||
default = upstream
|
||||
[gc]
|
||||
writeCommitGraph = true
|
||||
@@ -0,0 +1,127 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>kodos-{{ ansible_facts.user_id }}.codesignd.net</title>
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
|
||||
<style>
|
||||
/* Reset */
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
*, *::before, *::after {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
box-sizing: inherit;
|
||||
|
||||
text-decoration: none;
|
||||
list-style: none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Container styling */
|
||||
html {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
min-height: 100vh;
|
||||
|
||||
background: #efefef;
|
||||
}
|
||||
|
||||
body {
|
||||
min-width: 20rem;
|
||||
|
||||
background: #fff;
|
||||
box-shadow: 0 0 10px #ddd;
|
||||
}
|
||||
|
||||
@media (max-width: 25rem) {
|
||||
html {
|
||||
align-items: start;
|
||||
|
||||
background: initial;
|
||||
}
|
||||
|
||||
body {
|
||||
min-width: initial;
|
||||
width: 100%;
|
||||
padding-top: 1rem;
|
||||
|
||||
box-shadow: initial;
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
footer {
|
||||
border-top: 2px dotted #efefef;
|
||||
padding: 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* General Typography */
|
||||
:root {
|
||||
font-family: system-ui, sans-serif;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1 span {
|
||||
font-size: 1.8rem;
|
||||
|
||||
display: block;
|
||||
}
|
||||
|
||||
svg {
|
||||
width: 8rem;
|
||||
height: 8rem;
|
||||
|
||||
display: block;
|
||||
margin: 0 auto 1rem;
|
||||
}
|
||||
|
||||
.cog {
|
||||
animation: rotate 30s linear infinite;
|
||||
transform-origin: 50% 50%;
|
||||
}
|
||||
@keyframes rotate {
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
a {
|
||||
color: #ed8f1b;
|
||||
}
|
||||
footer a:not(:last-child) {
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<svg viewBox="0 0 1000 1000" xmlns="http://www.w3.org/2000/svg"><g fill="none"><path class="cog" d="M475.28 853.557L408.45 999.43a503.966 503.966 0 0 1-78.883-21.084l15.057-159.725a354.034 354.034 0 0 1-42.828-24.777l-130.73 92.853a510.782 510.782 0 0 1-57.761-57.762l92.853-130.729a354.034 354.034 0 0 1-24.777-42.828L21.655 670.434A503.967 503.967 0 0 1 .57 591.55l145.872-66.831a359.603 359.603 0 0 1-.85-24.72c0-8.31.287-16.553.85-24.72L.57 408.45a503.966 503.966 0 0 1 21.084-78.883l159.725 15.057a354.034 354.034 0 0 1 24.777-42.828l-92.853-130.73a510.782 510.782 0 0 1 57.762-57.761l130.729 92.853a354.034 354.034 0 0 1 42.828-24.777L329.566 21.655A503.967 503.967 0 0 1 408.45.57l66.831 145.872a359.404 359.404 0 0 1 49.44 0L591.55.57a503.966 503.966 0 0 1 78.883 21.084L655.377 181.38a354.034 354.034 0 0 1 42.828 24.777l130.73-92.853a510.782 510.782 0 0 1 57.761 57.762l-92.853 130.729a354.034 354.034 0 0 1 24.777 42.828l159.725-15.057a503.967 503.967 0 0 1 21.084 78.883L853.557 475.28a359.404 359.404 0 0 1 0 49.44l145.873 66.83a503.966 503.966 0 0 1-21.084 78.883L818.62 655.377a354.034 354.034 0 0 1-24.777 42.828l92.853 130.73a510.782 510.782 0 0 1-57.762 57.761l-130.729-92.853a354.034 354.034 0 0 1-42.828 24.777l15.057 159.725a503.967 503.967 0 0 1-78.883 21.084L524.72 853.557a359.404 359.404 0 0 1-49.44 0zM787.356 500c0-158.703-128.653-287.356-287.356-287.356S212.644 341.297 212.644 500 341.297 787.356 500 787.356 787.356 658.703 787.356 500z" fill="#F4B971"/><path stroke="#0BB888" stroke-width="57.471" d="M500 346.743l132.724 76.629v153.256L500 653.257l-132.724-76.629V423.372z"/><circle stroke="#ED8F1B" stroke-width="118.774" cx="500.001" cy="500" r="318.008"/></g></svg>
|
||||
<h1><span>kodos-{{ ansible_facts.user_id }}</span>.codesignd.net</h1>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<a href="https://codesignd.com/contact">Contact</a>
|
||||
<a href="https://codesignd.com/legal">Imprint</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user