Compare commits

68 Commits

Author SHA1 Message Date
549b420df2 Добавлен vacuum 2025-10-30 06:00:39 +00:00
edf76874fc misc 2025-10-12 18:25:13 +08:00
95ad6b0c6a rustdesk 1.4.2 2025-10-12 18:24:30 +08:00
ff36975eb7 frkn deprecated 2025-07-10 23:46:19 +08:00
5ae19346d6 wine misc, albert removed 2025-07-09 00:15:25 +08:00
53ee621747 duckdns improved 2025-07-08 23:50:53 +08:00
dd339f2939 duckdns misc 2025-07-05 10:23:59 +08:00
e0fbdf852e duckdns 2025-07-02 13:29:40 +08:00
b5983ed308 sublime text 4200 2025-06-21 22:48:29 +08:00
f39af6d446 makefile 2025-06-18 19:51:07 +08:00
8fe3d112ba Merge branch 'master' of git.axenov.dev:anthony/shell 2025-06-18 19:50:45 +08:00
4c81bcea73 rustdesk flatpak + kde permission 2025-06-18 19:50:28 +08:00
5623d08d85 suld 2025-05-23 00:19:28 +08:00
0a369efe1b Merge branch 'master' of git.axenov.dev:anthony/shell 2025-05-21 20:26:41 +08:00
1640ebfb45 neovim + lazyvim 2025-05-21 20:26:23 +08:00
d2c561fc28 upgraded lite-xl 2025-05-19 00:30:08 +08:00
a920e48422 Revert "telebit misc"
This reverts commit abad965e9a.
2025-05-18 23:54:02 +08:00
0ed07de2d2 php misc 2025-05-18 23:27:42 +08:00
abad965e9a telebit misc 2025-05-18 23:27:19 +08:00
b5b0140e34 vscode repo 2025-05-14 23:42:02 +08:00
5d75b6f79e vivaldi repo + install 2025-05-14 23:41:50 +08:00
87fd722509 albert draft 2025-05-14 19:58:43 +08:00
eaacecd87a ulauncher update 2025-05-14 18:51:18 +08:00
4c57a180ac sublimetext update 2025-05-14 18:49:44 +08:00
96bd945ef2 disable-ipv6 2025-03-29 18:58:45 +08:00
49fd27d3be display-rotate 2025-03-29 18:56:46 +08:00
3c9f1d71cb flameshot build form src 2025-03-24 19:48:25 +08:00
3a226ed5bb git helpers misc 2025-03-24 19:47:30 +08:00
fe83b3eb25 readme update 2025-03-24 19:46:01 +08:00
a34dda20c7 uninstall wine 2025-03-24 17:21:08 +08:00
021db1064e ubuntu tools misc 2025-03-19 19:08:19 +08:00
b70b89433b Merge branch 'master' of git.axenov.dev:anthony/shell 2025-03-18 13:45:33 +08:00
8531543982 make-swapfile 2025-03-18 13:45:29 +08:00
e05b47ae52 ubuntu server scripts misc 2025-02-20 10:22:39 +08:00
e9a6f4ddda docker-volume-snapshot 2025-02-20 10:22:25 +08:00
cbb493b5c4 ClamAV (WIP) 2025-02-10 21:32:52 +08:00
31ddf3a6d2 notification helpers 2025-02-10 21:30:36 +08:00
47827282a9 free-space misc 2025-02-10 21:30:24 +08:00
16075cdd61 new links in readme 2025-02-08 13:25:52 +08:00
29e5c960de docker, network and others 2025-02-08 13:25:41 +08:00
526dade1f8 new help examples 2025-02-08 13:24:30 +08:00
66126167c8 io misc 2025-02-08 13:23:48 +08:00
3696cc06af new traps example 2025-02-08 13:23:32 +08:00
8da2059d1e basic.sh new functions 2025-02-08 13:19:16 +08:00
9da84a69f2 free-space misc 2025-02-08 12:10:23 +08:00
50bd28abe4 io misc 2025-02-05 18:58:42 +08:00
bbbc0de694 arg() снова исправлен вызов tr 2025-01-29 19:50:52 +08:00
9258398be4 Merge branch 'master' of git.axenov.dev:anthony/shell 2025-01-27 15:10:30 +08:00
a60374033c arg() исправлен вызов tr 2025-01-27 15:10:18 +08:00
bcae2fb4cf dotfiles misc 2025-01-21 00:06:37 +08:00
c808cce9cd sublime text dotfiles 2025-01-21 00:05:57 +08:00
bacd71304a Merge branch 'master' of git.axenov.dev:anthony/shell 2025-01-20 16:11:56 +08:00
6fee688968 arg-parser -- fix utf8 2025-01-20 16:11:46 +08:00
ebd30c8a50 youtube-dl misc 2025-01-18 00:46:27 +08:00
c4b2af8073 new shebangs 2025-01-17 19:07:28 +08:00
45499ca5df args-parser refactor 2025-01-17 19:07:08 +08:00
53d5a31a30 many io misc useful updates 2025-01-16 14:23:46 +08:00
1e0d54f5d6 some basic helpers 2025-01-16 14:23:19 +08:00
5d3004c87b docker helpers 2025-01-16 13:39:16 +08:00
14f3f2caf2 arg-parser fixes 2025-01-16 13:39:02 +08:00
dc03b5f577 sublime merge 2102 + misc 2025-01-09 15:38:31 +08:00
2af5282e64 st4 4189 2024-12-26 00:49:56 +08:00
e2c0d1de87 wip 2024-12-02 16:12:18 +08:00
7bb8a8c839 Merge branch 'master' of git.axenov.dev:anthony/my-env 2024-11-24 14:47:02 +08:00
bc139e5cc5 st4 upgrade 2024-11-24 14:46:56 +08:00
beeb59b1aa vscode fix 2024-11-22 14:43:22 +08:00
3249c32cb2 Merge branch 'master' of git.axenov.dev:anthony/my-env 2024-11-22 14:38:43 +08:00
c18f014119 golang 1.23.0 2024-11-22 14:38:38 +08:00
144 changed files with 3522 additions and 776 deletions

View File

@@ -1,4 +1,4 @@
# Autogenerated at 22.11.2024 09:40 using ./gen-makefile # Autogenerated at 10.07.2025 23:45 using ./gen-makefile
.DEFAULT_GOAL := help .DEFAULT_GOAL := help
#=============================================== #===============================================
@@ -21,11 +21,15 @@ canon-mg2500:
chrome: chrome:
@./install/chrome @./install/chrome
##clamav: ClamAV (WIP)
clamav:
@./install/clamav
##composer: Install composer (latest) ##composer: Install composer (latest)
composer: composer:
@./install/composer @./install/composer
##docker: Install docker (latest) + docker-compose (latest) + ppa ##docker: Install docker (latest) + ppa
docker: docker:
@./install/docker @./install/docker
@@ -45,9 +49,9 @@ droidcam-obs:
flameshot: flameshot:
@./install/flameshot @./install/flameshot
##frkn: Install Wireguard + FRKN ##frkn.deprecated: Install Wireguard + FRKN
frkn: frkn.deprecated:
@./install/frkn @./install/frkn.deprecated
##git: Install git (latest) ##git: Install git (latest)
git: git:
@@ -81,15 +85,11 @@ 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
##lite-xl: Install lite-xl ##lite-xl: Install lite-xl v2.1.7
lite-xl: lite-xl:
@./install/lite-xl @./install/lite-xl
@@ -105,6 +105,10 @@ nodejs:
ntfy: ntfy:
@./install/ntfy @./install/ntfy
##nvim: Install nvim + lazyvim
nvim:
@./install/nvim
##obs-studio: Install obs-studio (latest snap) ##obs-studio: Install obs-studio (latest snap)
obs-studio: obs-studio:
@./install/obs-studio @./install/obs-studio
@@ -129,7 +133,7 @@ papirus:
pgsql: pgsql:
@./install/pgsql @./install/pgsql
##php: Install php v8.1 + ppa ##php: Install php v8.4
php: php:
@./install/php @./install/php
@@ -165,18 +169,30 @@ postman:
qt5: qt5:
@./install/qt5 @./install/qt5
##rustdesk: Install rustdesk client v1.1.9 (deb) ##rustdesk: Install rustdesk client (flatpak)
rustdesk: rustdesk:
@./install/rustdesk @./install/rustdesk
##rustdesk-deb: Install rustdesk client v1.4.0 (deb)
rustdesk-deb:
@./install/rustdesk-deb
##snap: Install bunch of software from snap ##snap: Install bunch of software from snap
snap: snap:
@./install/snap @./install/snap
##sublimetext: Install Sublime Text (build 4169) ##sublimemerge: Install Sublime Merge
sublimemerge:
@./install/sublimemerge
##sublimetext: Install Sublime Text
sublimetext: sublimetext:
@./install/sublimetext @./install/sublimetext
##suld: Samsung Unified Linux Driver repo
suld:
@./install/suld
##syncthing: Install syncthing (latest) + ppa ##syncthing: Install syncthing (latest) + ppa
syncthing: syncthing:
@./install/syncthing @./install/syncthing
@@ -201,7 +217,7 @@ vivaldi:
vscode: vscode:
@./install/vscode @./install/vscode
##wine: Install wine (latest) + ppa (focal) ##wine: Install wine (latest) + ppa
wine: wine:
@./install/wine @./install/wine
@@ -226,9 +242,6 @@ zsh:
# Scripts listed in ./packs # Scripts listed in ./packs
#=============================================== #===============================================
##flameshot: [TODO] [PACK] qt5 + flameshot from source
flameshot: qt5 flameshot-build
##lamp: [PACK] Apache + php + mariadb ##lamp: [PACK] Apache + php + mariadb
lamp: apache phpstack mariadb lamp: apache phpstack mariadb
@@ -240,8 +253,8 @@ omz: zsh omz-clean omz-fancy
chsh -s /usr/bin/zsh chsh -s /usr/bin/zsh
@exec zsh @exec zsh
##phptools: [PACK] Install only php tooling (composer, phpunit, psalm, phpcs, php-cs-fixer, php-spx, phpmd) ##phptools: [PACK] Install only php tooling (composer, phpunit, psalm, phpcs, php-cs-fixer, phpmd)
phptools: composer php-psalm php-spx phpcs phpmd phpstan phpunit phptools: composer php-psalm phpcs phpmd phpstan phpunit
##phpstack: [PACK] Install full php stack with tooling ##phpstack: [PACK] Install full php stack with tooling
phpstack: php phptools phpstack: php phptools
@@ -262,6 +275,18 @@ phpstack: php phptools
/apache2: /apache2:
@./uninstall/apache2 @./uninstall/apache2
##/canon-mg2500: Uninstall Canon Pixma MG2500 + ppa
/canon-mg2500:
@./uninstall/canon-mg2500
##/chrome: Uninstall google chrome
/chrome:
@./uninstall/chrome
##/composer: Uninstall composer
/composer:
@./uninstall/composer
##/docker: Uninstall docker + ppa ##/docker: Uninstall docker + ppa
/docker: /docker:
@./uninstall/docker @./uninstall/docker
@@ -282,10 +307,22 @@ phpstack: php phptools
/omz: /omz:
@./uninstall/omz @./uninstall/omz
##/sublimemerge: Uninstall Sublime Merge
/sublimemerge:
@./uninstall/sublimemerge
##/sublimetext: Uninstall Sublime Text
/sublimetext:
@./uninstall/sublimetext
##/vivaldi: Uninstall vivaldi + ppa ##/vivaldi: Uninstall vivaldi + ppa
/vivaldi: /vivaldi:
@./uninstall/vivaldi @./uninstall/vivaldi
##/wine: Uninstall wine
/wine:
@./uninstall/wine
#=============================================== #===============================================
# Service goals # Service goals
#=============================================== #===============================================

View File

