Compare commits
56 Commits
53d5a31a30
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 549b420df2 | |||
|
edf76874fc
|
|||
|
95ad6b0c6a
|
|||
|
ff36975eb7
|
|||
|
5ae19346d6
|
|||
|
53ee621747
|
|||
|
dd339f2939
|
|||
|
e0fbdf852e
|
|||
|
b5983ed308
|
|||
|
f39af6d446
|
|||
|
8fe3d112ba
|
|||
|
4c81bcea73
|
|||
|
5623d08d85
|
|||
|
0a369efe1b
|
|||
|
1640ebfb45
|
|||
|
d2c561fc28
|
|||
|
a920e48422
|
|||
|
0ed07de2d2
|
|||
|
abad965e9a
|
|||
|
b5b0140e34
|
|||
|
5d75b6f79e
|
|||
|
87fd722509
|
|||
|
eaacecd87a
|
|||
|
4c57a180ac
|
|||
|
96bd945ef2
|
|||
|
49fd27d3be
|
|||
|
3c9f1d71cb
|
|||
|
3a226ed5bb
|
|||
|
fe83b3eb25
|
|||
|
a34dda20c7
|
|||
|
021db1064e
|
|||
|
b70b89433b
|
|||
|
8531543982
|
|||
|
e05b47ae52
|
|||
|
e9a6f4ddda
|
|||
|
cbb493b5c4
|
|||
|
31ddf3a6d2
|
|||
|
47827282a9
|
|||
|
16075cdd61
|
|||
|
29e5c960de
|
|||
|
526dade1f8
|
|||
|
66126167c8
|
|||
|
3696cc06af
|
|||
|
8da2059d1e
|
|||
|
9da84a69f2
|
|||
|
50bd28abe4
|
|||
|
bbbc0de694
|
|||
|
9258398be4
|
|||
|
a60374033c
|
|||
|
bcae2fb4cf
|
|||
|
c808cce9cd
|
|||
|
bacd71304a
|
|||
|
6fee688968
|
|||
|
ebd30c8a50
|
|||
|
c4b2af8073
|
|||
|
45499ca5df
|
47
Makefile
47
Makefile
@@ -1,4 +1,4 @@
|
||||
# Autogenerated at 09.01.2025 15:37 using ./gen-makefile
|
||||
# Autogenerated at 10.07.2025 23:45 using ./gen-makefile
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
#===============================================
|
||||
@@ -21,6 +21,10 @@ canon-mg2500:
|
||||
chrome:
|
||||
@./install/chrome
|
||||
|
||||
##clamav: ClamAV (WIP)
|
||||
clamav:
|
||||
@./install/clamav
|
||||
|
||||
##composer: Install composer (latest)
|
||||
composer:
|
||||
@./install/composer
|
||||
@@ -45,9 +49,9 @@ droidcam-obs:
|
||||
flameshot:
|
||||
@./install/flameshot
|
||||
|
||||
##frkn: Install Wireguard + FRKN
|
||||
frkn:
|
||||
@./install/frkn
|
||||
##frkn.deprecated: Install Wireguard + FRKN
|
||||
frkn.deprecated:
|
||||
@./install/frkn.deprecated
|
||||
|
||||
##git: Install git (latest)
|
||||
git:
|
||||
@@ -81,15 +85,11 @@ kde-file-templates:
|
||||
kde-portal:
|
||||
@./install/kde-portal
|
||||
|
||||
##lazynvim: <no description>
|
||||
lazynvim:
|
||||
@./install/lazynvim
|
||||
|
||||
##libreoffice: Install libreoffice
|
||||
libreoffice:
|
||||
@./install/libreoffice
|
||||
|
||||
##lite-xl: Install lite-xl
|
||||
##lite-xl: Install lite-xl v2.1.7
|
||||
lite-xl:
|
||||
@./install/lite-xl
|
||||
|
||||
@@ -105,6 +105,10 @@ nodejs:
|
||||
ntfy:
|
||||
@./install/ntfy
|
||||
|
||||
##nvim: Install nvim + lazyvim
|
||||
nvim:
|
||||
@./install/nvim
|
||||
|
||||
##obs-studio: Install obs-studio (latest snap)
|
||||
obs-studio:
|
||||
@./install/obs-studio
|
||||
@@ -129,7 +133,7 @@ papirus:
|
||||
pgsql:
|
||||
@./install/pgsql
|
||||
|
||||
##php: Install php v8.3 + ppa
|
||||
##php: Install php v8.4
|
||||
php:
|
||||
@./install/php
|
||||
|
||||
@@ -165,10 +169,14 @@ postman:
|
||||
qt5:
|
||||
@./install/qt5
|
||||
|
||||
##rustdesk: Install rustdesk client v1.1.9 (deb)
|
||||
##rustdesk: Install rustdesk client (flatpak)
|
||||
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/snap
|
||||
@@ -181,6 +189,10 @@ sublimemerge:
|
||||
sublimetext:
|
||||
@./install/sublimetext
|
||||
|
||||
##suld: Samsung Unified Linux Driver repo
|
||||
suld:
|
||||
@./install/suld
|
||||
|
||||
##syncthing: Install syncthing (latest) + ppa
|
||||
syncthing:
|
||||
@./install/syncthing
|
||||
@@ -205,7 +217,7 @@ vivaldi:
|
||||
vscode:
|
||||
@./install/vscode
|
||||
|
||||
##wine: Install wine (latest) + ppa (focal)
|
||||
##wine: Install wine (latest) + ppa
|
||||
wine:
|
||||
@./install/wine
|
||||
|
||||
@@ -230,9 +242,6 @@ zsh:
|
||||
# Scripts listed in ./packs
|
||||
#===============================================
|
||||
|
||||
##flameshot: [TODO] [PACK] qt5 + flameshot from source
|
||||
flameshot: qt5 flameshot-build
|
||||
|
||||
##lamp: [PACK] Apache + php + mariadb
|
||||
lamp: apache phpstack mariadb
|
||||
|
||||
@@ -244,8 +253,8 @@ omz: zsh omz-clean omz-fancy
|
||||
chsh -s /usr/bin/zsh
|
||||
@exec zsh
|
||||
|
||||
##phptools: [PACK] Install only php tooling (composer, phpunit, psalm, phpcs, php-cs-fixer, php-spx, phpmd)
|
||||
phptools: composer php-psalm php-spx phpcs phpmd phpstan phpunit
|
||||
##phptools: [PACK] Install only php tooling (composer, phpunit, psalm, phpcs, php-cs-fixer, phpmd)
|
||||
phptools: composer php-psalm phpcs phpmd phpstan phpunit
|
||||
|
||||
##phpstack: [PACK] Install full php stack with tooling
|
||||
phpstack: php phptools
|
||||
@@ -310,6 +319,10 @@ phpstack: php phptools
|
||||
/vivaldi:
|
||||
@./uninstall/vivaldi
|
||||
|
||||
##/wine: Uninstall wine
|
||||
/wine:
|
||||
@./uninstall/wine
|
||||
|
||||
#===============================================
|
||||
# Service goals
|
||||
#===============================================
|
||||
|
||||
11
README.md
11
README.md
@@ -16,13 +16,13 @@ If some dependecies are missed for some of these scripts it is enougth to run `.
|
||||
|
||||
```shell
|
||||
# with git
|
||||
git clone git@git.axenov.dev:anthony/my-env.git --depth=1 --single-branch
|
||||
git clone git@git.axenov.dev:anthony/shell.git --depth=1 --single-branch
|
||||
|
||||
# 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 -
|
||||
|
||||
# get full list of `make` goals
|
||||
cd my-env && make
|
||||
cd shell && make
|
||||
```
|
||||
|
||||
## How to add my script?
|
||||
@@ -30,7 +30,7 @@ cd my-env && make
|
||||
1. Create a new shell script in `./install`, `./upgrade` or `./uninstall` directory.
|
||||
At the beggining of a file you must write these two lines:
|
||||
```shell
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Your description for Makefile
|
||||
```
|
||||
2. Make this script executable, e.g.:
|
||||
@@ -85,6 +85,9 @@ where:
|
||||
* 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
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# alias bashrc='source ~/.bashrc'
|
||||
alias zshrc='source ~/.zshrc'
|
||||
|
||||
@@ -106,3 +106,5 @@ if ! shopt -oq posix; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -f ~/.profile ] && source ~/.profile
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
[alias]
|
||||
a = "add"
|
||||
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
|
||||
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" #
|
||||
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
|
||||
br = "branch" #
|
||||
branches = "branch -a"
|
||||
; branches = "bvv"
|
||||
brd = "branch -D" # force delete unmerged branch
|
||||
brod = "!git branch -D "$1"; git push origin :"$1";" # brd + remove it from origin
|
||||
bv = "branch -v" # show branch list with those last commits
|
||||
bvv = "branch -vv" # bv + remote branches tracked by them
|
||||
|
||||
c = "commit"
|
||||
ca = "commit --all" # stage all changes and make a commit (interative)
|
||||
cam = "commit --all --message" # ca + cm (non-interactive)
|
||||
@@ -31,9 +30,7 @@ cp = "cherry-pick"
|
||||
cpa = "cherry-pick --abort" # abort cherry-picking
|
||||
cpc = "cherry-pick --continue" # continue cherry-picking
|
||||
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
|
||||
|
||||
d = "diff"
|
||||
dc = "diff --cached" # show diff of staged files
|
||||
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 --" # удаляет изменения в файле
|
||||
dw = "diff --word-diff" # show word diff in unstaged files
|
||||
dwc = "diff --word-diff --cached" # dc + dw
|
||||
|
||||
empty="!git commit --allow-empty"
|
||||
exec = "!exec"
|
||||
|
||||
f = "fetch"
|
||||
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"
|
||||
|
||||
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" # показать последний коммит в текущей ветке
|
||||
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
|
||||
init = "init -q"
|
||||
|
||||
l = "log"
|
||||
; last-tag = "describe --tags --abbrev=0"
|
||||
; last-tagged = "!git describe --tags $(git rev-list --tags --max-count=1)"
|
||||
lo = "log --oneline"
|
||||
log-all = "log --graph --decorate --all"
|
||||
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'"
|
||||
|
||||
m = "merge"
|
||||
ma = "merge --abort" # abort merging
|
||||
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
|
||||
merged = "bm"
|
||||
mn = "merge --no-commit" # merge without commit
|
||||
|
||||
optimizer = "!git pruner; git repacker; git prune-packed"
|
||||
orphans = "fsck --full"
|
||||
outbound = "log @{upstream}.."
|
||||
|
||||
p = "pull"
|
||||
pf = "pull --force" # получить ветку принудительно
|
||||
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
|
||||
pruner = "!git prune --expire=now; git reflog expire --expire-unreachable=now --rewrite --all"
|
||||
pullf = "pull --force"
|
||||
pullft = "pull --force --tags"
|
||||
pullt = "pull --tags" # получить теги
|
||||
pushf = "!git push --force" # отправить ветку принудительно
|
||||
; pushf = "!git push --force --set-upstream origin $(git current-branch)" # отправить ветку принудительно
|
||||
pushft = "!git push --tags --force" # отправить теги принудительно
|
||||
; pushft = "!git push --tags --force --set-upstream origin $(git current-branch)" # отправить теги принудительно
|
||||
pusht = "!git push --tags" # отправить теги
|
||||
; pusht = "!git push --tags --set-upstream origin $(git current-branch)" # отправить теги
|
||||
|
||||
r = "reset"
|
||||
rb = "rebase"
|
||||
rba = "rebase --abort"
|
||||
@@ -124,12 +106,34 @@ rsh = "reset --soft HEAD" # откат коммита с сохранением
|
||||
rso = "remote show origin" # показать состояние локальных веток относительно удалённых на origin bare
|
||||
rv = "revert"
|
||||
rvn = "revert --no-commit"
|
||||
|
||||
s = "status"
|
||||
sb = "show-branch"
|
||||
st = "status"
|
||||
start = "!git init -q && git commit --allow-empty -m 'Initial commit'"
|
||||
stashes = "stash list" # show stashed changes
|
||||
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"
|
||||
; sdi = "submodule deinit -f"
|
||||
; si = "submodule init"
|
||||
@@ -137,15 +141,3 @@ sub = "submodule"
|
||||
; sst = "submodule status"
|
||||
; sup = "submodule update"
|
||||
; 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
1
dotfiles/.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
Desktop.ini
|
||||
._*
|
||||
Thumbs.db
|
||||
nbproject/
|
||||
|
||||
@@ -28,26 +28,36 @@ fi
|
||||
|
||||
### AAA ##########################################
|
||||
|
||||
if [ -f ~/.bash_aliases ]; then
|
||||
. ~/.bash_aliases
|
||||
fi
|
||||
[ -f ~/.bash_aliases ] && source ~/.bash_aliases
|
||||
[ -f ~/bars/src/lis-docker/.bash_aliases ] && source ~/bars/src/lis-docker/.bash_aliases
|
||||
|
||||
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 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.
|
||||
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.
|
||||
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"
|
||||
|
||||
@@ -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"},
|
||||
]
|
||||
|
||||
|
||||
@@ -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"
|
||||
},
|
||||
]
|
||||
@@ -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",
|
||||
],
|
||||
}
|
||||
@@ -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-*"],
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
[ -f Makefile ] && mv Makefile Makefile.bak
|
||||
CHR_UPGRADE='^'
|
||||
CHR_UNINSTALL='/'
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/bin/bash
|
||||
#!/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
|
||||
|
||||
@@ -1,4 +1,84 @@
|
||||
# Argument parser for bash scripts
|
||||
# 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/)
|
||||
@@ -7,8 +87,8 @@ More info:
|
||||
Tested in Ubuntu 20.04.2 LTS in:
|
||||
|
||||
```
|
||||
bash 5.0.17(1)-release (x86_64-pc-linux-gnu)
|
||||
zsh 5.8 (x86_64-ubuntu-linux-gnu)
|
||||
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
|
||||
@@ -26,4 +106,6 @@ 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
|
||||
```
|
||||
|
||||
322
helpers/arg-parser/args.sh
Normal file → Executable file
322
helpers/arg-parser/args.sh
Normal file → Executable file
@@ -1,33 +1,11 @@
|
||||
#!/bin/bash
|
||||
#########################################################################
|
||||
# #
|
||||
# Argument parser for bash scripts #
|
||||
# #
|
||||
# Author: Anthony Axenov (Антон Аксенов) #
|
||||
# Version: 1.5 #
|
||||
# License: MIT #
|
||||
# #
|
||||
#########################################################################
|
||||
# #
|
||||
# With 'getopt' you cannot combine different #
|
||||
# arguments for different nested functions. #
|
||||
# #
|
||||
# 'getopts' does not support long arguments with #
|
||||
# values (like '--foo=bar'). #
|
||||
# #
|
||||
# These functions supports different arguments and #
|
||||
# their combinations: #
|
||||
# -a -b -c #
|
||||
# -a avalue -b bvalue -c cvalue #
|
||||
# -cab bvalue #
|
||||
# --arg #
|
||||
# --arg=value -ab -c cvalue --foo #
|
||||
# #
|
||||
# Tested in Ubuntu 20.04.2 LTS in: #
|
||||
# bash 5.0.17(1)-release (x86_64-pc-linux-gnu) #
|
||||
# zsh 5.8 (x86_64-ubuntu-linux-gnu) #
|
||||
# #
|
||||
#########################################################################
|
||||
#!/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
|
||||
@@ -35,7 +13,7 @@
|
||||
#exitcode 0 - string valid
|
||||
#exitcode 1 - string is not valid
|
||||
grep_match() {
|
||||
printf "%s" "$1" | grep -qP "$2" >/dev/null
|
||||
printf "%s" "$1" | grep -qE "$2" >/dev/null
|
||||
}
|
||||
|
||||
#purpose Find short argument or its value
|
||||
@@ -49,46 +27,48 @@ grep_match() {
|
||||
#usage To echo value: arg v
|
||||
#usage To echo 1 if flag exists: arg f
|
||||
arg() {
|
||||
local need=${1:0:1} # argument to find (only first letter)
|
||||
[ "$need" ] || {
|
||||
echo "Argument is not specified!" >&2
|
||||
exit 1
|
||||
}
|
||||
local isflag=$2 || 0 # should we find the value or just the presence of the $need?
|
||||
local retvar=$3 || 0 # var to return value into (if 0 then value will be echo'ed in stdout)
|
||||
for ((idx=0; idx<${#__MAIN_ARGS__[@]}; ++idx)) do # going through args
|
||||
local arg=${__MAIN_ARGS__[$idx]} # current argument
|
||||
# skip $arg if it starts with '--', letter or digit
|
||||
grep_match "$arg" "^(\w{1}|-{2})" && continue
|
||||
# clear $arg from special and duplicate characters
|
||||
# e.g. 'fas-)dfs' will become 'fasd'
|
||||
local chars="$(printf "%s" "${arg}" | tr -s [${arg}] | tr -d "[:punct:][:blank:]")"
|
||||
# now we can check if $need is one of $chars
|
||||
if grep_match "-$need" "^-[$chars]$"; then # if it is
|
||||
if [[ $isflag = 1 ]]; then # and we expect it as a flag
|
||||
# then return '1' back into $retvar (if exists) or echo in stdout
|
||||
[ "$retvar" ] && eval "$retvar='1'" || echo "1"
|
||||
else # but if $arg is not a flag
|
||||
# then get next argument as value of current one
|
||||
local value="${__MAIN_ARGS__[$idx+1]}"
|
||||
# check if it is valid value
|
||||
if grep_match "$value" "^[[:graph:]]+$"; then
|
||||
# and return it back back into $retvar (if exists) or echo in stdout
|
||||
[ "$retvar" ] && eval "$retvar='$value'" || echo "$value"
|
||||
break
|
||||
else # otherwise throw error message into stderr (just in case)
|
||||
echo "Argument '$arg' must have a correct value!" >&2
|
||||
break
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
[ "$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 - is it flag? 1 if is, otherwise 0 or nothing
|
||||
#argument $3 - variable to return value into
|
||||
#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')
|
||||
@@ -96,171 +76,83 @@ arg() {
|
||||
#usage To echo value: arg v
|
||||
#usage To echo 1 if flag exists: arg f
|
||||
argl() {
|
||||
local need=$1 # argument to find
|
||||
[ "$need" ] || {
|
||||
echo "Argument is not specified!" >&2
|
||||
exit 1
|
||||
}
|
||||
local isflag=$2 || 0 # should we find the value or just the presence of the $need?
|
||||
local retvar=$3 || 0 # var to return value into (if 0 then value will be echo'ed in stdout)
|
||||
for ((idx=0; idx<${#__MAIN_ARGS__[@]}; ++idx)) do # going through args
|
||||
local arg=${__MAIN_ARGS__[$idx]} # current argument
|
||||
# if we expect $arg as a flag
|
||||
if [[ $isflag = 1 ]]; then
|
||||
# and if $arg has correct format (like '--flag')
|
||||
if grep_match "$arg" "^--$need"; then
|
||||
# then return '1' back into $retvar (if exists) or echo in stdout
|
||||
[ "$retvar" = 0 ] && echo "1" || eval "$retvar=1"
|
||||
break
|
||||
fi
|
||||
else # but if $arg is not a flag
|
||||
# check if $arg has correct format (like '--foo=bar')
|
||||
if grep_match "$arg" "^--$need=.+$"; then # if it is
|
||||
# then return part from '=' to arg's end as value back into $retvar (if exists) or echo in stdout
|
||||
[ "$retvar" = 0 ] && echo "${arg#*=}" || eval "$retvar=${arg#*=}"
|
||||
break
|
||||
fi
|
||||
[ "$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
|
||||
}
|
||||
|
||||
#purpose Get argument by its index
|
||||
#argument $1 - (number) arg index
|
||||
#argument $2 - (string) variable to return arg's name into
|
||||
# (if not specified then it will be echo'ed in stdout)
|
||||
#returns (string) arg name or nothing
|
||||
#usage To get arg into var: argn 1 myvar or arg=$(argn 1)
|
||||
#usage To echo in stdout: argn 1
|
||||
argn() {
|
||||
local idx=$1 # argument index
|
||||
[ $idx ] || {
|
||||
error "Argument index is not specified!"
|
||||
exit 1
|
||||
}
|
||||
local retvar=$2 || 0 # var to return value into (if 0 then value will be echo'ed in stdout)
|
||||
local args=(${__MAIN_ARGS[0]}) # args we need are stored in 1st element of __MAIN_ARGS
|
||||
local arg=${args[$idx]} # current argument
|
||||
if [ $arg ]; then
|
||||
[ ! $retvar = 0 ] && eval "$retvar=$arg" || echo "$arg"
|
||||
[ "$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"
|
||||
}
|
||||
|
||||
# Keep in mind:
|
||||
# 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 -ac'
|
||||
# 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. Values cannot contain spaces even in quotes both for short and
|
||||
# long args, otherwise first word will return as value.
|
||||
# 6. You can use arg() or argl() to check presence of any arg, no matter
|
||||
# if it has value or not.
|
||||
################################
|
||||
|
||||
### USAGE ###
|
||||
# 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
|
||||
|
||||
# first we must save the original arguments passed
|
||||
# to the script when it was called:
|
||||
__MAIN_ARGS__=($@)
|
||||
# __RAW_ARGS__=("$@")
|
||||
|
||||
echo -e "\n1. Short args (vars):"
|
||||
arg a 1 a # -a
|
||||
arg v 0 v # -v v_value
|
||||
arg c 1 c # -c
|
||||
arg z 1 z # -z (not exists)
|
||||
echo "1.1 a=$a"
|
||||
echo "1.2 v=$v"
|
||||
echo "1.3 c=$c"
|
||||
echo "1.4 z=$z"
|
||||
# arg a 1 flag_a
|
||||
# echo "Flag -a has value '$flag_a'"
|
||||
# echo "Flag -a has value '$(arg a 1)'"
|
||||
|
||||
echo -e "\n2. Short args (echo):"
|
||||
echo "2.1 a=$(arg a 1)"
|
||||
echo "2.2 v=$(arg v 0)"
|
||||
echo "2.3 c=$(arg c 1)"
|
||||
echo "2.4 z=$(arg z 1)"
|
||||
# arg b 1 flag_b
|
||||
# echo "Flag -b has value '$flag_b'"
|
||||
# echo "Flag -b has value '$(arg b 1)'"
|
||||
|
||||
echo -e "\n3. Long args (vars):"
|
||||
argl flag 1 flag # --flag
|
||||
argl param1 0 param1 # --param1=test
|
||||
argl param2 0 param2 # --param2=password
|
||||
argl bar 1 bar # --bar (not exists)
|
||||
echo "3.1 flag=$flag"
|
||||
echo "3.2 param1=$param1"
|
||||
echo "3.3 param2=$param2"
|
||||
echo "3.4 bar=$bar"
|
||||
# arg c 1 flag_c
|
||||
# echo "Flag -c has value '$flag_c'"
|
||||
# echo "Flag -c has value '$(arg c 1)'"
|
||||
|
||||
echo -e "\n4. Long args (echo):"
|
||||
echo "4.1 flag=$(argl flag 1)"
|
||||
echo "4.2 param1=$(argl param1 0)"
|
||||
echo "4.3 param2=$(argl param2 0)"
|
||||
echo "4.4 bar=$(argl bar 1)"
|
||||
# arg d 1 flag_d
|
||||
# echo "Flag -d has value '$flag_d'"
|
||||
# echo "Flag -d has value '$(arg d 1)'"
|
||||
|
||||
echo -e "\n5. Args by index:"
|
||||
argn 1 first
|
||||
echo "5.1 arg[1]=$first"
|
||||
echo "5.2 arg[3]=$(argn 3)"
|
||||
# argl flag1 1 flag_1
|
||||
# echo "Flag --flag1 has value '$flag_1'"
|
||||
# echo "Flag --flag1 has value '$(argl flag1 1)'"
|
||||
|
||||
# Well, now we will try to get global args inside different functions
|
||||
# argl flag2 1 flag_2
|
||||
# echo "Flag --flag2 has value '$flag_2'"
|
||||
# echo "Flag --flag2 has value '$(argl flag2 1)'"
|
||||
|
||||
food() {
|
||||
echo -e "\n=== food() ==="
|
||||
arg f 0 food
|
||||
argl 'food' 0 food
|
||||
[ $food ] && echo "Om nom nom! $food is very tasty" || echo "Uh oh" >&2
|
||||
}
|
||||
# arg e 0 arg_e
|
||||
# echo "Arg -e has value '$arg_e'"
|
||||
# echo "Arg -e has value '$(arg e 0)'"
|
||||
|
||||
hello() {
|
||||
echo -e "\n=== hello() ==="
|
||||
arg n 0 name
|
||||
argl name 0 name
|
||||
[ $name ] && echo "Hi, $name! How u r doin?" || echo "Hello, stranger..." >&2
|
||||
}
|
||||
# arg f 0 arg_f
|
||||
# echo "Arg -f has value '$arg_f'"
|
||||
# echo "Arg -f has value '$(arg f 0)'"
|
||||
|
||||
hello
|
||||
food
|
||||
# argl arg1 0 arg_1
|
||||
# echo "Arg --arg1 has value '$arg_1'"
|
||||
# echo "Arg --arg1 has value '$(argl arg1 0)'"
|
||||
|
||||
### OUTPUT ###
|
||||
|
||||
# Command to run:
|
||||
# bash args.sh -va asdf --flag --param1=paramvalue1 -c --param2="somevalue2 sdf" --name="John" -f Seafood
|
||||
|
||||
# 1. Short args (vars):
|
||||
# 1.1 a=1
|
||||
# 1.2 v=v_value
|
||||
# 1.3 c=1
|
||||
# 1.4 z=
|
||||
#
|
||||
# 2. Short args (echo):
|
||||
# 2.1 a=1
|
||||
# 2.2 v=v_value
|
||||
# 2.3 c=1
|
||||
# 2.4 z=
|
||||
#
|
||||
# 3. Long args (vars):
|
||||
# 3.1 longflag=1
|
||||
# 3.2 param1=test
|
||||
# 3.3 param2=password
|
||||
# 3.4 barflag=
|
||||
#
|
||||
# 4. Long args (echo):
|
||||
# 4.1 longflag=1
|
||||
# 4.2 param1=test
|
||||
# 4.3 param2=password
|
||||
# 4.4 barflag=
|
||||
#
|
||||
# 5. Args by index:
|
||||
# 5.1 arg[1]=asdf
|
||||
# 5.2 arg[3]=--param1=paramvalue1
|
||||
#
|
||||
# === hello() ===
|
||||
# Hi, John! How u r doin?
|
||||
#
|
||||
# === food() ===
|
||||
# Om nom nom! Seafood is very tasty
|
||||
# argl arg2 0 arg_2
|
||||
# echo "Arg --arg2 has value '$arg_2'"
|
||||
# echo "Arg --arg2 has value '$(argl arg2 0)'"
|
||||
|
||||
@@ -1,10 +1,38 @@
|
||||
#!/bin/bash
|
||||
#!/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}")
|
||||
@@ -66,7 +94,7 @@ open_url() {
|
||||
# unpack .tar.gz file $1 into path $2
|
||||
unpack_targz() {
|
||||
require tar
|
||||
tar -xzf "$1" -C "$2"
|
||||
tar -xzvf "$1" -C "$2"
|
||||
}
|
||||
|
||||
# make soft symbolic link of path $1 to path $2
|
||||
@@ -93,3 +121,7 @@ is_int() {
|
||||
is_number() {
|
||||
[[ "$1" =~ ^[0-9]+([.,][0-9]+)?$ ]]
|
||||
}
|
||||
|
||||
trim() {
|
||||
echo "$1" | xargs
|
||||
}
|
||||
|
||||
@@ -1,26 +1,3 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
source $( dirname $(readlink -e -- "${BASH_SOURCE}"))/io.sh || exit 255
|
||||
|
||||
########################################################
|
||||
# Functions to debug scripts
|
||||
########################################################
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
########################################################
|
||||
# Docker wrappers
|
||||
@@ -46,3 +46,34 @@ docker.exec() {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
_dir=$( dirname $(readlink -e -- "${BASH_SOURCE}"))
|
||||
source $_dir/io.sh || exit 255
|
||||
source $_dir/basic.sh || exit 255
|
||||
source $_dir/pkg.sh || exit 255
|
||||
source "$_dir/io.sh" || exit 255
|
||||
source "$_dir/basic.sh" || exit 255
|
||||
source "$_dir/packages.sh" || exit 255
|
||||
|
||||
########################################################
|
||||
# Shorthands for git
|
||||
@@ -10,7 +10,7 @@ source $_dir/pkg.sh || exit 255
|
||||
|
||||
git.clone_quick() {
|
||||
require git
|
||||
git clone --depth=1 --single-branch $*
|
||||
git clone --depth=1 --single-branch "$@"
|
||||
}
|
||||
|
||||
git.is_repo() {
|
||||
@@ -64,12 +64,12 @@ git.reset() {
|
||||
|
||||
git.clone() {
|
||||
require git
|
||||
git clone $* 2>&1
|
||||
git clone "$*" 2>&1
|
||||
}
|
||||
|
||||
git.co() {
|
||||
require git
|
||||
git checkout $* 2>&1
|
||||
git checkout "$*" 2>&1
|
||||
}
|
||||
|
||||
git.is_it_current_branch() {
|
||||
|
||||
28
helpers/help.sh
Normal file
28
helpers/help.sh
Normal 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"
|
||||
}
|
||||
226
helpers/io.sh
226
helpers/io.sh
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
########################################################
|
||||
# Simple and fancy input & output
|
||||
@@ -7,93 +7,137 @@
|
||||
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}
|
||||
|
||||
[ $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=''
|
||||
# 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=''
|
||||
|
||||
[ $USE_COLORS = 1 ] && BOLD="\e[1m" || BOLD=''
|
||||
[ $USE_COLORS = 1 ] && DIM="\e[2m" || DIM=''
|
||||
[ $USE_COLORS = 1 ] && NOTBOLD="\e[22m" || NOTBOLD='' # sometimes \e[21m
|
||||
[ $USE_COLORS = 1 ] && NOTDIM="\e[22m" || NOTDIM=''
|
||||
[ $USE_COLORS = 1 ] && NORMAL="\e[20m" || NORMAL=''
|
||||
[ $USE_COLORS = 1 ] && RESET="\e[0m" || RESET=''
|
||||
# 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
|
||||
|
||||
[ $USE_COLORS = 1 ] && FRESET="\e[39m" || FRESET=''
|
||||
[ $USE_COLORS = 1 ] && FBLACK="\e[30m" || FBLACK=''
|
||||
[ $USE_COLORS = 1 ] && FWHITE="\e[97m" || FWHITE=''
|
||||
[ $USE_COLORS = 1 ] && FRED="\e[31m" || FRED=''
|
||||
[ $USE_COLORS = 1 ] && FGREEN="\e[32m" || FGREEN=''
|
||||
[ $USE_COLORS = 1 ] && FYELLOW="\e[33m" || FYELLOW=''
|
||||
[ $USE_COLORS = 1 ] && FBLUE="\e[34m" || FBLUE=''
|
||||
[ $USE_COLORS = 1 ] && FLRED="\e[91m" || FLRED=''
|
||||
[ $USE_COLORS = 1 ] && FLGREEN="\e[92m" || FLGREEN=''
|
||||
[ $USE_COLORS = 1 ] && FLYELLOW="\e[93m" || FLYELLOW=''
|
||||
[ $USE_COLORS = 1 ] && FLBLUE="\e[94m" || FLBLUE=''
|
||||
# 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
|
||||
|
||||
[ $USE_COLORS = 1 ] && BRESET="\e[49m" || BRESET=''
|
||||
[ $USE_COLORS = 1 ] && BBLACK="\e[40m" || BBLACK=''
|
||||
[ $USE_COLORS = 1 ] && BWHITE="\e[107m" || BWHITE=''
|
||||
[ $USE_COLORS = 1 ] && BRED="\e[41m" || BRED=''
|
||||
[ $USE_COLORS = 1 ] && BGREEN="\e[42m" || BGREEN=''
|
||||
[ $USE_COLORS = 1 ] && BYELLOW="\e[43m" || BYELLOW=''
|
||||
[ $USE_COLORS = 1 ] && BBLUE="\e[44m" || BBLUE=''
|
||||
[ $USE_COLORS = 1 ] && BLRED="\e[101m" || BLRED=''
|
||||
[ $USE_COLORS = 1 ] && BLGREEN="\e[102m" || BLGREEN=''
|
||||
[ $USE_COLORS = 1 ] && BLYELLOW="\e[103m" || BLYELLOW=''
|
||||
[ $USE_COLORS = 1 ] && BLBLUE="\e[104m" || BLBLUE=''
|
||||
# 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
|
||||
|
||||
dt() {
|
||||
# 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 ${BOLD}${BBLUE}${FWHITE}${IASK}${BRESET}\ ${BOLD}$1 ): " $2
|
||||
IFS= read -rp "$(print ${FBOLD}${FBBLUE}${FWHITE}${IASK}${FRESET}\ ${FBOLD}$1 ): " $2
|
||||
}
|
||||
|
||||
print() {
|
||||
echo -e "$*${RESET}"
|
||||
# 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 "${DIM}${BOLD}${RESET}${DIM}$(dt)${IDEBUG} ${FUNCNAME[1]:-?}():${BASH_LINENO:-?}\t$1 " >&2
|
||||
print "${FDIM}${FBOLD}${FRESET}${FDIM}$(now)${IDEBUG} ${FUNCNAME[1]:-?}():${BASH_LINENO:-?}\t$1 " >&2
|
||||
else
|
||||
print "${DIM}${BOLD}${RESET}${DIM}$(dt)${IDEBUG} $1 " >&2
|
||||
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 "${BOLD}$(dt)${IVRB}${RESET}${FYELLOW} $1 "
|
||||
print "${FBOLD}$(now)${IVRB}${FRESET}${FYELLOW} $1 "
|
||||
}
|
||||
|
||||
info() {
|
||||
print "${BOLD}$(dt)${FWHITE}${BLBLUE}${IINFO}${RESET}${FWHITE} $1 "
|
||||
print "${FBOLD}$(now)${FWHITE}${FBLBLUE}${IINFO}${FRESET}${FWHITE} $1 "
|
||||
}
|
||||
|
||||
note() {
|
||||
print "${BOLD}$(dt)${DIM}${FWHITE}${INOTE}${RESET} $1 "
|
||||
print "${FBOLD}$(now)${FDIM}${FWHITE}${INOTE}${FRESET} $1 "
|
||||
}
|
||||
|
||||
success() {
|
||||
print "${BOLD}$(dt)${BGREEN}${FWHITE}${ISUCCESS}${BRESET}$FGREEN $1 "
|
||||
print "${FBOLD}$(now)${FBGREEN}${FWHITE}${ISUCCESS}${FRESET}$FGREEN $1 "
|
||||
}
|
||||
|
||||
warn() {
|
||||
print "${BOLD}$(dt)${BYELLOW}${FBLACK}${IWARN}${BRESET}${FYELLOW} Warning:${RESET} $1 "
|
||||
print "${FBOLD}$(now)${FBYELLOW}${FBLACK}${IWARN}${FRESET}${FYELLOW} Warning:${FRESET} $1 "
|
||||
}
|
||||
|
||||
error() {
|
||||
print "${BOLD}$(dt)${BLRED}${FWHITE}${IERROR} Error: ${BRESET}${FLRED} $1 " >&2
|
||||
print "${FBOLD}$(now)${FBLRED}${FWHITE}${IERROR} Error: ${FRESET}${FLRED} $1 " >&2
|
||||
}
|
||||
|
||||
fatal() {
|
||||
print "${BOLD}$(dt)${BRED}${FWHITE}${IFATAL} FATAL: $1 " >&2
|
||||
print "${FBOLD}$(now)${FBRED}${FWHITE}${IFATAL} FATAL: $1 " >&2
|
||||
print_stacktrace
|
||||
}
|
||||
|
||||
@@ -116,10 +160,43 @@ 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/dtmilano/4055d6df5b6e4ea87c5a72dc2d604193
|
||||
# https://gist.github.com/nowmilano/4055d6df5b6e4ea87c5a72dc2d604193
|
||||
# https://gist.github.com/nick3499/402a6d7dccd474f2bdb679f4311b1238
|
||||
# https://gist.github.com/connorjan/2b02126868157c2b69f9aa0a052cdc86
|
||||
|
||||
@@ -143,53 +220,6 @@ die() {
|
||||
|
||||
# ===========
|
||||
|
||||
# Text color - normal
|
||||
# fgblack="$(tput setaf 0)" # Black
|
||||
# fgred="$(tput setaf 1)" # Red
|
||||
# fggreen="$(tput setaf 2)" # Green
|
||||
# fgyellow="$(tput setaf 3)" # Yellow
|
||||
# fgblue="$(tput setaf 4)" # Blue
|
||||
# fgpurple="$(tput setaf 5)" # Purple
|
||||
# fgcyan="$(tput setaf 6)" # Cyan
|
||||
# fgwhite="$(tput setaf 7)" # White
|
||||
|
||||
# # Text color - bright
|
||||
# bfgblack="$(tput setaf 8)" # Black
|
||||
# bfgred="$(tput setaf 9)" # Red
|
||||
# bfggreen="$(tput setaf 10)" # Green
|
||||
# bfgyellow="$(tput setaf 11)" # Yellow
|
||||
# bfgblue="$(tput setaf 12)" # Blue
|
||||
# bfgpurple="$(tput setaf 13)" # Purple
|
||||
# bfgcyan="$(tput setaf 14)" # Cyan
|
||||
# bfgwhite="$(tput setaf 15)" # White
|
||||
|
||||
# # Background color - normal
|
||||
# bgblack="$(tput setab 0)" # Black - Background
|
||||
# bgred="$(tput setab 1)" # Red
|
||||
# bggreen="$(tput setab 2)" # Green
|
||||
# bgyellow="$(tput setab 3)" # Yellow
|
||||
# bgblue="$(tput setab 4)" # Blue
|
||||
# bgpurple="$(tput setab 5)" # Purple
|
||||
# bgcyan="$(tput setab 6)" # Cyan
|
||||
# bgwhite="$(tput setab 7)" # White
|
||||
|
||||
# # Background color - bright
|
||||
# bbgblack="$(tput setab 8)" # Black - Background - Bright
|
||||
# bbgred="$(tput setab 9)" # Red
|
||||
# bbggreen="$(tput setab 10)" # Green
|
||||
# bbgyellow="$(tput setab 11)" # Yellow
|
||||
# bbgblue="$(tput setab 12)" # Blue
|
||||
# bbgpurple="$(tput setab 13)" # Purple
|
||||
# bbgcyan="$(tput setab 14)" # Cyan
|
||||
# bbgwhite="$(tput setab 15)" # White
|
||||
|
||||
# # Other attributes
|
||||
# normal="$(tput sgr0)" # text reset
|
||||
# bold="$(tput bold)" # make bold
|
||||
# underline="$(tput smul)" # underline
|
||||
# nounderlin="$(tput rmul)" # remove underline
|
||||
# mkblink="$(tput blink)" # make blink
|
||||
# reverse="$(tput rev)" # reverse
|
||||
|
||||
# ===========
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
########################################################
|
||||
# Logging functions
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
########################################################
|
||||
# Misc
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
# https://askubuntu.com/a/30414
|
||||
is_full_screen() {
|
||||
local WINDOW=$(echo $(xwininfo -id $(xdotool getactivewindow) -stats | \
|
||||
egrep '(Width|Height):' | \
|
||||
awk '{print $NF}') | \
|
||||
sed -e 's/ /x/')
|
||||
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
|
||||
@@ -17,19 +17,6 @@ is_full_screen() {
|
||||
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
|
||||
}
|
||||
|
||||
ytm() {
|
||||
youtube-dl \
|
||||
--extract-audio \
|
||||
@@ -38,29 +25,5 @@ ytm() {
|
||||
--format bestaudio \
|
||||
--write-info-json \
|
||||
--output "$HOME/Downloads/ytm/%(playlist_title)s/%(channel)s - %(title)s.%(ext)s" \
|
||||
$*
|
||||
}
|
||||
|
||||
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
|
||||
"$@"
|
||||
}
|
||||
|
||||
51
helpers/net.sh
Normal file
51
helpers/net.sh
Normal 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
63
helpers/notif.sh
Normal 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"
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
source $( dirname $(readlink -e -- "${BASH_SOURCE}"))/packages.sh || exit 255
|
||||
|
||||
########################################################
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
source $( dirname $(readlink -e -- "${BASH_SOURCE}"))/io.sh || exit 255
|
||||
|
||||
########################################################
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
source $( dirname $(readlink -e -- "${BASH_SOURCE}"))/io.sh || exit 255
|
||||
|
||||
########################################################
|
||||
|
||||
21
helpers/traps.sh
Normal file
21
helpers/traps.sh
Normal 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
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install apache2 (latest)
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install software from apt
|
||||
|
||||
sudo apt update && \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install Canon Pixma MG2500 + ppa
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install google chrome (latest)
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
6
install/clamav
Executable file
6
install/clamav
Executable 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
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install composer (latest)
|
||||
here=$( dirname $(readlink -e -- "${BASH_SOURCE}"))
|
||||
source "$here/../helpers.sh" || exit 255
|
||||
@@ -25,10 +25,10 @@ php "$HOME/install/other/composer-setup.php" \
|
||||
--filename="composer"
|
||||
|
||||
COMPOSER_GLOBAL_HOME="$($HOME/.local/bin/composer config -g home)"
|
||||
NEWPATH="export PATH=\"$COMPOSER_GLOBAL_HOME/vendor/bin:\${PATH}\""
|
||||
NEWPATH="PATH=\"$COMPOSER_GLOBAL_HOME/vendor/bin:\${PATH}\""
|
||||
cat "$HOME/.profile" | grep -qoh "$NEWPATH" || {
|
||||
$NEWPATH
|
||||
echo "$NEWPATH" >> "$HOME/.profile"
|
||||
export "$NEWPATH"
|
||||
echo "export $NEWPATH" >> "$HOME/.profile"
|
||||
}
|
||||
|
||||
source "$HOME/.profile"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install docker (latest) + ppa
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install dotfiles
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install droidcam v1.9.0
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install droidcam-obs plugin v1.5.1
|
||||
|
||||
#TODO
|
||||
|
||||
@@ -1,15 +1,54 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install flameshot (latest)
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
title
|
||||
|
||||
sudo apt install -y --autoremove flameshot && \
|
||||
sudo systemctl restart flameshot
|
||||
# https://github.com/flameshot-org/flameshot?tab=readme-ov-file#compilation
|
||||
# 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 ] && {
|
||||
echo
|
||||
success "flameshot installed!"
|
||||
flameshot -v
|
||||
# /opt/flameshot/flameshot -v
|
||||
echo
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
##makedesc: Install Wireguard + FRKN
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install Wireguard + FRKN (deprecated)
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
# https://frkn.org/ru/installation
|
||||
@@ -11,7 +11,7 @@ cd "$HOME/install/frkn"
|
||||
|
||||
apt_install wireguard jq
|
||||
|
||||
countries=(uk ru nl nl2 ch)
|
||||
countries=(jp nl tr at ru se)
|
||||
for idx in ${!countries[@]}; do
|
||||
country=${countries[idx]}
|
||||
info "Downloading config for $country ($(expr $idx + 1)/${#countries[@]})"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install git (latest)
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install golang v1.21.0
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install grub-customizer (latest + ppa)
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install JetBrains Mono fonts
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash (latest)
|
||||
#!/usr/bin/env bash (latest)
|
||||
##makedesc: Install KDE Window AppMenu Applet
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install KDE Backports
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install file templates (KDE)
|
||||
|
||||
echo
|
||||
@@ -48,7 +48,7 @@ EOF
|
||||
|
||||
echo "- Shell" ####################################################
|
||||
cat <<EOF > "$TPL_SRC/template.sh"
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
EOF
|
||||
|
||||
cat << EOF > "$TPL_DIR/sh.desktop"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install KDE portal
|
||||
|
||||
echo
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install libreoffice
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,43 +1,45 @@
|
||||
#!/bin/bash
|
||||
##makedesc: Install lite-xl
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install lite-xl v2.1.7
|
||||
|
||||
# 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 "Installing lite-xl v2.1.0..."
|
||||
echo "Installing lite-xl v2.1.7..."
|
||||
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_filepath="/tmp/lite-xl.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"
|
||||
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_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 \
|
||||
"$untar_dir" \
|
||||
#"$dest_config" \
|
||||
"$dest_bin_dir" \
|
||||
"$dest_share_dir"
|
||||
"$HOME/.local/bin" \
|
||||
"$HOME/.local/share/lite-xl"
|
||||
|
||||
tar -xzf "$tar_filepath" -C "$untar_dir"
|
||||
mv -fv "$untar_subdir/lite-xl" "$dest_bin_dir/lite-xl"
|
||||
mv -fvT "$untar_subdir/data" "$dest_share_subdir"
|
||||
rm -fr "$tar_file" "$untar_subdir"
|
||||
wget "$tar_url" -O "$tar_filepath" && \
|
||||
wget "$lpm_url" -O "$HOME/.local/bin/lpm" && \
|
||||
chmod +x "$HOME/.local/bin/lpm" && \
|
||||
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
|
||||
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]
|
||||
Type=Application
|
||||
Name=Lite XL
|
||||
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
|
||||
Terminal=false
|
||||
StartupWMClass=lite-xl
|
||||
@@ -48,53 +50,6 @@ EOF
|
||||
sudo update-desktop-database && \
|
||||
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 "Finish!"
|
||||
echo "- $dest_bin_dir/lite-xl"
|
||||
echo "- $dest_share_subdir"
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install mariadb (latest) and php-mysql + phpMyAdmin (if php is installed)
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install nodejs + npm via nvm
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install ntfy (latest) + ppa
|
||||
|
||||
echo
|
||||
|
||||
33
install/nvim
Executable file
33
install/nvim
Executable 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"
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install obs-studio (latest snap)
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install omz (latest)
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install omz fancy (powerline10k + MesloLGS font)
|
||||
|
||||
# https://gist.github.com/anthonyaxenov/b8460935d06b9f0da72def03d0f26515
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install openvpn v2.6.3 (src)
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install papirus-icon-theme (latest)
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install postgresql (latest) and php-pgsql (if php is installed)
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
11
install/php
11
install/php
@@ -1,16 +1,16 @@
|
||||
#!/bin/bash
|
||||
##makedesc: Install php v8.3 + ppa
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install php v8.4
|
||||
|
||||
[ $1 ] && PHPVER="$1" || PHPVER="8.3"
|
||||
[ "$1" ] && PHPVER="$1" || PHPVER="8.4"
|
||||
echo
|
||||
echo "==============================================="
|
||||
echo "Installing php${PHPVER}..."
|
||||
echo "==============================================="
|
||||
echo
|
||||
|
||||
sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
|
||||
sudo apt install -y --autoremove \
|
||||
php${PHPVER} \
|
||||
php${PHPVER}-fpm \
|
||||
php${PHPVER}-dev \
|
||||
php${PHPVER}-apcu \
|
||||
php${PHPVER}-bcmath \
|
||||
php${PHPVER}-cli \
|
||||
@@ -24,6 +24,7 @@ sudo apt install -y --autoremove \
|
||||
php${PHPVER}-mysql \
|
||||
php${PHPVER}-opcache \
|
||||
php${PHPVER}-pgsql \
|
||||
php${PHPVER}-simplexml \
|
||||
php${PHPVER}-soap \
|
||||
php${PHPVER}-sqlite3 \
|
||||
php${PHPVER}-xdebug \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install psalm
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install php-spx
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install phpcs + php-cs-fixer
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install phpmd
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install phpstan
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install phpunit
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install postman (latest)
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install qt5
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
##makedesc: Install rustdesk client v1.1.9 (deb)
|
||||
#!/usr/bin/env bash
|
||||
##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 "Installing rustdesk v$RDVER..."
|
||||
@@ -12,9 +12,13 @@ echo
|
||||
|
||||
deb_path="$HOME/install"
|
||||
deb_name="rustdesk-$RDVER.deb"
|
||||
mkdir -p $deb_path
|
||||
mkdir -p "$deb_path"
|
||||
deb="$deb_path/$deb_name"
|
||||
|
||||
sudo apt install -y libxdo3 python3-pip && \
|
||||
wget "https://github.com/rustdesk/rustdesk/releases/download/$RDVER/$deb_name" -O $deb && \
|
||||
sudo dpkg -i $deb
|
||||
sudo apt install -y libxdo3 python3-pip
|
||||
wget "https://github.com/rustdesk/rustdesk/releases/download/$RDVER/$deb_name" -O "$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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install bunch of software from snap
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install Sublime Merge
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,31 +1,34 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install Sublime Text
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
# 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='4189'
|
||||
[ "$1" ] && STVER="$1" || STVER='4200'
|
||||
|
||||
title
|
||||
|
||||
mkdir -p "$HOME/install"
|
||||
DEB_PATH="$HOME/install/sublime-text_build-${SMVER}_amd64.deb"
|
||||
DEB_PATH="$HOME/install/sublime-text_build-${STVER}_amd64.deb"
|
||||
BIN_PATH="/opt/sublime_text/sublime_text"
|
||||
|
||||
if [[ ! -f "$DEB_PATH" ]]; then
|
||||
download https://download.sublimetext.com/sublime-text_build-${STVER}_amd64.deb "$DEB_PATH"
|
||||
download "https://download.sublimetext.com/sublime-text_build-${STVER}_amd64.deb" "$DEB_PATH"
|
||||
fi
|
||||
|
||||
sudo dpkg -i "$DEB_PATH"
|
||||
sudo cp -f $BIN_PATH $BIN_PATH.old
|
||||
sudo cp -f "$BIN_PATH" "$BIN_PATH.old"
|
||||
|
||||
if [[ $STVER = 4169 ]]; then
|
||||
echo "00489f39: c640 0501 4885 c9" | sudo xxd -r - $BIN_PATH
|
||||
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
|
||||
sudo sed -i 's#\x80\x79\x05\x00\x0F\x94\xC2#\xC6\x41\x05\x01\xB2\x00\x90#' "$BIN_PATH"
|
||||
fi
|
||||
|
||||
echo
|
||||
|
||||
20
install/suld
Executable file
20
install/suld
Executable 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/"
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install syncthing (latest) + ppa
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install telebit (latest)
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install telegram (latest)
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install ulauncher (latest) + ppa
|
||||
|
||||
echo
|
||||
@@ -7,5 +7,7 @@ echo "Installing ulauncher (latest) + ppa..."
|
||||
echo "==============================================="
|
||||
echo
|
||||
|
||||
sudo add-apt-repository -y ppa:agornostal/ulauncher
|
||||
sudo apt install -y --autoremove ulauncher
|
||||
sudo add-apt-repository universe -y
|
||||
sudo add-apt-repository ppa:agornostal/ulauncher -y
|
||||
sudo apt update
|
||||
sudo apt install ulauncher
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install Vivaldi + ppa
|
||||
|
||||
# https://repo.vivaldi.com
|
||||
@@ -11,11 +11,9 @@ echo "Installing Vivaldi + ppa..."
|
||||
echo "==============================================="
|
||||
echo
|
||||
|
||||
wget -qO- https://repo.vivaldi.com/archive/linux_signing_key.pub \
|
||||
| gpg --dearmor \
|
||||
| sudo dd of=/usr/share/keyrings/vivaldi-browser.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
|
||||
wget -qO- https://repo.vivaldi.com/archive/linux_signing_key.pub | gpg --dearmor > packages.vivaldi.gpg
|
||||
sudo install -o root -g root -m 644 packages.vivaldi.gpg /etc/apt/trusted.gpg.d
|
||||
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
|
||||
|
||||
sudo apt update && sudo apt install vivaldi-stable
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: VSCode deb-package
|
||||
source "$( dirname $(readlink -e -- "${BASH_SOURCE}"))/../helpers.sh" || exit 255
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
##makedesc: Install wine (latest) + ppa (focal)
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install wine (latest) + ppa
|
||||
|
||||
echo
|
||||
echo "==============================================="
|
||||
@@ -9,6 +9,6 @@ echo
|
||||
|
||||
sudo dpkg --add-architecture i386
|
||||
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
|
||||
wine --version
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install youtube-dl (src)
|
||||
|
||||
# https://github.com/ytdl-org/youtube-dl#installation
|
||||
@@ -23,7 +23,12 @@ installed() {
|
||||
mkdir -p "$HOME/install/youtube-dl" "$HOME/.local/bin"
|
||||
|
||||
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
|
||||
! 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" && \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install ytdlcue
|
||||
|
||||
# https://gist.github.com/anthonyaxenov/8e11f18493c8419ee7abc94a8ea0cfaf
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install zint (latest)
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
##makedesc: Install vanilla zsh
|
||||
|
||||
echo
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
##flameshot: [TODO] [PACK] qt5 + flameshot from source
|
||||
flameshot: qt5 flameshot-build
|
||||
@@ -1,2 +1,2 @@
|
||||
##phptools: [PACK] Install only php tooling (composer, phpunit, psalm, phpcs, php-cs-fixer, php-spx, phpmd)
|
||||
phptools: composer php-psalm php-spx phpcs phpmd phpstan phpunit
|
||||
##phptools: [PACK] Install only php tooling (composer, phpunit, psalm, phpcs, php-cs-fixer, phpmd)
|
||||
phptools: composer php-psalm phpcs phpmd phpstan phpunit
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
# Shell scripts
|
||||
|
||||
## Russian
|
||||
# Shell-скрипты
|
||||
|
||||
Эти скрипты я писал в разное время для решения разных задач.
|
||||
Чтобы они не растерялись по репозиториям и носителям, я решил собрать их здесь в одну кучу.
|
||||
|
||||
Я всегда использую Ubuntu в качестве своих настольных и серверных ОС, поэтому все эти скрипты писались и использовались в этих средах с версий 18.*.
|
||||
|
||||
Многие скрипты зависимы от [io.sh](/io.sh).
|
||||
|
||||
## English
|
||||
|
||||
These scripts were written at different times to solve different my own problems.
|
||||
I decided to collect them here in a heap so that they are not lost in repositories and media.
|
||||
|
||||
I always use Ubuntu as my desktop and server OS, so all these scripts has been written and used in these environments since version 18.*.
|
||||
|
||||
Many scripts depending on [io.sh](/io.sh).
|
||||
|
||||
2
tools/dc
2
tools/dc
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/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
|
||||
|
||||
5
tools/disable-ipv6.sh
Executable file
5
tools/disable-ipv6.sh
Executable 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"
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
# https://gist.github.com/anthonyaxenov/c16e1181d4b8a8644c57ec8a1f6cf21c
|
||||
#########################################################################
|
||||
# #
|
||||
|
||||
11
tools/display-rotate.sh
Executable file
11
tools/display-rotate.sh
Executable 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"
|
||||
47
tools/docker-volume-snapshot.sh
Normal file
47
tools/docker-volume-snapshot.sh
Normal 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
|
||||
3
tools/duckdns/.env.example
Normal file
3
tools/duckdns/.env.example
Normal file
@@ -0,0 +1,3 @@
|
||||
DUCK_TOKEN=
|
||||
DUCK_DOMAINS=
|
||||
DUCK_IP=
|
||||
2
tools/duckdns/.gitignore
vendored
Normal file
2
tools/duckdns/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.env
|
||||
*.log
|
||||
9
tools/duckdns/install.sh
Executable file
9
tools/duckdns/install.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
thisdir="$( dirname "$(readlink -e -- "${BASH_SOURCE[0]}")")"
|
||||
|
||||
# https://www.duckdns.org/install.jsp
|
||||
|
||||
croncmd="$thisdir/update.sh"
|
||||
cronjob="*/30 * * * * $croncmd" # every 30 min
|
||||
( crontab -l | grep -v -F "$croncmd" ; echo "$cronjob" ) | crontab -
|
||||
cp -f "$thisdir/.env.example" "$thisdir/.env"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user