deployment-dcdn/bin/functions.sh

27 lines
558 B
Bash
Raw Normal View History

2024-05-02 23:54:06 +02:00
#!/bin/bash
install_pkg() {
pkg="$1"
if ! dpkg -s "$pkg" >/dev/null 2>&1; then
apt update && apt install -y "$pkg"
echo -e "${PURPLE}${BOLD}${pkg} installed${RESET}"
fi
}
get_username() {
if [[ -z "$username" ]]; then
username=$(getent passwd 1001 | cut -d: -f1)
fi
}
get_ip() {
if [[ -z "$ip" ]]; then
ip=$(hostname -I | cut -d' ' -f1)
fi
}
get_ssh_port() {
if [[ -z "$ssh_port" ]]; then
ssh_port=$(cat /etc/ssh/sshd_config.d/custom.conf | grep "Port " | sed 's/^Port //')
fi
}