Skip to content

Commit

Permalink
self-install-update (#9)
Browse files Browse the repository at this point in the history
* just the beginning of self-installation pkg

* emergency bkp due to covid-19 shutdown

* first self installing (not yet updating) attempt

* Add files via upload

Cover picture taken from this article: https://www.themoscowtimes.com/2016/12/30/russia-hacker-superpower-a56704

also mentioned here, in this reddit: https://www.reddit.com/r/russia/comments/5lbbm3/how_russia_became_a_hacking_superpower/

* Update README.md

* Update README.md

* Create LICENSE

* Update README.md

* fix .vimrc installation because of some syntax issues

* galledanza_dir & PATH vars are now properly set

* maybe working update-galledanza test

* resource .config everytime

* add versioning tags
  • Loading branch information
andreagalle authored May 10, 2020
1 parent 64470dc commit c3033f9
Show file tree
Hide file tree
Showing 31 changed files with 357 additions and 6 deletions.
50 changes: 50 additions & 0 deletions .bash_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

galledanza_dir=`dirname "${BASH_SOURCE[0]}"`

export galledanza_dir

# set PATH so it includes galledanza's private bin
if [ -d $galledanza_dir/bin ] ; then
PATH=$galledanza_dir/bin:"${PATH}"
fi

export PATH

if [ -f $galledanza_dir/.config ]; then
. $galledanza_dir/.config
fi

PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\W\[\033[m\]\$ "

export PS1

LSCOLORS="di=1;36;40:ln=1;31;40:so=32:pi=33:ex=35;40:bd=37;40:cd=37;42:su=35;47:sg=35;47:tw=1;36;44:ow=1;36;44"

export LSCOLORS

VISUAL=vim

export VISUAL

EDITOR="$VISUAL"

export EDITOR

## enable programmable completion features
#
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi

34 changes: 34 additions & 0 deletions .bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions

alias l='ls -lrth --color'
alias ll='ls -lrtha --color'
#alias ssh='ssh -X'
alias cl='clear'
alias grep='grep --color=auto'
alias bp='vi .bashrc'
alias sbp='source .bashrc'
alias pwx='pwd | xclip'
alias cx='xclip -o'
alias lf='ls -lrht *.f*'
alias lF='ls -lrht *.F*'
alias ld='ls -lrht *.dat'
alias sbag='. sbag'
alias sqag='squeue -u agallega --format="%10i%10u%15a%20j%5t%25R%10M%13l%8D%5C"'
alias srag='sqag | grep "$(jobname) "'
alias vv='vi *[^make].log'
alias vvv='tail -f *[^make].log'
alias mmm='simlog=$(ls | sort -V | tail -n 1); tail -f $simlog'
alias mmake='make -j8'

alias came='ssh -C [email protected]'
alias cama='ssh -C [email protected]'
13 changes: 13 additions & 0 deletions .config
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

git config --global user.email "[email protected]"
git config --global user.name "andreagalle"

cd $galledanza_dir

echo ""
echo "...galledanza package `git describe --tags` loaded"
echo ""

cd $OLDPWD

12 changes: 12 additions & 0 deletions .vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
" .vimrc

let fortran_free_source=1
let fortran_have_tabs=1
let fortran_more_precise=1
let fortran_do_enddo=1

syntax on
colorscheme desert

set ignorecase
set number
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Andrea Gallegati

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# galledanza-pkg
# galledanza package
Self-installing package to automatically set user defined commands & preferences (aliases, etc...)

![alt text](/doc/MoscowTimes.png) <!-- taken from here: https://www.themoscowtimes.com/2016/12/30/russia-hacker-superpower-a56704 -->

## setting up email alerts

1. edit the folllowing `sudo vi /etc/exim4/update-exim4.conf.conf` changing:
* from `dc_eximconfig_configtype='local'`
* to `dc_eximconfig_configtype='internet'`
2. finally launch `su /etc/init.d/exim4 restart`

3 changes: 0 additions & 3 deletions bin-galledanza/dv

This file was deleted.

File renamed without changes.
1 change: 1 addition & 0 deletions bin/bkpag
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nohup rsync -vaPuz *_2pp [email protected]:/var/services/homes/gallegati/gallegati-si-ftac-2019 >> gallegati-si-ftac-2019-rsync.log
File renamed without changes.
3 changes: 3 additions & 0 deletions bin/dv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
keyword=$1
#optpath=$2
grep --color=auto -inr $keyword ./* #$optpath
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions bin/myGit_diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# un-comment one diff tool you'd like to use

# side-by-side diff with custom options:
# /usr/bin/sdiff -w200 -l "$2" "$5"

# using kdiff3 as the side-by-side diff:
# /usr/bin/kdiff3 "$2" "$5"

# using Meld
#/usr/bin/meld "$2" "$5"

# using VIM
/usr/bin/vim -d "$2" "$5"
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions bin/rocall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
du -hs * | sort -h
10 changes: 8 additions & 2 deletions bin-galledanza/sbag → bin/sbag
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#!/bin/bash

ulimit -s unlimited

OMP_NUM_THREADS=$1
export OMP_NUM_THREADS
KMP_STACKSIZE=16000000
export KMP_STACKSIZE

OMP_STACKSIZE=16000000
export OMP_STACKSIZE

nohup ./$2 >> $2.log &

tail -f --pid=$(pgrep $2) $2.log
19 changes: 19 additions & 0 deletions bin/shifter
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

SHFITER=$2

for i in $1*
do
OLDNAME=$i
# echo $OLDNAME
OLDITER="$(echo $OLDNAME | sed -e s/[^0-9]//g)"
# echo $OLDITER
NEWITER=$(($((10#$OLDITER)) + $((10#$SHFITER))))
# echo $NEWITER
NEWITER=$(printf "%06d" $NEWITER)
# echo $NEWITER
NEWNAME="$(echo $OLDNAME | sed -e s/$OLDITER/$NEWITER/g)"
# echo $NEWNAME
echo "mv $OLDNAME $NEWNAME"
mv -- "$i" "$NEWNAME"
done
20 changes: 20 additions & 0 deletions bin/smag
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

ulimit -s unlimited

OMP_NUM_THREADS=$1
export OMP_NUM_THREADS

OMP_STACKSIZE=16000000
export OMP_STACKSIZE

exe=$2
log=$2.log

nohup ./$exe >> $log &

job=${exe:0:15}

tail -f --pid=$(pgrep $job) $log

tail -n 100 $log | mail -s "$exe" [email protected]
2 changes: 2 additions & 0 deletions bin/squag
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
squeue -u agallega --format="%10i%10u%15a%20j%5t%25R%10M%13l%8D%5C"

File renamed without changes.
1 change: 1 addition & 0 deletions bin/stero2monomp4
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ffmpeg -i $1 -strict -2 -filter_complex "amerge,pan=stereo:c0<c0+c2:c1<c1+c3" mono_$1
2 changes: 2 additions & 0 deletions bin/tmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
git log --graph --decorate --oneline

33 changes: 33 additions & 0 deletions bin/trailing_sbatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

if [ "$#" -lt 2 ]; then
echo "Illegal number of parameters. Give 2 or 3 parameters as follows"
echo "./trailing_sbatch <submit_script> <number_of_jobs> [<initial_afterok_jobid>]"
exit 1
fi

SUB_SCRIPT=$1
N_JOBS=$2

echo "Submitting executable $SUB_SCRIPT for $N_JOBS times"

echo "Submission number: 1"

if [ -z "$3" ]; then
echo "sbatch $SUB_SCRIPT > temp.sbatch"
sbatch $SUB_SCRIPT > temp.sbatch
else
echo "sbatch $SUB_SCRIPT --dependency=afterany:$3 > temp.sbatch"
sbatch --dependency=afterany:$3 $SUB_SCRIPT > temp.sbatch
fi

JOBID=$(cat temp.sbatch | cut -d " " -f4)

for i in $(seq 2 $N_JOBS); do
echo "Submission number: $i"
echo "sbatch $SUB_SCRIPT --dependency=afterany:$JOBID > temp.sbatch"
sbatch --dependency=afterany:$JOBID $SUB_SCRIPT > temp.sbatch
JOBID=$(cat temp.sbatch | cut -d " " -f4)
done

/bin/rm -f temp.sbatch
21 changes: 21 additions & 0 deletions bin/update-galledanza
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

cd $galledanza_dir

echo ""
echo "...updating galledanza package from `git describe --tags`"
echo ""

git checkout master
git pull

. $galledanza_dir/.bash_profile
. $galledanza_dir/.bashrc
. $galledanza_dir/.config

echo ""
echo "...galledanza package updated to `git describe --tags`"
echo ""

cd $OLDPWD

2 changes: 2 additions & 0 deletions bin/vvag
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tail -f $(ls -tr *.out | tail -1)

File renamed without changes.
Binary file added doc/MoscowTimes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions install
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash

echo ""
echo "...installing galledanza package `git describe --tags`"
echo ""

galledanza_dir=$PWD

echo ""
echo "...installing custom $galledanza_dir/.bash_profile"
echo ""

cat <<EOT >> ~/.bash_profile
# added by galledanza `git describe --tags` installer
if [ -f $galledanza_dir/.bash_profile ]; then
. $galledanza_dir/.bash_profile
fi
EOT

. ~/.bash_profile

cat $galledanza_dir/.bash_profile

echo ""
echo "...user $galledanza_dir/.bash_profile installed."
echo ""

echo ""
echo "...installing custom $galledanza_dir/.bashrc"
echo ""

cat <<EOT >> ~/.bashrc
# added by galledanza `git describe --tags` installer
if [ -f $galledanza_dir/.bashrc ]; then
. $galledanza_dir/.bashrc
fi
EOT

. ~/.bashrc

cat $galledanza_dir/.bashrc

echo ""
echo "...user $galledanza_dir/.bashrc installed."
echo ""

echo ""
echo "...installing custom $galledanza_dir/.vimrc"
echo ""

cat <<EOT >> ~/.vimrc
" added by galledanza `git describe --tags` installer
function! SomeCheck()
if filereadable("$galledanza_dir/.vimrc")
so "$galledanza_dir/.vimrc"
endif
endfunction
EOT

cat $galledanza_dir/.vimrc

echo ""
echo "...user $galledanza_dir/.vimrc installed."
echo ""

echo ""
echo "...setting custom $galledanza_dir/.config"
echo ""

. $galledanza_dir/.config

cat $galledanza_dir/.config

echo ""
echo "...user $galledanza_dir/.config set."
echo ""

echo "...the galledanza package installation is completed."
echo ""

0 comments on commit c3033f9

Please sign in to comment.