hosted mode create /var/lib/miaou-bash/semver_current
This commit is contained in:
+37
-60
@@ -155,33 +155,20 @@ function __vte_urlencode {
|
|||||||
# If not running interactively, don't do anything
|
# If not running interactively, don't do anything
|
||||||
[[ $- != *i* ]] && return
|
[[ $- != *i* ]] && return
|
||||||
|
|
||||||
[[ ! -v MIAOU_BASH_DIR ]] && MIAOU_BASH_DIR=/opt/miaou-bash && export MIAOU_BASH_DIR
|
|
||||||
|
|
||||||
## Add path for TOOLBOX if any
|
|
||||||
[[ -d "/TOOLBOX" ]] && PATH=$PATH:/TOOLBOX || true
|
|
||||||
|
|
||||||
# Add path to any tools folder in /opt/miaou-*
|
|
||||||
for i in {/opt,$HOME}/miaou-*/tools; do [[ -d "$i" ]] && PATH=$PATH:$i; done || true
|
|
||||||
|
|
||||||
HOSTNAME=$(hostname -f)
|
HOSTNAME=$(hostname -f)
|
||||||
|
|
||||||
# don't put duplicate lines or lines starting with space in the history.
|
|
||||||
HISTCONTROL=ignoreboth
|
HISTCONTROL=ignoreboth
|
||||||
|
HISTSIZE=10000
|
||||||
|
HISTFILESIZE=20000
|
||||||
|
|
||||||
# append to the history file, don't overwrite it
|
# append to the history file, don't overwrite it
|
||||||
shopt -s histappend
|
shopt -s histappend
|
||||||
|
|
||||||
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
||||||
HISTSIZE=10000
|
|
||||||
HISTFILESIZE=20000
|
|
||||||
|
|
||||||
# check the window size after each command and, if necessary,
|
# check the window size after each command and, if necessary,
|
||||||
# update the values of LINES and COLUMNS.
|
# update the values of LINES and COLUMNS.
|
||||||
shopt -s checkwinsize
|
shopt -s checkwinsize
|
||||||
|
|
||||||
# make less more friendly for non-text input files, see lesspipe(1)
|
|
||||||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
|
||||||
|
|
||||||
# set a fancy prompt (non-color, unless we know we "want" color)
|
# set a fancy prompt (non-color, unless we know we "want" color)
|
||||||
# One-liner: Do we have colors?
|
# One-liner: Do we have colors?
|
||||||
if [[ -t 1 ]] && [[ -v COLORTERM && "$COLORTERM" == "truecolor" || "$TERM" == *"256color"* || "$TERM" == 'xterm-ghostty' ]]; then
|
if [[ -t 1 ]] && [[ -v COLORTERM && "$COLORTERM" == "truecolor" || "$TERM" == *"256color"* || "$TERM" == 'xterm-ghostty' ]]; then
|
||||||
@@ -189,11 +176,38 @@ if [[ -t 1 ]] && [[ -v COLORTERM && "$COLORTERM" == "truecolor" || "$TERM" == *"
|
|||||||
export LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.sql.gz=01;35:*.mariadb.gz=01;35:*.postgres.gz=01;35:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:"
|
export LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.sql.gz=01;35:*.mariadb.gz=01;35:*.postgres.gz=01;35:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export LESS="r"
|
if [[ -t 0 ]]; then
|
||||||
|
stty -ixon # prevent CTRL+S to freeze in vim, CTRL+Q to unfreeze!
|
||||||
|
stty kill undef # release CTRL+U for the Readline library => undo
|
||||||
|
fi
|
||||||
|
|
||||||
# enable programmable completion features (you don't need to enable
|
PROMPT_COMMAND='__prompt_command' # Func to gen PS1 after CMDs
|
||||||
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
|
||||||
# sources /etc/bash.bashrc).
|
export LESS="r"
|
||||||
|
# make less more friendly for non text input files, see lesspipe(1)
|
||||||
|
if [[ -x /usr/bin/lesspipe ]]; then eval "$(SHELL=/bin/sh lesspipe)"; fi
|
||||||
|
|
||||||
|
# ALIASES
|
||||||
|
alias sudo='sudo ' # smart sudo alias trick!
|
||||||
|
alias ls='ls $COLOR_OPTIONS -h'
|
||||||
|
alias ll='ls $COLOR_OPTIONS -lh'
|
||||||
|
alias la='ls $COLOR_OPTIONS -lah'
|
||||||
|
alias ltr='ls $COLOR_OPTIONS -ltrh'
|
||||||
|
alias l=ls
|
||||||
|
alias cd..='cd ..'
|
||||||
|
alias ..=cd..
|
||||||
|
alias grep='grep $COLOR_OPTIONS '
|
||||||
|
alias fgrep='fgrep $COLOR_OPTIONS '
|
||||||
|
alias egrep='egrep $COLOR_OPTIONS '
|
||||||
|
alias transfer_cp='rsync -a --info=progress2 --no-inc-recursive'
|
||||||
|
alias ssu='ss -tupn'
|
||||||
|
# OVERRIDDEN ALIASES
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
|
[[ -f "/etc/bash.aliases" ]] && source "/etc/bash.aliases"
|
||||||
|
# shellcheck disable=SC1090,SC1091
|
||||||
|
[[ -f "$HOME/.bash_aliases" ]] && source "$HOME/.bash_aliases"
|
||||||
|
|
||||||
|
# BASH COMPLETIONS
|
||||||
if ! shopt -oq posix; then
|
if ! shopt -oq posix; then
|
||||||
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||||||
. /usr/share/bash-completion/bash_completion
|
. /usr/share/bash-completion/bash_completion
|
||||||
@@ -202,44 +216,7 @@ if ! shopt -oq posix; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -t 0 ]]; then
|
## Add path for TOOLBOX if any
|
||||||
stty -ixon # prevent CTRL+S to freeze in vim, CTRL+Q to unfreeze!
|
[[ -d "/TOOLBOX" ]] && PATH=$PATH:/TOOLBOX || true
|
||||||
stty kill undef # release CTRL+U to readline processing => undo
|
# Add path to any tools folder in /opt/miaou-*
|
||||||
fi
|
for i in {/opt,$HOME}/miaou-*/tools; do [[ -d "$i" ]] && PATH=$PATH:$i; done || true
|
||||||
|
|
||||||
PROMPT_COMMAND='__prompt_command' # Func to gen PS1 after CMDs
|
|
||||||
|
|
||||||
# ALIASES
|
|
||||||
|
|
||||||
alias sudo='sudo ' # smart sudo alias trick!
|
|
||||||
|
|
||||||
alias ls='ls $COLOR_OPTIONS -h'
|
|
||||||
alias ll='ls $COLOR_OPTIONS -lh'
|
|
||||||
alias la='ls $COLOR_OPTIONS -lah'
|
|
||||||
alias ltr='ls $COLOR_OPTIONS -ltrh'
|
|
||||||
alias l=ls
|
|
||||||
|
|
||||||
alias cd..='cd ..'
|
|
||||||
alias ..=cd..
|
|
||||||
|
|
||||||
alias grep='grep $COLOR_OPTIONS '
|
|
||||||
alias fgrep='fgrep $COLOR_OPTIONS '
|
|
||||||
alias egrep='egrep $COLOR_OPTIONS '
|
|
||||||
|
|
||||||
alias transfer_cp='rsync -a --info=progress2 --no-inc-recursive'
|
|
||||||
|
|
||||||
# shellcheck disable=SC2142
|
|
||||||
alias ssu="ss -ntelp | perl -pne 'if(/uid:(\\d+)/){@a=getpwuid(\$1);s/uid:(\\d+)/user:\$a[0]/}' | awk '{ print \$4 \"\\t\" \$7 \"\\t\" \$6 }'"
|
|
||||||
|
|
||||||
# shellcheck disable=SC2142
|
|
||||||
alias ssu4="ss -ntel4p | perl -pne 'if(/uid:(\\d+)/){@a=getpwuid(\$1);s/uid:(\\d+)/user:\$a[0]/}' | awk '{ print \$4 \"\\t\\t\" \$7 \"\\t\\t\" \$6 }'"
|
|
||||||
|
|
||||||
# Alias definitions.
|
|
||||||
if [[ -f "/etc/bash.aliases" ]]; then
|
|
||||||
# shellcheck disable=SC1091
|
|
||||||
source "/etc/bash.aliases"
|
|
||||||
fi
|
|
||||||
if [[ -f "$HOME/.bash_aliases" ]]; then
|
|
||||||
# shellcheck disable=SC1091
|
|
||||||
source "$HOME/.bash_aliases"
|
|
||||||
fi
|
|
||||||
|
|||||||
+7
-4
@@ -96,13 +96,16 @@ function _pluralize_simple {
|
|||||||
|
|
||||||
function fetch_distro_like {
|
function fetch_distro_like {
|
||||||
if grep -qE '^ID=debian|^ID_LIKE=debian' /etc/os-release; then
|
if grep -qE '^ID=debian|^ID_LIKE=debian' /etc/os-release; then
|
||||||
echo debian
|
DISTRO_LIKE=debian
|
||||||
elif grep -qE '^ID=arch|^ID_LIKE=arch' /etc/os-release; then
|
elif grep -qE '^ID=arch|^ID_LIKE=arch' /etc/os-release; then
|
||||||
echo arch
|
DISTRO_LIKE=arch
|
||||||
else
|
else
|
||||||
echo -n 'unsupported distro: '
|
local unsupported_distro
|
||||||
grep ^ID= /etc/os-release | cut -d= -f2
|
unsupported_distro=$(grep ^ID= /etc/os-release | cut -d= -f2)
|
||||||
|
>&2 echo -n "MIAOU ERROR: unsupported distro: $unsupported_distro"
|
||||||
|
return 99
|
||||||
fi
|
fi
|
||||||
|
export DISTRO_LIKE
|
||||||
}
|
}
|
||||||
|
|
||||||
function _confirm_destructive {
|
function _confirm_destructive {
|
||||||
|
|||||||
+11
-1
@@ -219,12 +219,19 @@ function launch_hooks {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function apply_mode {
|
||||||
|
if [[ "$MIAOU_BASH_MODE" == hosted ]]; then
|
||||||
|
sudo mkdir /var/lib/miaou-bash -p
|
||||||
|
sudo cp "$MIAOU_BASH_DIR"/.semver_git_tag /var/lib/miaou-bash/semver_current
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
||||||
source "$MIAOU_BASH_DIR"/lib/functions.bash
|
source "$MIAOU_BASH_DIR"/lib/functions.bash
|
||||||
|
|
||||||
assert_root
|
assert_root
|
||||||
DISTRO_LIKE=$(fetch_distro_like)
|
fetch_distro_like
|
||||||
install_required_packages
|
install_required_packages
|
||||||
fix_users_bashrc
|
fix_users_bashrc
|
||||||
fix_terminfo_ghostty
|
fix_terminfo_ghostty
|
||||||
@@ -232,4 +239,7 @@ ghostty_global_config
|
|||||||
link_config_files
|
link_config_files
|
||||||
link_miaou_bash
|
link_miaou_bash
|
||||||
create_sudoers
|
create_sudoers
|
||||||
|
|
||||||
|
fetch_mode
|
||||||
|
apply_mode
|
||||||
launch_hooks
|
launch_hooks
|
||||||
|
|||||||
Reference in New Issue
Block a user