Skip to content

Instantly share code, notes, and snippets.

@jessuppi
Last active September 10, 2020 20:21
Show Gist options
  • Save jessuppi/3356c3031281872eb85120020fca4daa to your computer and use it in GitHub Desktop.
Save jessuppi/3356c3031281872eb85120020fca4daa to your computer and use it in GitHub Desktop.
SlickStack Bash Functions (Aliases) + Environment Variables
#!/bin/bash
####################################################################################################
#### SlickStack: Critical Bash Functions (Aliases) + Script Variables ##############################
####################################################################################################
## the below functions are hardcoded into every SlickStack script to ensure reliability ##
## this also speeds up processing times by avoiding repeated inline commands ##
## add-apt-repository alias flags ##
function add-apt-repository {
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_PRIORITY=critical
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
command /usr/bin/add-apt-repository --yes "$@"
}
## apt alias flags ##
function apt {
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_PRIORITY=critical
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
command /usr/bin/apt --yes --quiet --option Dpkg::Options::=--force-confold --option Dpkg::Options::=--force-confdef "$@"
}
## cp alias flags ##
function cp {
command cp -R -f -d --no-preserve=mode,ownership "$@"
}
## ln alias flags ##
function ln {
command ln -s -f "$@"
}
## mkdir alias flags ##
function mkdir {
command mkdir -p "$@"
}
## mysql alias flags ##
function mysql {
command mysql --user=root --host=localhost --protocol=socket --port=3306 --force "$@"
}
## mysqldump alias flags ##
function mysqldump {
# /usr/bin/mysqldump
command mysqldump --user=$DB_USER --password=$DB_PASSWORD --host=$DB_HOST --protocol=tcp --port=3306 --no-tablespaces --single-transaction --skip-lock-tables --dump-date --force "$@"
}
## rm alias flags ##
function rm {
command rm -R -f "$@"
}
## rsync alias flags ##
function rsync {
command rsync -aI --ignore-errors "$@"
}
## unzip alias flags ##
function unzip {
command unzip -o "$@"
}
## wget alias flags ##
function wget {
command wget --no-check-certificate --no-cache --no-cookies --tries=3 --timeout=15 "$@"
}
####################################################################################################
#### SlickStack: Critical Variables For This Script To Work ########################################
####################################################################################################
## something like environment variables but not exactly that are placed in core scripts ##
## we keep these variables together for easy reference and better organization ##
UBUNTU_VERSION=`lsb_release -rs`
DISK_FREE=`df -k --output=avail "$PWD" | tail -n1`
@jessuppi
Copy link
Author

jessuppi commented Aug 8, 2020

Reserving first comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment