diff --git a/Makefile b/Makefile index ecee427..0f13438 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Autogenerated at 14.04.2023 12:03 using ./gen-makefile +# Autogenerated at 18.04.2023 15:28 using ./gen-makefile .DEFAULT_GOAL := help #=============================================== @@ -109,7 +109,7 @@ omz-clean: omz-fancy: @./install/omz-fancy -##openvpn: Install openvpn v2.5.8 (src) +##openvpn: Install openvpn v2.6.3 (src) openvpn: @./install/openvpn diff --git a/helpers b/helpers index de317a7..059dea5 100644 --- a/helpers +++ b/helpers @@ -4,6 +4,40 @@ installed() { command -v "$1" >/dev/null 2>&1 } +installed2() { + dpkg --list | grep -qw "ii $1" +} + +apt_install() { + sudo apt install -y --autoremove "$*" +} + +require() { + sw=() + for package in "$@"; do + if ! installed "$package" && ! installed2 "$package"; then + sw+=("$package") + fi + done + if [ ${#sw[@]} -gt 0 ]; then + info "This packages will be installed in your system:\n${sw[*]}" + apt_install "${sw[*]}" + [ $? -gt 0 ] && die "installation cancelled" 201 + fi +} + +require2() { + sw=() + for package in "$@"; do + if ! installed "$package" && ! installed2 "$package"; then + sw+=("$package") + fi + done + if [ ${#sw[@]} -gt 0 ]; then + die "This packages must be installed in your system:\n${sw[*]}" 200 + fi +} + title() { [ "$1" ] && title="$1" || title="$(grep -m 1 -oP "(?<=^##makedesc:\s).*$" ${BASH_SOURCE[1]})" info @@ -13,20 +47,17 @@ title() { info } -require() { - if ! installed "$1"; then - if [ "$2" ]; then - die "'$1' must to be installed in your system" 200 - else - info "Installing '$1' because it is required to continue" - sudo apt install "$1" - [ $? -gt 0 ] && die "installation cancelled" 201 - fi - fi +unpak_targz() { + require tar + tar -xzf "$1" -C "$2" +} + +symlink() { + ln -sf "$1" "$2" } download() { - require wget 1 + require wget wget "$1" -O "$2" } @@ -35,6 +66,11 @@ clone() { git clone $* } +clone_quick() { + require git + git clone $* --depth=1 --single-branch +} + abspath() { echo $(realpath -q "${1/#\~/$HOME}") } @@ -159,7 +195,6 @@ warn() { error() { print "${BOLD}${BLRED}${FWHITE}${IERROR} Error: ${BRESET}${FLRED} $1 " >&2 - # print_stacktrace } fatal() { @@ -168,19 +203,8 @@ fatal() { } die() { - error "$1" - [ "$2" ] && exit $2 || exit 100 -} - -die_fatal() { - fatal "$1" - [ "$2" ] && exit $2 || exit 100 -} - -die_help() { - error "$1" - [ "$2" ] && is_function "$2".help && $2.help - [ "$3" ] && exit $3 || exit 100 + error "${1:-halted}" + exit ${2:-100} } print_stacktrace() { diff --git a/install/jbmono b/install/jbmono index fce07ff..b0f4173 100755 --- a/install/jbmono +++ b/install/jbmono @@ -5,10 +5,10 @@ source `dirname $0`/../helpers || exit 255 # https://www.jetbrains.com/lp/mono/#how-to-install title + require unzip mkdir -p "$HOME/install/jbmono" "$HOME/.local/share/fonts/" - download "https://download.jetbrains.com/fonts/JetBrainsMono-2.304.zip" "$HOME/install/jbmono.zip" && \ unzip -oj "$HOME/install/jbmono.zip" "fonts/ttf/*.ttf" -d "$HOME/.local/share/fonts/" && \ fc-cache -vf "$HOME/.local/share/fonts/" diff --git a/install/kde-backports b/install/kde-backports index a5401a4..57687e1 100755 --- a/install/kde-backports +++ b/install/kde-backports @@ -1,14 +1,9 @@ #!/bin/bash ##makedesc: Install KDE Backports +source `dirname $0`/../helpers || exit 255 -echo -echo "===============================================" -echo "Installing KDE Backports..." -echo "===============================================" -echo +title -sudo add-apt-repository -y ppa:kubuntu-ppa/backports -# sudo add-apt-repository -y ppa:kubuntu-ppa/backports-extra -sudo apt update -# sudo pkcon update -sudo apt full-upgrade +sudo add-apt-repository -y ppa:kubuntu-ppa/backports && \ + sudo apt update && \ + sudo apt full-upgrade diff --git a/install/openvpn b/install/openvpn index 8f51da2..f52a536 100755 --- a/install/openvpn +++ b/install/openvpn @@ -1,37 +1,31 @@ #!/bin/bash -##makedesc: Install openvpn v2.5.8 (src) +##makedesc: Install openvpn v2.6.3 (src) +source `dirname $0`/../helpers || exit 255 # https://openvpn.net/community-downloads/ # https://openvpn.net/community-resources/installing-openvpn/ -[ $1 ] && OVPNVER="$1" || OVPNVER='2.5.8' +[ "$1" ] && OVPNVER="$1" || OVPNVER='2.6.3' -echo -echo "===============================================" -echo "Installing openvpn v${OVPNVER} (src)..." -echo "===============================================" -echo +title "Installing openvpn v${OVPNVER} (src)..." -set -ex - -sudo apt install -y \ - libssl-dev \ +require libssl-dev \ liblzo2-dev \ libpam0g-dev mkdir -p "$HOME/install/" -wget "https://swupdate.openvpn.org/community/releases/openvpn-${OVPNVER}.tar.gz" \ - -O "/tmp/openvpn-${OVPNVER}.tar.gz" -tar -xzf "/tmp/openvpn-${OVPNVER}.tar.gz" -C "$HOME/install/" -cd "$HOME/install/openvpn-${OVPNVER}" -sudo ./configure && \ +download "https://swupdate.openvpn.org/community/releases/openvpn-${OVPNVER}.tar.gz" "$HOME/install/openvpn-${OVPNVER}.tar.gz" && \ + unpak_targz "$HOME/install/openvpn-${OVPNVER}.tar.gz" "$HOME/install/" && \ + cd "$HOME/install/openvpn-${OVPNVER}" && \ + sudo ./configure && \ sudo make && \ sudo make install && - sudo apt install -y \ - network-manager-openvpn \ + apt_install network-manager-openvpn \ network-manager-openvpn-gnome -echo -echo "Finish!" -openvpn --version -echo +[ $? = 0 ] && { + echo + success "openvpn installed!" + openvpn --version + echo +} diff --git a/install/papirus b/install/papirus index e631bc7..1e576cb 100755 --- a/install/papirus +++ b/install/papirus @@ -1,34 +1,27 @@ #!/bin/bash ##makedesc: Install papirus-icon-theme (latest) +source `dirname $0`/../helpers || exit 255 -echo -echo "===============================================" -echo "Installing papirus-icon-theme (latest)..." -echo "===============================================" -echo +title -installed() { - command -v "$1" >/dev/null 2>&1 -} +mkdir -p "$HOME/install/papirus-icon-theme" "$HOME/.local/share/icons/" if installed git; then - mkdir -p "$HOME/install/" - git clone https://github.com/PapirusDevelopmentTeam/papirus-icon-theme.git "$HOME/install/papirus-icon-theme" --depth=1 --single-branch + clone_quick https://github.com/PapirusDevelopmentTeam/papirus-icon-theme.git "$HOME/install/" else - ! installed wget && sudo apt install -y wget - mkdir -p "$HOME/install/papirus-icon-theme" - wget https://github.com/PapirusDevelopmentTeam/papirus-icon-theme/archive/refs/heads/master.zip -O "$HOME/install/papirus-icon-theme.zip" - unzip -oq "$HOME/install/papirus-icon-theme.zip" -d "$HOME/install/papirus-icon-theme" - rm -f "$HOME/install/papirus-icon-theme.zip" + download https://github.com/PapirusDevelopmentTeam/papirus-icon-theme/archive/refs/heads/master.zip -O "$HOME/install/papirus-icon-theme.zip" && \ + unzip -oq "$HOME/install/papirus-icon-theme.zip" -d "$HOME/install/papirus-icon-theme" && \ + rm -f "$HOME/install/papirus-icon-theme.zip" fi -mkdir -p "$HOME/.local/share/icons/" -ln -sf "$HOME/install/papirus-icon-theme/Papirus" "$HOME/.local/share/icons/Papirus" -ln -sf "$HOME/install/papirus-icon-theme/Papirus-Dark" "$HOME/.local/share/icons/Papirus-Dark" -ln -sf "$HOME/install/papirus-icon-theme/Papirus-Light" "$HOME/.local/share/icons/Papirus-Light" +symlink "$HOME/install/papirus-icon-theme/Papirus" "$HOME/.local/share/icons/Papirus" && \ + symlink "$HOME/install/papirus-icon-theme/Papirus-Dark" "$HOME/.local/share/icons/Papirus-Dark" && \ + symlink "$HOME/install/papirus-icon-theme/Papirus-Light" "$HOME/.local/share/icons/Papirus-Light" + +[ $? = 0 ] && { + echo + success "Papirus icons installed!" + info "You can find them in $HOME/.local/share/icons/" + echo +} -echo -echo "Finish! Don't forget to change current icon theme." -echo "You can find them here:" -echo -e "\t$HOME/.local/share/icons/" -echo diff --git a/install/pgsql b/install/pgsql index 5386919..81de742 100755 --- a/install/pgsql +++ b/install/pgsql @@ -1,16 +1,14 @@ #!/bin/bash ##makedesc: Install postgresql (latest) and php-pgsql (if php is installed) +source `dirname $0`/../helpers || exit 255 -echo -echo "===============================================" -echo "Installing postgresql (latest)..." -echo "===============================================" -echo +title -installed() { - command -v "$1" >/dev/null 2>&1 -} - -sudo apt install -y --autoremove postgresql postgresql-contrib -sudo service postgresql restart -installed 'php' && sudo apt install -y --autoremove php-pgsql +require postgresql postgresql-contrib && \ + sudo service postgresql restart && \ + { + echo + success "openvpn installed!" + postgres --version + echo + } diff --git a/install/postman b/install/postman index 5b1b67f..e77f17f 100755 --- a/install/postman +++ b/install/postman @@ -1,28 +1,31 @@ #!/bin/bash ##makedesc: Install postman (latest) +source `dirname $0`/../helpers || exit 255 -echo -echo "===============================================" -echo "Installing postman (latest)..." -echo "===============================================" -echo +# https://learning.postman.com/docs/getting-started/installation-and-updates/#installing-postman-on-linux -mkdir -p $HOME/install/postman -mkdir -p $HOME/.local/bin -wget "https://dl.pstmn.io/download/latest/linux64" -O $HOME/install/postman.tar.gz && \ - tar -xzf $HOME/install/postman.tar.gz -C $HOME/install/postman && \ - ln -sf $HOME/install/postman/Postman/Postman $HOME/.local/bin/postman && \ - mkdir -p "$HOME/.local/share/applications" && \ - cat << EOF > "$HOME/.local/share/applications/Postman.desktop" -#!/usr/bin/env xdg-open +title +mkdir -p "$HOME/install" && \ + "$HOME/.local/bin" && \ + "$HOME/.local/share/applications" + +download "https://dl.pstmn.io/download/latest/linux64" $HOME/install/postman.tar.gz && \ + unpak_targz "$HOME/install/postman.tar.gz" "$HOME/install" && \ + symlink $HOME/install/Postman/Postman $HOME/.local/bin/postman && \ + cat << EOF > "$HOME/.local/share/applications/Postman.desktop" && sudo update-desktop-database [Desktop Entry] Name=Postman -Exec=$HOME/.local/bin/postman -Icon=$HOME/install/postman/Postman/app/icons/icon_128x128.png -Categories=Utility,Network +Exec=$HOME/.local/bin/postman %U +Icon=$HOME/install/Postman/app/icons/icon_128x128.png +Categories=Development,Network Terminal=false Type=Application Encoding=UTF-8 EOF -sudo update-desktop-database + +[ $? = 0 ] && { + echo + success "Postman installed!" + echo +}