Skip to content

Commit

Permalink
New config files written in bash
Browse files Browse the repository at this point in the history
Signed-off-by: Rodrigo Siqueira <[email protected]>
  • Loading branch information
rodrigosiqueira committed Apr 4, 2022
1 parent 8333e9f commit 0c098ef
Show file tree
Hide file tree
Showing 305 changed files with 31,013 additions and 31 deletions.
32 changes: 1 addition & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,5 @@
> Just run:
```
sudo ansible-playbook atma.yml
bash main.sh
```

# Here's some of the project I'm involved/interested

```
ansible-playbook free_sw_project.yml
```

# Test Machine

When working with Linux Kernel or embedded systems, It is common to have a
target machine that we use for testing, which could be a simple VM or a real
device. In my case, I usually have a VM and a device for testing my code,
because of this, I added a set of playbooks intended to configure my test
machines.

> Note: I'll use TM(tm) as an acronyms for "Test Machine"
If you want to use this scripts, keep in mind that you have to update the
following files:

1. hosts
2. tm_graphics

If you want to deploy the configurations in your test machine, just use:

```
ansible-playbook tm_graphics.yml -i inventory
```

> Note: Remember that you have to configure the ssh in the target machine
58 changes: 58 additions & 0 deletions bash/bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# ~/.bashrc
#

# Vim should be default
EDITOR=vim

# My laziness stuffs
R="$HOME/Documents/Repositories/"
notes="$HOME/Documents/Notes/"

Rk="$HOME/Documents/Repositories/kernels"
Rdrm="$Rk/drm/drm-misc/"

Rf="$HOME/Documents/Repositories/freedesktop"
Rigt="$Rf/igt-gpu-tools"
Rlibdrm="$Rf/libdrm"

M="$R/MAINTENANCE"
NOI="$R/NOI"

kdd="drivers/gpu/drm/amd/dal-dev/"
kd="drivers/gpu/drm/amd/display/"

export GPG_TTY=$(tty)
gpg-connect-agent updatestartuptty /bye >/dev/null

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

# Tools alias
alias ls='ls --color=auto'
alias grep='grep --color'
alias feh='feh --scale-down'
alias mpg123b='screen mpg123 -o pulse -z'
# llk stands for last line in known_hosts
alias dropllk="sed -i '\$d' ~/.ssh/known_hosts"

# Useful alias
alias kernel-test='[ -d "/usr/lib/modules/$(uname -r)" ] || echo "Kernel has been updated. Please reboot."'

# Bash color
PS1='[$?,\j][\D{%T}]\[\e[0;32m\]\u@\h\[\e[m\] \[\e[1;34m\]\w\[\e[m\] '
PS1+='\[\e[1;32m\]\[\e[0;33m\]$(__git_ps1 "[%s]")\n\[\e[1;32m\]'
PS1+='\$\[\e[m\] \[\e[0;37m\]'

# Miscellaneous export variables
export HISTTIMEFORMAT='%F %T '
export HISTCONTROL=erasedups

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
#export PATH="$PATH:$HOME/.rvm/bin"
#[ -s "/home/siqueira/.scm_breeze/scm_breeze.sh" ] && source "/home/siqueira/.scm_breeze/scm_breeze.sh"

# Adding the kdesrc-build directory to the path
#export PATH="$HOME/kde/src/kdesrc-build:$PATH"

PATH=~/.local/bin:$PATH
1 change: 1 addition & 0 deletions bash/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cp bash/bashrc ~/.bashrc
5 changes: 5 additions & 0 deletions breeze/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Get the project
git clone https://github.com/scmbreeze/scm_breeze.git ~/.scm_breeze

# Installing breeze
bash ~/.scm_breeze/install.sh
9 changes: 9 additions & 0 deletions git/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Global setup
git config --global user.name 'Rodrigo Siqueira'
git config --global user.email '[email protected]'
git config --global core.editor vim

