Browse Source

removed _tmp directory

- signed-off-by: trimstray <trimstray@gmail.com>
pull/1/head
trimstray 5 years ago
parent
commit
adc0a1a94a
13 changed files with 0 additions and 682 deletions
  1. +0
    -3
      _tmp/ana.conf
  2. +0
    -84
      _tmp/awesome-ninja-admins
  3. +0
    -205
      _tmp/install
  4. +0
    -4
      _tmp/lib/aliases/git
  5. +0
    -24
      _tmp/lib/aliases/main
  6. +0
    -1
      _tmp/lib/aliases/ssh
  7. +0
    -0
      _tmp/lib/aliases/system
  8. +0
    -15
      _tmp/lib/functions/_git
  9. +0
    -6
      _tmp/lib/functions/_scg
  10. +0
    -5
      _tmp/lib/functions/_scl
  11. +0
    -75
      _tmp/skel/.vimrc
  12. +0
    -234
      _tmp/src/helpers
  13. +0
    -26
      _tmp/src/settings

+ 0
- 3
_tmp/ana.conf View File

@@ -1,3 +0,0 @@
_functions=(_git _scg _scl)

_aliases=(git main ssh system)

+ 0
- 84
_tmp/awesome-ninja-admins View File

@@ -1,84 +0,0 @@
#!/usr/bin/env bash

### BEG SCRIPT INFO
#
# Header:
#
# fname : "ana-init"
# cdate : "24.05.2018"
# author : "Michał Żurawski <trimstray@gmail.com>"
# tab_size : "2"
# soft_tabs : "yes"
#
# Description:
#
# See README.md file for more information.
#
# License:
#
# awesome-ninja-admins, Copyright (C) 2018 Michał Żurawski
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
### END SCRIPT INFO

# The array that store call parameters.
# shellcheck disable=SC2034
__init_params=()
__script_params=("$@")

# Store the name of the script and directory call.
readonly _ana_dir="${HOME}/.awesome-ninja-admins"

# Directory structure.
# shellcheck disable=SC2154
readonly _ana_src="${_ana_dir}/src"
readonly _ana_lib="${_ana_dir}/lib"

# shellcheck disable=SC1090,SC1091
source "${_ana_src}/settings"
# shellcheck disable=SC1090
source "${_ana_src}/helpers"

# Include main configuration file.
# shellcheck disable=SC1090
source "${_ana_dir}/ana.conf" || (printf "%s\\n" "file not found" ; exit)

# shellcheck disable=SC2154
for _i in "${_functions[@]}" ; do

_fd="${_ana_lib}/functions/${_i}"
if [[ ! -z "$_fd" ]] && [[ -e "$_fd" ]] ; then

# If the file exists is loaded.
# shellcheck disable=SC1090
source "${_fd}"

fi

done

# shellcheck disable=SC2154
for _i in "${_aliases[@]}" ; do

_fd="${_ana_lib}/aliases/${_i}"
if [[ ! -z "$_fd" ]] && [[ -e "$_fd" ]] ; then

# If the file exists is loaded.
# shellcheck disable=SC1090
source "${_fd}"

fi

done

+ 0
- 205
_tmp/install View File

@@ -1,205 +0,0 @@
#!/usr/bin/env bash

### BEG SCRIPT INFO
#
# Header:
#
# fname : "awesome-ninja-admins"
# cdate : "24.05.2018"
# author : "Michał Żurawski <trimstray@gmail.com>"
# tab_size : "2"
# soft_tabs : "yes"
#
# Description:
#
# See README.md file for more information.
#
# License:
#
# awesome-ninja-admins, Copyright (C) 2018 Michał Żurawski
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
### END SCRIPT INFO


# The array that store call parameters.
# shellcheck disable=SC2034
__init_params=()
__script_params=("$@")

# Store the name of the script and directory call.
readonly _init_name="$(basename "$0")"
readonly _init_directory="$(dirname "$(readlink -f "$0")")"

# Set root directory.
readonly _rel="${_init_directory}"

# Directory structure.
# shellcheck disable=SC2154
readonly _src="${_rel}/src"
readonly _lib="${_rel}/lib"
readonly _cfg="${_rel}/etc"

# shellcheck disable=SC1090,SC1091
source "${_src}/settings"
# shellcheck disable=SC1090
source "${_src}/helpers"


################################################################################
######################### Main function (script init) ##########################
################################################################################

