LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Any shell scripts repository examples? (https://www.linuxquestions.org/questions/linux-newbie-8/any-shell-scripts-repository-examples-4175475605/)

RigsJuarez 09-02-2013 12:56 PM

Any shell scripts repository examples?
 
Hi all,

Is there any web site with common SysAdmin shell scripts repository examples?

I remember there was one with many categorized (file system/networking/processes, etc.) shell scripts but I can't find it anymore.

Regards.

TB0ne 09-02-2013 01:26 PM

Quote:

Originally Posted by RigsJuarez (Post 5020407)
Hi all,
Is there any web site with common SysAdmin shell scripts repository examples?

I remember there was one with many categorized (file system/networking/processes, etc.) shell scripts but I can't find it anymore.
Regards.

There are some sites like Hotscripts, and many more you can find with a Google search.

PTrenholme 09-02-2013 11:06 PM

I keep my common shell scripts in /usr/share/bash, and use this script to "include" the ones I want:
Code:

$ cat /usr/share/bash/include
#!/bin/bash
# Define the function to include all the programs listed in "$*" from /usr/share/bash
#
# Usage: include function1 {function2 ...}
#
# Note: This function assumes that any function to be included may be an executable script
#      and searches $PATH for any match before looking in the location array entries.
#
# Define the include function if it's not already defined
if [ "$(type -t include)" != "function" ]
then
  include ()
  {
    local d f abort loc found
    local -a locations
# This is the array naming the locations to be searched
    locations=("/usr/share/bash" "${HOME}/Scripts/Bash")
    abort=0
    for f in "$@"
    do
      loc=$(type -P "${f}")
      if [ -z "${loc}" ]
      then
        found=0
        for d in "${locations[@]}"
        do
          if [ -f "${d}/${f}" ]
          then
            . "${d}/${f}"
            found=1
            break
          fi
        done
        if [[ ${found} == 0 ]]
        then
          echo Error: The bash include file \"${f}"\" could not be found." > /dev/stderr
          abort=$((++abort))
        fi
      else
        . "${loc}"
      fi
    done
    [ ${abort} -gt 0 ] && exit ${abort}
  }
fi

Here's an example of how I use it:
Code:

# Load the local function definitions
. /usr/share/bash/include
include define_colors \
        sucmd \
        connect_using_nmcli_to \
        vg_activate \
        mount_noauto \
        mount_cifs \
        mount_iso


ajb57 05-13-2017 05:34 PM

Linux-shell-base
 
For a resource of solutions to low-level shell scripting problems in Linux, see linux-shell-base. It provides solutions for multiple aspects of the Linux application layer.

rtmistler 05-19-2017 12:28 PM

@ajb57 welcome to LQ.

Stop resurrecting very old questions and posting your same information and link.

If you wish to self-promote some code you may do so with a single new thread.

http://www.linuxquestions.org/questi...ts-4175538361/
http://www.linuxquestions.org/questi...es-4175509965/
http://www.linuxquestions.org/questi...es-4175420036/
http://www.linuxquestions.org/questi...es-4175475605/


All times are GMT -5. The time now is 11:41 AM.