addet sh scripts
This commit is contained in:
parent
b7645b88b1
commit
b900716d24
20 changed files with 3760 additions and 0 deletions
203
setup/arch-hyprland.sh
Normal file
203
setup/arch-hyprland.sh
Normal file
|
@ -0,0 +1,203 @@
|
|||
#!/bin/sh
|
||||
|
||||
# ╭───────────────╮
|
||||
# │ env functions │
|
||||
# ╰───────────────╯
|
||||
# ───────────────────────────────────< ANSI color codes >───────────────────────────────────
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
YELLOW='\033[0;33m'
|
||||
LIGHT_GREEN='\033[0;92m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo_error() {
|
||||
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||
}
|
||||
|
||||
echo_info() {
|
||||
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_warning() {
|
||||
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_note() {
|
||||
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
# ─────────────< Check if the user is root and set sudo variable if necessary >─────────────
|
||||
check_root() {
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command_exists sudo; then
|
||||
echo_info "User is not root. Using sudo for privileged operations."
|
||||
_sudo="sudo"
|
||||
else
|
||||
echo_error "No sudo found and you're not root! Can't install packages."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo_info "Root access confirmed."
|
||||
_sudo=""
|
||||
fi
|
||||
}
|
||||
|
||||
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||
get_packager() {
|
||||
if [ -e /etc/os-release ]; then
|
||||
echo_info "Detecting distribution..."
|
||||
. /etc/os-release
|
||||
|
||||
ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]')
|
||||
ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
case "$ID" in
|
||||
ubuntu | pop) _install() { $_sudo apt-get install --assume-yes "$@"; } ;;
|
||||
debian) _install() { $_sudo apt-get install --assume-yes "$@"; } ;;
|
||||
fedora) _install() { $_sudo dnf install -y "$@"; } ;;
|
||||
alpine) _install() { $_sudo apk add "$@"; } ;;
|
||||
arch | manjaro | garuda | endeavour) _install() { $pkger -S --noconfirm "$@"; } ;;
|
||||
opensuse*) _install() { $_sudo zypper in -y "$@"; } ;;
|
||||
*)
|
||||
if echo "$ID_LIKE" | grep -q "debian"; then
|
||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
||||
elif echo "$ID_LIKE" | grep -q "ubuntu"; then
|
||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
||||
elif echo "$ID_LIKE" | grep -q "arch"; then
|
||||
_install() { $pkger -S --noconfirm "$@"; }
|
||||
elif echo "$ID_LIKE" | grep -q "fedora"; then
|
||||
_install() { $_sudo dnf install -y "$@"; }
|
||||
elif echo "$ID_LIKE" | grep -q "suse"; then
|
||||
_install() { $_sudo zypper in -y "$@"; }
|
||||
else
|
||||
echo_error "Unsupported distribution: $ID"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo_error "Unable to detect distribution. /etc/os-release not found."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ──────────────────────< Check if the given command exists silently >──────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
check_aur() {
|
||||
if ! command_exists yay; then
|
||||
echo_error "Yay was not found.. looking for paru instead"
|
||||
if ! command_exists paru; then
|
||||
echo_error "No AUR helper found, please install before continuing!"
|
||||
exit 1
|
||||
else
|
||||
echo_info "Found paru, using it.."
|
||||
pkger="paru"
|
||||
fi
|
||||
exit 1
|
||||
else
|
||||
echo_info "Found yay, using it.."
|
||||
pkger="yay"
|
||||
fi
|
||||
}
|
||||
|
||||
check_deps() {
|
||||
deps="
|
||||
hyprland
|
||||
hyprpicker
|
||||
hyprlang
|
||||
hyprutils
|
||||
hyprwayland-scanner
|
||||
xdg-desktop-portal-hyprland
|
||||
|
||||
$BarOfChoise
|
||||
swww
|
||||
rofi
|
||||
wlogout
|
||||
libnotify
|
||||
"
|
||||
for dependency in $deps; do
|
||||
if ! command_exists "$dependency"; then
|
||||
echo_note "Installing $dependency.."
|
||||
_install "$dependency"
|
||||
else
|
||||
echo_info "$dependency is already installed"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
ask_bar() {
|
||||
echo_note "Which bar do you want to use?"
|
||||
echo_note "[g]Bar, [H]yprpanel, [W]aybar"
|
||||
read -r ask_bar </dev/tty
|
||||
case "$ask_bar" in
|
||||
g | G | gbar | gBar)
|
||||
BarOfChoise="gBar"
|
||||
;;
|
||||
h | H | Hyprpanel | hyprpanel | hypr | Hypr)
|
||||
BarOfChoise="ags-hyprpanel-git"
|
||||
;;
|
||||
w | W | waybar | Waybar)
|
||||
BarOfChoise="waybar"
|
||||
;;
|
||||
*)
|
||||
echo_error "You did not select something useful! Try again!"
|
||||
ask_bar
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
ask_dotfiles() {
|
||||
if [ ! -d "$HOME/.config/hypr" ]; then
|
||||
echo_note "Do you want to install the custom pika hyprdots?"
|
||||
echo_note "[Y/n]"
|
||||
read -r ask_dotfiles </dev/tty
|
||||
case "$ask_dotfiles" in
|
||||
n | N)
|
||||
echo_info "Finishing config now"
|
||||
;;
|
||||
*)
|
||||
if ! command_exists git; then
|
||||
_install git
|
||||
fi
|
||||
|
||||
if [ ! -d "$HOME/git" ]; then
|
||||
mkdir -p "$HOME/git"
|
||||
fi
|
||||
|
||||
git clone --recursive --depth=1 https://git.k4li.de/dotfiles/hyprdots.git "$HOME/git/hyprdots"
|
||||
cd "$HOME/git/hyprdots" || echo_error "Directory of choise doesnt work.."
|
||||
make
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
# ╭────────────────────────────────────╮
|
||||
# │ insert your scripts/functions here │
|
||||
# ╰────────────────────────────────────╯
|
||||
|
||||
# ───────────────────────────────< main function to execute >───────────────────────────────
|
||||
main() {
|
||||
if check_root; then
|
||||
if check_aur; then
|
||||
get_packager
|
||||
fi
|
||||
else
|
||||
echo_error "Something went terribly wrong!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ask_bar
|
||||
check_deps
|
||||
ask_dotfiles
|
||||
}
|
||||
|
||||
if ! command_exists hyprland; then
|
||||
main
|
||||
else
|
||||
echo_warning "Hyprland is already installed!"
|
||||
fi
|
157
setup/debian-major.sh
Normal file
157
setup/debian-major.sh
Normal file
|
@ -0,0 +1,157 @@
|
|||
#!/bin/sh
|
||||
|
||||
# ╭───────────────╮
|
||||
# │ env functions │
|
||||
# ╰───────────────╯
|
||||
# ───────────────────────────────────< ANSI color codes >───────────────────────────────────
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
YELLOW='\033[0;33m'
|
||||
LIGHT_GREEN='\033[0;92m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo_error() {
|
||||
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||
}
|
||||
|
||||
echo_info() {
|
||||
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_warning() {
|
||||
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_note() {
|
||||
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# ─────────────< Check if the user is root and set sudo variable if necessary >─────────────
|
||||
check_root() {
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command_exists sudo; then
|
||||
echo_info "User is not root. Using sudo for privileged operations."
|
||||
_sudo="sudo"
|
||||
else
|
||||
echo_error "No sudo found and you're not root! Can't install packages."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo_info "Root access confirmed."
|
||||
_sudo=""
|
||||
fi
|
||||
}
|
||||
|
||||
# ──────────────────────< Check if the given command exists silently >──────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# ╭────────────────────────────────────╮
|
||||
# │ insert your scripts/functions here │
|
||||
# ╰────────────────────────────────────╯
|
||||
|
||||
full_update_and_upgrade() {
|
||||
if command_exists apt-get; then
|
||||
echo_info "Updating sources.."
|
||||
$_sudo apt-get update || echo_error "Something went wrong, please check your connection and permissions!"
|
||||
$_sudo apt-get upgrade --assume-yes || echo_error "Something went wrong, please check your connection and permissions!"
|
||||
$_sudo apt-get full-upgrade --assume-yes || echo_error "Something went wrong, please check your connection and permissions!"
|
||||
else
|
||||
echo_error "The OS is not suitable for this script!"
|
||||
fi
|
||||
}
|
||||
|
||||
clean_and_full_upgrade() {
|
||||
if command_exists apt-get; then
|
||||
echo_info "Cleaning the environment.."
|
||||
$_sudo apt-get clean --assume-yes
|
||||
full_update_and_upgrade
|
||||
else
|
||||
echo_error "The OS is not suitable for this script!"
|
||||
fi
|
||||
}
|
||||
|
||||
post_clean() {
|
||||
if command_exists apt-get; then
|
||||
$_sudo apt-get autoremove --assume-yes
|
||||
else
|
||||
echo_error "The OS is not suitable for this script!"
|
||||
fi
|
||||
}
|
||||
|
||||
detect_version() {
|
||||
. /etc/os-release
|
||||
case "$VERSION_CODENAME" in
|
||||
bookworm)
|
||||
cur_os="bookworm"
|
||||
tar_os="trixie"
|
||||
;;
|
||||
buster)
|
||||
cur_os="buster"
|
||||
tar_os="bullseye"
|
||||
;;
|
||||
bullseye)
|
||||
cur_os="bullseye"
|
||||
tar_os="bookworm"
|
||||
;;
|
||||
*)
|
||||
echo_error "$VERSION_CODENAME is either not a debian version, or just simply not defined"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
update_sources() {
|
||||
# Create backup directory if it doesn't exist
|
||||
BACKUP_DIR="/var/backups/apt-sources"
|
||||
echo_info "Creating backup directory at $BACKUP_DIR..."
|
||||
$_sudo mkdir -p "$BACKUP_DIR"
|
||||
|
||||
echo_info "Backing up current sources lists..."
|
||||
$_sudo cp /etc/apt/sources.list "$BACKUP_DIR/sources.list.backup.$(date +%Y%m%d)"
|
||||
|
||||
echo_info "Updating sources from Bookworm to Trixie..."
|
||||
# Replace bookworm with trixie in main sources.list
|
||||
$_sudo sed -i "s/$cur_os/$tar_os/g" /etc/apt/sources.list
|
||||
|
||||
# Check and update any additional source files in sources.list.d
|
||||
if [ -d "/etc/apt/sources.list.d" ]; then
|
||||
for sourcefile in /etc/apt/sources.list.d/*.list; do
|
||||
if [ -f "$sourcefile" ]; then
|
||||
filename=$(basename "$sourcefile")
|
||||
echo_info "Backing up and updating $sourcefile..."
|
||||
$_sudo cp "$sourcefile" "$BACKUP_DIR/${filename}.backup.$(date +%Y%m%d)"
|
||||
$_sudo sed -i "s/$cur_os/$tar_os/g" "$sourcefile"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo_note "Sources have been updated to Trixie. Please run a full system update."
|
||||
echo_warning "Make sure to review the changes and ensure all repositories are compatible with Trixie!"
|
||||
echo_info "Backups stored in $BACKUP_DIR"
|
||||
echo ""
|
||||
__lsb_release__="$(lsb_release -a)"
|
||||
echo_info "$__lsb_release__"
|
||||
}
|
||||
|
||||
# ───────────────────────────────< main function to execute >───────────────────────────────
|
||||
main() {
|
||||
if check_root; then
|
||||
full_update_and_upgrade
|
||||
if detect_version; then
|
||||
update_sources
|
||||
fi
|
||||
clean_and_full_upgrade
|
||||
post_clean
|
||||
else
|
||||
echo_error "Something went terribly wrong!"
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
110
setup/docker-network.sh
Normal file
110
setup/docker-network.sh
Normal file
|
@ -0,0 +1,110 @@
|
|||
#!/bin/sh
|
||||
|
||||
# ╭───────────────╮
|
||||
# │ env functions │
|
||||
# ╰───────────────╯
|
||||
# ───────────────────────────────────< ANSI color codes >───────────────────────────────────
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
YELLOW='\033[0;33m'
|
||||
LIGHT_GREEN='\033[0;92m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo_error() {
|
||||
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||
}
|
||||
|
||||
echo_info() {
|
||||
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_warning() {
|
||||
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_note() {
|
||||
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# ─────────────< Check if the user is root and set sudo variable if necessary >─────────────
|
||||
check_root() {
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command_exists sudo; then
|
||||
echo_info "User is not root. Using sudo for privileged operations."
|
||||
_sudo="sudo"
|
||||
else
|
||||
echo_error "No sudo found and you're not root! Can't install packages."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo_info "Root access confirmed."
|
||||
_sudo=""
|
||||
fi
|
||||
}
|
||||
|
||||
# ──────────────────────< Check if the given command exists silently >──────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# ╭────────────────────────────────────╮
|
||||
# │ insert your scripts/functions here │
|
||||
# ╰────────────────────────────────────╯
|
||||
|
||||
# Function to initialize or update the Docker daemon configuration
|
||||
dnetwork_init() {
|
||||
if ! command_exists docker; then
|
||||
echo_error "No docker was found! Cannot continue!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
CONFIG_FILE="/etc/docker/daemon.json"
|
||||
|
||||
echo_info "Checking Docker daemon configuration..."
|
||||
|
||||
# Check if the configuration file exists
|
||||
if [ ! -f "$CONFIG_FILE" ]; then
|
||||
echo_warning "Docker daemon configuration file not found. Creating it."
|
||||
${_sudo} mkdir -p /etc/docker
|
||||
${_sudo} tee "$CONFIG_FILE" >/dev/null <<EOF
|
||||
{
|
||||
"default-address-pools": [
|
||||
{
|
||||
"base": "10.0.0.0/8",
|
||||
"size": 24
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
echo_note "Configuration file created with default network."
|
||||
else
|
||||
# Check if the "default-address-pools" entry exists
|
||||
if grep -q '"default-address-pools"' "$CONFIG_FILE"; then
|
||||
echo_note "Docker daemon configuration already contains 'default-address-pools'. No changes made."
|
||||
else
|
||||
echo_warning "Adding 'default-address-pools' to existing configuration."
|
||||
${_sudo} jq '. + {"default-address-pools": [{"base": "10.0.0.0/8", "size": 24}]}' "$CONFIG_FILE" | ${_sudo} tee "$CONFIG_FILE.tmp" >/dev/null
|
||||
${_sudo} mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
|
||||
echo_note "Default address pool added to configuration."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo_info "Restarting Docker to apply changes..."
|
||||
${_sudo} systemctl restart docker && echo_note "Docker restarted successfully." || echo_error "Failed to restart Docker."
|
||||
}
|
||||
|
||||
# ───────────────────────────────< main function to execute >───────────────────────────────
|
||||
main() {
|
||||
if check_root; then
|
||||
dnetwork_init
|
||||
else
|
||||
echo_error "Something went terribly wrong!"
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
369
setup/postinstall.sh
Executable file
369
setup/postinstall.sh
Executable file
|
@ -0,0 +1,369 @@
|
|||
{
|
||||
#!/bin/sh -e
|
||||
|
||||
# ╭──────────────╮
|
||||
# │ dependencies │
|
||||
# ╰──────────────╯
|
||||
deps="
|
||||
7zip
|
||||
bc
|
||||
btop
|
||||
exa
|
||||
fzf
|
||||
gawk
|
||||
gdu
|
||||
git
|
||||
make
|
||||
pv
|
||||
ripgrep
|
||||
rsync
|
||||
stow
|
||||
tmux
|
||||
trash-cli
|
||||
unzip
|
||||
zoxide
|
||||
zsh
|
||||
"
|
||||
|
||||
# ╭─────────────╮
|
||||
# │ ENVIRONMENT │
|
||||
# ╰─────────────╯
|
||||
# ANSI color codes
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
YELLOW='\033[0;33m'
|
||||
LIGHT_GREEN='\033[0;92m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Initialize storage variables
|
||||
_STORED_ERRORS=""
|
||||
_STORED_WARNINGS=""
|
||||
_STORED_INFOS=""
|
||||
_STORED_NOTES=""
|
||||
|
||||
# Modified echo functions that store and display messages
|
||||
echo_error() {
|
||||
message="${RED}$1${NC}\n"
|
||||
printf "$message" >&2
|
||||
_STORED_ERRORS="${_STORED_ERRORS}${message}"
|
||||
}
|
||||
|
||||
echo_warning() {
|
||||
message="${YELLOW}$1${NC}\n"
|
||||
printf "$message"
|
||||
_STORED_WARNINGS="${_STORED_WARNINGS}${message}"
|
||||
}
|
||||
|
||||
echo_info() {
|
||||
message="${CYAN}$1${NC}\n"
|
||||
printf "$message"
|
||||
_STORED_INFOS="${_STORED_INFOS}${message}"
|
||||
}
|
||||
|
||||
echo_note() {
|
||||
message="${LIGHT_GREEN}$1${NC}\n"
|
||||
printf "$message"
|
||||
_STORED_NOTES="${_STORED_NOTES}${message}"
|
||||
}
|
||||
|
||||
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────< get packager >─────────────────────────────────────
|
||||
checkPkg() {
|
||||
for pkg in apt-get dnf pacman apk zypper; do
|
||||
if command_exists $pkg; then
|
||||
printf "Using ${RED}${pkg}${NC} method.."
|
||||
pkger="$pkg"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# ─────────────────────────────────< check for root/sudo >───────────────────────────────
|
||||
checkRoot() {
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command_exists sudo; then
|
||||
echo_info "User is not root. Using sudo for privileged operations."
|
||||
_sudo="sudo -E"
|
||||
else
|
||||
echo_error "No sudo found and you're not root! Can't install packages."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo_info "Root access confirmed."
|
||||
_sudo=""
|
||||
fi
|
||||
}
|
||||
|
||||
# ╭─────╮
|
||||
# │ apt │
|
||||
# ╰─────╯
|
||||
aptCommentCDinSources() {
|
||||
# Path to sources.list
|
||||
sources_file="/etc/apt/sources.list"
|
||||
|
||||
# Check if file exists
|
||||
if [ ! -f "$sources_file" ]; then
|
||||
echo_error "Error: $sources_file not found"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Comment out CD-ROM entries using sudo
|
||||
$_sudo sed -i 's/^[[:space:]]*deb[[:space:]]\+cdrom:/#&/' "$sources_file"
|
||||
echo_info "CD-ROM entries have been commented out in $sources_file"
|
||||
}
|
||||
|
||||
aptBase() {
|
||||
aptCommentCDinSources
|
||||
echo_info "Updating sources.."
|
||||
if ! $_sudo apt-get update; then
|
||||
echo_error "Maybe you need a proxy?"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command_exists sudo; then
|
||||
echo_note "Installing sudo"
|
||||
apt-get install sudo --assume-yes
|
||||
fi
|
||||
|
||||
echo_note "Installing base packages: $deps"
|
||||
|
||||
for _deps in $deps; do
|
||||
if ! command_exists "$_deps"; then
|
||||
echo_info "Installing $_deps.."
|
||||
if ! $_sudo apt-get install "$_deps" --assume-yes; then
|
||||
echo_error "$_deps - failed to install!"
|
||||
fi
|
||||
else
|
||||
echo_note "$_deps - was already installed!"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
aptOptimize() {
|
||||
if command_exists nala; then
|
||||
echo_info "Nala is already present, fetching mirros now! (This might take a minute or two, depending on your internet speed)"
|
||||
$_sudo nala fetch --auto --assume-yes --https-only
|
||||
else
|
||||
echo_note "Nala is not installed on the system, do you want to install it now? (Y/n): "
|
||||
read -r inst_nala </dev/tty
|
||||
case "$inst_nala" in
|
||||
N | n)
|
||||
echo_warning "All right, continue without nala!"
|
||||
;;
|
||||
*)
|
||||
echo_note "Installing nala.."
|
||||
$_sudo apt-get install nala --assume-yes &&
|
||||
echo_info "Fetching best mirrors"
|
||||
$_sudo nala fetch --auto --assume-yes --https-only
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
# ╭────────╮
|
||||
# │ pacman │
|
||||
# ╰────────╯
|
||||
|
||||
pacmanBase() {
|
||||
if command_exists nano; then
|
||||
if command_exists vim; then
|
||||
echo_note "Removing nano, vim is backup"
|
||||
$_sudo pacman -R nano --noconfirm
|
||||
else
|
||||
echo_note "Removing nano and installing vim as a backup"
|
||||
$_sudo pacman -S vim --noconfirm
|
||||
fi
|
||||
fi
|
||||
|
||||
$_sudo pacman -S base-devel --noconfirm
|
||||
|
||||
echo_note "Installing base packages: $deps"
|
||||
|
||||
for _deps in $deps; do
|
||||
if ! command_exists "$_deps"; then
|
||||
if ! $_sudo pacman -S "$_deps" --noconfirm; then
|
||||
echo_error "$_deps - failed to install"
|
||||
fi
|
||||
else
|
||||
echo_note "$_deps - was already installed"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# ╭─────╮
|
||||
# │ dnf │
|
||||
# ╰─────╯
|
||||
dnfBase() {
|
||||
echo_info "Updating sources.."
|
||||
if ! $_sudo dnf update; then
|
||||
echo_error "Maybe you need a proxy?"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo_note "Installing base packages: $deps"
|
||||
|
||||
for _deps in $deps; do
|
||||
if ! command_exists "$_deps"; then
|
||||
echo_info "Installing $_deps.."
|
||||
if ! $_sudo dnf install "$_deps"; then
|
||||
echo_error "$_deps - failed to install!"
|
||||
fi
|
||||
else
|
||||
echo_note "$_deps - was already installed!"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# ╭────────╮
|
||||
# │ zypper │
|
||||
# ╰────────╯
|
||||
zypperBase() {
|
||||
echo_info "Updating sources.."
|
||||
if ! $_sudo zypper ref; then
|
||||
echo_error "Maybe you need a proxy?"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo_note "Installing base packages: $deps"
|
||||
|
||||
for _deps in $deps; do
|
||||
if ! command_exists "$_deps"; then
|
||||
echo_info "Installing $_deps.."
|
||||
if ! $_sudo zypper in "$_deps"; then
|
||||
echo_error "$_deps - failed to install!"
|
||||
fi
|
||||
else
|
||||
echo_note "$_deps - was already installed!"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# ╭───────────╮
|
||||
# │ FUNCTIONS │
|
||||
# ╰───────────╯
|
||||
|
||||
envCheck() {
|
||||
checkRoot
|
||||
checkPkg
|
||||
}
|
||||
|
||||
install_base() {
|
||||
envCheck
|
||||
|
||||
echo_info "Installing base packages..."
|
||||
case "$pkger" in
|
||||
apt)
|
||||
echo_info "apt"
|
||||
aptBase
|
||||
;;
|
||||
dnf)
|
||||
echo_info "dnf"
|
||||
dnfBase
|
||||
;;
|
||||
pacman)
|
||||
echo_info "pacman"
|
||||
pacmanBase
|
||||
;;
|
||||
zypper)
|
||||
echo_info "zypper"
|
||||
zypperBase
|
||||
;;
|
||||
apk) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
optimize_os() {
|
||||
envCheck
|
||||
|
||||
echo_info "Running OS optimizations..."
|
||||
case "$pkg" in
|
||||
apt)
|
||||
aptOptimize
|
||||
;;
|
||||
dnf)
|
||||
echo_warning "Currently, there are no optimizations for your linux distribution."
|
||||
;;
|
||||
pacman)
|
||||
echo_warning "Currently, there are no optimizations for your linux distribution."
|
||||
;;
|
||||
zypper)
|
||||
echo_warning "Currently, there are no optimizations for your linux distribution."
|
||||
;;
|
||||
apk)
|
||||
echo_warning "Currently, there are no optimizations for your linux distribution."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# setup_vpn() {
|
||||
# echo_info "Setting up VPN..."
|
||||
# # Add VPN setup logic here
|
||||
# }
|
||||
|
||||
# ╭──────────╮
|
||||
# │ ARGUMENTS │
|
||||
# ╰──────────╯
|
||||
show_help() {
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo " --install-base Install base packages"
|
||||
echo " --optimize-os Optimize the OS"
|
||||
echo " --all Uses all flags together"
|
||||
# echo " --setup-vpn Setup VPN"
|
||||
echo " --help Show this help message"
|
||||
echo ""
|
||||
echo "If you 'curl | sh' this script, then replace 'sh' with 'sh -s -- [OPTIONS]'"
|
||||
printf "So for example ${CYAN} curl https://path/to/postinstall.sh | sh -s -- --all ${NC}"
|
||||
}
|
||||
|
||||
# Default to no options
|
||||
INSTALL_BASE=false
|
||||
OPTIMIZE_OS=false
|
||||
# SETUP_VPN=false
|
||||
|
||||
# Parse command-line arguments
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--install-base)
|
||||
INSTALL_BASE=true
|
||||
;;
|
||||
--optimize-os)
|
||||
OPTIMIZE_OS=true
|
||||
;;
|
||||
--all)
|
||||
OPTIMIZE_OS=true
|
||||
INSTALL_BASE=true
|
||||
;;
|
||||
# --setup-vpn)
|
||||
# SETUP_VPN=true
|
||||
# ;;
|
||||
--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo_error "Unknown option: $1"
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Execute selected options
|
||||
$OPTIMIZE_OS && optimize_os
|
||||
$INSTALL_BASE && install_base
|
||||
# $SETUP_VPN && setup_vpn
|
||||
|
||||
# If no options were provided, show help
|
||||
if [ "$INSTALL_BASE" = false ] && [ "$OPTIMIZE_OS" = false ]; then # && [ "$SETUP_VPN" = false ]; then
|
||||
show_help
|
||||
exit 1
|
||||
fi
|
||||
}
|
143
setup/realmjoin.sh
Normal file
143
setup/realmjoin.sh
Normal file
|
@ -0,0 +1,143 @@
|
|||
#!/bin/sh -e
|
||||
# ╭───────────────╮
|
||||
# │ env functions │
|
||||
# ╰───────────────╯
|
||||
|
||||
# ───────────────────────────────────< ANSI color codes >───────────────────────────────────
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
YELLOW='\033[0;33m'
|
||||
LIGHT_GREEN='\033[0;92m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo_error() {
|
||||
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||
}
|
||||
|
||||
echo_info() {
|
||||
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_warning() {
|
||||
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_note() {
|
||||
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
# ────────────────< function to check if the given command exists silently >────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# ─────────────< Check if the user is root and set sudo variable if necessary >─────────────
|
||||
check_root() {
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command_exists sudo; then
|
||||
echo_info "User is not root. Using sudo for privileged operations."
|
||||
_sudo="sudo"
|
||||
else
|
||||
echo_error "No sudo found and you're not root! Can't install packages."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo_info "Root access confirmed."
|
||||
_sudo=""
|
||||
fi
|
||||
}
|
||||
|
||||
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||
get_packager() {
|
||||
if [ -e /etc/os-release ]; then
|
||||
echo_info "Detecting distribution..."
|
||||
. /etc/os-release
|
||||
|
||||
ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]')
|
||||
ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
case "$ID" in
|
||||
ubuntu | pop) _install() { $_sudo apt-get install --assume-yes "$@"; } ;;
|
||||
debian) _install() { $_sudo apt-get install --assume-yes "$@"; } ;;
|
||||
fedora) _install() { $_sudo dnf install -y "$@"; } ;;
|
||||
alpine) _install() { $_sudo apk add "$@"; } ;;
|
||||
arch | manjaro | garuda | endeavour) _install() { $_sudo pacman -S --noconfirm "$@"; } ;;
|
||||
opensuse*) _install() { $_sudo zypper in -y "$@"; } ;;
|
||||
*)
|
||||
if echo "$ID_LIKE" | grep -q "debian"; then
|
||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
||||
elif echo "$ID_LIKE" | grep -q "ubuntu"; then
|
||||
_install() { $_sudo apt-get install --assume-yes "$@"; }
|
||||
elif echo "$ID_LIKE" | grep -q "arch"; then
|
||||
_install() { $_sudo pacman -S --noconfirm "$@"; }
|
||||
elif echo "$ID_LIKE" | grep -q "fedora"; then
|
||||
_install() { $_sudo dnf install -y "$@"; }
|
||||
elif echo "$ID_LIKE" | grep -q "suse"; then
|
||||
_install() { $_sudo zypper in -y "$@"; }
|
||||
else
|
||||
echo_error "Unsupported distribution: $ID"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo_error "Unable to detect distribution. /etc/os-release not found."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ──────────────────────────< define your functions/script here >────────────────────────
|
||||
dependencies() {
|
||||
_deps="krb5-user realmd sssd-tools sssd libnss-sss libpam-sss adcli"
|
||||
|
||||
for dependency in $_deps; do
|
||||
if ! command_exists "$dependency"; then
|
||||
echo_info "Installing $dependency.."
|
||||
sleep 0.3
|
||||
if ! _install "$dependency"; then
|
||||
echo_error "$dependency - could not be installed!"
|
||||
else
|
||||
echo_note "$dependency - was installed successfully!"
|
||||
fi
|
||||
else
|
||||
echo_note "$dependency is already installed."
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
_join() {
|
||||
domain="swu.dom"
|
||||
echo_note "You are trying to connect to $domain.."
|
||||
sleep 1
|
||||
echo_note "Please enter an administrator user like this: [example-user]"
|
||||
printf "Admin User: " >&2
|
||||
read -r _admin </dev/tty
|
||||
|
||||
if [ -n "$_admin" ]; then
|
||||
if realm join -v -U "$_admin@$domain" "$domain"; then
|
||||
echo_note "Successfully joined domain $domain."
|
||||
else
|
||||
echo_error "Failed to join domain $domain."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo_error "Administrator username cannot be empty."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ───────────────────────────────< define the main function >───────────────────────────────
|
||||
main() {
|
||||
if check_root; then
|
||||
get_packager &&
|
||||
dependencies &&
|
||||
_join
|
||||
else
|
||||
echo_error "Root privileges are required. Exiting."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ──────────────────────────────< execute the main function >────────────────────────────
|
||||
main
|
86
setup/unattendet-upgrades.sh
Normal file
86
setup/unattendet-upgrades.sh
Normal file
|
@ -0,0 +1,86 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
LOG_FILE="/var/log/unattended-upgrades-check.log"
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
YELLOW='\033[0;33m'
|
||||
LIGHT_GREEN='\033[0;92m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo_error() {
|
||||
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||
}
|
||||
|
||||
echo_info() {
|
||||
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_warning() {
|
||||
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_note() {
|
||||
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
run_checks() {
|
||||
echo_info "Checking if unattended-upgrades is active..."
|
||||
|
||||
if command_exists unattended-upgrades; then
|
||||
# if dpkg-query -W -f='${Status}' unattended-upgrades 2>/dev/null | grep -q "install ok installed"; then
|
||||
echo_note "unattended-upgrades is already installed."
|
||||
else
|
||||
echo_warning "unattended-upgrades is not installed. Attempting to install..."
|
||||
if command_exists apt-get; then
|
||||
if apt-get update && apt-get install --assume-yes unattended-upgrades; then
|
||||
echo_note "unattended-upgrades successfully installed."
|
||||
else
|
||||
echo_error "Failed to install unattended-upgrades. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo_error "apt is not available on this system. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Enable unattended-upgrades
|
||||
UNATTENDED_UPGRADES_FILE="/etc/apt/apt.conf.d/50unattended-upgrades"
|
||||
if [ -f "$UNATTENDED_UPGRADES_FILE" ]; then
|
||||
echo_info "Configuring unattended upgrades in $UNATTENDED_UPGRADES_FILE"
|
||||
# Add or modify configurations as needed
|
||||
# Example: $_sudo sed -i 's/old_value/new_value/' "$UNATTENDED_UPGRADES_FILE"
|
||||
else
|
||||
echo_error "Unattended upgrades file not found!"
|
||||
fi
|
||||
}
|
||||
|
||||
run_setup() {
|
||||
if command_exists unattended-upgrades; then
|
||||
systemctl enable --now unattended-upgrades || echo_error "Something went wrong! Could not setup the service/autostart"
|
||||
fi
|
||||
}
|
||||
|
||||
# Main script
|
||||
main() {
|
||||
echo_info "Starting unattended-upgrades check script..."
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo_error "This script must be run as root. Please run with sudo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run_checks
|
||||
|
||||
run_setup && echo_note "Script completed successfully!"
|
||||
}
|
||||
|
||||
main
|
157
setup/updates.sh
Executable file
157
setup/updates.sh
Executable file
|
@ -0,0 +1,157 @@
|
|||
#!/bin/sh
|
||||
|
||||
# ─< ANSI color codes >───────────────────────────────────────────────────────────────────
|
||||
RED='\033[0;31m'
|
||||
CYAN='\033[0;36m'
|
||||
YELLOW='\033[0;33m'
|
||||
LIGHT_GREEN='\033[0;92m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo_error() {
|
||||
printf "${BOLD}${RED}ERROR: ${NC}${RED}%s${NC}\n" "$1" >&2
|
||||
}
|
||||
|
||||
echo_info() {
|
||||
printf "${BOLD}${CYAN}INFO: ${NC}${CYAN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_warning() {
|
||||
printf "${BOLD}${YELLOW}WARNING: ${NC}${YELLOW}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
echo_note() {
|
||||
printf "${BOLD}${LIGHT_GREEN}NOTE: ${NC}${LIGHT_GREEN}%s${NC}\n" "$1"
|
||||
}
|
||||
|
||||
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# ─< Check if the user is root and set sudo variable if necessary >───────────────────────
|
||||
check_root() {
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
if command_exists sudo; then
|
||||
echo_info "User is not root. Using sudo for privileged operations."
|
||||
_sudo="sudo"
|
||||
else
|
||||
echo_error "No sudo found and you're not root! Can't install packages."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo_info "Root access confirmed."
|
||||
_sudo=""
|
||||
fi
|
||||
}
|
||||
|
||||
# ─< Distribution detection and installation >────────────────────────────────────────
|
||||
get_packager() {
|
||||
if [ -e /etc/os-release ]; then
|
||||
echo_info "Detecting distribution..."
|
||||
. /etc/os-release
|
||||
|
||||
# ─< Convert $ID and $ID_LIKE to lowercase >──────────────────────────────────────────────
|
||||
ID=$(printf "%s" "$ID" | tr '[:upper:]' '[:lower:]')
|
||||
ID_LIKE=$(printf "%s" "$ID_LIKE" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
case "$ID" in
|
||||
ubuntu | pop) packager="apt" ;;
|
||||
debian) packager="apt" ;;
|
||||
fedora) packager="dnf" ;;
|
||||
alpine) packager="apk" ;;
|
||||
arch | manjaro | garuda | endeavour) packager="pacman" ;;
|
||||
opensuse*) packager="zypper" ;;
|
||||
*)
|
||||
if [ "${ID_LIKE#*debian}" != "$ID_LIKE" ]; then
|
||||
packager="apt"
|
||||
elif [ "${ID_LIKE#*ubuntu}" != "$ID_LIKE" ]; then
|
||||
packager="apt"
|
||||
elif [ "${ID_LIKE#*arch}" != "$ID_LIKE" ]; then
|
||||
packager="pacman"
|
||||
elif [ "${ID_LIKE#*fedora}" != "$ID_LIKE" ]; then
|
||||
packager="dnf"
|
||||
elif [ "${ID_LIKE#*suse}" != "$ID_LIKE" ]; then
|
||||
packager="zypper"
|
||||
else
|
||||
echo_error "Unsupported distribution: $ID"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo_error "Unable to detect distribution. /etc/os-release not found."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
_update() {
|
||||
case "$packager" in
|
||||
apt)
|
||||
if command_exists nala; then
|
||||
echo_note "Using nala to update packages.. Please be patient.."
|
||||
sleep 1
|
||||
$_sudo nala update
|
||||
$_sudo nala upgrade -y
|
||||
$_sudo nala autoremove -y
|
||||
$_sudo apt-get autoclean -y
|
||||
else
|
||||
echo_note "Using nala to update packages.. Please be patient.."
|
||||
sleep 1
|
||||
$_sudo apt-get update
|
||||
$_sudo apt-get upgrade -y
|
||||
$_sudo apt-get autoremove -y
|
||||
$_sudo apt-get autoclean -y
|
||||
fi
|
||||
;;
|
||||
dnf)
|
||||
echo_note "Using dnf to update packages.. Please be patient.."
|
||||
sleep 1
|
||||
$_sudo dnf update
|
||||
;;
|
||||
pacman)
|
||||
echo_note "Using pacman to update packages.. Please be patient.."
|
||||
sleep 1
|
||||
$_sudo pacman -Syu --noconfirm
|
||||
;;
|
||||
apk)
|
||||
echo_note "Using apk to update packages.. Please be patient.."
|
||||
sleep 1
|
||||
$_sudo apk update
|
||||
$_sudo apk upgrade
|
||||
;;
|
||||
zypper)
|
||||
echo_note "Using zypper to update packages.. Please be patient.."
|
||||
sleep 1
|
||||
$_sudo zypper dup
|
||||
;;
|
||||
*)
|
||||
if [ -z "$packager" ]; then
|
||||
echo_error "The packager variable is not declared.."
|
||||
else
|
||||
echo_error "$packager is not a known packager.."
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_flatpak() {
|
||||
if command_exists flatpak; then
|
||||
echo_info "Trying to update flatpaks.."
|
||||
sleep 1
|
||||
flatpak update
|
||||
else
|
||||
echo_note "No flatpaks found"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
check_root
|
||||
sleep 1
|
||||
if get_packager; then
|
||||
_update
|
||||
_flatpak
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
Loading…
Add table
Add a link
Reference in a new issue