From a2a2de5d7263823608a58b84c2ed60cdc18dcf1b Mon Sep 17 00:00:00 2001 From: Christoph Date: Sat, 15 Jan 2022 20:25:07 +0100 Subject: [PATCH 1/5] Replace ssh keys for 'wadmin'. --- .../user_templates/wadmin/.ssh/authorized_keys | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/supported-files/user_templates/wadmin/.ssh/authorized_keys b/supported-files/user_templates/wadmin/.ssh/authorized_keys index c50eeb5..8f382a1 100644 --- a/supported-files/user_templates/wadmin/.ssh/authorized_keys +++ b/supported-files/user_templates/wadmin/.ssh/authorized_keys @@ -1,7 +1,6 @@ ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO90culn3sicU2chTHn40ytcTay0nUIHap0uF/5fVM6P chris@sol ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOQHMUKlDh2ufno5pZOhUY5xFljC1R5zQ/GjOHDkS58D root@sol -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCqy6ddUTgh5gbIBbu6WkO5Rm6wje1N+fEOmdNzBlfzpGngj0+94ONpR/dZyIECGFexz5ofizo8XdlGKMR97e9PLXrQXQ6CFO8+vFAwMx8Cs/T0Rx8B5tNl7UWiQ5bDmXPFForuDw7hJetWC5p0yK6+FHqhLDuYQ7qu/fQWneCiZDePmaLtxOaME6AAGJqwn+cqaRvfs0ZN1XRSH4KMk/S8re/+8txOB+uUIeTUkhz5LICcbeTdAWZdnGiNqudmKDGTOV4PZOmxqjtwK+aofqE/ua+x+08C58+Am0yClT0WFup/UmChnf50URApvnXwiJOmW3g+7k5tPRmEMnNglovksTurbKpKdTMVaTfwbVUe03//+/bI92PTH3fSIlmDpXAiolZ22WiGro6LVrx0e9E8a9b4MWOSYLUm19r7pL1gGagBNZcRssp2/9b2T/13SQ8qcFSpA1+B2C8jYgPUW2pxck5S+AK8KZ+nBDWmb44B8xecsmgu61jUTwLMsgjKck85IsVXlYWjHmfros9ni5Hj/0x+poqXB+g5Plww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v9EXRpyuy++daC6nKMtWSmLdSVVb5aaUzkloNiwbi+kz0xKjAIs3407VKuaGXLvi0xk5DO64QC34ZWYi2BvkWqEbmxK9yfCRKuP8zkeQO3kZKb2g3DzkXmZZKC0ueuUMvLjevrPAV4KVEwYTBwQgXMQIwP2omKQ/X1LJRJ6prq6DjOGBPddCOeCf+bJgmrk6t+ZmMpSGaUjt7TInyaVrs4vki9jBXJtk8YFNcOE5UVHB8RwjO3W7LG5S1IWg7Aj31OgxLXakr8tFJfCyK36nhRtxqFN62++0iXc0GVPLq8vRZN43QfoNwKGyQBCZVLC67XZ4gBDiZ0nHzqpBjnnO5zGhmv8hYIoGBSPpc433rliK2G8RGLzuQBo+gAmvNyNc9AfD2+v0Ucj7Y1w5uiH/N1IpKz9FQlL4+XGO59vRtrdYUdflTnlBiSF5vh4aL5P3kJPhUtupJ9/Qme6SAfvifwh1zH037wzo1zL+px6b6nLkUemD8gChCqOddJWwqjAbo5ILXJlUbhoIwtDM8ZYo28+/geEkEuD6CJLixqeLs1MgBidwX6W/RrTYU615gGXppcGFomOw== wadmin@ga-st-lsx1 +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIF5GDIFA6/i6lzkr+EP/EZM9glrK0eSR0nmrEFgUJ4n8 wadmin@ga-st-lsx1 +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID17MN6fUg0D1dMSgVYIBpIy+sDBBmiaHmXRXU63TXJA wadmin@ga-st-li1303 +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKtK8/rxHL1MKX5AHrgAzUYu0kV+1iYCmknpTQ7F0ham wadmin@wolf-debtest +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIcaDFxj0pYjOv/ohFVxVY2RKvy6ACZFPX9UkrUPHkbN wadmin@wolf-x1 From 15eb3e872be25f34bf2c80b8e7120c6a1efc0fe3 Mon Sep 17 00:00:00 2001 From: Christoph Date: Sat, 11 Jun 2022 02:20:34 +0200 Subject: [PATCH 2/5] reboot-LXC-host.sh: a really minor change on script output. --- reboot-LXC-host.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reboot-LXC-host.sh b/reboot-LXC-host.sh index cf10557..222fc79 100755 --- a/reboot-LXC-host.sh +++ b/reboot-LXC-host.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#/usr/bin/env bash script_name="$(basename $(realpath $0))" working_dir="$(dirname $(realpath $0))" @@ -204,7 +204,7 @@ else terminal=false fi -which lxc-ls || fatal "Seems not to be a LX Host. Missing command \033[33mlxc-ls" +[[ -n "$(which lxc-ls)" ]] || fatal "Seems not to be a LX Host. Missing command \033[33mlxc-ls" From b7f543721a2fdc72f0599f14bcb96cab5930f820 Mon Sep 17 00:00:00 2001 From: Christoph Date: Thu, 16 Jun 2022 12:47:08 +0200 Subject: [PATCH 3/5] add_new_user.sh: add user erik. --- add_new_user.sh | 6 ++++++ supported-files/user_templates/erik/.ssh/authorized_keys | 5 +++++ 2 files changed, 11 insertions(+) create mode 100644 supported-files/user_templates/erik/.ssh/authorized_keys diff --git a/add_new_user.sh b/add_new_user.sh index 7ef5aa8..93663f9 100755 --- a/add_new_user.sh +++ b/add_new_user.sh @@ -23,6 +23,7 @@ sudo_users=" sysadm localadmin chris + erik wadmin ilker ckubu @@ -261,6 +262,11 @@ if $password_needed ; then elif [[ "$user_name" = 'ilker' ]]; then perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$6\\\$6PRR6JwU\\\$RBsPa/W.ThyGVJVFls9Uxf6GZYyjCeJfNtGbgNosC/jlkCHWCZBWWxL/nwxaJBEKIB1f8f3YBIbm13.see7u3.:\2#" /etc/shadow + # - erik + # - + elif [[ "$user_name" = 'erik' ]]; then + perl -i -n -p -e "s#^(${user_name}):[^:]+:(.+)#\1:\\\$6\\\$GntX81EP\\\$O1GEmQF.BbOQfTMMw/m/BDKSXmANVpqmz0nyzw4O4R2/iK9huGOAjT/2eq8FVdMghvNOvdwrWtwohO.Mg4V9n.:\2#" /etc/shadow + # - c3po # - elif [[ "$user_name" = 'c3po' ]]; then diff --git a/supported-files/user_templates/erik/.ssh/authorized_keys b/supported-files/user_templates/erik/.ssh/authorized_keys new file mode 100644 index 0000000..a009725 --- /dev/null +++ b/supported-files/user_templates/erik/.ssh/authorized_keys @@ -0,0 +1,5 @@ +ssh-dss AAAAB3NzaC1kc3MAAACBALn4mbLybmqFaEu6M+kZ7bKBmWP6izx0gJfIpv81zD5rv+QPgvNkqe2pJb49Uk2NJy7pjdSQHUPiVLHSVkJLD3cytExPh/R7jSpXWeChpf1jwmPgOaph8XvnqE8TxYiYEMvCty1Z3rxmaJV6KR1mti00yifcaKS0mYB62lB8Ws7bAAAAFQD8D2a6DSoGQcFVCTC1TkulQgyQEQAAAIBuY2g4xI3lIiiSS2ASER63ucZPH2LGuHUS3MoBMu37C1JxC4i7UuA7I4F685Yiqbs7ZXQAC32saAGvKVWQnOlHBG6nb2mxywcwa+YH+H+ZRy76kwLWF8bQ9VtMS67H3Ep+KV2smqDRGUoelXeq8Wv3AT5Cxd+65LUs9H0nOyxNoQAAAIEArmj7KfUjFKL73BrwEQCSrvXvMKInGd8NwJ/P7RsV9ef/nVApJJECRuiXqdvVLHmTfsqbZOvygN4jpBwn2l8mU8P6Iv319TWrI2rOqBLDUe82Y0bcB/7nqumHLe1LC2h0CKlhMY8XtNza0a8RpOFY9OlmcCkZpTA1zhn+mUtSTDo= erik@loki +ssh-dss AAAAB3NzaC1kc3MAAACBAKjNYbWMlUJ0yOG5pq0FuekLC2zj8sJAICUIQs4Y34LDBkRH4iT4NRHBuuXFig6Z8iLAEBiPdm0u5HF8gJE2i8z7VBvdAXSb2FxqQwhL5GLdvcY1oR/AB0gsmNngDlBiL7bxLzG+i0yf/qJUWzuQDkoxHfQRAh0JEp+FcqVd3HO9AAAAFQC3TIjvmFsBLcC5VKHQ+eTnzM9yAQAAAIBFbnV0H8Y+QrxRtEoOgZHiI0CF5WD9W82t9vc3P0Mg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hGII2jTfMzPOQfhx97QyrtGLjaVxKHybD98zLBAAAAFQCxtu0FGELooom0XD633uIe+xAueQAAAIAdNOVUFLKyMAXt2Sdg+LDvWF/rbCIQyCh5tPXo0eoKHvmQGjc0sTgxmBdY7kkON/TDoUGlFba9ysH1z2KBeiXgO2YQymGENAd6WYMWuk2YRmcKA7HkVHNaga0/ly5Rgi9+fShabDDDhGC5REI3VPbiZCJNLLLTU23P0GgIrNo5OwAAAIA0a3yZFt1VOSjVfQvCP73MXHC/o1zsz5NKaLYazNLpPqZctNmK465CMpC52Kv9niTRujz80oiD5A+K6yYAEES1+wFo625DU2L8duXTFMlSAqPuKuvsST1gok5rA2CUFkxD6AwEuuxACItRq908Rh3ReFZuT+nkhgCkTFGzwYIujg== erik.grziwotz@nokia.com +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP6c9lnTkXLAbhiPVy6Y+0r27YDi+XOUyTpFqFrh5NAI erik@erik From f74638c326186966d1b887df54778636698abaa6 Mon Sep 17 00:00:00 2001 From: Christoph Date: Fri, 17 Jun 2022 17:42:01 +0200 Subject: [PATCH 4/5] Add script 'check_mount_count.sh'. --- check_mount_count.sh | 307 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 307 insertions(+) create mode 100755 check_mount_count.sh diff --git a/check_mount_count.sh b/check_mount_count.sh new file mode 100755 index 0000000..0ad91cd --- /dev/null +++ b/check_mount_count.sh @@ -0,0 +1,307 @@ +#!/usr/bin/env bash + +script_name="$(basename $(realpath $0))" +working_dir="$(dirname $(realpath $0))" +conf_file="${working_dir}/conf/${script_name%%.*}.conf" + +LOCK_DIR="/tmp/${script_name%%.*}.LOCK" + +log_file="${LOCK_DIR}/${script_name%%.*}.log" + +#--------------------------------------- +#----------------------------- +# Base Function(s) +#----------------------------- +#--------------------------------------- + +usage() { + + + [[ -n "$1" ]] && error "$1" + + + [[ $terminal ]] && echo -e " +\033[1mUsage:\033[m + + $(basename $0) + +\033[1mDescription\033[m + + Script checks if 'Mount count' of a given partition exceed 'Maximum mount count' of + that partition. If 'Mount count' is greater as 'Maximum mount count', a warning is + printed out. + +\033[1mOptions\033[m + + No Options available + +\033[1mExample:\033[m + + Check mount count of partition /dev/mapper/backup + + $(basename $0) /dev/mapper/backup + +" + + clean_up 1 +} + + +clean_up() { + + # Perform program exit housekeeping + rm -rf "$LOCK_DIR" + blank_line + exit $1 +} + +echononl(){ + if $terminal && $LOGGING ; then + echo X\\c > /tmp/shprompt$$ + if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then + echo -e -n " $*\\c" 1>&2 + else + echo -e -n " $*" 1>&2 + fi + rm /tmp/shprompt$$ + fi +} + + +fatal(){ + echo "" + if $terminal ; then + echo -e " [ \033[31m\033[1mFatal\033[m ] $*" + else + echo -e " [ Fatal ] $*" + fi + echo "" + if $terminal ; then + echo -e " \033[1mScript terminated\033[m.." + else + echo -e " Script terminated.." + fi + clean_up 1 +} + +error (){ + echo "" + if $terminal ; then + echo -e " [ \033[31m\033[1mError\033[m ] $*" + else + echo " [ Error ] $*" + fi + echo "" +} + +warn (){ + echo "" + if $terminal ; then + echo -e " [ \033[33m\033[1mWarn\033[m ] $*" + else + echo " [ Warn ] $*" + fi + echo "" +} + +info (){ + if $LOGGING || $terminal ; then + echo "" + if $terminal ; then + echo -e " [ \033[32m\033[1mInfo\033[m ] $*" + else + echo " [ Info ] $*" + fi + echo "" + fi +} + +echo_ok() { + if $terminal && $LOGGING ; then + echo -e "\033[75G[ \033[32mok\033[m ]" + else + if $LOGGING ; then + echo " [ ok ]" + fi + fi +} +echo_failed(){ + if $terminal && $LOGGING ; then + echo -e "\033[75G[ \033[1;31mfailed\033[m ]" + else + if $LOGGING ; then + echo " [ failed ]" + fi + fi +} +echo_skipped() { + if $terminal && $LOGGING ; then + echo -e "\033[75G[ \033[33m\033[1mskipped\033[m ]" + else + if $LOGGING ; then + echo " [ skipped ]" + fi + fi +} +echo_warning() { + if $terminal && $LOGGING ; then + echo -e "\033[75G[ \033[33m\033[1mwarning\033[m ]" + else + if $LOGGING ; then + echo " [ skipped ]" + fi + fi +} + + +is_number() { + + return $(test ! -z "${1##*[!0-9]*}" > /dev/null 2>&1); + + # - also possible + # - + #[[ ! -z "${1##*[!0-9]*}" ]] && return 0 || return 1 + #return $([[ ! -z "${1##*[!0-9]*}" ]]) +} + +blank_line() { + if $terminal ; then + echo "" + fi +} + +trim() { + local var="$*" + var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters + var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters + echo -n "$var" +} + + +# ---------- +# - Jobhandling +# ---------- + +# - If job already runs, stop execution.. +# - +if mkdir "$LOCK_DIR" 2> /dev/null ; then + + ## - Remove lockdir when the script finishes, or when it receives a signal + trap "clean_up 1" SIGHUP SIGINT SIGTERM + +else + + datum="$(date +"%d.%m.%Y %H:%M")" + + msg="[ Error ]: A previos instance of \"`basename $0`\" seems already be running.\n\n Exiting now.." + + echo "" + echo "[ Error ]: A previos instance of that script \"`basename $0`\" seems already be running." + echo "" + echo -e " Exiting now.." + echo "" + + for _email in ${alert_email_arr[@]} ; do + echo -e "To:${_email}\n${content_type}\nSubject:Error cronjob `basename $0` -- $datum\n${msg}\n" \ + | sendmail -F "Error `hostname -f`" -f $sender_address $_email + done + + exit 1 + +fi + + + + +#--------------------------------------- +#----------------------------- +# Check some prerequisites +#----------------------------- +#--------------------------------------- + +# - Running in a terminal? +# - +if [[ -t 1 ]] ; then + terminal=true + LOGGING=true +else + terminal=false + LOGGING=false +fi + +if [[ -n "$1" ]] ; then + part_name=$1 +else + error "No Partition given!" + usage +fi + + +#--------------------------------------- +#----------------------------- +# Check mount count. +#----------------------------- +#--------------------------------------- + +if $LOGGING ; then + declare -i _length="${#part_name}" + echo -e "\n Check mount count of partition $part_name.." + echo -en " =================================" + declare -i i=0 + while [[ $i -lt $_length ]] ; do + echo -n "=" + ((i++)) + done + echo "" +fi + + +blank_line +echononl "Determin actual mount count of partitin $part_name .." +declare -i mount_count=$(tune2fs -l $part_name | grep "Mount count" | cut -d ":" -f 2) +if [[ $? -ne 0 ]]; then + echo_failed + fatal "Cannot determin mount count of partitin ${part_name}!" +else + if $(is_number $mount_count) ; then + echo_ok + else + echo_failed + fatal "Cannot determin mount count of partitin ${part_name}!" + fi +fi + +echononl "Determin maximal mount count of partitin $part_name .." +declare -i max_mount_count=$(tune2fs -l $part_name | grep "Maximum mount count" | cut -d ":" -f 2) +if [[ $? -ne 0 ]]; then + echo_failed + fatal "Cannot determin maximal mount count of partitin ${part_name}!" +else + if $(is_number $max_mount_count) ; then + if [[ $max_mount_count -lt 2 ]] ; then + echo_warning + fatal "Maximal mount count of partitin ${part_name} is set incorrect (value: $max_mount_count)!" + else + echo_ok + fi + else + if [[ $max_mount_count -eq -1 ]] ; then + echo_warning + fatal "Maximal mount count of partitin ${part_name} not set (actual value: $max_mount_count)!" + else + echo_failed + fatal "Cannot determin maximl mount count of partitin ${part_name}!" + fi + fi +fi + +blank_line +if [[ $mount_count -gt max_mount_count ]] ; then + warn "Mount count (${mount_count}) of partition ${part_name} exceeds Maximal mount count (${max_mount_count})" +else + info "Mount count (${mount_count}) of partition ${part_name} is less than Maximal mount count (${max_mount_count}) + + \033[1mAll is fine.\033[m" +fi + +clean_up 0 From 4bbc428cee38f84d24ef44bfeb8bad593d063f47 Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 22 Jun 2022 15:59:43 +0200 Subject: [PATCH 5/5] add_new_user.sh: add xmatti to sudo users. --- add_new_user.sh | 1 + .../user_templates/xmatti/.bash_logout | 7 + supported-files/user_templates/xmatti/.bashrc | 124 +++++++++++++ .../user_templates/xmatti/.profile | 31 ++++ .../xmatti/.ssh/authorized_keys | 2 + supported-files/user_templates/xmatti/.vimrc | 173 ++++++++++++++++++ 6 files changed, 338 insertions(+) create mode 100644 supported-files/user_templates/xmatti/.bash_logout create mode 100644 supported-files/user_templates/xmatti/.bashrc create mode 100644 supported-files/user_templates/xmatti/.profile create mode 100644 supported-files/user_templates/xmatti/.ssh/authorized_keys create mode 100644 supported-files/user_templates/xmatti/.vimrc diff --git a/add_new_user.sh b/add_new_user.sh index 7ef5aa8..e1b55da 100755 --- a/add_new_user.sh +++ b/add_new_user.sh @@ -31,6 +31,7 @@ sudo_users=" defa init marcus + xmatti " diff --git a/supported-files/user_templates/xmatti/.bash_logout b/supported-files/user_templates/xmatti/.bash_logout new file mode 100644 index 0000000..de4f5f7 --- /dev/null +++ b/supported-files/user_templates/xmatti/.bash_logout @@ -0,0 +1,7 @@ +# ~/.bash_logout: executed by bash(1) when login shell exits. + +# when leaving the console clear the screen to increase privacy + +if [ "$SHLVL" = 1 ]; then + [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q +fi diff --git a/supported-files/user_templates/xmatti/.bashrc b/supported-files/user_templates/xmatti/.bashrc new file mode 100644 index 0000000..080da51 --- /dev/null +++ b/supported-files/user_templates/xmatti/.bashrc @@ -0,0 +1,124 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi +__hostname="$(hostname -f)" +__hostname="${__hostname%.*}" +__hostname="${__hostname%.*}" +if [ "$color_prompt" = yes ]; then + #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@${__hostname}:\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + #PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' + PS1='${debian_chroot:+($debian_chroot)}\u@${__hostname}:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + #alias grep='grep --color=auto' + #alias fgrep='fgrep --color=auto' + #alias egrep='egrep --color=auto' +fi + +# some more ls aliases +alias ll='ls -l' +alias la='ls -A' +alias l='ls -CF' + +alias ..='cd ..' +alias ...='cd ../..' +alias ....='cd ../../..' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi + +export EDITOR=vim + +## - set beep more quiet +## - +#xset b 10 500 50 diff --git a/supported-files/user_templates/xmatti/.profile b/supported-files/user_templates/xmatti/.profile new file mode 100644 index 0000000..552cd39 --- /dev/null +++ b/supported-files/user_templates/xmatti/.profile @@ -0,0 +1,31 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# this is for the midnight-commander +# to become the last directory the midnight commander was in +# as the current directory when leaving the midnight commander +# +#. /usr/lib/mc/bin/mc.sh +if [ -f "/usr/share/mc/bin/mc.sh" ]; then + source /usr/share/mc/bin/mc.sh +fi diff --git a/supported-files/user_templates/xmatti/.ssh/authorized_keys b/supported-files/user_templates/xmatti/.ssh/authorized_keys new file mode 100644 index 0000000..47f4021 --- /dev/null +++ b/supported-files/user_templates/xmatti/.ssh/authorized_keys @@ -0,0 +1,2 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO90culn3sicU2chTHn40ytcTay0nUIHap0uF/5fVM6P chris@sol +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCZAWX2xF4msYC3Q8S2RopJW329LNaXSIClfh9Fuog5izi9hwQYZrACVQgWxU3OHn3o43DBvJORG0TMR5CDslFbtPc2uw8PupHNGYDT+F8zvYdLxm5lERIr44s8ymYk9/YVvDlbCHcIqaluMxBKBR/0lKWTCFhTM1lv4DPcn2Wdv9qgN8orrWbV0ADIk5lqZPmiSZwUYJ7FiJdGK43+Ps9luEsaPkF2bTiN5qp+TS1t2wFVws8RbkdAxfctRUv8VPFB78rxyp13m6N0czSiO+AHBOWQO3lVoumKDZmO4OS69fo6kEVvRJHqDbNnx61WnicVQhscSJkiNZF7/wfd6TRhBQ2kivQ/hwVN9pmJ+sqIUNIQB94PqjxEq7gpFQObJNQxJVqx+vEWDBaWWPVwfMWYl95kKPDGMt1QIrSCyk30gtIyfw4fw3ge/MBVs9mSau5AaopCK1VgPnWfoIn8OZjEg3jBXOPSYNabUIsdbEUFwTpXsKWiEEgOI0c5bxzyJIu977jHx4d73IRHYTrNI/SBUTim0qaSmpJwBl3Vu+GyEw+Raxz8EBjw4A/9gtLKPPD+kxNV7Ybb4+qvbbi4Q/teFLFx16NzuUOAgc7OfMY2OLBQvSSGExPTRW8AJK4IA4kKyqa4BE914bD0VsVDjLKGxn621opgbElUe6bE+Rmtsw== xmatti@posteo.de diff --git a/supported-files/user_templates/xmatti/.vimrc b/supported-files/user_templates/xmatti/.vimrc new file mode 100644 index 0000000..0bf54d9 --- /dev/null +++ b/supported-files/user_templates/xmatti/.vimrc @@ -0,0 +1,173 @@ +" An example for a vimrc file. +" +" Maintainer: Bram Moolenaar +" Last change: 1999 Sep 09 +" +" To use it, copy it to +" for Unix and OS/2: ~/.vimrc +" for Amiga: s:.vimrc +" for MS-DOS and Win32: $VIM\_vimrc + +" This line should not be removed as it ensures that various options are +" properly set to work with the Vim-related packages available in Debian. +runtime! debian.vim + +set nocompatible " Use Vim defaults (much better!) +set bs=2 " allow backspacing over everything in insert mode +set ai " always set autoindenting on +" set backup " keep a backup file +"set viminfo='20,\"50 " read/write a .viminfo file, don't store more + " than 50 lines of registers +set viminfo='20,\"50,:20,%,n~/.viminfo +set history=50 " keep 50 lines of command line history +set ruler " show the cursor position all the time +set ignorecase " suchen case-insenitiv +set showmatch " zeige passende klammern +set shell=/bin/bash " shell to start with ! +set expandtab " tabs --> blanks +set showmode " anzeige INSERT/REPLACE/... + +" set smartcase " Do smart case matching + +set incsearch " Incremental search + " Start searching when you type the first character of + " the search string. As you type in more characters, the + " search is refined. + +set t_Co=256 " To enable 256 colors in vim, put this your .vimrc before setting the colorscheme + +" einrueckung +set shiftwidth=3 +set tabstop=3 +" Round indent to multiple of 'shiftwidth' for > and < commands +set shiftround + +" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries +" let &guioptions = substitute(&guioptions, "t", "", "g") + +" Don't use Ex mode, use Q for formatting +map Q gq + +" Make p in isual Visual mode replace the selected text with the "" register. +vnoremap p :let current_reg = @"gvdi=current_reg + +" Switch syntax highlighting on, when the terminal has colors +" Also switch on highlighting the last used search pattern. +if &t_Co > 2 || has("gui_running") + syntax on + set hlsearch +endif + +" Only do this part when compiled with support for autocommands. +if has("autocmd") + +" In text files, always limit the width of text to 78 characters + autocmd BufRead *.txt set tw=78 + + augroup cprog + " Remove all cprog autocommands + au! + + " When starting to edit a file: + " For C and C++ files set formatting of comments and set C-indenting on. + " For other files switch it off. + " Don't change the order, it's important that the line with * comes first. + autocmd FileType * set formatoptions=tcql nocindent comments& + autocmd FileType c,cpp set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,:// + augroup END + + augroup gzip + " Remove all gzip autocommands + au! + + " Enable editing of gzipped files + " set binary mode before reading the file + autocmd BufReadPre,FileReadPre *.gz,*.bz2 set bin + autocmd BufReadPost,FileReadPost *.gz call GZIP_read("gunzip") + autocmd BufReadPost,FileReadPost *.bz2 call GZIP_read("bunzip2") + autocmd BufWritePost,FileWritePost *.gz call GZIP_write("gzip") + autocmd BufWritePost,FileWritePost *.bz2 call GZIP_write("bzip2") + autocmd FileAppendPre *.gz call GZIP_appre("gunzip") + autocmd FileAppendPre *.bz2 call GZIP_appre("bunzip2") + autocmd FileAppendPost *.gz call GZIP_write("gzip") + autocmd FileAppendPost *.bz2 call GZIP_write("bzip2") + + " After reading compressed file: Uncompress text in buffer with "cmd" + fun! GZIP_read(cmd) + let ch_save = &ch + set ch=2 + execute "'[,']!" . a:cmd + set nobin + let &ch = ch_save + execute ":doautocmd BufReadPost " . expand("%:r") + endfun + + " After writing compressed file: Compress written file with "cmd" + fun! GZIP_write(cmd) + if rename(expand(""), expand(":r")) == 0 + execute "!" . a:cmd . " :r" + endif + endfun + + " Before appending to compressed file: Uncompress file with "cmd" + fun! GZIP_appre(cmd) + execute "!" . a:cmd . " " + call rename(expand(":r"), expand("")) + endfun + + augroup END + + " This is disabled, because it changes the jumplist. Can't use CTRL-O to go + " back to positions in previous files more than once. + if 0 + " When editing a file, always jump to the last cursor position. + " This must be after the uncompress commands. + autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$") | exe "normal `\"" | endif + endif + +endif " has("autocmd") + +" toggle syntax highlighting +map :if exists("syntax_on") syntax off else syntax on endif +map :nohls + +" use to toggle line numbers +nmap :set number! + + +" If using a dark background within the editing area and syntax highlighting +" turn on this option as well +set background=dark + + +" set color for search +hi clear search +hi search term=bold,reverse cterm=bold,reverse gui=bold,reverse + +" set color for Comment +hi clear Comment +"highlight Comment term=bold cterm=bold ctermfg=LightBlue guifg=#80a0ff gui=bold +"highlight Comment term=none cterm=none ctermfg=LightBlue guifg=#80a0ff gui=bold +"highlight Comment term=bold cterm=bold ctermfg=grey guifg=#80a0ff gui=bold +highlight Comment term=none cterm=none ctermfg=grey guifg=#80a0ff gui=bold +"highlight Comment term=none cterm=none ctermfg=177 guifg=#80a0ff gui=bold +"highlight Comment term=none cterm=none ctermfg=215 guifg=#80a0ff gui=bold + +" Go back to the position the cursor was on the last time this file was edited +au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")|execute("normal `\"")|endif + +" visual shifting (does not exit Visual mode) +vnoremap < >gv + +" Scroll when cursor gets within 3 characters of top/bottom edge +set scrolloff=3 + +" Show line, column number, and relative position within a file in the status line +" set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L] +"set statusline=\ %F\ %(\|\ flags:\ %R%M%H%W\ %)%(\|\ type:\ %Y\ %)%(\|\ format:\ %{&ff}\ %)%(\|\ syntax:\ %{synIDattr(synID(line('.'),col('.'),0),'name')}%)\ \ %=line:\ %l/%L\ \|\ column:\ %c%V\ \|\ relative\:\ %p%%\ +set statusline=\ %F\ %(\|\ flags:\ %R%M%H%W\ %)%(\|\ type:\ %Y\ %)%(\|\ format:\ %{&ff}\ %)\ \ %=line:\ %l/%L\ \|\ col:\ %c%V\ \|\ %p%% +" Always show status line, even for one window +set laststatus=2 +highlight StatusLine cterm=none ctermfg=white ctermbg=blue +