@@ -1,46 +1,28 @@
# My Ubuntu environment # My shell environment
`make`-ready bunch of scripts for easily installation of different software. `make`-ready bunch of scripts for easily (de)installation of different software and bunch of useful handy functions for custom scripting.
## Requirements ## Requirements
* Ubuntu >= 20.04 (not tested with version < 20) * Ubuntu >= 20.04 (not tested with version < 20)
* `bash`, `zsh` or other `sh`-compatible shell * `bash`, `zsh` or other `sh`-compatible shell
* `make` (optional but recommended) * `make` (optional but recommended)
* `wget` (necessary for some scripts) * `wget` (required for some scripts)
* `git` (necessary for some scripts) * `git` (required for some scripts)
If some dependecies are missed for some of these scripts it is enougth to run `./install/apt` in most cases. If some dependecies are missed for some of these scripts it is enougth to run `./install/apt` in most cases, otherwise script will suggest (or even install) them.
## Usage ## Usage
### Clone this repo (recommended)
```shell ```shell
# if git is installed # with git
git clone git@git.axenov.dev:anthony/my-env.git --depth=1 git clone git@git.axenov.dev:anthony/shell.git --depth=1 --single-branch
# if git is not installed # without git
wget -qO - https://git.axenov.dev/anthony/my-env/archive/master.tar.gz | tar -zxf - wget -qO - https://git.axenov.dev/anthony/shell/archive/master.tar.gz | tar -zxf -
# switch to repo dir
cd my-env
# generate fresh ./Makefile and get full list of `make` goals
./gen-makefile
# get full list of `make` goals # get full list of `make` goals
make cd shell && make
```
### Selective straightforward installation
```shell
# from remote file (you can meet interaction bugs this way!)
wget -qO - https://git.axenov.dev/anthony/my-env/raw/branch/master/install/apt | bash
# from locally cloned repo (except scripts from ./packs)
./install/apt
``` ```
## How to add my script? ## How to add my script?
@@ -48,7 +30,7 @@ wget -qO - https://git.axenov.dev/anthony/my-env/raw/branch/master/install/apt |
1. Create a new shell script in `./install`, `./upgrade` or `./uninstall` directory. 1. Create a new shell script in `./install`, `./upgrade` or `./uninstall` directory.
At the beggining of a file you must write these two lines: At the beggining of a file you must write these two lines:
```shell ```shell
#!/bin/bash #!/usr/bin/env bash
##makedesc: Your description for Makefile ##makedesc: Your description for Makefile
``` ```
2. Make this script executable, e.g.: 2. Make this script executable, e.g.:
@@ -78,17 +60,35 @@ mypackX: goalA goalB
``` ```
where: where:
* `mypack*` is the pack name * `mypack*` is the pack name of your choice
* `goal*` are script names in `./install` * `goal*` are script names in `./install`
## TODO ## Useful links and sources used
* build: [flameshot](https://github.com/flameshot-org/flameshot#compilation) * https://gist.github.com/anthonyaxenov/d53c4385b7d1466e0affeb56388b1005
* build: [rustdesk](https://github.com/rustdesk/rustdesk#build) * https://gist.github.com/anthonyaxenov/89c99e09ddb195985707e2b24a57257d
* [JB mono](https://www.jetbrains.com/ru-ru/lp/mono/#how-to-install) ([2](https://fonts.google.com/specimen/JetBrains+Mono)) * ...and other my [gists](https://gist.github.com/anthonyaxenov/) with [SHELL] prefix
* update scripts (when possible) * https://github.com/nvie/gitflow/blob/develop/gitflow-common (BSD License)
* uninstall scripts (when possible) * https://github.com/petervanderdoes/gitflow-avh/blob/develop/gitflow-common (FreeBSD License)
* https://github.com/vaniacer/bash_color/blob/master/color
* https://misc.flogisoft.com/bash/tip_colors_and_formatting
* https://www-users.york.ac.uk/~mijp1/teaching/2nd_year_Comp_Lab/guides/grep_awk_sed.pdf
* https://www.galago-project.org/specs/notification/
* https://laurvas.ru/bash-trap/
* https://stackoverflow.com/a/52674277
* https://rtfm.co.ua/bash-funkciya-getopts-ispolzuem-opcii-v-skriptax/
* https://gist.github.com/jacknlliu/7c51e0ee8b51881dc8fb2183c481992e
* https://gist.github.com/anthonyaxenov/d53c4385b7d1466e0affeb56388b1005
* https://github.com/nvie/gitflow/blob/develop/gitflow-common
* https://github.com/petervanderdoes/gitflow-avh/blob/develop/gitflow-common
* https://gitlab.com/kyb/autorsync/-/blob/master/
* https://lug.fh-swf.de/vim/vim-bash/StyleGuideShell.en.pdf
* https://www.thegeekstuff.com/2010/06/bash-array-tutorial/
* https://www.distributednetworks.com/linux-network-admin/module4/ephemeral-reserved-portNumbers.php
* https://github.com/community-scripts/ProxmoxVE/tree/main/install
* https://github.com/community-scripts/ProxmoxVE/tree/main/misc
* https://faculty.cs.niu.edu/~hutchins/csci480/signals.htm
## License ## License
[WTFPLv2](LICENSE) [WTFPLv2](LICENSE) but other licences are also possible.

13
TODO.md
View File

@@ -1,6 +1,11 @@
# Todo list # Todo list
* [ ] tdesktop (https://desktop.telegram.org) * tdesktop (https://desktop.telegram.org)
* [ ] spoofdpi (https://git.axenov.dev/mirrors/SpoofDPI/tags) * spoofdpi (https://git.axenov.dev/mirrors/SpoofDPI/tags)
* [ ] lazynvim (https://www.lazyvim.org) * lazynvim (https://www.lazyvim.org)
* [ ] ... * build: [flameshot](https://github.com/flameshot-org/flameshot#compilation)
* build: [rustdesk](https://github.com/rustdesk/rustdesk#build)
* update scripts (when possible)
* uninstall scripts (when possible)
* ...

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# alias bashrc='source ~/.bashrc' # alias bashrc='source ~/.bashrc'
alias zshrc='source ~/.zshrc' alias zshrc='source ~/.zshrc'

View File

@@ -106,3 +106,5 @@ if ! shopt -oq posix; then
. /etc/bash_completion . /etc/bash_completion
fi fi
fi fi
[ -f ~/.profile ] && source ~/.profile

View File

@@ -1,20 +1,19 @@
[alias] [alias]
a = "add" a = "add"
aa = "add --all" # add all unstaged into index aa = "add --all" # add all unstaged into index
aliases = "config --get-regexp '^alias'" # show all aliases aliases = "config --get-regexp '^alias.*'" # show all aliases
amend = "commit --amend --all --no-edit" # add new changes into last commit amend = "commit --amend --all --no-edit" # add new changes into last commit
amendm = "commit --amend --all --message" # amend + edit commit message amendm = "commit --amend --all --message" # amend + edit commit message
archive = "!f() { top=$(rev-parse --show-toplevel); cd $top; tar cvzf $top.tar.gz $top ; }; f" # make repo .tar.gz
b = "branch" # b = "branch" #
bm = "branch --merged" # branches whose tips are reachable from commit or HEAD bm = "branch --merged" # branches whose tips are reachable from commit or HEAD
bnm = "branch --no-merged" # branches whose tips are NOT reachable from commit or HEAD bnm = "branch --no-merged" # branches whose tips are NOT reachable from commit or HEAD
br = "branch" #
branches = "branch -a" branches = "branch -a"
; branches = "bvv"
brd = "branch -D" # force delete unmerged branch brd = "branch -D" # force delete unmerged branch
brod = "!git branch -D "$1"; git push origin :"$1";" # brd + remove it from origin brod = "!git branch -D "$1"; git push origin :"$1";" # brd + remove it from origin
bv = "branch -v" # show branch list with those last commits bv = "branch -v" # show branch list with those last commits
bvv = "branch -vv" # bv + remote branches tracked by them bvv = "branch -vv" # bv + remote branches tracked by them
c = "commit" c = "commit"
ca = "commit --all" # stage all changes and make a commit (interative) ca = "commit --all" # stage all changes and make a commit (interative)
cam = "commit --all --message" # ca + cm (non-interactive) cam = "commit --all --message" # ca + cm (non-interactive)
@@ -31,9 +30,7 @@ cp = "cherry-pick"
cpa = "cherry-pick --abort" # abort cherry-picking cpa = "cherry-pick --abort" # abort cherry-picking
cpc = "cherry-pick --continue" # continue cherry-picking cpc = "cherry-pick --continue" # continue cherry-picking
cpn = "cherry-pick --no-commit" # cherry-pick without commit cpn = "cherry-pick --no-commit" # cherry-pick without commit
; cpnx = "cherry-pick --no-commit -x"
current-branch = "branch --show-current" #rev-parse --abbrev-ref HEAD current-branch = "branch --show-current" #rev-parse --abbrev-ref HEAD
d = "diff" d = "diff"
dc = "diff --cached" # show diff of staged files dc = "diff --cached" # show diff of staged files
default-branch = "config init.defaultBranch" # get default branch name default-branch = "config init.defaultBranch" # get default branch name
@@ -43,30 +40,23 @@ develop = "!git checkout develop && git pull" # quick switch on develop branch a
discard = "checkout --" # удаляет изменения в файле discard = "checkout --" # удаляет изменения в файле
dw = "diff --word-diff" # show word diff in unstaged files dw = "diff --word-diff" # show word diff in unstaged files
dwc = "diff --word-diff --cached" # dc + dw dwc = "diff --word-diff --cached" # dc + dw
empty="!git commit --allow-empty"
exec = "!exec" exec = "!exec"
f = "fetch" f = "fetch"
fa = "fetch --all" # fetch branches from all remotes fa = "fetch --all" # fetch branches from all remotes
fuck = "!git checkout $(git default-branch) && git fetch origin --prune && git reset --hard origin/$(git default-branch) && git clean -ffd" fuck = "!git checkout $(git default-branch) && git fetch origin --prune && git reset --hard origin/$(git default-branch) && git clean -ffd"
guser = "config --global --get-regexp '^user'" # show global user settings guser = "config --global --get-regexp '^user'" # show global user settings
gzip = !"f() { top=$(rev-parse --show-toplevel); cd $top; tar cvzf $top.tar.gz $top ; }; f" # make repo .tar.gz gwhoami = "guser"
gzip = "!f(){ top=$(rev-parse --show-toplevel); cd $top; tar cvzf $top.tar.gz $top};f" # make repo .tar.gz
head = "log -1 HEAD" # показать последний коммит в текущей ветке head = "log -1 HEAD" # показать последний коммит в текущей ветке
heads = "log --graph --decorate --simplify-by-decoration --oneline" # show last commit of each branch as tree graph heads = "log --graph --decorate --simplify-by-decoration --oneline" # show last commit of each branch as tree graph
inbound = "!git remote update --prune; git log ..@{upstream}" # get inbound = "!git remote update --prune; git log ..@{upstream}" # get
init = "init -q" init = "init -q"
l = "log" l = "log"
; last-tag = "describe --tags --abbrev=0"
; last-tagged = "!git describe --tags $(git rev-list --tags --max-count=1)"
lo = "log --oneline" lo = "log --oneline"
log-all = "log --graph --decorate --all" log-all = "log --graph --decorate --all"
log-my = "!git log --author $(git config user.email)" log-my = "!git log --author $(git config user.email)"
log-small = "log --graph --decorate --all --pretty=format:'%C(bold red)%h%C(reset) %C(bold blue)%an%C(reset) %C(green)%cr%C(reset) [%aD]%d%n%B'" log-small = "log --graph --decorate --all --pretty=format:'%C(bold red)%h%C(reset) %C(bold blue)%an%C(reset) %C(green)%cr%C(reset) [%aD]%d%n%B'"
m = "merge" m = "merge"
ma = "merge --abort" # abort merging ma = "merge --abort" # abort merging
main = "!git checkout main && git pull" # quick switch on main branch and update it main = "!git checkout main && git pull" # quick switch on main branch and update it
@@ -74,28 +64,20 @@ master = "!git checkout master && git pull" # quick switch on master branch and
mc = "merge --continue" # continue merging mc = "merge --continue" # continue merging
merged = "bm" merged = "bm"
mn = "merge --no-commit" # merge without commit mn = "merge --no-commit" # merge without commit
optimizer = "!git pruner; git repacker; git prune-packed" optimizer = "!git pruner; git repacker; git prune-packed"
orphans = "fsck --full" orphans = "fsck --full"
outbound = "log @{upstream}.." outbound = "log @{upstream}.."
p = "pull" p = "pull"
pf = "pull --force" # получить ветку принудительно pf = "pull --force" # получить ветку принудительно
pft = "pull --force --tags" # получить теги pft = "pull --force --tags" # получить теги
; ploh = "pull origin HEAD" # получить текущую ветку из origin
; pr = "!git fetch origin pull/$1/head:pr/$1 && git checkout pr/$1" # github: встать на PR с указанным id
prs = "pull --recurse-submodules" # pull with submodules prs = "pull --recurse-submodules" # pull with submodules
pruner = "!git prune --expire=now; git reflog expire --expire-unreachable=now --rewrite --all" pruner = "!git prune --expire=now; git reflog expire --expire-unreachable=now --rewrite --all"
pullf = "pull --force" pullf = "pull --force"
pullft = "pull --force --tags" pullft = "pull --force --tags"
pullt = "pull --tags" # получить теги pullt = "pull --tags" # получить теги
pushf = "!git push --force" # отправить ветку принудительно pushf = "!git push --force" # отправить ветку принудительно
; pushf = "!git push --force --set-upstream origin $(git current-branch)" # отправить ветку принудительно
pushft = "!git push --tags --force" # отправить теги принудительно pushft = "!git push --tags --force" # отправить теги принудительно
; pushft = "!git push --tags --force --set-upstream origin $(git current-branch)" # отправить теги принудительно
pusht = "!git push --tags" # отправить теги pusht = "!git push --tags" # отправить теги
; pusht = "!git push --tags --set-upstream origin $(git current-branch)" # отправить теги
r = "reset" r = "reset"
rb = "rebase" rb = "rebase"
rba = "rebase --abort" rba = "rebase --abort"
@@ -124,12 +106,34 @@ rsh = "reset --soft HEAD" # откат коммита с сохранением
rso = "remote show origin" # показать состояние локальных веток относительно удалённых на origin bare rso = "remote show origin" # показать состояние локальных веток относительно удалённых на origin bare
rv = "revert" rv = "revert"
rvn = "revert --no-commit" rvn = "revert --no-commit"
s = "status" s = "status"
sb = "show-branch" sb = "show-branch"
st = "status"
start = "!git init -q && git commit --allow-empty -m 'Initial commit'" start = "!git init -q && git commit --allow-empty -m 'Initial commit'"
stashes = "stash list" # show stashed changes stashes = "stash list" # show stashed changes
sub = "submodule" sub = "submodule"
tags = "tag -n1 --list" # shot tag names and commit message
targz = "archive"
trim = "!DEFAULT=$(git default-branch); git branch --merged ${1-$DEFAULT} | grep -v " ${1-$DEFAULT}$" | xargs git branch -d; git remote prune origin;"
uncommit = "rs HEAD~1"
undo = "uncommit"
unstage = "reset HEAD" # staged file => unstaged
upstream-branch = "!git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD)"
user = "config --local --get-regexp '^user'" # show local user settings (in current repo)
vacuum="!git reflog expire --expire-unreachable=now --all; git gc --prune=now"
whoami = "user"
wip = "!git add . && git commit -am 'WIP'"
wipa = "!git add . && git commit --amend -am 'WIP'"
; branches = "bvv"
; cpnx = "cherry-pick --no-commit -x"
; last-tag = "describe --tags --abbrev=0"
; last-tagged = "!git describe --tags $(git rev-list --tags --max-count=1)"
; ploh = "pull origin HEAD" # получить текущую ветку из origin
; pr = "!git fetch origin pull/$1/head:pr/$1 && git checkout pr/$1" # github: встать на PR с указанным id
; sa = "submodule add" ; sa = "submodule add"
; sdi = "submodule deinit -f" ; sdi = "submodule deinit -f"
; si = "submodule init" ; si = "submodule init"
@@ -137,15 +141,3 @@ sub = "submodule"
; sst = "submodule status" ; sst = "submodule status"
; sup = "submodule update" ; sup = "submodule update"
; sy = "remote update origin --prune" ; sy = "remote update origin --prune"
tags = "tag -n1 --list" # shot tag names and commit message
trim = "!DEFAULT=$(git default-branch); git branch --merged ${1-$DEFAULT} | grep -v " ${1-$DEFAULT}$" | xargs git branch -d; git remote prune origin;"
uncommit = "rs HEAD~1"
unstage = "reset HEAD" # staged file => unstaged
;unwip = "reset --mixed HEAD~"
upstream-branch = "!git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD)"
user = "config --local --get-regexp '^user'" # show local user settings (in current repo)
wip = "!git add . && git commit -am 'WIP'"
wipa = "!git add . && git commit --amend -am 'WIP'"

1
dotfiles/.gitignore vendored
View File

@@ -2,3 +2,4 @@
Desktop.ini Desktop.ini
._* ._*
Thumbs.db Thumbs.db
nbproject/

View File

@@ -28,26 +28,36 @@ fi
### AAA ########################################## ### AAA ##########################################
if [ -f ~/.bash_aliases ]; then [ -f ~/.bash_aliases ] && source ~/.bash_aliases
. ~/.bash_aliases [ -f ~/bars/src/lis-docker/.bash_aliases ] && source ~/bars/src/lis-docker/.bash_aliases
fi
export LD_LIBRARY_PATH="/opt/oci"
# export NLS_LANG='RUSSIAN_RUSSIA.AL32UTF8'
# export NLS_DATE_FORMAT='DD.MM.YYYY'
# export NLS_CURRENCY='р.'
# export NLS_DUAL_CURRENCY='р.'
# export NLS_CALENDAR='GREGORIAN'
# export NLS_ISO_CURRENCY='RUSSIA'
export JAVA_HOME="/usr/bin/"
export ANDROID_SDK_ROOT="$HOME/android/sdk"
export LITE_SCALE=1 # workaround https://github.com/lite-xl/lite-xl/issues/1173 export LITE_SCALE=1 # workaround https://github.com/lite-xl/lite-xl/issues/1173
export PATH="$HOME/.local/share/JetBrains/Toolbox/scripts:$HOME/.config/composer/vendor/bin:$PATH" export JAVA_HOME="/usr/bin/"
export PATH="/opt/nvim-linux64/bin:$PATH"
export PATH="$HOME/.local/bin/:$PATH"
export PATH="$HOME/.local/share/JetBrains/Toolbox/scripts:$PATH"
export PATH="$(composer config -g home)/vendor/bin:$PATH"
# phpbrew
# export PHPBREW_SET_PROMPT=1
# export PHPBREW_RC_ENABLE=1
# [ -f ~/.phpbrew/bashrc ] && source ~/.phpbrew/bashrc
# golang
export PATH="/usr/local/go/bin:$PATH"
export GOPATH="$HOME/.go"
# rust cargo
[ -f ~/.cargo/env ] && source ~/.cargo/env
# nvm
# export NVM_DIR="$HOME/.nvm"
# [ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" # This loads nvm
# [ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# The next line updates PATH for Yandex Cloud CLI. # The next line updates PATH for Yandex Cloud CLI.
if [ -f "$HOME/yandex-cloud/path.bash.inc" ]; then source "$HOME/yandex-cloud/path.bash.inc"; fi [ -f "$HOME/yandex-cloud/path.bash.inc" ] && source "$HOME/yandex-cloud/path.bash.inc"
# The next line enables shell command completion for yc. # The next line enables shell command completion for yc.
if [ -f "$HOME/yandex-cloud/completion.zsh.inc" ]; then source "$HOME/yandex-cloud/completion.zsh.inc"; fi [ -f "$HOME/yandex-cloud/completion.zsh.inc" ] && source "$HOME/yandex-cloud/completion.zsh.inc"

View File

@@ -6,6 +6,10 @@
"https://daocloud.io", "https://daocloud.io",
"https://c.163.com/", "https://c.163.com/",
"https://registry.docker-cn.com", "https://registry.docker-cn.com",
"https://huecker.io" "https://huecker.io",
"https://public.ecr.aws",
"https://quay.io",
"https://registry.access.redhat.com",
"https://registry.redhat.io"
] ]
} }

View File

@@ -0,0 +1,8 @@
// https://docs.sublimetext.io/reference/commands.html
// https://docs.sublimetext.io/reference/key_bindings.html
[
{ "keys": ["ctrl+k", "ctrl+o"], "command": "prompt_open_folder" },
{ "keys": ["ctrl+f2"], "command": "find_all_under"},
]

View File

@@ -0,0 +1,9 @@
// https://docs.sublimetext.io/reference/commands.html
// https://docs.sublimetext.io/reference/mouse_bindings.html
[
{
"button": "button2", "modifiers": ["ctrl"],
"command": "fold",
"press_command": "drag_select"
},
]

View File

@@ -0,0 +1,18 @@
{
"bootstrapped": true,
"in_process_packages":
[
],
"installed_packages":
[
"Docker Based Build Systems",
"Dockerfile Syntax Highlighting",
"LogView",
"Markdown Extended",
"MarkdownLivePreview",
"MarkdownPreview",
"Materialize",
"Package Control",
"phpfmt",
],
}

View File

@@ -0,0 +1,26 @@
{
"ignored_packages":
[
"Vintage",
],
"color_scheme": "Packages/Materialize/schemes/Material One Dark.tmTheme",
"theme": "Material One Dark.sublime-theme",
"index_files": true,
"font_face": "JetBrains Mono NL",
"font_options": [
"dlig",
"ss01",
"gray_antialias"
],
"fade_fold_buttons": false,
"rulers": [120],
"translate_tabs_to_spaces": true,
"highlight_line": true,
"control_character_style": "names",
"trim_trailing_white_space_on_save": "all",
"trim_only_modified_white_space": false,
"ensure_newline_at_eof_on_save": true,
"scroll_speed": 1.2,
"show_tab_close_buttons": false,
"folder_exclude_patterns": [".svn", ".hg", "CVS", ".Trash", ".Trash-*"],
}

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
[ -f Makefile ] && mv Makefile Makefile.bak [ -f Makefile ] && mv Makefile Makefile.bak
CHR_UPGRADE='^' CHR_UPGRADE='^'
CHR_UNINSTALL='/' CHR_UNINSTALL='/'

224
helpers
View File

@@ -1,224 +0,0 @@
#!/bin/bash
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
info "==============================================="
info "$title"
info "==============================================="
info
}
unpak_targz() {
require tar
tar -xzf "$1" -C "$2"
}
symlink() {
ln -sf "$1" "$2"
}
download() {
require wget
wget "$1" -O "$2"
}
clone() {
require git
git clone $*
}
clone_quick() {
require git
git clone $* --depth=1 --single-branch
}
abspath() {
echo $(realpath -q "${1/#\~/$HOME}")
}
is_writable() {
[ -w "$(abspath $1)" ]
}
is_dir() {
[ -d "$(abspath $1)" ]
}
is_file() {
[ -f "$(abspath $1)" ]
}
is_function() {
declare -F "$1" > /dev/null
}
regex_match() {
printf "%s" "$1" | grep -qP "$2"
}
in_array() {
local find=$1
shift
for e in "$@"; do
[[ "$e" == "$find" ]] && return 0
done
return 1
}
implode() {
local d=${1-}
local f=${2-}
if shift 2; then
printf %s "$f" "${@/#/$d}"
fi
}
IINFO="( i )"
INOTE="( * )"
IWARN="( # )"
IERROR="( ! )"
IFATAL="( @ )"
ISUCCESS="( ! )"
IASK="( ? )"
IDEBUG="(DBG)"
IVRB="( + )"
BOLD="\e[1m"
DIM="\e[2m"
NOTBOLD="\e[22m" # sometimes \e[21m
NOTDIM="\e[22m"
NORMAL="\e[20m"
RESET="\e[0m"
FRESET="\e[39m"
FBLACK="\e[30m"
FWHITE="\e[97m"
FRED="\e[31m"
FGREEN="\e[32m"
FYELLOW="\e[33m"
FBLUE="\e[34m"
FLRED="\e[91m"
FLGREEN="\e[92m"
FLYELLOW="\e[93m"
FLBLUE="\e[94m"
BRESET="\e[49m"
BBLACK="\e[40m"
BWHITE="\e[107m"
BRED="\e[41m"
BGREEN="\e[42m"
BYELLOW="\e[43m"
BBLUE="\e[44m"
BLRED="\e[101m"
BLGREEN="\e[102m"
BLYELLOW="\e[103m"
BLBLUE="\e[104m"
dt() {
echo "[$(date +'%H:%M:%S')] "
}
ask() {
IFS= read -rp "$(print ${BOLD}${BBLUE}${FWHITE}${IASK}${BRESET}\ ${BOLD}$1 ): " $2
}
print() {
echo -e "$*${RESET}"
}
debug() {
if [ "$2" ]; then
print "${DIM}${BOLD}${RESET}${DIM}${FUNCNAME[1]:-?}():${BASH_LINENO:-?}\t$1 "
else
print "${DIM}${BOLD}${RESET}${DIM}$1 "
fi
}
verbose() {
print "${BOLD}${IVRB}${RESET}${FYELLOW} $1 "
}
info() {
print "${BOLD}${FWHITE}${BLBLUE}${IINFO}${RESET}${FWHITE} $1 "
}
note() {
print "${BOLD}${DIM}${FWHITE}${INOTE}${RESET} $1 "
}
success() {
print "${BOLD}${BGREEN}${FWHITE}${ISUCCESS}${BRESET}$FGREEN $1 "
}
warn() {
print "${BOLD}${BYELLOW}${FBLACK}${IWARN}${BRESET}${FYELLOW} Warning:${RESET} $1 "
}
error() {
print "${BOLD}${BLRED}${FWHITE}${IERROR} Error: ${BRESET}${FLRED} $1 " >&2
}
fatal() {
print "${BOLD}${BRED}${FWHITE}${IFATAL} FATAL: $1 " >&2
print_stacktrace
}
die() {
error "${1:-halted}"
exit ${2:-100}
}
print_stacktrace() {
STACK=""
local i
local stack_size=${#FUNCNAME[@]}
debug "Callstack:"
# for (( i=$stack_size-1; i>=1; i-- )); do
for (( i=1; i<$stack_size; i++ )); do
local func="${FUNCNAME[$i]}"
[ x$func = x ] && func=MAIN
local linen="${BASH_LINENO[$(( i - 1 ))]}"
local src="${BASH_SOURCE[$i]}"
[ x"$src" = x ] && src=non_file_source
debug " at $func $src:$linen"
done
}

20
helpers.sh Normal file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -oe pipefail
__root__=$( dirname $(readlink -e -- "${BASH_SOURCE}"))
source $__root__/helpers/io.sh || exit 255
source $__root__/helpers/git.sh || exit 255
source $__root__/helpers/basic.sh || exit 255
source $__root__/helpers/debug.sh || exit 255
source $__root__/helpers/packages.sh || exit 255
title() {
[[ $__AAA_NO_TITLE = 1 ]] || {
[ "$1" ] && title="$1" || title="$(grep -m 1 -oP "(?<=^##makedesc:\s).*$" ${BASH_SOURCE[1]})"
info
info "==============================================="
info "$title"
info "==============================================="
info
}
}

View File

@@ -0,0 +1,111 @@
# Argument parser for bash scripts v1.6
## Usage
```shell
# 1. add these lines after shebang:
__RAW_ARGS__=("$@")
source args.sh
# 2. read arguments as flags:
arg a 1 flag_a
echo "Flag -a has value '$flag_a'"
echo "Flag -a has value '$(arg a 1)'"
arg b 1 flag_b
echo "Flag -b has value '$flag_b'"
echo "Flag -b has value '$(arg b 1)'"
arg c 1 flag_c
echo "Flag -c has value '$flag_c'"
echo "Flag -c has value '$(arg c 1)'"
arg d 1 flag_d
echo "Flag -d has value '$flag_d'"
echo "Flag -d has value '$(arg d 1)'"
argl flag1 1 flag_1
echo "Flag --flag1 has value '$flag_1'"
echo "Flag --flag1 has value '$(argl flag1 1)'"
argl flag2 1 flag_2
echo "Flag --flag2 has value '$flag_2'"
echo "Flag --flag2 has value '$(argl flag2 1)'"
# 3. and/or read arguments' values:
arg a 0 arg_a
echo "Arg -a has value '$arg_a'"
echo "Arg -a has value '$(arg a 0)'"
arg b 0 arg_b
echo "Arg -b has value '$arg_b'"
echo "Arg -b has value '$(arg b 0)'"
argl arg1 0 arg_1
echo "Arg --arg1 has value '$arg_1'"
echo "Arg --arg1 has value '$(argl arg1 0)'"
argl arg2 0 arg_2
echo "Arg --arg2 has value '$arg_2'"
echo "Arg --arg2 has value '$(argl arg2 0)'"
```
## How it works
1. Short arguments can be specified contiguously or separately
and their order does not matter, but before each of them
(or the first of them) one leading dash must be specified.
> Valid combinations: `-a -b -c`, `-cba`, `-b -azc "value of z"`
2. Short arguments can have values and if are - value must go
next to argument itself.
> Valid combinations: `-ab avalue`, `-ba avalue`, `-a avalue -b`
3. Long arguments cannot be combined like short ones and each
of them must be specified separately with two leading dashes.
> Valid combinations: `--foo --bar`, `--bar --foo`
4. Long arguments can have a value which must be specified after `=`.
> Valid combinations: `--foo value --bar`, `--bar --foo=value`
5. If arg value may contain space then value must be "double-quoted".
6. You can use arg() or argl() to check presence of any arg, no matter
if it has value or not.
More info:
* 🇷🇺 [axenov.dev/bash-args](https://axenov.dev/bash-args/)
* 🇺🇸 [axenov.dev/en/bash-processing-arguments-in-a-script-when-called-from-the-shell/](https://axenov.dev/en/bash-processing-arguments-in-a-script-when-called-from-the-shell)
Tested in Ubuntu 20.04.2 LTS in:
```
bash 5.0.17(1)-release (x86_64-pc-linux-gnu) and later
zsh 5.8 (x86_64-ubuntu-linux-gnu) and later
```
## Version history
```
v1.0 - initial
v1.1 - arg(): improved skipping uninteresting args
- arg(): check next arg to be valid value
v1.2 - removed all 'return' statements
- arg(): error message corrected
- new examples
v1.3 - argl(): improved flag check
- some text corrections
v1.4 - new function argn()
- some text corrections
v1.5 - arg(), grep_match(): fixed searching for -e argument
- grep_match(): redirect output into /dev/null
v1.6 - removed useless argn()
- arg() and argl() refactored and now support values with whitespaces
```

158
helpers/arg-parser/args.sh Executable file
View File

@@ -0,0 +1,158 @@
#!/usr/bin/env bash
# Argument parser for bash scripts
#
# Author: Anthony Axenov (Антон Аксенов)
# Version: 1.6
# License: MIT
# Description: https://git.axenov.dev/anthony/shell/src/branch/master/helpers/arg-parser
#purpose Little helper to check if string matches PCRE
#argument $1 - some string
#argument $2 - regex
#exitcode 0 - string valid
#exitcode 1 - string is not valid
grep_match() {
printf "%s" "$1" | grep -qE "$2" >/dev/null
}
#purpose Find short argument or its value
#argument $1 - (string) argument (without leading dashes; only first letter will be processed)
#argument $2 - (number) is it flag? 1 if is, otherwise 0 or nothing
#argument $3 - (string) variable to return value into
# (if not specified then it will be echo'ed in stdout)
#returns (string) 1 (if $2 == 1), value (if correct and if $2 != 1) or nothing
#usage To get value into var: arg v 0 myvar or myvalue=$(arg 'v')
#usage To find flag into var: arg f 1 myvar or flag=$(arg 'f')
#usage To echo value: arg v
#usage To echo 1 if flag exists: arg f
arg() {
[ "$1" ] || { echo "Argument name is not specified!" >&2 && exit 1; }
local arg_name="${1:0:1}" # first character of argument name to find
local is_flag="$2" || 0 # 1 if we need just find a flag, 0 to get a value
local var_name="$3" || 0 # variable name to return value into or 0 to echo it in stdout
local value= # initialize empty value to check if we found one later
local arg_found=0 # marker of found argument
for idx in "${!__RAW_ARGS__[@]}"; do # going through all args
local arg_search=${__RAW_ARGS__[idx]} # get current argument
# skip $arg_search if it starts with '--' or letter
grep_match "$arg_search" "^(\w|--)" && continue
# clear $arg_search from special and duplicate characters, e.g. 'fas-)dfs' will become 'fasd'
local arg_chars="$(printf "%s" "$arg_search" \
| tr -s "[$arg_search]" 2>/dev/null \
| tr -d "[:punct:][:blank:]" 2>/dev/null)"
# if $arg_name is not one of $arg_chars the skip it
grep_match "-$arg_name" "^-[$arg_chars]$" || continue
arg_found=1
# then return '1'|'0' back into $value if we need flag or next arg value otherwise
[ "$is_flag" = 1 ] && value=1 || value="${__RAW_ARGS__[idx+1]}"
break
done
[ "$is_flag" = 1 ] && [ -z "$value" ] && value=0;
# if value we found is empty or looks like another argument then exit with error message
if [ "$arg_found" = 1 ] && ! grep_match "$value" "^[[:graph:]]+$" || grep_match "$value" "^--?\w+$"; then
echo "ERROR: Argument '-$arg_name' must have correct value!" >&2 && exit 1
fi
# return '$value' back into $var_name (if exists) or echo in stdout
[ "$var_name" ] && eval "$var_name='$value'" || echo "$value"
}
#purpose Find long argument or its value
#argument $1 - argument (without leading dashes)
#argument $2 - (number) is it flag? 1 if is, otherwise 0 or nothing
#argument $3 - (string) variable to return value into
# (if not specified then it will be echo'ed in stdout)
#returns (string) 1 (if $2 == 1), value (if correct and if $2 != 1) or nothing
#usage To get value into var: arg v 0 myvar or myvalue=$(arg 'v')
#usage To find flag into var: arg f 1 myvar or flag=$(arg 'f')
#usage To echo value: arg v
#usage To echo 1 if flag exists: arg f
argl() {
[ "$1" ] || { echo "Argument name is not specified!" >&2 && exit 1; }
local arg_name="$1" # argument name to find
local is_flag="$2" || 0 # 1 if we need just find a flag, 0 to get a value
local var_name="$3" || 0 # variable name to return value into or 0 to echo it in stdout
local value= # initialize empty value to check if we found one later
local arg_found=0 # marker of found argument
for idx in "${!__RAW_ARGS__[@]}"; do # going through all args
local arg_search="${__RAW_ARGS__[idx]}" # get current argument
if [ "$arg_search" = "--$arg_name" ]; then # if current arg begins with two dashes
# then return '1' back into $value if we need flag or next arg value otherwise
[ "$is_flag" = 1 ] && value=1 || value="${__RAW_ARGS__[idx+1]}"
break # stop the loop
elif grep_match "$arg_search" "^--$arg_name=.+$"; then # check if $arg like '--foo=bar'
# then return '1' back into $value if we need flag or part from '=' to arg's end as value otherwise
[ "$is_flag" = 1 ] && value=1 || value="${arg_search#*=}"
break # stop the loop
fi
done
[ "$is_flag" = 1 ] && [ -z "$value" ] && value=0;
# if value we found is empty or looks like another argument then exit with error message
if [ "$arg_found" = 1 ] && ! grep_match "$value" "^[[:graph:]]+$" || grep_match "$value" "^--?\w+$"; then
echo "ERROR: Argument '--$arg_name' must have correct value!" >&2 && exit 1;
fi
# return '$value' back into $var_name (if exists) or echo in stdout
[ "$var_name" ] && eval "$var_name='$value'" || echo "$value"
}
################################
# This is simple examples which you can play around with.
# 1. uncomment code below
# 2. call thi sscript to see what happens:
# /args.sh -abcd --flag1 --flag2 -e evalue -f fvalue --arg1=value1 --arg2 value2
# __RAW_ARGS__=("$@")
# arg a 1 flag_a
# echo "Flag -a has value '$flag_a'"
# echo "Flag -a has value '$(arg a 1)'"
# arg b 1 flag_b
# echo "Flag -b has value '$flag_b'"
# echo "Flag -b has value '$(arg b 1)'"
# arg c 1 flag_c
# echo "Flag -c has value '$flag_c'"
# echo "Flag -c has value '$(arg c 1)'"
# arg d 1 flag_d
# echo "Flag -d has value '$flag_d'"
# echo "Flag -d has value '$(arg d 1)'"
# argl flag1 1 flag_1
# echo "Flag --flag1 has value '$flag_1'"
# echo "Flag --flag1 has value '$(argl flag1 1)'"
# argl flag2 1 flag_2
# echo "Flag --flag2 has value '$flag_2'"
# echo "Flag --flag2 has value '$(argl flag2 1)'"
# arg e 0 arg_e
# echo "Arg -e has value '$arg_e'"
# echo "Arg -e has value '$(arg e 0)'"
# arg f 0 arg_f
# echo "Arg -f has value '$arg_f'"
# echo "Arg -f has value '$(arg f 0)'"
# argl arg1 0 arg_1
# echo "Arg --arg1 has value '$arg_1'"
# echo "Arg --arg1 has value '$(argl arg1 0)'"
# argl arg2 0 arg_2
# echo "Arg --arg2 has value '$arg_2'"
# echo "Arg --arg2 has value '$(argl arg2 0)'"

127
helpers/basic.sh Normal file
View File

@@ -0,0 +1,127 @@
#!/usr/bin/env bash
source $( dirname $(readlink -e -- "${BASH_SOURCE}"))/io.sh || exit 255
########################################################
# Little handy helpers for scripting
########################################################
is_bash() {
[[ "$(basename "$SHELL")" != "bash" ]]
}
is_sourced() {
[[ "${BASH_SOURCE[0]}" != "$0" ]]
}
is_root() {
[[ "$(id -u)" -ne 0 || $(ps -o comm= -p $PPID) == "sudo" ]]
}
get_os() {
case "$(uname -s)" in
Linux*) echo Linux ;;
Darwin*) echo Macos ;;
CYGWIN*) echo Cygwin ;;
MINGW*) echo MinGw ;;
MSYS_NT*) echo Git ;;
*) return 1 ;;
esac
}
get_os_id() {
[ -f /etc/os-release ] && source /etc/os-release
echo "$ID"
}
# convert relative path $1 to full one
abspath() {
echo $(realpath -q "${1/#\~/$HOME}")
}
# check if path $1 is writable
is_writable() {
[ -w "$(abspath $1)" ]
}
# check if path $1 is a directory
is_dir() {
[ -d "$(abspath $1)" ]
}
# check if path $1 is a file
is_file() {
[ -f "$(abspath $1)" ]
}
# check if an argument is a shell function
is_function() {
declare -F "$1" > /dev/null
}
# check if string $1 matches regex $2
regex_match() {
printf "%s" "$1" | grep -qP "$2"
}
# check if array $2 contains string $1
in_array() {
local find=$1
shift
for e in "$@"; do
[[ "$e" == "$find" ]] && return 0
done
return 1
}
# join all elements of array $2 with delimiter $1
implode() {
local d=${1-}
local f=${2-}
if shift 2; then
printf %s "$f" "${@/#/$d}"
fi
}
# open url $1 in system web-browser
open_url() {
if which xdg-open > /dev/null; then
xdg-open "$1" </dev/null >/dev/null 2>&1 & disown
elif which gnome-open > /dev/null; then
gnome-open "$1" </dev/null >/dev/null 2>&1 & disown
fi
}
# unpack .tar.gz file $1 into path $2
unpack_targz() {
require tar
tar -xzvf "$1" -C "$2"
}
# make soft symbolic link of path $1 to path $2
symlink() {
ln -sf "$1" "$2"
}
# download file $1 into path $2 using wget
download() {
require wget
wget "$1" -O "$2"
}
# download file $1 into path $2 using curl
cdownload() {
require curl
curl -fsSL "$1" -o "$2"
}
is_int() {
[[ "$1" =~ ^[0-9]+$ ]]
}
is_number() {
[[ "$1" =~ ^[0-9]+([.,][0-9]+)?$ ]]
}
trim() {
echo "$1" | xargs
}

3
helpers/debug.sh Normal file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
source $( dirname $(readlink -e -- "${BASH_SOURCE}"))/io.sh || exit 255

79
helpers/docker.sh Normal file
View File

@@ -0,0 +1,79 @@
#!/usr/bin/env bash
########################################################
# Docker wrappers
########################################################
# Вызывает корректную команду docker compose
docker.compose() {
require docker
argl profiles 0 profiles
args=${*/--profiles=[a-zA-Z_,0-9]*/}
if $(docker compose &>/dev/null); then
local cmd="docker compose $args"
elif installed_pkg "docker-compose"; then
local cmd="docker-compose $args"
warn
warn "docker-compose v1 устарел и не поддерживается, его поведение непредсказуемо."
warn "Обнови docker согласно документации: https://docs.docker.com/engine/install/"
warn
else
error "Должен быть установлен docker-compose-plugin!"
die "Установи docker согласно документации: https://docs.docker.com/engine/install/" 2
fi
if [[ "$profiles" ]]; then
export COMPOSE_PROFILES=$profiles
debug "Выполнено: export COMPOSE_PROFILES=$profiles"
fi
debug "Команда: $cmd"
$cmd
}
# Выводит информацию о контейнере
docker.inspect() {
cmd="docker inspect $*"
debug "Команда: $cmd"
$cmd 2>/dev/null
}
# Выполняет команду в контейнере от имени root
docker.exec() {
cmd="docker exec -u root -it $*"
debug "Команда: $cmd"
$cmd
}
# Выводит информацию о контейнере
docker.inspect() {
cmd="docker inspect $*"
debug "Команда: $cmd"
$cmd 2>/dev/null
}
docker.ip() { # not finished
if [ "$1" ]; then
if [ "$1" = "-a" ]; then
docker ps -aq \
| xargs -n 1 docker inspect --format '{{.Name}}{{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' \
| sed -e 's#^/##' \
| column -t
elif [ "$1" = "-c" ]; then
docker-compose ps -q \
| xargs -n 1 docker inspect --format '{{.Name}}{{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' \
| sed -e 's#^/##' \
| column -t
else
docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$1"
docker port "$1"
fi
else
docker ps -q \
| xargs -n 1 docker inspect --format '{{.Name}}{{range .NetworkSettings.Networks}} {{.IPAddress}}{{end}}' \
| sed -e 's#^/##' \
| column -t
fi
}

178
helpers/git.sh Normal file
View File

@@ -0,0 +1,178 @@
#!/usr/bin/env bash
_dir=$( dirname $(readlink -e -- "${BASH_SOURCE}"))
source "$_dir/io.sh" || exit 255
source "$_dir/basic.sh" || exit 255
source "$_dir/packages.sh" || exit 255
########################################################
# Shorthands for git
########################################################
git.clone_quick() {
require git
git clone --depth=1 --single-branch "$@"
}
git.is_repo() {
require git
[ "$1" ] || die "Path is not specified" 101
require_dir "$1/"
check_dir "$1/.git"
}
git.require_repo() {
require git
git.is_repo "$1" || die "'$1' is not git repository!" 10
}
git.cfg() {
require git
[ "$1" ] || die "Key is not specified" 101
if [[ "$2" ]]; then
git config --global --replace-all "$1" "$2"
else
echo $(git config --global --get-all "$1")
fi
}
git.set_user() {
require git
[ "$1" ] || die "git.set_user: Repo is not specified" 100
git.cfg "$1" "user.name" "$2"
git.cfg "$1" "user.email" "$3"
success "User set to '$name <$email>' in ${FWHITE}$1"
}
git.fetch() {
require git
if [ "$1" ]; then
if git.remote_branch_exists "origin/$1"; then
git fetch origin "refs/heads/$1:refs/remotes/origin/$1" --progress --prune --quiet 2>&1 || die "Could not fetch $1 from origin" 12
else
warn "Tried to fetch branch 'origin/$1' but it does not exist."
fi
else
git fetch origin --progress --prune --quiet 2>&1 || exit 12
fi
}
git.reset() {
require git
git reset --hard HEAD
git clean -fd
}
git.clone() {
require git
git clone "$*" 2>&1
}
git.co() {
require git
git checkout "$*" 2>&1
}
git.is_it_current_branch() {
require git
[ "$1" ] || die "git.is_it_current_branch: Branch is not specified" 19
[[ "$(git.current_branch)" = "$1" ]]
}
git.pull() {
require git
[ "$1" ] && BRANCH=$1 || BRANCH=$(git.current_branch)
# note "Updating branch $BRANCH..."
git pull origin "refs/heads/$BRANCH:refs/remotes/origin/$BRANCH" --prune --force --quiet 2>&1 || exit 13
git pull origin --tags --force --quiet 2>&1 || exit 13
# [ "$1" ] || die "git.pull: Branch is not specified" 19
# if [ "$1" ]; then
# note "Updating branch $1..."
# git pull origin "refs/heads/$1:refs/remotes/origin/$1" --prune --force --quiet 2>&1 || exit 13
# else
# note "Updating current branch..."
# git pull
# fi
}
git.current_branch() {
require git
git branch --show-current || exit 18
}
git.local_branch_exists() {
require git
[ -n "$(git for-each-ref --format='%(refname:short)' refs/heads/$1)" ]
}
git.update_refs() {
require git
info "Updating local refs..."
git remote update origin --prune 1>/dev/null 2>&1 || exit 18
}
git.delete_remote_branch() {
require git
[ "$1" ] || die "git.remote_branch_exists: Branch is not specified" 19
if git.remote_branch_exists "origin/$1"; then
git push origin :"$1" # || die "Could not delete the remote $1 in $ORIGIN"
return 0
else
warn "Trying to delete the remote branch $1, but it does not exists in origin"
return 1
fi
}
git.is_clean_worktree() {
require git
git rev-parse --verify HEAD >/dev/null || exit 18
git update-index -q --ignore-submodules --refresh
git diff-files --quiet --ignore-submodules || return 1
git diff-index --quiet --ignore-submodules --cached HEAD -- || return 2
return 0
}
git.is_branch_merged_into() {
require git
[ "$1" ] || die "git.remote_branch_exists: Branch1 is not specified" 19
[ "$2" ] || die "git.remote_branch_exists: Branch2 is not specified" 19
git.update_refs
local merge_hash=$(git merge-base "$1"^{} "$2"^{})
local base_hash=$(git rev-parse "$1"^{})
[ "$merge_hash" = "$base_hash" ]
}
git.remote_branch_exists() {
require git
[ "$1" ] || die "git.remote_branch_exists: Branch is not specified" 19
git.update_refs
[ -n "$(git for-each-ref --format='%(refname:short)' refs/remotes/$1)" ]
}
git.new_branch() {
require git
[ "$1" ] || die "git.new_branch: Branch is not specified" 19
if [ "$2" ] && ! git.local_branch_exists "$2" && git.remote_branch_exists "origin/$2"; then
git.co -b "$1" origin/"$2"
else
git.co -b "$1" "$2"
fi
}
git.require_clean_worktree() {
require git
if ! git.is_clean_worktree; then
warn "Your working tree is dirty! Look at this:"
git status -bs
_T="What should you do now?\n"
_T="${_T}\t${BOLD}${FWHITE}0.${RESET} try to continue as is\t- errors may occur!\n"
_T="${_T}\t${BOLD}${FWHITE}1.${RESET} hard reset\t\t\t- clear current changes and new files\n"
_T="${_T}\t${BOLD}${FWHITE}2.${RESET} stash changes (default)\t- save all changes in safe to apply them later via 'git stash pop'\n"
_T="${_T}\t${BOLD}${FWHITE}3.${RESET} cancel\n"
ask "${_T}${BOLD}${FWHITE}Your choice [0-3]" reset_answer
case $reset_answer in
1 ) warn "Clearing your work..." && git.reset ;;
3 ) exit ;;
* ) git stash -a -u -m "WIP before switch to $branch_task" ;;
esac
fi
}

