Merge branch 'master' of git.axenov.dev:anthony/my-env

This commit is contained in:
Anthony Axenov 2024-11-22 14:38:43 +08:00
commit 3249c32cb2
Signed by: anthony
GPG Key ID: EA9EC32FF7CCD4EC
9 changed files with 230 additions and 14 deletions

View File

@ -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 .DEFAULT_GOAL := help
#=============================================== #===============================================
@ -81,6 +81,10 @@ kde-file-templates:
kde-portal: kde-portal:
@./install/kde-portal @./install/kde-portal
##lazynvim: <no description>
lazynvim:
@./install/lazynvim
##libreoffice: Install libreoffice ##libreoffice: Install libreoffice
libreoffice: libreoffice:
@./install/libreoffice @./install/libreoffice
@ -193,6 +197,10 @@ ulauncher:
vivaldi: vivaldi:
@./install/vivaldi @./install/vivaldi
##vscode: VSCode deb-package
vscode:
@./install/vscode
##wine: Install wine (latest) + ppa (focal) ##wine: Install wine (latest) + ppa (focal)
wine: wine:
@./install/wine @./install/wine
@ -262,6 +270,10 @@ phpstack: php phptools
/grub-customizer: /grub-customizer:
@./uninstall/grub-customizer @./uninstall/grub-customizer
##/lazynvim: <no description>
/lazynvim:
@./uninstall/lazynvim
##/lite-xl: Uninstall lite-xl ##/lite-xl: Uninstall lite-xl
/lite-xl: /lite-xl:
@./uninstall/lite-xl @./uninstall/lite-xl

6
TODO.md Normal file
View File

@ -0,0 +1,6 @@
# Todo list
* [ ] tdesktop (https://desktop.telegram.org)
* [ ] spoofdpi (https://git.axenov.dev/mirrors/SpoofDPI/tags)
* [ ] lazynvim (https://www.lazyvim.org)
* [ ] ...

View File

@ -9,7 +9,7 @@ installed2() {
} }
apt_install() { apt_install() {
sudo apt install -y --autoremove "$*" sudo apt install -y --autoremove $*
} }
require() { require() {
@ -21,7 +21,7 @@ require() {
done done
if [ ${#sw[@]} -gt 0 ]; then if [ ${#sw[@]} -gt 0 ]; then
info "This packages will be installed in your system:\n${sw[*]}" info "This packages will be installed in your system:\n${sw[*]}"
apt_install "${sw[*]}" apt_install ${sw[*]}
[ $? -gt 0 ] && die "installation cancelled" 201 [ $? -gt 0 ] && die "installation cancelled" 201
fi fi
} }

64
install/lazynvim Executable file
View File

@ -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

View File

@ -26,8 +26,8 @@ fi
# snapi gtk2-common-themes # snapi gtk2-common-themes
snapi peek snapi peek
snapi telegram-desktop # snapi telegram-desktop #todo
snapi code # snapi code # deb https://github.com/microsoft/vscode/issues/221836
snapi skype snapi skype
snapi dbeaver-ce snapi dbeaver-ce
# snapi mysql-workbench-community # snapi mysql-workbench-community

18
install/vscode Executable file
View File

@ -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
}

48
tools/free-space.sh Normal file
View File

@ -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

View File

@ -1,13 +1,19 @@
#!/bin/bash #!/bin/bash
function disconnect() { function disconnect() {
echo "Отключаю $1" echo "Disconnecting: $1"
sudo wg-quick down "$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 echo
} }
function connect() { 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" sudo wg-quick up "frkn-$1"
echo echo
} }
@ -21,7 +27,44 @@ function in_array() {
return 1 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=() countries=()
current=$(sudo wg show | head -n 1 | awk '{print $2}') current=$(sudo wg show | head -n 1 | awk '{print $2}')
@ -32,10 +75,10 @@ for file in /etc/wireguard/*.conf; do
done done
correct=-1 correct=-1
if [ -z "$country" ] ; then if [ -z "$command" ] ; then
while [ $correct -lt 0 ]; do while [ $correct -lt 0 ]; do
read -rp "Выбери страну (${countries[*]}): " country read -rp "Entry on of country code (${countries[*]}): " command
if in_array "$country" ${countries[@]}; then if in_array "$command" ${countries[@]}; then
correct=1 correct=1
else else
echo "Неверный код страны!" echo "Неверный код страны!"
@ -43,14 +86,23 @@ if [ -z "$country" ] ; then
done done
fi 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" ) "down" )
if [ -n "$current" ]; then if [ -n "$current" ]; then
disconnect "$current" disconnect "$current"
fi fi
;; ;;
"status"|"show" ) "show" )
sudo wg show sudo wg show
;; ;;
@ -58,6 +110,6 @@ case "$country" in
if [ -n "$current" ]; then if [ -n "$current" ]; then
disconnect "$current" disconnect "$current"
fi fi
connect "$country" connect "$command"
;; ;;
esac esac

16
uninstall/lazynvim Executable file
View File

@ -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"