diff --git a/Makefile b/Makefile index 9bdf117..8b30d43 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Autogenerated at 02.08.2024 00:03 using ./gen-makefile +# Autogenerated at 22.11.2024 09:40 using ./gen-makefile .DEFAULT_GOAL := help #=============================================== @@ -81,6 +81,10 @@ kde-file-templates: kde-portal: @./install/kde-portal +##lazynvim: +lazynvim: + @./install/lazynvim + ##libreoffice: Install libreoffice libreoffice: @./install/libreoffice @@ -193,6 +197,10 @@ ulauncher: vivaldi: @./install/vivaldi +##vscode: VSCode deb-package +vscode: + @./install/vscode + ##wine: Install wine (latest) + ppa (focal) wine: @./install/wine @@ -262,6 +270,10 @@ phpstack: php phptools /grub-customizer: @./uninstall/grub-customizer +##/lazynvim: +/lazynvim: + @./uninstall/lazynvim + ##/lite-xl: Uninstall lite-xl /lite-xl: @./uninstall/lite-xl diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..91bb068 --- /dev/null +++ b/TODO.md @@ -0,0 +1,6 @@ +# Todo list + +* [ ] tdesktop (https://desktop.telegram.org) +* [ ] spoofdpi (https://git.axenov.dev/mirrors/SpoofDPI/tags) +* [ ] lazynvim (https://www.lazyvim.org) +* [ ] ... diff --git a/helpers b/helpers index 2cb2065..f834a3f 100644 --- a/helpers +++ b/helpers @@ -9,7 +9,7 @@ installed2() { } apt_install() { - sudo apt install -y --autoremove "$*" + sudo apt install -y --autoremove $* } require() { @@ -21,7 +21,7 @@ require() { done if [ ${#sw[@]} -gt 0 ]; then info "This packages will be installed in your system:\n${sw[*]}" - apt_install "${sw[*]}" + apt_install ${sw[*]} [ $? -gt 0 ] && die "installation cancelled" 201 fi } diff --git a/install/lazynvim b/install/lazynvim new file mode 100755 index 0000000..c840285 --- /dev/null +++ b/install/lazynvim @@ -0,0 +1,64 @@ +#!/bin/bash +# https://www.devas.life/effective-neovim-setup-for-web-development-towards-2024/ + +set -eo pipefail +trap ontrap SIGINT SIGTERM SIGSTOP + +ontrap() { + echo + echo "[!] Interrupted" + exit +} + +[ -z "$1" ] && version=0.10.1 || version="$1" + +filedir="$HOME/install/neovim-$version" +filename="nvim-linux64.tar.gz" +filepath="$filedir/$filename" +configdir="$HOME/.config/nvim" +localdir="$HOME/.local" + +echo "[*] Installing neovim v$version" + +if [ -d $configdir ]; then + mv $configdir "$configdir.bak-$(date +'%Y%m%d_%H%M%S')" +fi + +mkdir -p $filedir $configdir $localdir/{bin,lib,share} + +if [ ! -f $filepath ]; then + echo "[*] Downloading to $filepath..." + wget -q https://github.com/neovim/neovim/releases/download/v$version/nvim-linux64.tar.gz \ + -O $filepath \ + --show-progress +fi + +echo "[*] Unpacking: $filepath..." +tar -zxf $filepath -C $filedir +cp -rf $filedir/nvim-linux64/bin/nvim $localdir/bin/ +cp -rf $filedir/nvim-linux64/lib/nvim $localdir/lib/ +cp -rf $filedir/nvim-linux64/share $localdir/share +rm -rf $filedir/nvim-linux64 + +echo "[*] Reinit git repo..." +git clone https://github.com/LazyVim/starter \ + $configdir \ + --depth=1 \ + --single-branch +cd $configdir +rm -rf .git +git init -q + + + + + + + + + + + + + + diff --git a/install/snap b/install/snap index 97ae0a1..bdb804c 100755 --- a/install/snap +++ b/install/snap @@ -26,8 +26,8 @@ fi # snapi gtk2-common-themes snapi peek -snapi telegram-desktop -snapi code +# snapi telegram-desktop #todo +# snapi code # deb https://github.com/microsoft/vscode/issues/221836 snapi skype snapi dbeaver-ce # snapi mysql-workbench-community diff --git a/install/vscode b/install/vscode new file mode 100755 index 0000000..2d1e47b --- /dev/null +++ b/install/vscode @@ -0,0 +1,18 @@ +#!/bin/bash +##makedesc: VSCode deb-package +source `dirname $0`/../helpers || exit 255 + +title + +mkdir -p "$HOME/install" + +download "https://code.visualstudio.com/docs/?dv=linux64_deb" \ + "$HOME/install/vscode.deb" && \ + sudo dpkg -i "$HOME/install/vscode.deb" + +[ $? = 0 ] && { + echo + success "VSCode installed" + vscode --version + echo +} diff --git a/tools/free-space.sh b/tools/free-space.sh new file mode 100644 index 0000000..8c7b27a --- /dev/null +++ b/tools/free-space.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# Очистка места на диске +# https://gist.github.com/anthonyaxenov/02c00c965be4eb5bb163a153abdf4c2b +# https://itsfoss.com/free-up-space-ubuntu-linux/ + +df -h +echo "" +echo "[1/5] Removing apt caches and unused packages" +echo "" + +sudo apt autoremove --purge +sudo apt autoclean +sudo apt clean + +echo "" +echo "[2/5] Removing old journalctl logs" +echo "" + +sudo journalctl --vacuum-time=1d +sudo rm -rf /var/log/journal/user-*@* +sudo rm -rf /var/log/journal/system*@* + +echo "" +echo "[3/5] Cleaning user trash and thumbnails" +echo "" + +rm -rf ~/.local/share/Trash/files/* +rm -rf ~/.cache/thumbnails/* + +echo "" +echo "[4/5] Cleaning out dangling docker objects" +echo "" + +docker system prune -f +# docker system prune -af + +echo "" +echo "[5/5] Removing disabled unused snaps" +echo "" + +sudo snap list --all | awk '/disabled/{print $1, $3}' | + while read snapname revision; do + sudo snap remove "$snapname" --revision="$revision" + done + +echo "" +echo "" +df -h diff --git a/tools/frkn.sh b/tools/frkn.sh index 8f1bd66..a4cf3f6 100755 --- a/tools/frkn.sh +++ b/tools/frkn.sh @@ -1,13 +1,19 @@ #!/bin/bash function disconnect() { - echo "Отключаю $1" + echo "Disconnecting: $1" sudo wg-quick down "$1" + sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 + sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 + sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1 echo } function connect() { - echo "Подключаю frkn-$1" + echo "Connecting: frkn-$1" + sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 + sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0 + sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0 sudo wg-quick up "frkn-$1" echo } @@ -21,7 +27,44 @@ function in_array() { return 1 } -country="$1" +function update_wg() { + sudo apt install -y wireguard jq && wg --version +} + +function update_frkn() { + local countries=(uk ru nl nl2 ch) + for idx in ${!countries[@]}; do + country=${countries[idx]} + echo "Downloading config for $country ($(expr $idx + 1)/${#countries[@]})" + + json=$(curl -s "https://api.frkn.org/peer?location=$country" | jq) + + iface_address=$(echo $json | jq -r .iface.address) + iface_privkey=$(echo $json | jq -r .iface.key) + iface_dns=$(echo $json | jq -r .iface.dns) + peer_pubkey=$(echo $json | jq -r .peer.pubkey) + peer_psk=$(echo $json | jq -r .peer.psk) + peer_allowed_ips=$(echo $json | jq -r .peer.allowed_ips) + peer_endpoint=$(echo $json | jq -r .peer.endpoint) + + cat << EOF > "./frkn-$country.conf" +[Interface] +Address = $iface_address +DNS = $iface_dns +PrivateKey = $iface_privkey + +[Peer] +PublicKey = $peer_pubkey +PresharedKey = $peer_psk +AllowedIPs = $peer_allowed_ips +Endpoint = $peer_endpoint +PersistentKeepalive = 25 +EOF + done + sudo mv -f ./frkn-*.conf /etc/wireguard/ +} + +command="$1" countries=() current=$(sudo wg show | head -n 1 | awk '{print $2}') @@ -32,10 +75,10 @@ for file in /etc/wireguard/*.conf; do done correct=-1 -if [ -z "$country" ] ; then +if [ -z "$command" ] ; then while [ $correct -lt 0 ]; do - read -rp "Выбери страну (${countries[*]}): " country - if in_array "$country" ${countries[@]}; then + read -rp "Entry on of country code (${countries[*]}): " command + if in_array "$command" ${countries[@]}; then correct=1 else echo "Неверный код страны!" @@ -43,14 +86,23 @@ if [ -z "$country" ] ; then done fi -case "$country" in +case "$command" in + "update" ) + if update_wg && update_frkn; then + echo "Wireguard and FRKN updated" + else + echo "Something went wrong" + exit 1 + fi + ;; + "down" ) if [ -n "$current" ]; then disconnect "$current" fi ;; - "status"|"show" ) + "show" ) sudo wg show ;; @@ -58,6 +110,6 @@ case "$country" in if [ -n "$current" ]; then disconnect "$current" fi - connect "$country" + connect "$command" ;; esac diff --git a/uninstall/lazynvim b/uninstall/lazynvim new file mode 100755 index 0000000..12aa285 --- /dev/null +++ b/uninstall/lazynvim @@ -0,0 +1,16 @@ +#!/bin/bash +set -eo pipefail +trap ontrap SIGINT SIGTERM SIGSTOP + +ontrap() { + echo + echo "[!] Interrupted" + exit +} + +echo "[*] Uninstalling neovim" + +find "$HOME/.config" -type f -path "*/nvim*" -exec rm -rfv {} + +find "$HOME/.local" -type f -path "*/nvim*" -exec rm -rfv {} + + +echo "[*] Finish"