28
helpers/help.sh Normal file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env bash
#TODO source basic.sh
#TODO source args-parser/args.sh
########################################################
# Help functions
########################################################
process_help_arg() {
command="${FUNCNAME[1]}"
need_help=$(arg help 1)
[[ "$need_help" -eq 0 ]] && need_help=$(argl help 1)
[[ "$need_help" -eq 1 ]] && help "$command"
}
help() {
is_function "help.$1" && help."$1" && exit
echo "Main help message"
}
help.example() {
echo "Example help message"
}
example() {
process_help_arg
echo "Example command"
}

393
helpers/io.sh Normal file
View File

@@ -0,0 +1,393 @@
#!/usr/bin/env bash
########################################################
# Simple and fancy input & output
########################################################
which tput > /dev/null 2>&1 && [[ $(tput -T$TERM colors) -gt 8 ]] && CAN_USE_COLORS=1 || CAN_USE_COLORS=0
USE_COLORS=${USE_COLORS:-$CAN_USE_COLORS}
# Icons (message prefixes)
[[ "$USE_COLORS" == 1 ]] && IINFO="( i )" || IINFO=''
[[ "$USE_COLORS" == 1 ]] && INOTE="( * )" || INOTE=''
[[ "$USE_COLORS" == 1 ]] && IWARN="( # )" || IWARN=''
[[ "$USE_COLORS" == 1 ]] && IERROR="( ! )" || IERROR=''
[[ "$USE_COLORS" == 1 ]] && IFATAL="( @ )" || IFATAL=''
[[ "$USE_COLORS" == 1 ]] && ISUCCESS="( ! )" || ISUCCESS=''
[[ "$USE_COLORS" == 1 ]] && IASK="( ? )" || IASK=''
[[ "$USE_COLORS" == 1 ]] && IDEBUG="(DBG)" || IDEBUG=''
[[ "$USE_COLORS" == 1 ]] && IVRB="( + )" || IVRB=''
# Text attributes
[[ "$USE_COLORS" == 1 ]] && FRESET="$(tput sgr0)" || FRESET='' # Normal
[[ "$USE_COLORS" == 1 ]] && FBOLD="$(tput bold)" || FBOLD='' # Bold
[[ "$USE_COLORS" == 1 ]] && FDIM="$(tput dim)" || FDIM='' # Dimmed
[[ "$USE_COLORS" == 1 ]] && FLINE="$(tput smul)" || FLINE='' # Underlined
[[ "$USE_COLORS" == 1 ]] && FENDLINE="$(tput rmul)" || FENDLINE='' # End of underlined
[[ "$USE_COLORS" == 1 ]] && FBLINK="$(tput blink)" || FBLINK='' # Blink
[[ "$USE_COLORS" == 1 ]] && FREV="$(tput rev)" || FREV='' # Reversed
# Text colors - normal
[[ "$USE_COLORS" == 1 ]] && FBLACK="$(tput setaf 0)" || FBLACK='' # Black
[[ "$USE_COLORS" == 1 ]] && FRED="$(tput setaf 1)" || FRED='' # Red
[[ "$USE_COLORS" == 1 ]] && FGREEN="$(tput setaf 2)" || FGREEN='' # Green
[[ "$USE_COLORS" == 1 ]] && FYELLOW="$(tput setaf 3)" || FYELLOW='' # Yellow
[[ "$USE_COLORS" == 1 ]] && FBLUE="$(tput setaf 4)" || FBLUE='' # Blue
[[ "$USE_COLORS" == 1 ]] && FPURPLE="$(tput setaf 5)" || FPURPLE='' # Purple
[[ "$USE_COLORS" == 1 ]] && FCYAN="$(tput setaf 6)" || FCYAN='' # Cyan
[[ "$USE_COLORS" == 1 ]] && FWHITE="$(tput setaf 7)" || FWHITE='' # White
# Text colors - bright
[[ "$USE_COLORS" == 1 ]] && FLBLACK="$(tput setaf 8)" || FLBLACK='' # Black
[[ "$USE_COLORS" == 1 ]] && FLRED="$(tput setaf 9)" || FLRED='' # Red
[[ "$USE_COLORS" == 1 ]] && FLGREEN="$(tput setaf 10)" || FLGREEN='' # Green
[[ "$USE_COLORS" == 1 ]] && FLYELLOW="$(tput setaf 11)" || FLYELLOW='' # Yellow
[[ "$USE_COLORS" == 1 ]] && FLBLUE="$(tput setaf 12)" || FLBLUE='' # Blue
[[ "$USE_COLORS" == 1 ]] && FLPURPLE="$(tput setaf 13)" || FLPURPLE='' # Purple
[[ "$USE_COLORS" == 1 ]] && FLCYAN="$(tput setaf 14)" || FLCYAN='' # Cyan
[[ "$USE_COLORS" == 1 ]] && FLWHITE="$(tput setaf 15)" || FLWHITE='' # White
# Background colors - normal
[[ "$USE_COLORS" == 1 ]] && FBBLACK="$(tput setab 0)" || FBBLACK='' # Black
[[ "$USE_COLORS" == 1 ]] && FBRED="$(tput setab 1)" || FBRED='' # Red
[[ "$USE_COLORS" == 1 ]] && FBGREEN="$(tput setab 2)" || FBGREEN='' # Green
[[ "$USE_COLORS" == 1 ]] && FBYELLOW="$(tput setab 3)" || FBYELLOW='' # Yellow
[[ "$USE_COLORS" == 1 ]] && FBBLUE="$(tput setab 4)" || FBBLUE='' # Blue
[[ "$USE_COLORS" == 1 ]] && FBPURPLE="$(tput setab 5)" || FBPURPLE='' # Purple
[[ "$USE_COLORS" == 1 ]] && FBCYAN="$(tput setab 6)" || FBCYAN='' # Cyan
[[ "$USE_COLORS" == 1 ]] && FBWHITE="$(tput setab 7)" || FBWHITE='' # White
# Background colors - bright
[[ "$USE_COLORS" == 1 ]] && FBLBLACK="$(tput setab 8)" || FBLBLACK='' # Black
[[ "$USE_COLORS" == 1 ]] && FBLRED="$(tput setab 9)" || FBLRED='' # Red
[[ "$USE_COLORS" == 1 ]] && FBLGREEN="$(tput setab 10)" || FBLGREEN='' # Green
[[ "$USE_COLORS" == 1 ]] && FBLYELLOW="$(tput setab 11)" || FBLYELLOW='' # Yellow
[[ "$USE_COLORS" == 1 ]] && FBLBLUE="$(tput setab 12)" || FBLBLUE='' # Blue
[[ "$USE_COLORS" == 1 ]] && FBLPURPLE="$(tput setab 13)" || FBLPURPLE='' # Purple
[[ "$USE_COLORS" == 1 ]] && FBLCYAN="$(tput setab 14)" || FBLCYAN='' # Cyan
[[ "$USE_COLORS" == 1 ]] && FBLWHITE="$(tput setab 15)" || FBLWHITE='' # White
now() {
echo "[$(date +'%H:%M:%S')] "
}
ask() {
IFS= read -rp "$(print ${FBOLD}${FBBLUE}${FWHITE}${IASK}${FRESET}\ ${FBOLD}$1 ): " $2
}
print() {
# if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi
echo -e "$*${FRESET}"
}
link() {
echo -e "\e]8;;$2\a$1\e]8;;\a"
}
debug() {
if [ "$2" ]; then
print "${FDIM}${FBOLD}${FRESET}${FDIM}$(now)${IDEBUG} ${FUNCNAME[1]:-?}():${BASH_LINENO:-?}\t$1 " >&2
else
print "${FDIM}${FBOLD}${FRESET}${FDIM}$(now)${IDEBUG} $1 " >&2
fi
}
var_dump() {
debug "$1 = ${!1}"
}
print_stacktrace() {
STACK=""
local i
local stack_size=${#FUNCNAME[@]}
debug "Callstack:"
# for (( i=$stack_size-1; i>=1; i-- )); do
for (( i=1; i<$stack_size; i++ )); do
local func="${FUNCNAME[$i]}"
[ x$func = x ] && func=MAIN
local linen="${BASH_LINENO[$(( i - 1 ))]}"
local src="${BASH_SOURCE[$i]}"
[ x"$src" = x ] && src=non_file_source
debug " at $func $src:$linen"
done
}
verbose() {
print "${FBOLD}$(now)${IVRB}${FRESET}${FYELLOW} $1 "
}
info() {
print "${FBOLD}$(now)${FWHITE}${FBLBLUE}${IINFO}${FRESET}${FWHITE} $1 "
}
note() {
print "${FBOLD}$(now)${FDIM}${FWHITE}${INOTE}${FRESET} $1 "
}
success() {
print "${FBOLD}$(now)${FBGREEN}${FWHITE}${ISUCCESS}${FRESET}$FGREEN $1 "
}
warn() {
print "${FBOLD}$(now)${FBYELLOW}${FBLACK}${IWARN}${FRESET}${FYELLOW} Warning:${FRESET} $1 "
}
error() {
print "${FBOLD}$(now)${FBLRED}${FWHITE}${IERROR} Error: ${FRESET}${FLRED} $1 " >&2
}
fatal() {
print "${FBOLD}$(now)${FBRED}${FWHITE}${IFATAL} FATAL: $1 " >&2
print_stacktrace
}
die() {
error "${1:-halted}"
exit ${2:-255}
}
# var='test var_dump'
# var_dump var
# debug 'test debug'
# verbose 'test verbose'
# info 'test info'
# note 'test note'
# success 'test success'
# warn 'test warn'
# error 'test error'
# fatal 'test fatal'
# die 'test die'
# experiments ==============================================================================
# spinner() {
# local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
# local spin_i=0
# local interval=0.1
# printf "\e[?25l"
# local color="${FGREEN}"
# while true; do
# printf "\r ${color}%s${CL}" "${frames[spin_i]}"
# spin_i=$(( (spin_i + 1) % ${#frames[@]} ))
# sleep "$interval"
# done
# }
# echo "lorem ipsum dolor sit amet"
# spinner &
# SPINNER_PID=$!
# ===========
# https://unix.stackexchange.com/a/269085
# https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
# https://linuxcommand.org/lc3_adv_tput.php
# https://gist.github.com/nowmilano/4055d6df5b6e4ea87c5a72dc2d604193
# https://gist.github.com/nick3499/402a6d7dccd474f2bdb679f4311b1238
# https://gist.github.com/connorjan/2b02126868157c2b69f9aa0a052cdc86
# tput setaf 0
# echo "BLACK FOREGROUND"
# tput setaf 1
# echo "RED FOREGROUND"
# tput setaf 2
# echo "GREEN FOREGROUND"
# tput setaf 3
# echo "YELLOW FOREGROUND"
# tput setaf 4
# echo "BLUE FOREGROUND"
# tput setaf 5
# echo "MAGENTA FOREGROUND"
# tput setaf 6
# echo "CYAN FOREGROUND"
# tput setaf 7
# echo "WHITE FOREGROUND"
# tput reset
# ===========
# ===========
# tohex(){
# dec=$(($1%256)) ### input must be a number in range 0-255.
# if [ "$dec" -lt "16" ]; then
# bas=$(( dec%16 ))
# mul=128
# [ "$bas" -eq "7" ] && mul=192
# [ "$bas" -eq "8" ] && bas=7
# [ "$bas" -gt "8" ] && mul=255
# a="$(( (bas&1) *mul ))"
# b="$(( ((bas&2)>>1)*mul ))"
# c="$(( ((bas&4)>>2)*mul ))"
# printf 'dec= %3s basic= #%02x%02x%02x\n' "$dec" "$a" "$b" "$c"
# elif [ "$dec" -gt 15 ] && [ "$dec" -lt 232 ]; then
# b=$(( (dec-16)%6 )); b=$(( b==0?0: b*40 + 55 ))
# g=$(( (dec-16)/6%6)); g=$(( g==0?0: g*40 + 55 ))
# r=$(( (dec-16)/36 )); r=$(( r==0?0: r*40 + 55 ))
# printf 'dec= %3s color= #%02x%02x%02x\n' "$dec" "$r" "$g" "$b"
# else
# gray=$(( (dec-232)*10+8 ))
# printf 'dec= %3s gray= #%02x%02x%02x\n' "$dec" "$gray" "$gray" "$gray"
# fi
# }
# for i in $(seq 0 255); do
# tohex ${i}
# done
# ===========
# fromhex(){
# hex=${1#"#"}
# r=$(printf '0x%0.2s' "$hex")
# g=$(printf '0x%0.2s' ${hex#??})
# b=$(printf '0x%0.2s' ${hex#????})
# printf '%03d' "$(( (r<75?0:(r-35)/40)*6*6 +
# (g<75?0:(g-35)/40)*6 +
# (b<75?0:(b-35)/40) + 16 ))"
# }
# fromhex 00fc7b
# ===========
# mode2header(){
# #### For 16 Million colors use \e[0;38;2;R;G;Bm each RGB is {0..255}
# printf '\e[mR\n' # reset the colors.
# printf '\n\e[m%59s\n' "Some samples of colors for r;g;b. Each one may be 000..255"
# printf '\e[m%59s\n' "for the ansi option: \e[0;38;2;r;g;bm or \e[0;48;2;r;g;bm :"
# }
# mode2colors(){
# # foreground or background (only 3 or 4 are accepted)
# local fb="$1"
# [[ $fb != 3 ]] && fb=4
# local samples=(0 63 127 191 255)
# for r in "${samples[@]}"; do
# for g in "${samples[@]}"; do
# for b in "${samples[@]}"; do
# printf '\e[0;%s8;2;%s;%s;%sm%03d;%03d;%03d ' "$fb" "$r" "$g" "$b" "$r" "$g" "$b"
# done; printf '\e[m\n'
# done; printf '\e[m'
# done; printf '\e[mReset\n'
# }
# mode2header
# mode2colors 3
# mode2colors 4
# ===========
# printf '\e[48;5;%dm ' {0..255}; printf '\e[0m \n'
# for r in {200..255..5}; do
# fb=4
# g=1
# b=1
# printf '\e[0;%s8;2;%s;%s;%sm ' "$fb" "$r" "$g" "$b"
# done
# echo
# ===========
# color(){
# for c; do
# printf '\e[48;5;%dm%03d' $c $c
# done
# printf '\e[0m \n'
# }
# IFS=$' \t\n'
# color {0..15}
# for ((i=0;i<6;i++)); do
# color $(seq $((i*36+16)) $((i*36+51)))
# done
# color {232..255}
# ===========
# for ((i=0; i<256; i++)) ;do
# echo -n ' '
# tput setab $i
# tput setaf $(( ( (i>231&&i<244 ) || ( (i<17)&& (i%8<2)) ||
# (i>16&&i<232)&& ((i-16)%6 <(i<100?3:2) ) && ((i-16)%36<15) )?7:16))
# printf " C %03d " $i
# tput op
# (( ((i<16||i>231) && ((i+1)%8==0)) || ((i>16&&i<232)&& ((i-15)%6==0)) )) &&
# printf "\n" ''
# done
# ===========
# echo "tput character test"
# echo "==================="
# echo
# tput bold; echo "This text has the bold attribute."; tput sgr0
# tput smul; echo "This text is underlined (smul)."; tput rmul
# # Most terminal emulators do not support blinking text (though xterm
# # does) because blinking text is considered to be in bad taste ;-)
# tput blink; echo "This text is blinking (blink)."; tput sgr0
# tput rev; echo "This text has the reverse attribute"; tput sgr0
# # Standout mode is reverse on many terminals, bold on others.
# tput smso; echo "This text is in standout mode (smso)."; tput rmso
# tput sgr0
# echo
# experiments ==============================================================================
# function delay_spinner(){
# ##
# ## Usage:
# ##
# ## $ long-running-command &
# ## $ delay_spinner " Please wait msg..."
# ##
# ## Spinner exists when long-running-command completes
# ##
# local PROGRESSTXT
# if [ ! "$1" ]; then
# PROGRESSTXT=" Please wait..."
# else
# PROGRESSTXT="$1"
# fi
# # visual progress marker function
# # http://stackoverflow.com/users/2869509/wizurd
# # vars
# local pid=$!
# local delay=0.1
# local spinstr='|/-\'
# echo -e "\n\n"
# while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
# local temp=${spinstr#?}
# printf "\r$PROGRESSTXT[%c] " "$spinstr"
# local spinstr=$temp${spinstr%"$temp"}
# sleep $delay
# printf "\b\b\b\b\b\b"
# done
# printf -- '\n\n'
# #
# # <-- end function ec2cli_spinner -->
# #
# }
# sleep 10 && echo 'test' &
# delay_spinner "Please wait msg..."

13
helpers/log.sh Normal file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
########################################################
# Logging functions
########################################################
# write some message $1 in log file and stdout with timestamp
log_path="/home/$USER/logs"
log() {
[ ! -d "$log_path" ] && log_path="./log"
[ ! -d "$log_path" ] && mkdir -p "$log_path"
echo -e "[$(date '+%H:%M:%S')] $*" | tee -a "$log_path/$(date '+%Y%m%d').log"
}

29
helpers/misc.sh Normal file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
########################################################
# Misc
########################################################
# https://askubuntu.com/a/30414
is_full_screen() {
local WINDOW=$(xwininfo -id "$(xdotool getactivewindow)" -stats \
| grep -E '(Width|Height):' \
| awk '{print $NF}' \
| sed -e 's/ /x/')
local SCREEN=$(xdpyinfo | grep -m1 dimensions | awk '{print $2}')
if [ "$WINDOW" = "$SCREEN" ]; then
return 0
fi
return 1
}
ytm() {
youtube-dl \
--extract-audio \
--audio-format flac \
--audio-quality 0 \
--format bestaudio \
--write-info-json \
--output "$HOME/Downloads/ytm/%(playlist_title)s/%(channel)s - %(title)s.%(ext)s" \
"$@"
}

51
helpers/net.sh Normal file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env bash
########################################################
# Networking functions
########################################################
get_current_ip() {
local CURRENT_IP
[ -f /etc/os-release ] && source /etc/os-release
case "$ID" in
debian|ubuntu) CURRENT_IP=$(hostname -I | awk '{print $1}') ;;
alpine) CURRENT_IP=$(ip -4 addr show eth0 | awk '/inet / {print $2}' | cut -d/ -f1 | head -n 1) ;;
*) CURRENT_IP="Unknown" ;;
esac
echo "$CURRENT_IP"
}
get_external_ip() {
local ip="$(curl -s https://api.myip.com | jq .ip)"
echo "$ip" | tr -d '"'
}
is_valid_ipv4() {
local ip="$1"
local regex="^([0-9]{1,3}\.){3}[0-9]{1,3}$"
if [[ $ip =~ $regex ]]; then
IFS='.' read -r -a parts <<< "$ip"
for part in "${parts[@]}"; do
if ! [[ $part =~ ^[0-9]+$ ]] || ((part < 0 || part > 255)); then
return 1
fi
done
return 0
fi
return 1
}
curltime() {
curl -w @- -o /dev/null -s "$@" <<'EOF'
time_namelookup: %{time_namelookup} sec\n
time_connect: %{time_connect} sec\n
time_appconnect: %{time_appconnect} sec\n
time_pretransfer: %{time_pretransfer} sec\n
time_redirect: %{time_redirect} sec\n
time_starttransfer: %{time_starttransfer} sec\n
---------------\n
time_total: %{time_total} sec\n
EOF
}

