Add bash configuration files
This commit is contained in:
parent
1849cd96a2
commit
9fad99b12f
8
aliases.d/colors
Normal file
8
aliases.d/colors
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Colors
|
||||
alias ls='ls --color=auto'
|
||||
alias grep='grep --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
alias less='less -R'
|
4
aliases.d/fun
Normal file
4
aliases.d/fun
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Fun
|
||||
alias matrix='tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"'
|
8
aliases.d/generic
Normal file
8
aliases.d/generic
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Cd
|
||||
alias cdup='cd ..'
|
||||
|
||||
# Ls
|
||||
alias ll='ls -lh'
|
||||
alias lla='ls -lha'
|
17
aliases.d/git
Normal file
17
aliases.d/git
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Git
|
||||
if [ -x /usr/bin/git ]
|
||||
then
|
||||
alias gs='git status'
|
||||
alias ga='git add'
|
||||
alias gc='git commit'
|
||||
alias gca='git commit -a'
|
||||
alias gp='git push'
|
||||
alias gu='git pull'
|
||||
alias gd='git diff'
|
||||
alias gb='git branch'
|
||||
alias gco='git checkout'
|
||||
alias gw='git whatchanged'
|
||||
alias gl='git log --graph'
|
||||
fi
|
6
aliases.d/power
Normal file
6
aliases.d/power
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Power
|
||||
alias reboot='sudo reboot'
|
||||
alias halt='sudo halt'
|
||||
alias shutdown='sudo shutdown'
|
6
aliases.d/security
Normal file
6
aliases.d/security
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Security
|
||||
alias rm='rm -i'
|
||||
alias mv='mv -i'
|
||||
alias cp='cp -i'
|
4
aliases.d/ssh
Normal file
4
aliases.d/ssh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# SSH
|
||||
alias ssh!='ssh -q -oStrictHostKeyChecking=no -oIdentitiesOnly=yes'
|
5
aliases.d/system
Normal file
5
aliases.d/system
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# System tools
|
||||
if [ -f /sbin/ifconfig ] && [ -x /sbin/ifconfig ]; then alias ifconfig='/sbin/ifconfig'; fi
|
||||
if [ -f /sbin/ip ] && [ -x /sbin/ip ]; then alias ip='/sbin/ip'; fi
|
9
aliases.d/vim
Normal file
9
aliases.d/vim
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Vim Editor
|
||||
if [ -x /usr/bin/vim ]
|
||||
then
|
||||
alias vi='vim -p'
|
||||
alias view='vim -R'
|
||||
alias vless='vim -u /usr/share/vim/vim73/macros/less.vim'
|
||||
fi
|
2
bash_logout
Normal file
2
bash_logout
Normal file
@ -0,0 +1,2 @@
|
||||
# Clear the screen for security's sake.
|
||||
clear
|
14
bash_profile
Normal file
14
bash_profile
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -f $HOME/.bash/profile ]; then source $HOME/.bash/profile; fi
|
||||
if [ -d $HOME/.bash/profile ]; then for file in $(ls $HOME/.bash/profile/*); do source $file; done; fi
|
||||
if [ -d $HOME/.bash/profile.d ]; then for file in $(ls $HOME/.bash/profile.d/*); do source $file; done; fi
|
||||
|
||||
# This file is sourced by bash for login shells. The following line
|
||||
# runs your .bashrc and is recommended by the bash info pages.
|
||||
[[ -f ~/.bashrc ]] && . ~/.bashrc
|
||||
|
||||
if [ -d $HOME/.gem/ruby/1.9.1/bin ] ; then export PATH=$PATH:$HOME/.gem/ruby/1.9.1/bin ; fi
|
||||
|
||||
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
|
||||
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
|
65
bashrc
Normal file
65
bashrc
Normal file
@ -0,0 +1,65 @@
|
||||
# This file is sourced by all *interactive* bash shells on startup,
|
||||
# including some apparently interactive shells such as scp and rcp
|
||||
# that can't tolerate any output. So make sure this doesn't display
|
||||
# anything or bad things will happen !
|
||||
|
||||
# Test for an interactive shell. There is no need to set anything
|
||||
# past this point for scp and rcp, and it's important to refrain from
|
||||
# outputting anything in those cases.
|
||||
if [[ $- != *i* ]] ; then
|
||||
# Shell is non-interactive. Be done now!
|
||||
return
|
||||
fi
|
||||
|
||||
# Source custom libs
|
||||
if [ -d $HOME/.bash/libs ]; then for lib in $(ls $HOME/.bash/libs/*.bash); do source $lib; done; fi
|
||||
|
||||
# Source alias definitions
|
||||
if [ -f $HOME/.bash_aliases ]; then source $HOME/.bash_aliases; fi
|
||||
if [ -f $HOME/.bash/aliases ]; then source $HOME/.bash/aliases; fi
|
||||
if [ -d $HOME/.bash/aliases ]; then for file in $(ls $HOME/.bash/aliases/*); do source $file; done; fi
|
||||
if [ -d $HOME/.bash/aliases.d ]; then for file in $(ls $HOME/.bash/aliases.d/*); do source $file; done; fi
|
||||
|
||||
# Source bash completion definitions
|
||||
[[ -f /etc/bash-completion ]] && source /etc/bash-completion
|
||||
[[ -f /etc/profile.d/bash-completion ]] && source /etc/profile.d/bash-completion
|
||||
if [ -f $HOME/.bash_completion ]; then source $HOME/.bash_completion; fi
|
||||
if [ -f $HOME/.bash/completion ]; then source $HOME/.bash/completion; fi
|
||||
if [ -d $HOME/.bash/completion ]; then for file in $(ls $HOME/.bash/completion/*); do source $file; done; fi
|
||||
if [ -d $HOME/.bash/completion.d ]; then for file in $(ls $HOME/.bash/completion.d/*); do source $file; done; fi
|
||||
|
||||
# Customize the prompt
|
||||
if [ "$UID" -eq 0 ]; then
|
||||
export PS1='\[\e[01;31m\]\u@\h\[\e[01;34m\] \w \$\[\e[0m\] '
|
||||
else
|
||||
export PS1='\[\e[01;32m\]\u@\h\[\e[01;34m\] \w \$\[\e[0m\] '
|
||||
fi
|
||||
|
||||
smiley() {
|
||||
ret_val=$?
|
||||
if [ "$ret_val" = "0" ]
|
||||
then
|
||||
echo -e "\e[01;32m:)\e[0m"
|
||||
else
|
||||
echo -e "\e[01;31m:(\e[0m"
|
||||
fi
|
||||
}
|
||||
|
||||
#export PS1='\[\e[01;32m\]\u@\h\[\e[01;34m\] \w \$\[\e[0m\] '"\$(smiley) "
|
||||
|
||||
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489
|
||||
if [[ -f ~/.dir_colors ]]; then
|
||||
eval `dircolors -b ~/.dir_colors`
|
||||
elif [[ -f /etc/DIR_COLORS ]]; then
|
||||
eval `dircolors -b /etc/DIR_COLORS`
|
||||
fi
|
||||
|
||||
# Change the window title of X terminals
|
||||
case $TERM in
|
||||
xterm*|rxvt*|urxvt*|Eterm)
|
||||
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
|
||||
;;
|
||||
screen*)
|
||||
PROMPT_COMMAND='echo -ne "\033k${USER}@${HOSTNAME%%.*}\033\\"'
|
||||
;;
|
||||
esac
|
10
completion.d/ssh
Normal file
10
completion.d/ssh
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
#SSH
|
||||
if [ -e ~/.ssh/config ]; then
|
||||
complete -W "$(cat ~/.ssh/config | egrep -i "^\s*host\s+[a-zA-Z]" | sed -e "s/^host\s*//i")" ssh
|
||||
fi
|
||||
|
||||
if [ -e ~/.ssh/known_hosts ]; then
|
||||
complete -W "$(cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\[")" ssh
|
||||
fi
|
9
create-links.bash
Executable file
9
create-links.bash
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd $HOME || exit 1
|
||||
|
||||
CONFDIR=.bash
|
||||
|
||||
ln -sf $CONFDIR/bash_profile .bash_profile
|
||||
ln -sf $CONFDIR/bashrc .bashrc
|
||||
ln -sf $CONFDIR/bash_logout .bash_logout
|
5
libs/basedir.bash
Executable file
5
libs/basedir.bash
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
function basedir() {
|
||||
echo $( cd $(dirname $0) && pwd )
|
||||
}
|
16
libs/cgroups.bash
Executable file
16
libs/cgroups.bash
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Use cgroups
|
||||
if [ "$PS1" ] ; then
|
||||
if [ -d /sys/fs/cgroup ] ; then
|
||||
cdir=/sys/fs/cgroup
|
||||
elif [ -d /dev/cgroup ]; then
|
||||
cdir=/dev/cgroup
|
||||
fi
|
||||
if [ -z "$cdir" ]; then
|
||||
mkdir -p -m 0700 $cdir/user/$$ > /dev/null 2>&1
|
||||
/bin/echo $$ > $cdir/user/$$/tasks
|
||||
/bin/echo '1' > $cdir/user/$$/notify_on_release
|
||||
unset -v cdir
|
||||
fi
|
||||
fi
|
94
libs/colors.bash
Executable file
94
libs/colors.bash
Executable file
@ -0,0 +1,94 @@
|
||||
#!/bin/bash
|
||||
|
||||
#ANSI CODES
|
||||
#Code Effect
|
||||
#0 All attributes off
|
||||
#1 Bold
|
||||
#2 Faint
|
||||
#3 Italic
|
||||
#4 Underline
|
||||
#5 Blink
|
||||
#6 Rapid blink
|
||||
#7 Reverse video
|
||||
#8 Concealed
|
||||
#30 Black foreground
|
||||
#31 Red foreground
|
||||
#32 Green foreground
|
||||
#33 Yellow foreground
|
||||
#34 Blue foreground
|
||||
#35 Magenta foreground
|
||||
#36 Cyan foreground
|
||||
#37 White foreground
|
||||
#40 Black background
|
||||
#41 Red background
|
||||
#42 Green background
|
||||
#43 Yellow background
|
||||
#44 Blue background
|
||||
#45 Magenta background
|
||||
#46 Cyan background
|
||||
#47 White background
|
||||
#48 Subscript
|
||||
#49 Superscript
|
||||
|
||||
#T_ROWS=`tput lines` # Define current terminal dimension
|
||||
#T_COLS=`tput cols` #+ in rows and columns.
|
||||
#_UNDERLINE_ON=`tput smul` # turn on underline
|
||||
#_UNDERLINE_OFF=`tput rmul` # turn off underline
|
||||
#tput setf 4 # tput setf {fg color number}
|
||||
#tput setb 2 # tput setb {bg color number}
|
||||
|
||||
#tput bold - Bold effect
|
||||
#tput tsmi - Italic
|
||||
#tput rev - Display inverse colors
|
||||
#tput sgr0 - Reset everything
|
||||
|
||||
default='\E[39;49;00m'
|
||||
bold='\E[1m'
|
||||
italic='\E[3m'
|
||||
underline='\E[4m'
|
||||
blink='\E[5m'
|
||||
|
||||
blackonwhite='\E[30;47m'
|
||||
|
||||
#reset=`escape 0m`
|
||||
#black='\E[30;47m'
|
||||
#red='\E[31;47m'
|
||||
#green='\E[32;47m'
|
||||
#yellow='\E[33;47m'
|
||||
#blue='\E[34;47m'
|
||||
#magenta='\E[35;47m'
|
||||
#cyan='\E[36;47m'
|
||||
#white='\E[37;47m'
|
||||
#bold_on=`escape 1m`
|
||||
#bold_off=`escape 22m`
|
||||
#blink_on=`escape 5m`
|
||||
#blink_off=`escape 25m`
|
||||
|
||||
|
||||
function echo_reverse
|
||||
{
|
||||
echo -ne $blackonwhite
|
||||
echo -ne "$*"
|
||||
echo -e $default
|
||||
}
|
||||
|
||||
function echo_italic
|
||||
{
|
||||
echo -ne $italic
|
||||
echo -ne "$*"
|
||||
echo -e $default
|
||||
}
|
||||
|
||||
function echo_bold
|
||||
{
|
||||
echo -ne $bold
|
||||
echo -ne "$*"
|
||||
echo -e $default
|
||||
}
|
||||
|
||||
function echo_underline
|
||||
{
|
||||
echo -ne $underline
|
||||
echo -ne "$*"
|
||||
echo -e $default
|
||||
}
|
1
libs/grepp.bash
Executable file
1
libs/grepp.bash
Executable file
@ -0,0 +1 @@
|
||||
grepp() { x=$1; shift; perl -00ne ' print if /'"$x"'/i ' "$*" ; }
|
31
libs/ipplan.bash
Executable file
31
libs/ipplan.bash
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
function ipplan_search_by_ip()
|
||||
{
|
||||
echo "select inet_ntoa(ipaddr) as ip, location, hname, descrip, userinf from ipaddr where ipaddr = inet_aton('$1');" | ssh virt-cha-nettools mysql --database ipplan --default-character-set=latin1 --table
|
||||
}
|
||||
|
||||
function ipplan_search_by_location()
|
||||
{
|
||||
echo "select inet_ntoa(ipaddr) as ip, location, hname, descrip, userinf from ipaddr where location like '%$1%';" | ssh virt-cha-nettools mysql --database ipplan --default-character-set=latin1 --table
|
||||
}
|
||||
|
||||
function ipplan_search_by_name()
|
||||
{
|
||||
echo "select inet_ntoa(ipaddr) as ip, location, hname, descrip, userinf from ipaddr where hname like '%$1%';" | ssh virt-cha-nettools mysql --database ipplan --default-character-set=latin1 --table
|
||||
}
|
||||
|
||||
function ipplan_search_by_desc()
|
||||
{
|
||||
echo "select inet_ntoa(ipaddr) as ip, location, hname, descrip, userinf from ipaddr where descrip like '%$1%';" | ssh virt-cha-nettools mysql --database ipplan --default-character-set=latin1 --table
|
||||
}
|
||||
|
||||
function ipplan_search_by_user()
|
||||
{
|
||||
echo "select inet_ntoa(ipaddr) as ip, location, hname, descrip, userinf from ipaddr where userinf like '%$1%';" | ssh virt-cha-nettools mysql --database ipplan --default-character-set=latin1 --table
|
||||
}
|
||||
|
||||
function ipplan_list_ingesys()
|
||||
{
|
||||
echo "select inet_ntoa(ipaddr) as ip, location, hname, descrip, userinf from ipaddr where userinf like '%ing%sys%'; " | ssh virt-cha-nettools mysql --database ipplan --default-character-set=latin1 --table
|
||||
}
|
17
libs/password.bash
Executable file
17
libs/password.bash
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
encpasswd() {
|
||||
local password_clear=$1
|
||||
local password_md5hash=$(openssl passwd -1 $password_clear)
|
||||
echo "Password : $password_clear"
|
||||
echo "MD5HASH : $password_md5hash"
|
||||
}
|
||||
|
||||
genpasswd() {
|
||||
local l=$1
|
||||
[ "$l" == "" ] && l=12
|
||||
local password_clear=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs)
|
||||
local password_md5hash=$(openssl passwd -1 $password_clear)
|
||||
echo "Password : $password_clear"
|
||||
echo "MD5HASH : $password_md5hash"
|
||||
}
|
26
libs/screen.bash
Executable file
26
libs/screen.bash
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# GNU Screen stuff
|
||||
if ( which screen &> /dev/null )
|
||||
then
|
||||
if [[ $TERM != screen* ]]
|
||||
then
|
||||
if [ "$(screen -ls | sed -ne 's/[[:space:]]//' -ne 's/(Attached)// p')" ]
|
||||
then
|
||||
echo ''
|
||||
echo_reverse 'Il existe des sessions screen attachées sur cette machine pour cet utilisateur !'
|
||||
echo ''
|
||||
screen -ls | grep "Attached" | sed -e 's/^/ /'
|
||||
echo ''
|
||||
fi
|
||||
if [ "$(screen -ls | sed -ne 's/[[:space:]]//' -ne 's/(Detached)// p')" ]
|
||||
then
|
||||
echo ''
|
||||
echo_reverse "Il existe des sessions screen détachées sur cette machine pour cet utilisateur !"
|
||||
echo ''
|
||||
screen -ls | grep "Detached" | sed -e 's/^/ /'
|
||||
echo ''
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
17
libs/term.bash
Executable file
17
libs/term.bash
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
function term_change_title
|
||||
{
|
||||
case $TERM in
|
||||
# Change the window title of X terminals
|
||||
xterm*|rxvt*|urxvt*|Eterm)
|
||||
PROMPT_COMMAND='echo -ne "\033]0;${1}\007"'
|
||||
;;
|
||||
|
||||
# Change the window title of screen terminals
|
||||
screen*)
|
||||
PROMPT_COMMAND='echo -ne "\033k${1}\033\\"'
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
11
libs/urxvt.bash
Executable file
11
libs/urxvt.bash
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
function urxvt_set_font
|
||||
{
|
||||
printf '\33]50;%s\007' "xft:$1"
|
||||
}
|
||||
|
||||
function urxvt_set_title
|
||||
{
|
||||
# set window title
|
||||
printf '\33]2;%s\007' "$1"
|
||||
}
|
152
libs/virtualization.bash
Executable file
152
libs/virtualization.bash
Executable file
@ -0,0 +1,152 @@
|
||||
#!/bin/bash
|
||||
|
||||
hypervisor_connect() {
|
||||
|
||||
if [ -e "${1}" ]; then echo "Usage : $0 hypervisor_name_or_ip"; return 1; fi
|
||||
hypervisor=${1}
|
||||
|
||||
echo
|
||||
echo "Trying to start interactive virsh session on ${hypervisor}"
|
||||
virsh --connect=qemu+ssh://${USER}@${hypervisor}/system
|
||||
|
||||
}
|
||||
|
||||
hypervisor_command() {
|
||||
|
||||
if [ -e "${1}" ]; then echo "Usage : $0 hypervisor_name_or_ip"; return 1; fi
|
||||
hypervisor=${1}
|
||||
shift
|
||||
|
||||
echo
|
||||
echo "Trying to exec virsh command ($*) on ${hypervisor}"
|
||||
virsh --connect=qemu+ssh://${USER}@${hypervisor}/system "$*"
|
||||
|
||||
}
|
||||
|
||||
vm_create() {
|
||||
|
||||
if [ $# -ne 5 ]; then echo "Usage : $0 hypervisor_name_or_ip vm_name vm_ram_size vm_disk_size vm_mac"; return 1; fi
|
||||
hypervisor=${1}
|
||||
name=${2}
|
||||
ramsize=${3}
|
||||
disksize=${4}
|
||||
mac=${5}
|
||||
#mac=$( grep ${name} ~/repositories/fai/config-dhcp/dhcpd-hosts.conf | sed -e 's/^.*hardware.*ethernet\s*\([0-9a-zA-Z:]*\);.*$/\1/' )
|
||||
|
||||
echo "Creating VM with virt-install"
|
||||
virt-install --connect=qemu+ssh://${USER}@${hypervisor}/system \
|
||||
--name=${name} \
|
||||
--description="${name}" \
|
||||
--cpu=host \
|
||||
--ram=${ramsize} \
|
||||
--disk=/dev/lvm_guests_system/${name},size=${disksize},bus=virtio,cache=writethrough,io=native \
|
||||
--network=bridge=br192,mac=${mac},model=virtio \
|
||||
--os-type=linux \
|
||||
--os-variant=debiansqueeze \
|
||||
--boot=network,hd,menu=on \
|
||||
--pxe \
|
||||
--graphics=vnc \
|
||||
--noautoconsole
|
||||
|
||||
echo "Done"
|
||||
|
||||
}
|
||||
|
||||
vm_start() {
|
||||
|
||||
if [ $# -ne 2 ]; then echo "Usage : $0 hypervisor_name_or_ip vm_name"; return 1; fi
|
||||
hypervisor=${1}
|
||||
name=${2}
|
||||
|
||||
echo
|
||||
echo "Trying to start ${name} on ${hypervisor} with virsh"
|
||||
virsh --connect=qemu+ssh://${USER}@${hypervisor}/system start ${name}
|
||||
|
||||
}
|
||||
|
||||
vm_stop() {
|
||||
|
||||
if [ $# -ne 2 ]; then echo "Usage : $0 hypervisor_name_or_ip vm_name"; return 1; fi
|
||||
hypervisor=${1}
|
||||
name=${2}
|
||||
|
||||
echo
|
||||
echo "Trying to stop ${name} on ${hypervisor} with virsh"
|
||||
virsh --connect=qemu+ssh://${USER}@${hypervisor}/system shutdown ${name}
|
||||
|
||||
}
|
||||
|
||||
vm_destroy() {
|
||||
|
||||
if [ $# -ne 2 ]; then echo "Usage : $0 hypervisor_name_or_ip vm_name"; return 1; fi
|
||||
hypervisor=${1}
|
||||
name=${2}
|
||||
|
||||
echo
|
||||
echo "Trying to destroy ${name} on ${hypervisor} with virsh"
|
||||
virsh --connect=qemu+ssh://${USER}@${hypervisor}/system destroy ${name}
|
||||
|
||||
}
|
||||
|
||||
vm_connect() {
|
||||
|
||||
if [ $# -ne 2 ]; then echo "Usage : $0 hypervisor_name_or_ip vm_name"; return 1; fi
|
||||
hypervisor=${1}
|
||||
name=${2}
|
||||
|
||||
echo
|
||||
echo "Trying to connect to ${name} on ${hypervisor} with virsh"
|
||||
virsh --connect=qemu+ssh://${USER}@${hypervisor}/system ttyconsole ${name}
|
||||
virsh --connect=qemu+ssh://${USER}@${hypervisor}/system console ${name}
|
||||
|
||||
}
|
||||
|
||||
#### A tester
|
||||
vm_change_bridge() {
|
||||
|
||||
if [ $# -ne 2 ]; then echo "Usage : $0 hypervisor_name_or_ip vm_name vm_mac vm_new_bridge"; return 1; fi
|
||||
hypervisor=${1}
|
||||
name=${2}
|
||||
mac=${3}
|
||||
bridge=${4}
|
||||
|
||||
#domiflist ${name}
|
||||
#detach-interface --config --domain ${name} --type bridge --mac ${mac}
|
||||
#attach-interface --config --domain ${name} --type bridge --mac ${mac} --source ${bridge}
|
||||
|
||||
}
|
||||
|
||||
#### A tester
|
||||
vm_add_data_disk() {
|
||||
|
||||
if [ $# -ne 2 ]; then echo "Usage : $0 hypervisor_name_or_ip vm_name size"; return 1; fi
|
||||
hypervisor=${1}
|
||||
name=${2}
|
||||
size=${3}
|
||||
|
||||
#pool-list
|
||||
#vol-create-as --pool guests_data --name virt-cha-mirror --capacity 200G --format raw
|
||||
#attach-disk virt-cha-mirror /dev/lvm_guests_data/virt-cha-mirror vdb --cache writethrough
|
||||
#domblklist virt-cha-mirror
|
||||
|
||||
}
|
||||
|
||||
#### bash completion
|
||||
|
||||
_hypervisors() {
|
||||
if [ -e ~/.ssh/config ]; then
|
||||
configured_hypervisors=$(cat ~/.ssh/config | egrep -i "^\s*host\s+[a-zA-Z]" | sed -e "s/^host\s*//i" | grep -i hypervisor)
|
||||
fi
|
||||
if [ -e ~/.ssh/known_hosts ]; then
|
||||
known_hypervisors=$(cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | grep -v "\[" | grep -i hypervisor | uniq)
|
||||
fi
|
||||
echo $configured_hypervisors $known_hypervisors
|
||||
}
|
||||
|
||||
#complete -W "$(cat ~/.ssh/config | egrep -i "^\s*host\s+[a-zA-Z]" | sed -e "s/^host\s*//i" | grep -i hypervisor)" hypervisor_connect
|
||||
complete -W "$(_hypervisors)" hypervisor_connect
|
||||
complete -W "$(_hypervisors)" hypervisor_command
|
||||
complete -W "$(_hypervisors)" vm_create
|
||||
complete -W "$(_hypervisors)" vm_start
|
||||
complete -W "$(_hypervisors)" vm_stop
|
||||
complete -W "$(_hypervisors)" vm_connect
|
8
profile.d/apps
Normal file
8
profile.d/apps
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Defined prefered applications
|
||||
export TERMINAL=urxvtc
|
||||
export PAGER=less
|
||||
export EDITOR=vim
|
||||
export BROWSER=firefox
|
||||
|
8
profile.d/history
Normal file
8
profile.d/history
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Customize history format
|
||||
export HISTSIZE=5000
|
||||
export HISTFILESIZE=20000
|
||||
export HISTTIMEFORMAT="[%d/%m/%Y %H:%M:%S] "
|
||||
export HISTCONTROL="ignoreboth"
|
||||
export HISTIGNORE="[bf]g:exit:history*:*rm*-rf*:*rm*-f*:reboot:ls:ll:man:mutt"
|
4
profile.d/lang
Normal file
4
profile.d/lang
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Define prefered LANG
|
||||
export LANG=fr_FR.utf8
|
4
profile.d/mail
Normal file
4
profile.d/mail
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Mail
|
||||
export MAILPATH=~/Mails/
|
5
profile.d/path
Normal file
5
profile.d/path
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Customize PATH
|
||||
if [ -d $HOME/bin ] ; then export PATH=$PATH:$HOME/bin ; fi
|
||||
if [ -d $HOME/scripts ] ; then export PATH=$PATH:$HOME/scripts ; fi
|
4
profile.d/tsocks
Normal file
4
profile.d/tsocks
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Proxy
|
||||
export TSOCKS_CONF_FILE=~/.config/tsocks/tsocks.conf
|
Loading…
x
Reference in New Issue
Block a user