You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB

## library functions
function install_pacapt {
if [[ $DISTRO == 'arch' ]]; then
PACMAN_CMD=$(which pacman)
echo 'pacman natively detected!'
else
if [[ ! -f $HOME/.local/bin/pacman ]]; then
[[ $DISTRO == 'debian' ]] && apt install -y apt-utils
mkdir -p $HOME/.local/bin
curl -sLo $HOME/.local/bin/pacman https://github.com/icy/pacapt/raw/ng/pacapt
chmod 755 $HOME/.local/bin/pacman
echo "pacapt/pacman ($PACMAN_CMD) successfully installed!"
fi
PACMAN_CMD="$HOME/.local/bin/pacman"
fi
}
function install_idem_packages {
if ! pacman -Qi $1 &>/dev/null; then
sudo $HOME/.local/bin/pacman -S --noconfirm $1 >/dev/null
echo "$2 installed successfully"
else
echo "$2 already installed!"
fi
}
function install_packages {
install_idem_packages "${DISTRO_PACKAGES[_]}" "generic packages"
[ -v "DISTRO_PACKAGES[${DISTRO}]" ] && install_idem_packages "${DISTRO_PACKAGES[${DISTRO}]}" "distro specific packages: [$DISTRO]"
true
}
function postgres_newdb {
if ! (sudo -u postgres -- psql --csv -tc "SELECT 1 as found FROM pg_roles WHERE rolname = '$DB_USER'" | grep -q ^1$); then
sudo -iu postgres psql -c "CREATE USER $DB_USER WITH PASSWORD '$DB_USER'"
sudo -iu postgres psql -c "ALTER USER $DB_USER WITH SUPERUSER"
fi
}