63
helpers/notif.sh Normal file
View File

@@ -0,0 +1,63 @@
#!/usr/bin/env bash
########################################################
# Notifications
########################################################
TITLE="$0"
NTFY_CHANNEL="example"
# отправляет простую нотификацию
ntfy_info() {
require ntfy
ntfy send \
--title "$TITLE" \
--message "$1" \
--priority 1 \
"$NTFY_CHANNEL"
}
# отправляет нотификацию с предупреждением
ntfy_warn() {
require ntfy
ntfy send \
--title "$TITLE" \
--tags "warning" \
--message "$1" \
--priority 5 \
"$NTFY_CHANNEL"
}
notify () {
if ! installed "notify-send"; then
warning "Notifications toggled on, but 'notify-send' is not installed!"
return 1
fi
[ -n "$1" ] && local title="$1"
local text="$2"
local level="$3"
local icon="$4"
case "$level" in
critical) local timeout=0 ;;
low) local timeout=5000 ;;
*) local timeout=10000 ;;
esac
debug "$title / $text / $level / $icon / $timeout"
notify-send "$title" "$text" -a "$0" -u "$level" -i "$icon" -t $timeout
}
# TODO: docblock
notify_error() {
notify "Error" "$1" "critical" "dialog-error"
}
# TODO: docblock
notify_warning() {
notify "Warning" "$1" "normal" "dialog-warning"
}
# TODO: docblock
notify_info() {
notify "" "$1" "low" "dialog-information"
}