# Autocomplete
printf '# Git magic\n' >> ~/.bashrc
printf 'source /usr/share/git/completion/git-completion.bash\n' >> ~/.bashrc
printf 'source /usr/share/git/completion/git-prompt.sh\n' >> ~/.bashrc
34 changes: 34 additions & 0 deletions include.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#Used for file sourcing.
#This function should used for file sourcing instead of `. file.sh --source-only`
#
# @filepath Path to the file to be sourced
#
# Returns:
# 0 on a succesful import, 1 if the file can't be read and 2 if it can´t be found
function include()
{
local filepath="$1"
local fullpath

if [[ ! -r "$filepath" ]]; then
if [[ ! -e "$filepath" ]]; then
printf '%s\n' "File $filepath could not be found, check your file path."
return 2 # ENOENT
fi
printf '%s\n' "File $filepath could not be read, check your file permissions."
return 1 # EPERM
fi

fullpath="$(realpath "$filepath")"

if [[ -v KW_INCLUDES_SET ]]; then
[[ -v KW_INCLUDED_PATHS["$fullpath"] ]] && return 0

KW_INCLUDED_PATHS["$fullpath"]=1
else
declare -g KW_INCLUDES_SET=1
declare -gA KW_INCLUDED_PATHS=(["$fullpath"]=1)
fi

. "$filepath" --source-only
}
58 changes: 58 additions & 0 deletions lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
function detect_distro()
{
local root_path="$1"
local str_check="$2"
local distro_id='none'
local etc_path
declare -a debian_family=('debian' 'ubuntu' 'raspbian')
declare -a arch_family=('arch' 'manjaro')
declare -a fedora_family=('fedora')

etc_path=$(join_path "$root_path" /etc)

if [[ -n "$str_check" ]]; then
distro_id="$str_check"
elif [[ -d $etc_path ]]; then
distro_id=$(cat "$etc_path"/*-release | grep -w ID | cut -d = -f 2)
fi

# Debian family
if [[ "${debian_family[*]}" =~ ${distro_id} ]]; then
printf '%s\n' 'debian'
# ArchLinux family
elif [[ "${arch_family[*]}" =~ ${distro_id} ]]; then
printf '%s\n' 'arch'
# Fedora family
elif [[ "${fedora_family[*]}" =~ ${distro_id} ]]; then
printf '%s\n' 'fedora'
else
printf '%s\n' 'none'
fi
}

function join_path()
{
local target_path=$1
local member=$2
local joined

# TODO: Extended pattern matching. We should consider to use it as a default
# in this project.
shopt -s extglob
member=${member%%+(/)}
member=${member##+(/)}

joined="${target_path%%+(/)}/$member"

printf '%s\n' "$joined" | tr -s '/'
}

function install_packages()
{
local -n list="$1"
local package_manager_cmd="$2"

printf -v list_str '%s ' "${list[@]}"

eval "${package_manager_cmd} ${list_str}"
}
21 changes: 21 additions & 0 deletions main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
. 'include.sh' --source-only

include 'lib.sh'

# Setup variables per distro target
export TARGET_DISTRO=$(detect_distro)
if [[ "$TARGET_DISTRO" == 'arch' ]]; then
export PACKAGE_MANAGER='yes | sudo pacman -Syu --noconfirm '
else
export PACKAGE_MANAGER='sudo apt install -y '
fi

# Keep in mind that the order metters here.

include 'packages/setup.sh'
include 'vim/setup.sh'
include 'repositories/setup.sh'
include 'bash/setup.sh'
include 'git/setup.sh'
include 'rvm/setup.sh'
include 'breeze/setup.sh'
41 changes: 41 additions & 0 deletions packages/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ArchLinux package names
declare -a arch_packages=(
'rsync'
'wget'
'vim'
'git'
'htop'
'konsole'
'libreoffice-fresh'
'okular'
'zim'
'openconnect'
'screen'
'pv'
'bzip2'
'lzip'
'lzop'
'zstd'
'mpg123'
'man'
'man-db'
'chromium'
'firefox'
'ntfs-3g'
'gnupg'
'bash-completion'
'openconnect'
# Kernel packages
'base-devel'
'xmlto'
'kmod'
'inetutils'
'bc'
'libelf'
'cpio'
'perl'
'tar'
'xz'
)

install_packages "${TARGET_DISTRO}"_packages "${PACKAGE_MANAGER}"
55 changes: 55 additions & 0 deletions repositories/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
REPOS="${HOME}/Documents/Repositories"

declare -a other_projects=(
'https://github.com/webfolder/siqueira.tech'
'https://github.com/rodrigosiqueira/myConfigFiles.git'
)

declare -a kw_repos=(
'https://github.com/kworkflow/kworkflow.git'
'https://github.com/kworkflow/blog.git'
'https://github.com/kworkflow/miscellaneous.git'
)

declare -a kernel_repos=(
'https://anongit.freedesktop.org/git/drm/drm-misc.git'
'https://github.com/raspberrypi/linux.git'
)

declare -a freedesktop_repos=(
'https://gitlab.freedesktop.org/mesa/drm'

)

function clone_project_to()
{
local -n project_list="$1"
local repo_path="$2"

# Clone misc projects
for repository in "${project_list[@]}"; do
repo_name=$(basename "$repository")
repo_name="${repo_name%%.*}"

[[ -d "${repo_path}/${repo_name}" ]] && continue

git -C "${repo_path}" clone "$repository"
done
}

mkdir -p "${REPOS}"

# Clone other projects
clone_project_to other_projects "${REPOS}"

# Clone kw project
mkdir -p "${REPOS}/kw"
clone_project_to kw_repos "${REPOS}/kw"

# Clone kernel freedesktop
mkdir -p "${REPOS}/freedesktop"
clone_project_to freedesktop_repos "${REPOS}/freedesktop"

# Clone kernel projects
mkdir -p "${REPOS}/kernels"
clone_project_to kernel_repos "${REPOS}/kernels"
8 changes: 8 additions & 0 deletions rvm/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Reference: https://rvm.io/rvm/install

gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -

# Setup ruby
curl -sSL https://get.rvm.io | bash -s stable --ruby
29 changes: 29 additions & 0 deletions vim/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Object files
*.o
*.ko
*.obj
*.elf

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
12 changes: 12 additions & 0 deletions vim/.vim/.netrwhist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
let g:netrw_dirhistmax =10
let g:netrw_dirhistcnt =7
let g:netrw_dirhist_7='/home/siqueira/Documents/Repositories/kernels/drm'
let g:netrw_dirhist_6='/home/siqueira/Documents/Repositories/kw/kworkflow/etc/init_templates/x86-64'
let g:netrw_dirhist_5='/home/siqueira/Documents/Repositories/kw/kworkflow/etc/init_templates/rpi4-raspbian-64-cross-x86-arm'
let g:netrw_dirhist_4='/home/siqueira/Documents/Repositories/kw/kworkflow/etc/init_templates/rpi4-raspbian-32-cross-x86-arm'
let g:netrw_dirhist_3='/home/siqueira/Documents/Repositories/kw/kworkflow/etc/init_templates'
let g:netrw_dirhist_2='/home/siqueira/Documents/Repositories/kw/kworkflow/etc/init_templates/rpi4-raspbian-32-cross-x86-arm'
let g:netrw_dirhist_1='/home/siqueira/Documents/Repositories/kw/kworkflow/etc/init_templates'
let g:netrw_dirhist_0='/home/siqueira/Documents/Repositories/kw/kworkflow/src'
let g:netrw_dirhist_9='/home/siqueira/Documents/Repositories/kw/kworkflow'
let g:netrw_dirhist_8='/home/siqueira/Documents/Repositories/kw/kworkflow/documentation/dependencies'
Loading

0 comments on commit 0c098ef

Please sign in to comment.