function __main__() {

local _FUNCTION_ID="__main__"
local _STATE="0"

# Stores the current date.
readonly _cdate=$(date +%Y%m%d)

# External configuration file (-c|--config script param).
config=""
load_state="0"

# Declaration of output variables (--debug and --verbose params).
stdout_mode=""
printf_mode=""
# Enable/disable output colors.
# shellcheck disable=SC2034
s_color="true"

# We place here used commands at script runtime, as strings to anything
# unnecessarily run.
readonly commands=("basename" "dirname" "stat" "date" "grep" "egrep" "cut" \
"sed" "gzip" "tar")

# If you intend to specify the full path to the command we do it like:
# readonly exec_gzip="/bin/gzip"

# Stores the names of the missing commands.
missing_hash=()
missing_counter="0"

for i in "${commands[@]}" ; do

if [[ ! -z "$i" ]] ; then

hash "$i" >/dev/null 2>&1 ; state="$?"

# If the command was not found put it in the array
if [[ "$state" -ne 0 ]] ; then

missing_hash+=("$i")
((missing_counter++))

fi

fi

done

# It is a good idea to terminate the script at this stage
# with information for the user to fix the errors if at least one
# of the required commands in the commands array is not found.
if [[ "$missing_counter" -gt 0 ]] ; then

printf "not found in PATH: %s\\n" "${missing_hash[*]}" >&2
exit 1

fi

# Specifies the call parameters of the script, the exact description
# can be found in _help_ and file README.md.
local _short_opt=""
local _long_opt="help"

_GETOPT_PARAMS=$(getopt -o "${_short_opt}" --long "${_long_opt}" \
-n "${_init_name}" -- "${__script_params[@]}")

# With this structure, in the case of problems with the parameters placed
# in the _GETOPT_PARAMS variable we finish the script. Keep this in mind
# because it has some consequences - the __main __() function will not be
# executed.

# Ends an error if the parameter or its argument is not valid.
_getopt_state="$?"
if [ "$_getopt_state" != 0 ] ; then
exit 1
fi

eval set -- "$_GETOPT_PARAMS"
while true ; do

case $1 in

--help)

_help_

shift ; exit 0 ;;

*)

if [[ "$2" == "-" ]] || [[ ! -z "$2" ]] ; then

printf "%s: invalid option -- '%s'\\n" "$_init_name" "$2"
exit 1

# elif [[ -z "$2" ]] ; then break ; fi
else break ; fi

;;

esac

done

################################# USER SPACE #################################
# ````````````````````````````````````````````````````````````````````````````
# Put here all your variable declarations, function calls
# and all the other code blocks.

# In this section we add external file (for -c|--config script param).
if [[ "$load_state" -eq 1 ]] ; then _load "head" "$config" ; fi

# shellcheck disable=SC2034
# Generate random value.
_random=$(date +"%s")

local _user

_user=$(whoami)

_sprintf "head" "Awesome-Ninja-Admins"

_sprintf "info" "tasks:"

_init_skel

echo

# ````````````````````````````````````````````````````````````````````````````

return "$_STATE"

}


# We pass arguments to the __main__ function.
# It is required if you want to run on arguments type $1, $2, ...
__main__ "${__script_params[@]}"

exit 0

+ 0
- 4
_tmp/lib/aliases/git View File

@@ -1,4 +0,0 @@
alias git.a='git add'
alias git.show='git log --oneline --decorate --graph --all'

alias git.pm='_ana_git_pull master'

+ 0
- 24
_tmp/lib/aliases/main View File

@@ -1,24 +0,0 @@
alias ssh_nonpass='ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no'
alias xfce.restart.panel='xfce4-panel -r'

alias cpu.low='cpupower frequency-set -d'
alias cpu.high='cpupower frequency-set -u'
alias cpu.show='cpupower frequency-info'

alias git.commit='git add . && git commit -m "uncommited changes"'

alias claminit='/usr/bin/clamscan --suppress-ok-results --block-encrypted --database=/home/admin/.clamtk/db --scan-mail=yes --scan-archive=yes --max-scansize=500M --exclude-dir=^/home/admin/.clamtk/viruses --exclude-dir=^/sys/ --exclude-dir=^/dev/ --exclude-dir=^/proc/ --follow-dir-symlinks=1 --follow-file-symlinks=1 --detect-broken --recursive=yes'
alias ssh.pentest-kali='ssh 139.59.154.194 -p 9000'
alias ssh.ext-web1='ssh 46.101.164.125 -p 8200'

alias l='ls -lFh --group-directories-first' #size,show type,human readable
alias la='ls -lAFh --group-directories-first' #long list,show almost all,show type,human readable
alias lr='ls -tRFh --group-directories-first' #sorted by date,recursive,show type,human readable
alias lt='ls -ltFh --group-directories-first' #long list,sorted by date,show type,human readable
alias ll='ls -l --group-directories-first' #long list