32
helpers/notifications.sh Normal file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
source $( dirname $(readlink -e -- "${BASH_SOURCE}"))/packages.sh || exit 255
########################################################
# Desktop notifications
########################################################
notify () {
require "notify-send"
[ -n "$1" ] && local title="$1" || local title="My notification"
local text="$2"
local level="$3"
local icon="$4"
case $level in
"critical") local timeout=0 ;;
"low") local timeout=5000 ;;
*) local timeout=10000 ;;
esac
notify-send "$title" "$text" -a "MyScript" -u "$level" -i "$icon" -t $timeout
}
notify_error() {
notify "Error" "$1" "critical" "dialog-error"
}
notify_warning() {
notify "Warning" "$1" "normal" "dialog-warning"
}
notify_info() {
notify "" "$1" "low" "dialog-information"
}

72
helpers/packages.sh Normal file
View File

@@ -0,0 +1,72 @@
#!/usr/bin/env bash
source $( dirname $(readlink -e -- "${BASH_SOURCE}"))/io.sh || exit 255
########################################################
# Functions to control system packages
########################################################
installed() {
command -v "$1" >/dev/null 2>&1
}
installed_pkg() {
dpkg --list | grep -qw "ii $1"
}
apt_ppa_add() {
sudo add-apt-repository -y $*
}
apt_ppa_remove() {
sudo add-apt-repository -ry $*
}
apt_update() {
sudo apt update $*
}
apt_install() {
sudo apt install -y $*
}
apt_remove() {
sudo apt purge -y $*
}
dpkg_install() {
sudo dpkg -i $*
}
dpkg_remove() {
sudo dpkg -r $*
}
dpkg_arch() {
dpkg --print-architecture
}
require() {
sw=()
for package in "$@"; do
if ! installed "$package" && ! installed_pkg "$package"; then
sw+=("$package")
fi
done
if [ ${#sw[@]} -gt 0 ]; then
info "These packages will be installed in your system:\n${sw[*]}"
apt_install ${sw[*]}
[ $? -gt 0 ] && die "installation cancelled" 201
fi
}
require_pkg() {
sw=()
for package in "$@"; do
if ! installed "$package" && ! installed_pkg "$package"; then
sw+=("$package")
fi
done
if [ ${#sw[@]} -gt 0 ]; then
die "These packages must be installed in your system:\n${sw[*]}" 200
fi
}

89
helpers/testing.sh Normal file
View File

@@ -0,0 +1,89 @@
#!/usr/bin/env bash
source $( dirname $(readlink -e -- "${BASH_SOURCE}"))/io.sh || exit 255
########################################################
# Testing functions
########################################################
# $1 - command to exec
assert_exec() {
[ "$1" ] || exit 1
local prefix="$(dt)${BOLD}${FWHITE}[TEST EXEC]"
if $($1 1>/dev/null 2>&1); then
local text="${BGREEN} PASSED"
else
local text="${BLRED} FAILED"
fi
print "${prefix} ${text} ${BRESET} ($?):${RESET} $1"
}
# usage:
# func1() {
# return 0
# }
# func2() {
# return 1
# }
# assert_exec "func1" # PASSED
# assert_exec "func2" # FAILED
# assert_exec "whoami" # PASSED
# $1 - command to exec
# $2 - expected output
assert_output() {
[ "$1" ] || exit 1
[ "$2" ] && local expected="$2" || local expected=''
local prefix="$(dt)${BOLD}${FWHITE}[TEST OUTP]"
local output=$($1 2>&1)
local code=$?
if [[ "$output" == *"$expected"* ]]; then
local text="${BGREEN} PASSED"
else
local text="${BLRED} FAILED"
fi
print "${prefix} ${text} ${BRESET} (${code}|${expected}):${RESET} $1"
# print "\tOutput > $output"
}
# usage:
# func1() {
# echo "some string"
# }
# func2() {
# echo "another string"
# }
# expect_output "func1" "string" # PASSED
# expect_output "func2" "some" # FAILED
# expect_output "func2" "string" # PASSED
# $1 - command to exec
# $2 - expected exit-code
assert_code() {
[ "$1" ] || exit 1
[ "$2" ] && local expected=$2 || local expected=0
local prefix="$(dt)${BOLD}${FWHITE}[TEST CODE]"
$($1 1>/dev/null 2>&1)
local code=$?
if [[ $code -eq $expected ]]; then
local text="${BGREEN} PASSED"
else
local text="${BLRED} FAILED"
fi
print "${prefix} ${text} ${BRESET} (${code}|${expected}):${RESET} $1"
}
# usage:
# func1() {
# # exit 0
# return 0
# }
# func2() {
# # exit 1
# return 1
# }
# expect_code "func1" 0 # PASSED
# expect_code "func1" 1 # FAILED
# expect_code "func2" 0 # FAILED
# expect_code "func2" 1 # PASSED

21
helpers/traps.sh Normal file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
#TODO source basic.sh
#TODO source args-parser/args.sh
########################################################
# Trap usage examples
########################################################
# for sig in SIGHUP SIGINT SIGQUIT SIGABRT SIGKILL SIGTERM SIGTSTP; do
# # shellcheck disable=SC2064
# trap "set +x && echo && echo && echo '*** Прервано сигналом $sig, остановка ***' && exit" $sig
# done
for sig in SIGHUP SIGINT SIGQUIT SIGABRT SIGKILL SIGTERM SIGTSTP; do
trap "myfunc" $sig
done
myfunc() {
echo "trapped!"
exit
}

View File

@@ -1,15 +1,11 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install apache2 (latest) ##makedesc: Install apache2 (latest)
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
title title
sudo apt install -y --autoremove apache2 && \ apt_install apache2
sudo systemctl restart apache2 sudo systemctl restart apache2
[ $? = 0 ] && { success "apache2 installed!"
echo apache2 -v
success "apache2 installed!"
apache2 -v
echo
}

View File

@@ -1,8 +1,5 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install software from apt ##makedesc: Install software from apt
source `dirname $0`/../helpers || exit 255
title
sudo apt update && \ sudo apt update && \
sudo apt upgrade -y --autoremove && \ sudo apt upgrade -y --autoremove && \
@@ -27,7 +24,6 @@ sudo apt update && \
libghc-zlib-dev \ libghc-zlib-dev \
libssl-dev \ libssl-dev \
lsb-release \ lsb-release \
lsp-plugins \
make \ make \
mc \ mc \
meld \ meld \
@@ -36,7 +32,7 @@ sudo apt update && \
net-tools \ net-tools \
nmap \ nmap \
p7zip-full \ p7zip-full \
pulseeffects \ easyeffects \
software-properties-common \ software-properties-common \
terminator \ terminator \
ubuntu-restricted-extras \ ubuntu-restricted-extras \
@@ -51,9 +47,4 @@ sudo apt update && \
tree \ tree \
earlyoom earlyoom
# sqlitebrowser # sqlitebrowser
# etckeeper \ # etckeeper
# geoclue-2.0 \
# gnome-software \
# minder \
# redshift \
# redshift-gtk

View File

@@ -1,17 +1,13 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install Canon Pixma MG2500 + ppa ##makedesc: Install Canon Pixma MG2500 + ppa
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
title title
sudo add-apt-repository -y ppa:thierry-f/fork-michael-gruz && \ apt_ppa_add ppa:thierry-f/fork-michael-gruz
sudo apt install -y \
cnijfilter-mg2500series \
scangearmp-mg2500series
[ $? = 0 ] && { apt_install cnijfilter-mg2500series
echo apt_install scangearmp-mg2500series
success "Canon Pixma MG2500 installed!"
info "Now you must add a new printer in your system." success "Drivers for Canon Pixma MG2500 installed!"
echo info "Now you must reboot PC and connect your printer."
}

View File

@@ -1,20 +1,17 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install google chrome (latest) ##makedesc: Install google chrome (latest)
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
# https://t.me/axenov_blog/251 # https://t.me/axenov_blog/251
title title
mkdir -p "$HOME/install" mkdir -p "$HOME/install/deb"
download "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb" \ download "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb" \
"$HOME/install/google-chrome.deb" && \ "$HOME/install/deb/google-chrome.deb"
sudo dpkg -i "$HOME/install/google-chrome.deb"
[ $? = 0 ] && { dpkg_install "$HOME/install/deb/google-chrome.deb"
echo
success "Google Chrome installed!" success "Google Chrome installed!"
google-chrome --version google-chrome --version
echo
}

6
install/clamav Executable file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
##makedesc: ClamAV (WIP)
sudo apt install clamav -y && \
echo "DatabaseMirror packages.microsoft.com/clamav" | sudo tee -a /etc/clamav/freshclam.conf && \
sudo freshclam

View File

@@ -1,6 +1,7 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install composer (latest) ##makedesc: Install composer (latest)
source `dirname $0`/../helpers || exit 255 here=$( dirname $(readlink -e -- "${BASH_SOURCE}"))
source "$here/../helpers.sh" || exit 255
# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md # https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
@@ -8,34 +9,30 @@ title
require php require php
if installed "composer"; then if installed composer; then
warn "WARNING: Removing current composer to install its actual version" warn "WARNING: Removing current composer to install latest one"
sudo apt remove -y --autoremove composer composer --version
sudo rm -f \ __AAA_NO_TITLE=1 source $here/../uninstall/composer
"$HOME/.local/bin/composer" \
/bin/composer \
/usr/bin/composer \
/usr/local/bin/composer \
/usr/src/composer \
"$HOME/.local/bin/composer"
fi fi
mkdir -p "$HOME/install" "$HOME/.local/bin" mkdir -p "$HOME/install/other" "$HOME/.local/bin"
download "https://getcomposer.org/installer" "$HOME/install/composer-setup.php" && \
php "$HOME/install/composer-setup.php" --install-dir="$HOME/.local/bin/composer"
[ $? = 0 ] && { download "https://getcomposer.org/installer" \
COMPOSER_GLOBAL_HOME="$($HOME/.local/bin/composer config -g home)" "$HOME/install/other/composer-setup.php"
NEWPATH="export PATH=\"$COMPOSER_GLOBAL_HOME/vendor/bin:\${PATH}\""
cat "$HOME/.profile" | grep -qoh "$NEWPATH" || {
$NEWPATH
echo "$NEWPATH" >> "$HOME/.profile"
}
echo php "$HOME/install/other/composer-setup.php" \
success "composer installed!" --install-dir="$HOME/.local/bin/" \
composer --version --filename="composer"
echo
COMPOSER_GLOBAL_HOME="$($HOME/.local/bin/composer config -g home)"
NEWPATH="PATH=\"$COMPOSER_GLOBAL_HOME/vendor/bin:\${PATH}\""
cat "$HOME/.profile" | grep -qoh "$NEWPATH" || {
export "$NEWPATH"
echo "export $NEWPATH" >> "$HOME/.profile"
} }
source "$HOME/.profile" source "$HOME/.profile"
success "composer installed!"
composer --version

View File

@@ -1,35 +1,39 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install docker (latest) + docker-compose (latest) + ppa ##makedesc: Install docker (latest) + ppa
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
# https://docs.docker.com/engine/install/ubuntu/ # https://docs.docker.com/engine/install/ubuntu/
# https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user
title title
require ca-certificates for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do
require curl apt_remove $pkg
require gnupg done
require lsb-release
sudo mkdir -p /etc/apt/keyrings require ca-certificates lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \ source /etc/os-release
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
sudo chmod a+r /etc/apt/keyrings/docker.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null && \
sudo apt update && \
sudo apt install -y --autoremove \
docker-ce \
docker-ce-cli \
containerd.io \
docker-compose-plugin && \
sudo usermod -aG docker $(whoami)
[ $? = 0 ] && { key="/etc/apt/keyrings/docker.asc"
echo
success "Docker installed!" sudo install -m 0755 -d /etc/apt/keyrings
info "Probably, you need to relogin to apply 'docker' group." sudo cdownload https://download.docker.com/linux/ubuntu/gpg $key
info "Your ones currently are: $(groups)" sudo chmod a+r $key
docker --version
echo echo "deb [arch=$(dpkg_arch) signed-by=$key] https://download.docker.com/linux/ubuntu $VERSION_CODENAME stable" \
} | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt_update
apt_install \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
sudo usermod -aG docker $(whoami)
newgrp docker
success "Docker installed!"
docker --version
info "Probably, you need to relogin to apply 'docker' group permanently."

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install dotfiles ##makedesc: Install dotfiles
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
title title

View File

@@ -1,22 +1,21 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install droidcam v1.9.0 ##makedesc: Install droidcam v1.9.0
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
# https://www.dev47apps.com/droidcam/linux/ #TODO
exit
# https://droidcam.app/linux/
title title
mkdir -p "$HOME/install/droidcam" mkdir -p "$HOME/install/deb/"
download "https://files.dev47apps.net/linux/droidcam_1.9.0.zip" "$HOME/install/droidcam.zip" && \ download "https://beta.droidcam.app/go/droidCam.client.setup.deb" "$HOME/install/deb/droidcam_client_amd64.deb"
unzip -oq "$HOME/install/droidcam.zip" -d "$HOME/install/droidcam" && \
cd "$HOME/install/droidcam" && \
sudo ./install-client
[ $? = 0 ] && { dpkg_install "$HOME/install/deb/droidcam_client_amd64.deb"
echo apt_install v4l2loopback-dkms
success "droidcam installed!"
info "Don't forget to install the android app:" success "droidcam installed!"
info "https://play.google.com/store/apps/developer?id=Dev47Apps" info "Don't forget to install the android app:"
echo info "https://play.google.com/store/apps/developer?id=Dev47Apps"
}

View File

@@ -1,11 +1,22 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install droidcam-obs plugin v1.5.1 ##makedesc: Install droidcam-obs plugin v1.5.1
#TODO
# ffmpeg -version | head -n 1 | awk '{print $3}'
# https://github.com/dev47apps/droidcam-obs-plugin/releases
exit
# https://www.dev47apps.com/droidcam/linux/ # https://www.dev47apps.com/droidcam/linux/
# https://www.dev47apps.com/obs/ # https://www.dev47apps.com/obs/
# https://www.dev47apps.com/obs/usage.html # https://www.dev47apps.com/obs/usage.html
# https://obsproject.com/forum/threads/how-to-start-virtual-camera-without-sudo-privileges.139783/ # https://obsproject.com/forum/threads/how-to-start-virtual-camera-without-sudo-privileges.139783/
echo echo
echo "===============================================" echo "==============================================="
echo "Installing droidcam-obs..." echo "Installing droidcam-obs..."

View File

@@ -1,15 +1,54 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install flameshot (latest) ##makedesc: Install flameshot (latest)
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
title title
sudo apt install -y --autoremove flameshot && \ # https://github.com/flameshot-org/flameshot?tab=readme-ov-file#compilation
sudo systemctl restart flameshot # sudo apt install -y --autoremove flameshot && \
# sudo systemctl restart flameshot
dir="$HOME/install"
clone_dir="$dir/flameshot"
mkdir -p "$dir"
sudo apt install -y \
g++ \
cmake \
build-essential \
qtbase5-dev \
qttools5-dev-tools \
libqt5svg5-dev \
qttools5-dev \
libqt5dbus5 \
libqt5network5 \
libqt5core5a \
libqt5widgets5 \
libqt5gui5 \
libqt5svg5
if [ ! -d "$clone_dir" ]; then
git clone --depth=1 --single-branch https://github.com/flameshot-org/flameshot.git "$clone_dir"
fi
# Directory where build files will be placed, may be relative
export BUILD_DIR=build
# Directory prefix where flameshot will be installed. If you are just building and don't want to
# install, comment this environment variable.
# This excludes the bin/flameshot part of the install,
# e.g. in /opt/flameshot/bin/flameshot, the CMAKE_INSTALL_PREFIX is /opt/flameshot
# This must be an absolute path. Requires CMAKE 3.29.
export CMAKE_INSTALL_PREFIX=/opt/flameshot
cd "$clone_dir" && \
git pull && \
cmake -S . -B "$BUILD_DIR" && \
cmake --build "$BUILD_DIR"
[ $? = 0 ] && { [ $? = 0 ] && {
echo echo
success "flameshot installed!" success "flameshot installed!"
flameshot -v # /opt/flameshot/flameshot -v
echo echo
} }

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install Wireguard + FRKN ##makedesc: Install Wireguard + FRKN (deprecated)
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
# https://frkn.org/ru/installation # https://frkn.org/ru/installation
@@ -11,7 +11,7 @@ cd "$HOME/install/frkn"
apt_install wireguard jq apt_install wireguard jq
countries=(uk ru nl nl2 ch) countries=(jp nl tr at ru se)
for idx in ${!countries[@]}; do for idx in ${!countries[@]}; do
country=${countries[idx]} country=${countries[idx]}
info "Downloading config for $country ($(expr $idx + 1)/${#countries[@]})" info "Downloading config for $country ($(expr $idx + 1)/${#countries[@]})"

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install git (latest) ##makedesc: Install git (latest)
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
title title

View File

@@ -1,12 +1,12 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install golang v1.21.0 ##makedesc: Install golang v1.21.0
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
# https://go.dev/dl/ # https://go.dev/dl/
# https://golang.org/doc/install # https://golang.org/doc/install
# https://www.vultr.com/docs/install-the-latest-version-of-golang-on-ubuntu # https://www.vultr.com/docs/install-the-latest-version-of-golang-on-ubuntu
[ $1 ] && VERSION="$1" || VERSION="1.21.6" [ $1 ] && VERSION="$1" || VERSION="1.23.0"
title "Installing golang v$VERSION..." title "Installing golang v$VERSION..."
FILE="go$VERSION.linux-amd64.tar.gz" FILE="go$VERSION.linux-amd64.tar.gz"

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install grub-customizer (latest + ppa) ##makedesc: Install grub-customizer (latest + ppa)
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
title title

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install JetBrains Mono fonts ##makedesc: Install JetBrains Mono fonts
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
# https://www.jetbrains.com/lp/mono/#how-to-install # https://www.jetbrains.com/lp/mono/#how-to-install

View File

@@ -1,4 +1,4 @@
#!/bin/bash (latest) #!/usr/bin/env bash (latest)
##makedesc: Install KDE Window AppMenu Applet ##makedesc: Install KDE Window AppMenu Applet
echo echo

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install KDE Backports ##makedesc: Install KDE Backports
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
title title

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install file templates (KDE) ##makedesc: Install file templates (KDE)
echo echo
@@ -48,7 +48,7 @@ EOF
echo "- Shell" #################################################### echo "- Shell" ####################################################
cat <<EOF > "$TPL_SRC/template.sh" cat <<EOF > "$TPL_SRC/template.sh"
#!/bin/bash #!/usr/bin/env bash
EOF EOF
cat << EOF > "$TPL_DIR/sh.desktop" cat << EOF > "$TPL_DIR/sh.desktop"

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install KDE portal ##makedesc: Install KDE portal
echo echo

View File

@@ -1,64 +0,0 @@
#!/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

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install libreoffice ##makedesc: Install libreoffice
echo echo

View File

@@ -1,43 +1,45 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install lite-xl ##makedesc: Install lite-xl v2.1.7
# https://github.com/lite-xl/lite-xl/releases # https://github.com/lite-xl/lite-xl/releases
# https://lite-xl.com/en/documentation/build # https://lite-xl.com/setup/getting-started/
echo echo
echo "===============================================" echo "==============================================="
echo "Installing lite-xl v2.1.0..." echo "Installing lite-xl v2.1.7..."
echo "===============================================" echo "==============================================="
echo echo
tar_url="https://github.com/lite-xl/lite-xl/releases/download/v2.1.0/lite-xl-v2.1.0-addons-linux-x86_64-portable.tar.gz" tar_url="https://github.com/lite-xl/lite-xl/releases/download/v2.1.7/lite-xl-v2.1.7-addons-linux-x86_64-portable.tar.gz"
tar_filepath="/tmp/lite-xl.tar.gz" lpm_url="https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.x86_64-linux"
tar_filepath="$HOME/install/lite-xl-v2.1.7.tar.gz"
untar_dir="$HOME/install" untar_dir="$HOME/install"
untar_subdir="$untar_dir/lite-xl"
dest_bin_dir="$HOME/.local/bin"
dest_config_dir="$HOME/.config/lite-xl"
dest_share_dir="$HOME/.local/share"
dest_share_subdir="$dest_share_dir/lite-xl"
wget "$tar_url" -O "$tar_filepath" rm -rf \
"$HOME/.local/bin/lpm" \
"$HOME/install/lite-xl" \
"$HOME/.local/bin/lite-xl" \
"$HOME/.local/share/lite-xl"
mkdir -vp \ mkdir -vp \
"$untar_dir" \ "$untar_dir" \
#"$dest_config" \ "$HOME/.local/bin" \
"$dest_bin_dir" \ "$HOME/.local/share/lite-xl"
"$dest_share_dir"
tar -xzf "$tar_filepath" -C "$untar_dir" wget "$tar_url" -O "$tar_filepath" && \
mv -fv "$untar_subdir/lite-xl" "$dest_bin_dir/lite-xl" wget "$lpm_url" -O "$HOME/.local/bin/lpm" && \
mv -fvT "$untar_subdir/data" "$dest_share_subdir" chmod +x "$HOME/.local/bin/lpm" && \
rm -fr "$tar_file" "$untar_subdir" tar -xzf "$tar_filepath" -C "$untar_dir" && \
cp -vf "$untar_dir/lite-xl/lite-xl" "$HOME/.local/bin/" && \
cp -vfr "$untar_dir"/lite-xl/data/* "$HOME/.local/share/lite-xl/"
# echo -e "\nexport LITE_SCALE=1 # https://github.com/lite-xl/lite-xl/issues/1173\n" >> $HOME/.profile # echo -e "\nexport LITE_SCALE=1 # https://github.com/lite-xl/lite-xl/issues/1173\n" >> $HOME/.profile
cat << EOF > "$dest_share_dir/applications/org.lite_xl.lite_xl.desktop" cat << EOF > "$HOME/.local/share/applications/org.lite_xl.lite_xl.desktop"
[Desktop Entry] [Desktop Entry]
Type=Application Type=Application
Name=Lite XL Name=Lite XL
Comment=A lightweight text editor written in Lua Comment=A lightweight text editor written in Lua
Exec=env LITE_SCALE=1 ${dest_bin_dir}/lite-xl %F Exec=$HOME/.local/bin/lite-xl %F
Icon=lite-xl Icon=lite-xl
Terminal=false Terminal=false
StartupWMClass=lite-xl StartupWMClass=lite-xl
@@ -48,53 +50,6 @@ EOF
sudo update-desktop-database && \ sudo update-desktop-database && \
xdg-desktop-menu forceupdate xdg-desktop-menu forceupdate
echo
echo "==============================================="
echo "Installing lite-xl plugins..."
echo "https://github.com/lite-xl/lite-xl-plugins"
echo "==============================================="
echo
download_plugin() {
echo "- $1"
curl -s "https://raw.githubusercontent.com/lite-xl/lite-xl-plugins/master/plugins/$1.lua" \
> "$dest_share_subdir/plugins/$1.lua"
}
download_plugin "align_carets"
download_plugin "autosaveonfocuslost"
download_plugin "bracketmatch"
download_plugin "copyfilelocation"
download_plugin "dragdropselected"
download_plugin "fontconfig"
download_plugin "force_syntax"
download_plugin "lfautoinsert"
download_plugin "markers"
download_plugin "memoryusage"
download_plugin "minimap"
download_plugin "navigate"
download_plugin "openselected"
download_plugin "restoretabs"
download_plugin "smoothcaret"
# echo "- eofnewline-xl"
# curl -s "https://raw.githubusercontent.com/bokunodev/lite_modules/master/plugins/eofnewline-xl.lua" \
# > "$dest_share_subdir/plugins/eofnewline-xl.lua"
echo "- language_env"
curl -s "https://raw.githubusercontent.com/anthonyaxenov/lite-xl-env-syntax/master/language_env.lua" \
> "$dest_share_subdir/plugins/language_env.lua"
echo "- language_ignore"
curl -s "https://raw.githubusercontent.com/anthonyaxenov/lite-xl-ignore-syntax/master/language_ignore.lua" \
> "$dest_share_subdir/plugins/language_ignore.lua"
# echo "- language-containerfile"
# git clone -q "https://github.com/FilBot3/lite-xl-language-containerfile.git" \
# "$dest_share_subdir/plugins/language_containerfile"
echo echo
echo "Finish!" echo "Finish!"
echo "- $dest_bin_dir/lite-xl"
echo "- $dest_share_subdir"
echo echo

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install mariadb (latest) and php-mysql + phpMyAdmin (if php is installed) ##makedesc: Install mariadb (latest) and php-mysql + phpMyAdmin (if php is installed)
echo echo

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install nodejs + npm via nvm ##makedesc: Install nodejs + npm via nvm
echo echo

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install ntfy (latest) + ppa ##makedesc: Install ntfy (latest) + ppa
echo echo

33
install/nvim Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env bash
##makedesc: Install nvim + lazyvim
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
# https://www.lazyvim.org/installation
# https://www.devas.life/effective-neovim-setup-for-web-development-towards-2024/
title
require git
nvimUrl="https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz"
installPath="$HOME/install"
installTar="$installPath/nvim.tar.gz"
[ -d "$HOME/.config/nvim" ] && mv "$HOME"/.config/nvim{,.bak}
[ -d "$HOME/.local/share/nvim" ] && mv "$HOME"/.local/share/nvim{,.bak}
[ -d "$HOME/.local/state/nvim" ] && mv "$HOME"/.local/state/nvim{,.bak}
[ -d "$HOME/.cache/nvim" ] && mv "$HOME"/.cache/nvim{,.bak}
download "$nvimUrl" "$installTar"
unpack_targz "$installTar" "$installPath"
sudo rm -vrf /opt/nvim
sudo mv -v "$installPath/nvim-linux-x86_64" /opt/nvim
git.clone_quick https://github.com/LazyVim/starter "$HOME/.config/nvim"
rm -rf "$HOME/.config/nvim/.git"
sudo update-desktop-database && \
xdg-desktop-menu forceupdate
# export PATH="$PATH:/opt/nvim-linux-x86_64/bin"

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install obs-studio (latest snap) ##makedesc: Install obs-studio (latest snap)
echo echo

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install omz (latest) ##makedesc: Install omz (latest)
echo echo

View File

@@ -1,6 +1,15 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install omz fancy (powerline10k + MesloLGS font) ##makedesc: Install omz fancy (powerline10k + MesloLGS font)
# https://gist.github.com/anthonyaxenov/b8460935d06b9f0da72def03d0f26515
# Based on:
# https://github.com/Powerlevel9k/powerlevel9k/wiki/Install-Instructions
# https://github.com/ohmyzsh/ohmyzsh
# https://powerline.readthedocs.io/en/latest/installation/linux.html#fonts-installation
# https://gist.github.com/dogrocker/1efb8fd9427779c827058f873b94df95
# https://linuxhint.com/install_zsh_shell_ubuntu_1804/
echo echo
echo "===============================================" echo "==============================================="
echo "Installing omz fancy: powerline10k + MesloLGS font..." echo "Installing omz fancy: powerline10k + MesloLGS font..."

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install openvpn v2.6.3 (src) ##makedesc: Install openvpn v2.6.3 (src)
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
# https://openvpn.net/community-downloads/ # https://openvpn.net/community-downloads/
# https://openvpn.net/community-resources/installing-openvpn/ # https://openvpn.net/community-resources/installing-openvpn/
@@ -15,7 +15,7 @@ require libssl-dev \
mkdir -p "$HOME/install/" mkdir -p "$HOME/install/"
download "https://swupdate.openvpn.org/community/releases/openvpn-${OVPNVER}.tar.gz" "$HOME/install/openvpn-${OVPNVER}.tar.gz" && \ 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/" && \ unpack_targz "$HOME/install/openvpn-${OVPNVER}.tar.gz" "$HOME/install/" && \
cd "$HOME/install/openvpn-${OVPNVER}" && \ cd "$HOME/install/openvpn-${OVPNVER}" && \
sudo ./configure && \ sudo ./configure && \
sudo make && \ sudo make && \

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install papirus-icon-theme (latest) ##makedesc: Install papirus-icon-theme (latest)
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
title title

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install postgresql (latest) and php-pgsql (if php is installed) ##makedesc: Install postgresql (latest) and php-pgsql (if php is installed)
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
title title

View File

@@ -1,16 +1,16 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install php v8.1 + ppa ##makedesc: Install php v8.4
[ $1 ] && PHPVER="$1" || PHPVER="8.1" [ "$1" ] && PHPVER="$1" || PHPVER="8.4"
echo echo
echo "===============================================" echo "==============================================="
echo "Installing php${PHPVER}..." echo "Installing php${PHPVER}..."
echo "===============================================" echo "==============================================="
echo echo
sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
sudo apt install -y --autoremove \ sudo apt install -y --autoremove \
php${PHPVER} \ php${PHPVER}-fpm \
php${PHPVER}-dev \
php${PHPVER}-apcu \ php${PHPVER}-apcu \
php${PHPVER}-bcmath \ php${PHPVER}-bcmath \
php${PHPVER}-cli \ php${PHPVER}-cli \
@@ -24,6 +24,7 @@ sudo apt install -y --autoremove \
php${PHPVER}-mysql \ php${PHPVER}-mysql \
php${PHPVER}-opcache \ php${PHPVER}-opcache \
php${PHPVER}-pgsql \ php${PHPVER}-pgsql \
php${PHPVER}-simplexml \
php${PHPVER}-soap \ php${PHPVER}-soap \
php${PHPVER}-sqlite3 \ php${PHPVER}-sqlite3 \
php${PHPVER}-xdebug \ php${PHPVER}-xdebug \

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install psalm ##makedesc: Install psalm
echo echo

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install php-spx ##makedesc: Install php-spx
echo echo

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install phpcs + php-cs-fixer ##makedesc: Install phpcs + php-cs-fixer
echo echo

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install phpmd ##makedesc: Install phpmd
echo echo

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install phpstan ##makedesc: Install phpstan
echo echo

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install phpunit ##makedesc: Install phpunit
echo echo

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install postman (latest) ##makedesc: Install postman (latest)
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
# https://learning.postman.com/docs/getting-started/installation-and-updates/#installing-postman-on-linux # https://learning.postman.com/docs/getting-started/installation-and-updates/#installing-postman-on-linux
@@ -13,7 +13,7 @@ mkdir -p "$HOME/install" && \
"$HOME/.local/share/applications" "$HOME/.local/share/applications"
download "https://dl.pstmn.io/download/latest/linux64" "$HOME/install/postman.tar.gz" && \ download "https://dl.pstmn.io/download/latest/linux64" "$HOME/install/postman.tar.gz" && \
unpak_targz "$HOME/install/postman.tar.gz" "$HOME/install" && \ unpack_targz "$HOME/install/postman.tar.gz" "$HOME/install" && \
symlink "$HOME/install/Postman/Postman" "$HOME/.local/bin/postman" && \ symlink "$HOME/install/Postman/Postman" "$HOME/.local/bin/postman" && \
cat << EOF > "$HOME/.local/share/applications/Postman.desktop" && sudo update-desktop-database cat << EOF > "$HOME/.local/share/applications/Postman.desktop" && sudo update-desktop-database
[Desktop Entry] [Desktop Entry]

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install qt5 ##makedesc: Install qt5
echo echo

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install rustdesk client v1.1.9 (deb) ##makedesc: Install rustdesk client v1.4.2 (deb)
[ $1 ] && RDVER="$1" || RDVER="1.1.9" [ "$1" ] && RDVER="$1" || RDVER="1.4.2"
echo echo
echo "===============================================" echo "==============================================="
echo "Installing rustdesk v$RDVER..." echo "Installing rustdesk v$RDVER..."
@@ -12,9 +12,13 @@ echo
deb_path="$HOME/install" deb_path="$HOME/install"
deb_name="rustdesk-$RDVER.deb" deb_name="rustdesk-$RDVER.deb"
mkdir -p $deb_path mkdir -p "$deb_path"
deb="$deb_path/$deb_name" deb="$deb_path/$deb_name"
sudo apt install -y libxdo3 python3-pip && \ sudo apt install -y libxdo3 python3-pip
wget "https://github.com/rustdesk/rustdesk/releases/download/$RDVER/$deb_name" -O $deb && \ wget "https://github.com/rustdesk/rustdesk/releases/download/$RDVER/$deb_name" -O "$deb"
sudo dpkg -i $deb sudo dpkg -i "$deb"
# flatpak install -y com.rustdesk.RustDesk
# https://develop.kde.org/docs/administration/portal-permissions/
# flatpak permission-set kde-authorized remote-desktop com.rustdesk.RustDesk yes

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install bunch of software from snap ##makedesc: Install bunch of software from snap
echo echo

45
install/sublimemerge Executable file
View File

@@ -0,0 +1,45 @@
#!/usr/bin/env bash
##makedesc: Install Sublime Merge
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
# https://www.sublimemerge.com/download
# https://gist.github.com/lugrus2000/1fc55158b87f94d799392a6dd1ac0ce2
# https://gist.github.com/maboloshi/feaa63c35f4c2baab24c9aaf9b3f4e47
[ "$1" ] && SMVER="$1" || SMVER='2102'
title
mkdir -p "$HOME/install"
DEB_PATH="$HOME/install/sublime-merge_build-${SMVER}_amd64.deb"
BIN_PATH="/opt/sublime_merge/sublime_merge"
if [[ ! -f "$DEB_PATH" ]]; then
download https://download.sublimetext.com/sublime-merge_build-${SMVER}_amd64.deb "$DEB_PATH"
fi
sudo dpkg -i "$DEB_PATH"
# sudo cp -f $BIN_PATH $BIN_PATH.old
# if [[ $SMVER = 2102 ]]; then
#TODO not working
# printf '\x48\xC7\xC0\x19\x01\x00\x00\xC3' | sudo dd of=$BIN_PATH bs=1 seek=$((0x003A5400)) conv=notrunc
# printf '\x90\x90\x90\x90\x90' | sudo dd of=$BIN_PATH bs=1 seek=$((0x003A7EC9)) conv=notrunc
# printf '\x90\x90\x90\x90\x90' | sudo dd of=$BIN_PATH bs=1 seek=$((0x003A7EE4)) conv=notrunc
# printf '\x48\x31\xC0\x48\xFF\xC0\xC3' | sudo dd of=$BIN_PATH bs=1 seek=$((0x003A67FE)) conv=notrunc
# printf '\xC3' | sudo dd of=$BIN_PATH bs=1 seek=$((0x003A514E)) conv=notrunc
# printf '\xC3' | sudo dd of=$BIN_PATH bs=1 seek=$((0x003A40D2)) conv=notrunc
#TODO segfault
# echo 0045a360: 48 C7 C0 19 01 00 00 C3 | sudo xxd -r - $BIN_PATH
# echo 0045d21d: 90 90 90 90 90 | sudo xxd -r - $BIN_PATH
# echo 0045d23a: 90 90 90 90 90 | sudo xxd -r - $BIN_PATH
# echo 0045b990: C3 | sudo xxd -r - $BIN_PATH
# echo 0045a05a: C3 | sudo xxd -r - $BIN_PATH
# echo 00459aba: C3 | sudo xxd -r - $BIN_PATH
# fi
echo
success "Sublime Merge installed!"
$BIN_PATH --version
echo

View File

@@ -1,22 +1,37 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install Sublime Text (build 4169) ##makedesc: Install Sublime Text
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
# https://www.sublimetext.com/download_thanks?target=x64-deb # https://www.sublimetext.com/download
# https://gist.github.com/skoqaq/3f3e8f28e23c881143cef9cf49d821ff # https://gist.axenov.dev/anthony/sublime
# https://gist.axenov.dev/anthony/sublime2
# https://gist.github.com/lugrus2000/1fc55158b87f94d799392a6dd1ac0ce2
# https://gist.github.com/maboloshi/feaa63c35f4c2baab24c9aaf9b3f4e47
[ "$1" ] && STVER="$1" || STVER='4200'
title title
mkdir -p "$HOME/install" mkdir -p "$HOME/install"
DEB_PATH="$HOME/install/sublime-text_build-${STVER}_amd64.deb"
BIN_PATH="/opt/sublime_text/sublime_text"
download https://download.sublimetext.com/sublime-text_build-4169_amd64.deb \ if [[ ! -f "$DEB_PATH" ]]; then
"$HOME/install/sublime-text_build-4169_amd64.deb" && \ download "https://download.sublimetext.com/sublime-text_build-${STVER}_amd64.deb" "$DEB_PATH"
sudo dpkg -i "$HOME/install/sublime-text_build-4169_amd64.deb" && \ fi
echo "00489f39: c640 0501 4885 c9" | sudo xxd -r - /opt/sublime_text/sublime_text
[ $? = 0 ] && { sudo dpkg -i "$DEB_PATH"
echo sudo cp -f "$BIN_PATH" "$BIN_PATH.old"
success "Sublime Text installed!"
subl --version if [[ $STVER = 4169 ]]; then
echo echo "00489f39: c640 0501 4885 c9" | sudo xxd -r - "$BIN_PATH"
} elif [[ $STVER = 4200 ]]; then
sudo sed -i 's#\x0F\xB6\x51\x05\x83\xF2\x01#\xC6\x41\x05\x01\xB2\x00\x90#' "$BIN_PATH"
else
sudo sed -i 's#\x80\x79\x05\x00\x0F\x94\xC2#\xC6\x41\x05\x01\xB2\x00\x90#' "$BIN_PATH"
fi
echo
success "Sublime Text installed!"
$BIN_PATH --version
echo

20
install/suld Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
##makedesc: Samsung Unified Linux Driver repo
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
# https://www.bchemnet.com/suldr/
# https://www.bchemnet.com/suldr/supported.html
title
mkdir -vp "$HOME/install"
sudo bash -c 'echo "deb https://www.bchemnet.com/suldr/ debian extra" >> /etc/apt/sources.list.d/samsung.list'
download \
https://www.bchemnet.com/suldr/pool/debian/extra/su/suldr-keyring_3_all.deb \
"$HOME/install/suldr-keyring_3_all.deb"
sudo dpkg -i "$HOME/install/suldr-keyring_3_all.deb"
apt_install suld-driver2-1.00.39
success "Samsung Unified Linux Driver installed!"
info "Don't forget to connect your Samsung printer"
info "See more info here: https://www.bchemnet.com/suldr/"

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install syncthing (latest) + ppa ##makedesc: Install syncthing (latest) + ppa
echo echo

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install telebit (latest) ##makedesc: Install telebit (latest)
echo echo

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install telegram (latest) ##makedesc: Install telegram (latest)
echo echo

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install ulauncher (latest) + ppa ##makedesc: Install ulauncher (latest) + ppa
echo echo
@@ -7,5 +7,7 @@ echo "Installing ulauncher (latest) + ppa..."
echo "===============================================" echo "==============================================="
echo echo
sudo add-apt-repository -y ppa:agornostal/ulauncher sudo add-apt-repository universe -y
sudo apt install -y --autoremove ulauncher sudo add-apt-repository ppa:agornostal/ulauncher -y
sudo apt update
sudo apt install ulauncher

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install Vivaldi + ppa ##makedesc: Install Vivaldi + ppa
# https://repo.vivaldi.com # https://repo.vivaldi.com
@@ -11,11 +11,9 @@ echo "Installing Vivaldi + ppa..."
echo "===============================================" echo "==============================================="
echo echo
wget -qO- https://repo.vivaldi.com/archive/linux_signing_key.pub \ wget -qO- https://repo.vivaldi.com/archive/linux_signing_key.pub | gpg --dearmor > packages.vivaldi.gpg
| gpg --dearmor \ sudo install -o root -g root -m 644 packages.vivaldi.gpg /etc/apt/trusted.gpg.d
| sudo dd of=/usr/share/keyrings/vivaldi-browser.gpg sudo sh -c 'echo "deb [arch=amd64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.vivaldi.gpg] https://repo.vivaldi.com/archive/deb stable main" > /etc/apt/sources.list.d/vivaldi.list'
rm -f packages.vivaldi.gpg
echo "deb [signed-by=/usr/share/keyrings/vivaldi-browser.gpg arch=$(dpkg --print-architecture)] https://repo.vivaldi.com/archive/deb/ stable main" \
| sudo dd of=/etc/apt/sources.list.d/vivaldi-archive.list
sudo apt update && sudo apt install vivaldi-stable sudo apt update && sudo apt install vivaldi-stable

View File

@@ -1,18 +1,18 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: VSCode deb-package ##makedesc: VSCode deb-package
source `dirname $0`/../helpers || exit 255 source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
title title
mkdir -p "$HOME/install" mkdir -p "$HOME/install"
download "https://code.visualstudio.com/docs/?dv=linux64_deb" \ download "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64" \
"$HOME/install/vscode.deb" && \ "$HOME/install/vscode.deb" && \
sudo dpkg -i "$HOME/install/vscode.deb" sudo dpkg -i "$HOME/install/vscode.deb"
[ $? = 0 ] && { [ $? = 0 ] && {
echo echo
success "VSCode installed" success "VSCode installed"
vscode --version code --version
echo echo
} }

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install wine (latest) + ppa (focal) ##makedesc: Install wine (latest) + ppa
echo echo
echo "===============================================" echo "==============================================="
@@ -9,6 +9,6 @@ echo
sudo dpkg --add-architecture i386 sudo dpkg --add-architecture i386
wget -qO- https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add - wget -qO- https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add -
sudo add-apt-repository -y 'deb https://dl.winehq.org/wine-builds/ubuntu/ focal main' sudo add-apt-repository -y "deb https://dl.winehq.org/wine-builds/ubuntu/ $(lsb_release -cs 2>/dev/null) main"
sudo apt install -y --autoremove winehq-stable sudo apt install -y --autoremove winehq-stable
wine --version wine --version

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install youtube-dl (src) ##makedesc: Install youtube-dl (src)
# https://github.com/ytdl-org/youtube-dl#installation # https://github.com/ytdl-org/youtube-dl#installation
@@ -23,7 +23,12 @@ installed() {
mkdir -p "$HOME/install/youtube-dl" "$HOME/.local/bin" mkdir -p "$HOME/install/youtube-dl" "$HOME/.local/bin"
if installed git; then if installed git; then
git clone https://github.com/ytdl-org/youtube-dl.git "$HOME/install/youtube-dl" --depth=1 --single-branch if [[ -d "$HOME/install/youtube-dl" ]]; then
cd "$HOME/install/youtube-dl"
git pull
else
git clone https://github.com/ytdl-org/youtube-dl.git "$HOME/install/youtube-dl" --depth=1 --single-branch
fi
else else
! installed wget && sudo apt install -y wget ! installed wget && sudo apt install -y wget
wget https://github.com/ytdl-org/youtube-dl/archive/refs/heads/master.zip -O "$HOME/install/youtube-dl.zip" && \ wget https://github.com/ytdl-org/youtube-dl/archive/refs/heads/master.zip -O "$HOME/install/youtube-dl.zip" && \

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install ytdlcue ##makedesc: Install ytdlcue
# https://gist.github.com/anthonyaxenov/8e11f18493c8419ee7abc94a8ea0cfaf # https://gist.github.com/anthonyaxenov/8e11f18493c8419ee7abc94a8ea0cfaf

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install zint (latest) ##makedesc: Install zint (latest)
echo echo

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
##makedesc: Install vanilla zsh ##makedesc: Install vanilla zsh
echo echo

View File

@@ -1,2 +0,0 @@
##flameshot: [TODO] [PACK] qt5 + flameshot from source
flameshot: qt5 flameshot-build

View File

@@ -1,2 +1,2 @@
##phptools: [PACK] Install only php tooling (composer, phpunit, psalm, phpcs, php-cs-fixer, php-spx, phpmd) ##phptools: [PACK] Install only php tooling (composer, phpunit, psalm, phpcs, php-cs-fixer, phpmd)
phptools: composer php-psalm php-spx phpcs phpmd phpstan phpunit phptools: composer php-psalm phpcs phpmd phpstan phpunit

6
tools/README.md Normal file
View File

@@ -0,0 +1,6 @@
# Shell-скрипты
Эти скрипты я писал в разное время для решения разных задач.
Чтобы они не растерялись по репозиториям и носителям, я решил собрать их здесь в одну кучу.
Я всегда использую Ubuntu в качестве своих настольных и серверных ОС, поэтому все эти скрипты писались и использовались в этих средах с версий 18.*.

26
tools/dc Normal file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env bash
CONTAINER="my-container" # the name of the container in which to 'exec' something
CONFIG="$(dirname $([ -L $0 ] && readlink -f $0 || echo $0))/docker-compose.yml" # path to compose yml file
CMD="docker-compose -f $CONFIG" # docker-compose command
APP_URL='http://localhost:8000/'
open_browser() {
if which xdg-open > /dev/null; then
xdg-open "$1" </dev/null >/dev/null 2>&1 & disown
elif which gnome-open > /dev/null; then
gnome-open "$1" </dev/null >/dev/null 2>&1 & disown
fi
}
case "$1" in
'' | 'help' ) echo -e "Provide one of operations: \t start, stop, up, down, restart, rebuild, open";
echo "Otherwise all args will be passed to 'docker exec -ti $CONTAINER ...'" ;;
'open' ) open_browser $APP_URL ;;
'up' ) $CMD up -d --build ;; # build and start containers
'down' ) $CMD down --remove-orphans ;; # stop and remove containers
'start' ) $CMD start ;; # start containers
'stop' ) $CMD stop ;; # stop containers
'restart' ) $CMD stop && $CMD start ;; # restart containers
'rebuild' ) $CMD down --remove-orphans && $CMD up -d --build ;; # rebuild containers
* ) docker exec -ti $CONTAINER $@ # exec anything in container
esac

5
tools/disable-ipv6.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
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"

View File

@@ -1,54 +1,55 @@
#!/bin/bash #!/usr/bin/env bash
# https://gist.github.com/anthonyaxenov/c16e1181d4b8a8644c57ec8a1f6cf21c
######################################################################### #########################################################################
# # # #
# Set display resolution # # Set output resolution #
# # # #
# Author: Anthony Axenov (Антон Аксенов) # # Author: Anthony Axenov (Антон Аксенов) #
# Version: 1.0 # # Version: 1.0 #
# License: WTFPL # # License: WTFPLv2 #
# # # #
######################################################################### #########################################################################
# # # #
# Using this script you can change your display resolution # # Using this script you can change your output resolution #
# to any one you need. Just adjust some vars below and run script # # to any one you need. Just adjust some vars below and run script #
# (chmod +x needed). # # (chmod +x needed). #
# # # #
######################################################################### #########################################################################
# https://gist.github.com/anthonyaxenov/c16e1181d4b8a8644c57ec8a1f6cf21c # Set output name to work with. You can get it via 'xrandr --listactivemonitors'
output="HDMI-3"
# Set display name to work with. You can get it via 'xrandr --listactivemonitors' # Set width of this output in px
display="HDMI-2" width=1920
# Set width of this display in px # Set height of this output in px
width=1600 height=1080
# Set height of this display in px # Set refresh rate in Hz of this output in px
height=900 refresh=120
# Sometimes cvt and gtf generates different modelines. # Sometimes cvt and gtf generates different modelines.
# You can play around and look which of them gives best result: # You can play around and look which of them gives best result:
modeline=$(cvt ${width} ${height} | grep "Modeline") modeline=$(cvt ${width} ${height} ${refresh} | grep "Modeline")
# modeline=$(gtf ${width} ${height} 60 | grep "Modeline") # modeline=$(gtf ${width} ${height} ${refresh} | grep "Modeline")
# Some important data needed to xrandr: # Some important data needed to xrandr:
modename="${width}x${height}_my" modename="${width}x${height}@${refresh}_my"
params=$(echo "$modeline" | sed "s|^\s*Modeline\s*\"[0-9x_.]*\"\s*||") params=$(echo "$modeline" | sed "s|^\s*Modeline\s*\"[0-9x_.]*\"\s*||")
echo "Set resolution ${width}x${height} on display $display:" echo "Set resolution ${width}x${height}@${refresh} on output $output:"
echo "$modename $params" echo "$modename $params"
# Simple logic: # Simple logic:
# 1. Switch display to safe mode which always exists (I believe) to avoid errors # 1. Switch output to safe mode which always exists (I believe) to avoid errors
xrandr --output $display --mode 640x480 xrandr --output $output --mode 640x480 --verbose
# 2. If display aready have our mode -- we must delete it to avoid errors # 2. If output aready have our mode -- we must delete it to avoid errors
if $(xrandr | grep -q "$modename"); then if $(xrandr | grep -q "$modename"); then
# 2.1. Detach mode from display # 2.1. Detach mode from output
xrandr --delmode $display $modename xrandr --delmode $output $modename
# 2.2. Remove mode itself # 2.2. Remove mode itself
xrandr --rmmode $modename xrandr --rmmode $modename
fi fi
# 3. Create new mode with freshly generated parameters # 3. Create new mode with freshly generated parameters
xrandr --newmode $modename $params xrandr --newmode $modename $params --verbose
# 4. Attach mode to our display # 4. Attach mode to our output
xrandr --addmode $display $modename xrandr --addmode $output $modename --verbose
# 5. Switch display to this mode immidiately # 5. Switch output to this mode immidiately
xrandr --output $display --mode $modename xrandr --output $output --mode $modename --refresh $refresh --verbose

11
tools/display-rotate.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env bash
# X11:
# xrandr --listactivemonitors
# xrandr --output $OUTPUT --rotate (left|right|normal|...)
# Wayland KDE: https://www.reddit.com/r/kde/comments/11vrbwc/how_do_i_rotate_the_screen_on_kde_with_wayland/
# kscreen-doctor --outputs
OUTPUT='HDMI-0'
DIRECTION="$1" # (left|right|normal|inverted)
kscreen-doctor "output.$OUTPUT.rotation.$DIRECTION"

View File

@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Original filename: docker-volume-snapshot
# Author: Juned Khatri
# License: MIT
# Repo: https://github.com/junedkhatri31/docker-volume-snapshot
set -e -o pipefail
programname=`basename "$0"`
display_usage() {
echo "usage: $programname (create|restore) source destination"
echo " create create snapshot file from docker volume"
echo " restore restore snapshot file to docker volume"
echo " source source path"
echo " destination destination path"
echo
echo "Tip: Supports tar's compression algorithms automatically"
echo " based on the file extention, for example .tar.gz"
echo
echo "Examples:"
echo "docker-volume-snapshot create xyz_volume xyz_volume.tar"
echo "docker-volume-snapshot create xyz_volume xyz_volume.tar.gz"
echo "docker-volume-snapshot restore xyz_volume.tar xyz_volume"
echo "docker-volume-snapshot restore xyz_volume.tar.gz xyz_volume"
}
case "$1" in
"create")
if [[ -z "$2" || -z "$3" ]]; then display_usage; exit 1; fi
directory=`dirname "$3"`
if [ "$directory" == "." ]; then directory=$(pwd); fi
filename=`basename "$3"`
docker run --rm -v "$2:/source" -v "$directory:/dest" busybox tar cvaf "/dest/$filename" -C /source .
;;
"restore")
if [[ -z "$2" || -z "$3" ]]; then display_usage; exit 1; fi
directory=`dirname "$2"`
if [ "$directory" == "." ]; then directory=$(pwd); fi
filename=`basename "$2"`
docker run --rm -v "$3:/dest" -v "$directory:/source" busybox tar xvf "/source/$filename" -C /dest
;;
*)
display_usage
exit 1 # Command to come out of the program with status 1
;;
esac

Some files were not shown because too many files have changed in this diff Show More