Files
sh/full_install.sh

123 lines
2.6 KiB
Bash
Raw Normal View History

2025-12-06 13:50:26 -06:00
#!/usr/bin/env bash
# ERR Trap Inheritance by shell functions, command substitutions, and subshells.
set -E
# Exit on Error Causes the script to immediately exit if any command returns a non-zero exit status unless that command is followed by || to explicitly handle the error.
set -e
# Treats the use of undefined variables as an error, causing the script to exit.
set -u
# Ensures that a pipeline (a series of commands connected by |) fails if any command within it fails, rather than only failing if the last command fails.
set -o pipefail
# Cleaup script.
trap cleanup SIGINT SIGTERM ERR EXIT
# Get the script location and cd to it.
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
# Usage error message.
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
Script description here.
Available options:
-h, --help Print this help and exit
-v, --verbose Print script debug info
EOF
exit
}
# Cleaup up script iplementation.
cleanup() {
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
}
# Color setup implementation.
setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}
# Message helper function implementation.
msg() {
echo >&2 -e "${1-}"
}
# Script exit implementation.
die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "\033[0;31m$msg\033[0m"
exit "$code"
}
# Parameter parsing implementation.
parse_params() {
while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done
args=("$@")
return 0
}
# ----- Script Start -----
# Parse parameters and setup colors for script.
parse_params "$@"
setup_colors
# ----- Sudo Check -----
sudo -n true
test $? -eq 0 || exit 1 "you should have sudo privilege to run this script"
apt update
apt install sudo -y
apt install gpg -y
apt install zsh -y
apt install tmux -y
apt install vim-gtk3 -y
apt install git -y
apt install fzf -y
apt install universal-ctags -y
apt install curl -y
apt install wget -y
apt install zip -y
apt install unzip -y
apt install dpkg -y
apt install tar -y
apt install gzip -y
apt install coreutils -y
apt install build-essential -y
apt install freecad -y
apt install kicad -y
exit 0