alias git.reft="git pull origin testing && git fetch --all && git fetch --prune --tags"
alias git.refm="git pull origin master && git fetch --all && git fetch --prune --tags"

alias show.dns="ll /etc/dnsmasq.d/templates"
alias show.vpn="ll /etc/netrog/vpn"

+ 0
- 1
_tmp/lib/aliases/ssh View File

@@ -1 +0,0 @@
alias ssh.nonpass='ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no'

+ 0
- 0
_tmp/lib/aliases/system View File


+ 0
- 15
_tmp/lib/functions/_git View File

@@ -1,15 +0,0 @@
#!/usr/bin/env bash

function _ana_git_pull() {

local _arg=("$@")

for _i in "${_arg[@]}" ; do

printf "%s" "$_i"

git pull origin "$_i" && git fetch --all && git fetch --prune --tags

done

}

+ 0
- 6
_tmp/lib/functions/_scg View File

@@ -1,6 +0,0 @@
function scg() {

/usr/bin/keychain $HOME/.ssh/id_rsa.blueservices.pl
source $HOME/.keychain/$HOSTNAME-sh

}

+ 0
- 5
_tmp/lib/functions/_scl View File

@@ -1,5 +0,0 @@
function scl() {

/usr/bin/keychain --clear

}

+ 0
- 75
_tmp/skel/.vimrc View File

@@ -1,75 +0,0 @@
" au BufWritePost * :set nobinary | set eol
autocmd FileType * setlocal eol nobinary fileformats="unix,mac,dos"

set pastetoggle=<F6>

set history=256

filetype plugin on

set autoread

set so=7

set wildmenu
set wildignore=*.o,*~,*.pyc

set cmdheight=2

set hid

set backspace=eol,start,indent
set whichwrap+=<,>,h,l

set ignorecase
set smartcase
set hlsearch
set incsearch

set lazyredraw

set magic

set number

set showmatch
set mat=2

set noerrorbells
set novisualbell
set t_vb=
set tm=500

syntax enable

colorscheme desert
set background=dark

if has("gui_running")
set guioptions-=T
set guioptions+=e
set t_Co=256
set guitablabel=%M\ %t
endif

set encoding=utf8
set ffs=unix,dos,mac

set expandtab
set smarttab
set shiftwidth=2
set tabstop=2

set lbr
set tw=500

set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines

set linebreak
set showbreak=>\ \ \

set laststatus=2

map <Esc><Esc> :wq!<CR>

+ 0
- 234
_tmp/src/helpers View File

@@ -1,234 +0,0 @@
#!/usr/bin/env bash

# shellcheck shell=bash

################################################################################
####################### Definitions of global functions ########################
################################################################################

# ``````````````````````````````````````````````````````````````````````````````
# Function name: _sprintf()
#
# Description:
# Function designed to output to the screen in a clear format.
#
# Usage:
# _sprintf "type" "message"
#
# Examples:
# _sprintf "head" "correct certificate: $_ssl_cert_file"
#

function _sprintf() {

local _FUNCTION_ID="_sprintf"
local _STATE="0"

local _s_type="$1"
local _s_info="$2"

# Determine the type of character and color for each type
# of output information.
if [[ "$_s_type" == "head" ]] ; then

s_char="::"
s_trgb="1;32"

elif [[ "$_s_type" == "info" ]] ; then

s_char="»"
s_trgb="0;33"

elif [[ "$_s_type" == "warn" ]] ; then

s_char="!"
s_trgb="1;37"

elif [[ "$_s_type" == "stop" ]] ; then

s_char="!"
s_trgb="1;31"

else

s_char="-"
s_trgb="0;37"

fi

# If verbose mode is enabled, display info message.
# shellcheck disable=SC2154
if [[ "$_s_type" == "info" ]] ; then

printf ' \e['${s_trgb}'m%s\e[m %s\n\n' "$s_char" "$_s_info"

elif [[ "$_s_type" == "light-red" ]] ; then

s_char="»"
printf ' \e[1;49;31m%s\e[m %s\n' "$s_char" "$_s_info"

elif [[ "$_s_type" == "light-green" ]] ; then

s_char="»"
printf ' \e[1;49;32m%s\e[m %s\n' "$s_char" "$_s_info"

elif [[ "$_s_type" == "light-cyan" ]] ; then

s_char="»"
printf ' \e[1;49;36m%s\e[m %s\n' "$s_char" "$_s_info"

else

# If not, just display only the head, warn or stop string.
# shellcheck disable=SC2154
if [[ "$_s_type" == "head" ]] ; then

if [[ "$s_color" == "true" ]] ; then

c_trgb="1;38"

printf '\e['${s_trgb}'m%s\e[m \e['${c_trgb}'m%s\e[m\n\n' "$s_char" "$_s_info"

else

printf '\e['${s_trgb}'m%s\e[m %s\n\n' "$s_char" "$_s_info"

fi

elif [[ "$_s_type" == "warn" ]] ; then

if [[ "$s_color" == "true" ]] ; then

c_trgb="1;43"

printf ' \e['${s_trgb}'m%s\e[m \e['${c_trgb}'m%s\e[m\n' "$s_char" "$_s_info"

else

printf ' \e['${s_trgb}'m%s\e[m %s\n' "$s_char" "$_s_info"

fi

elif [[ "$_s_type" == "stop" ]] ; then

if [[ "$s_color" == "true" ]] ; then

c_trgb="1;41"

printf ' \e['${s_trgb}'m%s\e[m \e['${c_trgb}'m%s\e[m\n' "$s_char" "$_s_info"

else

printf ' \e['${s_trgb}'m%s\e[m %s\n' "$s_char" "$_s_info"

fi

fi

fi

return "$_STATE"

}

# ``````````````````````````````````````````````````````````````````````````````
# Function name: _load()
#
# Description:
# Responsible for loading the configuration file, $config variable
# parameter is defined in the script call.
#
# Usage:
# _load "type" "path_to_config_file"
#
# Examples:
# _load "info" "$config"
# _load "head" "/tmp/file.cfg"
#

function _load() {

local _FUNCTION_ID="_load"
local _STATE="0"

local _type="$1"
local _filename="$2"

if [[ ! -z "$_filename" ]] && [[ -e "$_filename" ]] ; then

# If we do not want to inform that the file is loaded,
# the value is 'null', otherwise:
if [[ "$_type" == "head" ]] ; then

_sprintf "info" "load configuration: '$_filename'"

elif [[ "$_type" == "info" ]] ; then

_sprintf "info" "load configuration: '$_filename'"

fi

# shellcheck disable=SC1090
# If the file exists is loaded.
. "$_filename" && \
_logger "info" \
"${_FUNCTION_ID}()" \
"configuration file: '$_filename'"

elif [ -z "$_filename" ] ; then

_sprintf "stop" "incorrectly loaded '$_filename' file (incorrect filename)"

else

_sprintf "stop" "incorrectly loaded '$_filename' file (does not exist?)"

fi

return "$_STATE"

}

# ``````````````````````````````````````````````````````````````````````````````
# Function name: _init_skel()
#
# Description:
# Init user skel:
# - create directory structure
#
# Usage:
# _init_skel
#
# Examples:
# _init_skel
#

function _init_skel() {

local _FUNCTION_ID="_init_skel"
local _STATE="0"

local _shell_config="${HOME}/.bashrc"
local _ana_string="source \"${HOME}/.awesome-ninja-admins/awesome-ninja-admins\""

# shellcheck disable=SC2154
_sprintf "light-cyan" "init user skel"

# shellcheck disable=SC2154
rsync -a "${HOME}/.awesome-ninja-admins/skel/" "${HOME}" > /dev/null 2>&1

# shellcheck disable=SC2154
_sprintf "light-cyan" "enable awesome-ninja-admins"

_if_exist=$(grep -q "${_ana_string}" "${_shell_config}" ; echo "$?")

if [[ "$_if_exist" -ne 0 ]] ; then

echo "source \"${HOME}/.awesome-ninja-admins/awesome-ninja-admins\"" \
>> "${_shell_config}"

fi

return "$_STATE"

}

+ 0
- 26
_tmp/src/settings View File

@@ -1,26 +0,0 @@
# shellcheck shell=bash

################################################################################
################## The configuration parameters of the script ##################
################################################################################

# Bash 'Strict Mode':
# errexit - exit the script if any statement returns a non-true return value
# pipefail - exit the script if any command in a pipeline errors
# nounset - exit the script if you try to use an uninitialised variable
# xtrace - display debugging information
set -o pipefail

# Internal field separator (more flexible):
# IFS_ORIG="$IFS"
# IFS_HACK=$'\n\t'
# IFS="$IFS_HACK"

# PATH env variable setup:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# Setting permissions in the script environment:
# 0022 - less restrictive settings (default value)
# 0027 - for better security than above
# 0077 - only for user access (more restrictive)
umask 0027

Loading…
Cancel
Save