more comments in tux colors source linux-chroot shell scripts
This commit is contained in:
1 parent
30cae3814c
commit
b61f61d07e
4 files changed
+70
-84
No files matched your search
+43
-44
@@ -1,65 +1,64 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
#------ cli variables -------------------------------------------------------------------------------------------------------------------------------
|
||||||
PATH=$1
|
PATH=$1 # path for new root
|
||||||
SHELL=$2
|
SHELL=$2 # shell to use in chroot
|
||||||
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
#------- Check root func -------------------
|
#------- Check root func ----------------------------------------------------------------------------------------------------------------------------
|
||||||
check_root() {
|
check_root() {
|
||||||
if [ $(/usr/bin/id -u) -ne 0 ]; then
|
if [ $(/usr/bin/id -u) -ne 0 ]; then # cheking root priveleges
|
||||||
printf "** You must be root\n"
|
printf "** You must be root\n"
|
||||||
exit 1
|
exit 1 # exit with exit code 1 error
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
#-------------------------------------------
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#----------- checking or create dirs ----------------------------------------------------------------------------------------------------------------
|
||||||
#----------- checking or create dirs -------
|
|
||||||
check_or_mkdir() {
|
check_or_mkdir() {
|
||||||
[ ! -d $PATH/dev ] && mkdir -pv $PATH/dev
|
[ ! -d $PATH/dev ] && mkdir -pv $PATH/dev # if directory not exists then mkdir
|
||||||
[ ! -d $PATH/proc ] && mkdir -pv $PATH/proc
|
[ ! -d $PATH/proc ] && mkdir -pv $PATH/proc # if directory not exists then mkdir
|
||||||
[ ! -d $PATH/sys ] && mkdir -pv $PATH/sys
|
[ ! -d $PATH/sys ] && mkdir -pv $PATH/sys # if directory not exists then mkdir
|
||||||
[ ! -d $PATH/run ] && mkdir -pv $PATH/run
|
[ ! -d $PATH/run ] && mkdir -pv $PATH/run # if directory not exists then mkdir
|
||||||
}
|
}
|
||||||
#-------------------------------------------
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#-------- mount virtual filesystems -----------------------------------------------------------------------------------------------------------------
|
||||||
#-------- mount virtual filesystems --------
|
|
||||||
mount_virtual() {
|
mount_virtual() {
|
||||||
/usr/bin/mount -v --bind /dev $PATH/dev
|
/usr/bin/mount -v --bind /dev $PATH/dev # mount bind devtmpfs to /dev
|
||||||
/usr/bin/mount -vt devpts devpts -o gid=5,mode=0620 $PATH/dev/pts
|
/usr/bin/mount -vt devpts devpts -o gid=5,mode=0620 $PATH/dev/pts # mount devpts to /dev/pts
|
||||||
/usr/bin/mount -vt proc proc $PATH/proc
|
/usr/bin/mount -vt proc proc $PATH/proc # mount procfs to /proc
|
||||||
/usr/bin/mount -vt sysfs sysfs $PATH/sys
|
/usr/bin/mount -vt sysfs sysfs $PATH/sys # mount sysfs to /sys
|
||||||
/usr/bin/mount -vt tmpfs tmpfs $PATH/run
|
/usr/bin/mount -vt tmpfs tmpfs $PATH/run # mount tmpfs to /run
|
||||||
if [ -h $PATH/dev/shm ]; then
|
if [ -h $PATH/dev/shm ]; then # check
|
||||||
/usr/bin/install -v -d -m 1777 $PATH$(/usr/bin/realpath /dev/shm)
|
/usr/bin/install -v -d -m 1777 $PATH$(/usr/bin/realpath /dev/shm) # install directories
|
||||||
else
|
else
|
||||||
/usr/bin/mount -vt tmpfs -o nosuid,nodev tmpfs $PATH/dev/shm
|
/usr/bin/mount -vt tmpfs -o nosuid,nodev tmpfs $PATH/dev/shm # mount tmpfs to /dev/shm
|
||||||
fi
|
fi
|
||||||
/usr/bin/cp -v /etc/resolv.conf $PATH/etc/resolv.conf
|
/usr/bin/cp -v /etc/resolv.conf $PATH/etc/resolv.conf # copy resolv.conf file to chroot
|
||||||
}
|
}
|
||||||
#-------------------------------------------
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#------ umount virtual filesystems ------------------------------------------------------------------------------------------------------------------
|
||||||
#------ umount virtual filesystems ---------
|
|
||||||
umount_virtual() {
|
umount_virtual() {
|
||||||
/usr/bin/mountpoint -q $PATH/dev/shm && /usr/bin/umount $PATH/dev/shm
|
/usr/bin/mountpoint -q $PATH/dev/shm && /usr/bin/umount $PATH/dev/shm # umount /dev/shm
|
||||||
/usr/bin/umount $PATH/dev/pts
|
/usr/bin/umount $PATH/dev/pts # umount /dev/pts
|
||||||
/usr/bin/umount $PATH/{sys,proc,run,dev}
|
/usr/bin/umount $PATH/{sys,proc,run,dev} # umount /sys,/proc,/run,/dev
|
||||||
}
|
}
|
||||||
#-------------------------------------------
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#------ get shell path func -------------------------------------------------------------------------------------------------------------------------
|
||||||
#------ get shell path func ----------------
|
|
||||||
get_shell() {
|
get_shell() {
|
||||||
if [[ "$SHELL" != "" ]]; then
|
if [[ "$SHELL" != "" ]]; then # if shell is not empty
|
||||||
echo $SHELL
|
echo $SHELL # return shell
|
||||||
fi
|
fi
|
||||||
echo "/bin/sh"
|
echo "/bin/sh" # if shell is empty return /bin/sh
|
||||||
}
|
}
|
||||||
#-------------------------------------------
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#------- main ---------------------------------------------------------------------------------------------------------------------------------------
|
||||||
check_root
|
check_root # check root priveleges
|
||||||
check_or_mkdir
|
check_or_mkdir # check directories for mount virtual filesystems in chroot
|
||||||
mount_virtual
|
mount_virtual # mount virtual filesystems to chroot
|
||||||
|
#---- do chroot in chroot path using shell ----------------------------------------------------------------------------------------------------------
|
||||||
/usr/bin/chroot \
|
/usr/bin/chroot \
|
||||||
$PATH \
|
$PATH \
|
||||||
/usr/bin/env -i \
|
/usr/bin/env -i \
|
||||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin \
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin \
|
||||||
$(get_shell)
|
$(get_shell)
|
||||||
umount_virtual
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
umount_virtual # umount virtual filesystems from chroot
|
||||||
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
+9
-7
@@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
#-------- function to print little tux ascii image ----------------------------------------------------------
|
||||||
print_little_tux() {
|
print_little_tux() {
|
||||||
echo " .--."
|
echo " .--."
|
||||||
echo " |o_o |"
|
echo " |o_o |"
|
||||||
@@ -9,7 +9,8 @@ print_little_tux() {
|
|||||||
echo "/'\_ _/\`\ "
|
echo "/'\_ _/\`\ "
|
||||||
echo "\___)=(___/"
|
echo "\___)=(___/"
|
||||||
}
|
}
|
||||||
|
#------------------------------------------------------------------------------------------------------------
|
||||||
|
#------------- function to print big tux ascii image --------------------------------------------------------
|
||||||
print_big_tux() {
|
print_big_tux() {
|
||||||
echo " .88888888:."
|
echo " .88888888:."
|
||||||
echo " 88888888.88888."
|
echo " 88888888.88888."
|
||||||
@@ -38,16 +39,17 @@ print_big_tux() {
|
|||||||
echo " \`'.:::::::::::88888888888.88:::::::::'"
|
echo " \`'.:::::::::::88888888888.88:::::::::'"
|
||||||
echo " \`':::_:' -- '' -'-' \`':_::::'\`"
|
echo " \`':::_:' -- '' -'-' \`':_::::'\`"
|
||||||
}
|
}
|
||||||
|
#------------------------------------------------------------------------------------------------------------
|
||||||
|
#------- main -----------------------------------------------------------------------------------------------
|
||||||
case "$1" in
|
case "$1" in
|
||||||
big|b|-b)
|
big|b|-b)
|
||||||
print_big_tux
|
print_big_tux # print big tux image
|
||||||
;;
|
;;
|
||||||
little|l|-l)
|
little|l|-l)
|
||||||
print_little_tux
|
print_little_tux # print little tux image
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
print_little_tux
|
print_little_tux # default is print little tux image
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
#------------------------------------------------------------------------------------------------------------
|
||||||
+2
-10
@@ -1,9 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
#--- reset colors ---------------
|
||||||
#--- reset colors ---
|
|
||||||
RESET="\033[0m"
|
RESET="\033[0m"
|
||||||
#--------------------
|
#--------------------------------
|
||||||
|
|
||||||
#--------- regularcolrs ---------
|
#--------- regularcolrs ---------
|
||||||
GREEN="\033[0;32m" #GREEN
|
GREEN="\033[0;32m" #GREEN
|
||||||
BLUE="\033[0;34m" #BLUE
|
BLUE="\033[0;34m" #BLUE
|
||||||
@@ -14,7 +12,6 @@ PURPLE="\033[0;35m" #PURPLE
|
|||||||
CYAN="\033[0;36m" #CYAN
|
CYAN="\033[0;36m" #CYAN
|
||||||
WHITE="\033[0;37m" #WHITE
|
WHITE="\033[0;37m" #WHITE
|
||||||
#--------------------------------
|
#--------------------------------
|
||||||
|
|
||||||
#-------- bold ------------------
|
#-------- bold ------------------
|
||||||
BBLACK="\033[1;30m" #BLACK
|
BBLACK="\033[1;30m" #BLACK
|
||||||
BRED="\033[1;31m" #RED
|
BRED="\033[1;31m" #RED
|
||||||
@@ -25,7 +22,6 @@ BPURPLE="\033[1;35m" #PURPLE
|
|||||||
BCYAN="\033[1;36m" #CYAN
|
BCYAN="\033[1;36m" #CYAN
|
||||||
BWHITE="\033[1;37m" #WHITE
|
BWHITE="\033[1;37m" #WHITE
|
||||||
#--------------------------------
|
#--------------------------------
|
||||||
|
|
||||||
#-------- Underline -------------
|
#-------- Underline -------------
|
||||||
UBLACK="\033[4;30m" #BLACK
|
UBLACK="\033[4;30m" #BLACK
|
||||||
URED="\033[4;31m" #RED
|
URED="\033[4;31m" #RED
|
||||||
@@ -36,7 +32,6 @@ UPURPLE="\033[4;35m" #PURPLE
|
|||||||
UCYAN="\033[4;36m" #CYAN
|
UCYAN="\033[4;36m" #CYAN
|
||||||
UWHITE="\033[4;37m" #WHITE
|
UWHITE="\033[4;37m" #WHITE
|
||||||
#--------------------------------
|
#--------------------------------
|
||||||
|
|
||||||
#--------- Background -----------
|
#--------- Background -----------
|
||||||
ON_BLACK="\033[40m" #BLACK
|
ON_BLACK="\033[40m" #BLACK
|
||||||
ON_RED="\033[41m" #RED
|
ON_RED="\033[41m" #RED
|
||||||
@@ -47,7 +42,6 @@ ON_PURPLE="\033[45m" #PURPLE
|
|||||||
ON_CYAN="\033[46m" #CYAN
|
ON_CYAN="\033[46m" #CYAN
|
||||||
ON_WHITE="\033[47m" #WHITE
|
ON_WHITE="\033[47m" #WHITE
|
||||||
#--------------------------------
|
#--------------------------------
|
||||||
|
|
||||||
#------ HighIntensity -----------
|
#------ HighIntensity -----------
|
||||||
IBLACK="\033[0;90m" #BLACK
|
IBLACK="\033[0;90m" #BLACK
|
||||||
IRED="\033[0;91m" #RED
|
IRED="\033[0;91m" #RED
|
||||||
@@ -58,7 +52,6 @@ IPURPLE="\033[0;95m" #PURPLE
|
|||||||
ICYAN="\033[0;96m" #CYAN
|
ICYAN="\033[0;96m" #CYAN
|
||||||
IWHITE="\033[0;97m" #WHITE
|
IWHITE="\033[0;97m" #WHITE
|
||||||
#--------------------------------
|
#--------------------------------
|
||||||
|
|
||||||
#------ BoldHighIntensity -------
|
#------ BoldHighIntensity -------
|
||||||
BIBLACK="\033[1;90m" #BLACK
|
BIBLACK="\033[1;90m" #BLACK
|
||||||
BIRED="\033[1;91m" #RED
|
BIRED="\033[1;91m" #RED
|
||||||
@@ -69,7 +62,6 @@ BIPURPLE="\033[1;95m" #PURPLE
|
|||||||
BICYAN="\033[1;96m" #CYAN
|
BICYAN="\033[1;96m" #CYAN
|
||||||
BIWHITE="\033[1;97m" #WHITE
|
BIWHITE="\033[1;97m" #WHITE
|
||||||
#--------------------------------
|
#--------------------------------
|
||||||
|
|
||||||
#--- HighIntensitybackgrounds ---
|
#--- HighIntensitybackgrounds ---
|
||||||
ON_IBLACK="\033[0;100m" #BLACK
|
ON_IBLACK="\033[0;100m" #BLACK
|
||||||
ON_IRED="\033[0;101m" #RED
|
ON_IRED="\033[0;101m" #RED
|
||||||
|
|||||||
+16
-23
@@ -1,14 +1,11 @@
|
|||||||
|
#--- path -------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
#--- path ---
|
|
||||||
export PATH=$PATH:~/dotfiles/bin:~/dotfiles/hypr/bin:~/dotfiles/dwm/bin/:~/.cargo/bin
|
export PATH=$PATH:~/dotfiles/bin:~/dotfiles/hypr/bin:~/dotfiles/dwm/bin/:~/.cargo/bin
|
||||||
export GTK2_RC_FILES=~/.config/gtk-2.0/gtkrc # gtk2 theme
|
export GTK2_RC_FILES=~/.config/gtk-2.0/gtkrc # gtk2 theme
|
||||||
#------------
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#--- colors -----------------------------------------------------------------------------------------------------------------------------------------
|
||||||
#--- colors ---
|
|
||||||
. ~/dotfiles/shell/colors.sh # include bash colors
|
. ~/dotfiles/shell/colors.sh # include bash colors
|
||||||
#--------------
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#--- sys --------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
#--- sys ---
|
|
||||||
alias psa='busybox ps' # show all processes
|
alias psa='busybox ps' # show all processes
|
||||||
alias c='clear' # clear terminal screen
|
alias c='clear' # clear terminal screen
|
||||||
alias e='echo' # print in terminal
|
alias e='echo' # print in terminal
|
||||||
@@ -18,7 +15,7 @@ alias ff='fastfetch' # system data
|
|||||||
alias una='uname -a' # system name
|
alias una='uname -a' # system name
|
||||||
alias ifcnf='ifconfig' # ifconfig
|
alias ifcnf='ifconfig' # ifconfig
|
||||||
alias sudo='sudo -p "Give me your fucking password: "' # sudo prompt alias
|
alias sudo='sudo -p "Give me your fucking password: "' # sudo prompt alias
|
||||||
#--- pacman ---
|
#--- pacman -----------------------------------------------------------------------------------------------------------------------------------------
|
||||||
alias p='sudo pacman' # pacman
|
alias p='sudo pacman' # pacman
|
||||||
alias psy='sudo pacman -Sy' # update repositories
|
alias psy='sudo pacman -Sy' # update repositories
|
||||||
alias psyu='sudo pacman -Syu' # upgrade system
|
alias psyu='sudo pacman -Syu' # upgrade system
|
||||||
@@ -29,14 +26,14 @@ alias pq='sudo pacman -Q' # list installed packages
|
|||||||
alias pql='sudo pacman -Ql' # list files in packages
|
alias pql='sudo pacman -Ql' # list files in packages
|
||||||
alias prm='sudo pacman -R' # delete pacman package
|
alias prm='sudo pacman -R' # delete pacman package
|
||||||
alias prns='sudo pacman -Rns' # delete pacman package with all dependencies
|
alias prns='sudo pacman -Rns' # delete pacman package with all dependencies
|
||||||
#--------------
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
#--- apt ---
|
#--- apt --------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
alias aptu='sudo apt update' # update apt repositories
|
alias aptu='sudo apt update' # update apt repositories
|
||||||
alias apti='sudo apt install -y' # install apt package
|
alias apti='sudo apt install -y' # install apt package
|
||||||
alias aptui='sudo apt upgrade -y' # upgrade apt packages
|
alias aptui='sudo apt upgrade -y' # upgrade apt packages
|
||||||
alias aptrm='sudo apt remove -y' # remove apt package
|
alias aptrm='sudo apt remove -y' # remove apt package
|
||||||
alias aptautorm='sudo apt autoremove -y' # remove apt package with dependencies
|
alias aptautorm='sudo apt autoremove -y' # remove apt package with dependencies
|
||||||
#-----------
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
alias ipr='ip route' # show routes
|
alias ipr='ip route' # show routes
|
||||||
alias ipa='ip addr' # show addresses
|
alias ipa='ip addr' # show addresses
|
||||||
alias ipl='ip link' # show links
|
alias ipl='ip link' # show links
|
||||||
@@ -46,9 +43,8 @@ alias sctlst='systemctl status' # service status
|
|||||||
alias sctlp='systemctl stop' # service stop
|
alias sctlp='systemctl stop' # service stop
|
||||||
alias H='Hyprland' # start Hyprland
|
alias H='Hyprland' # start Hyprland
|
||||||
alias sx='startx' # startx - start xorg
|
alias sx='startx' # startx - start xorg
|
||||||
#-----------
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#--- git --------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
#--- git ---
|
|
||||||
alias g='git' # git
|
alias g='git' # git
|
||||||
alias ga='git add' # add unstaged changes
|
alias ga='git add' # add unstaged changes
|
||||||
alias gaa='git add --all' # add all unstaged changes
|
alias gaa='git add --all' # add all unstaged changes
|
||||||
@@ -77,9 +73,8 @@ alias grrm='git remote remove' # remove remote repositor
|
|||||||
alias gstall='git stash --all' # stash all in repository
|
alias gstall='git stash --all' # stash all in repository
|
||||||
alias gstc='git stash clear' # clear git stash
|
alias gstc='git stash clear' # clear git stash
|
||||||
alias gst='git status' # status repository
|
alias gst='git status' # status repository
|
||||||
#-----------
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#--- docker -----------------------------------------------------------------------------------------------------------------------------------------
|
||||||
#--- docker ---
|
|
||||||
alias dpa='docker ps -a' # list all docker containers
|
alias dpa='docker ps -a' # list all docker containers
|
||||||
alias dp='docker ps' # list active docker containers
|
alias dp='docker ps' # list active docker containers
|
||||||
alias dia='docker images -a' # list all docker images
|
alias dia='docker images -a' # list all docker images
|
||||||
@@ -91,13 +86,11 @@ alias ds='docker start' # start docker container
|
|||||||
alias dst='docker stop' # stop docker container
|
alias dst='docker stop' # stop docker container
|
||||||
alias dspa='docker system prune -a' # delete all docker data
|
alias dspa='docker system prune -a' # delete all docker data
|
||||||
alias dcaq='docker ps -aq' # stop all containers
|
alias dcaq='docker ps -aq' # stop all containers
|
||||||
#--------------
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
#--- bluetooth --------------------------------------------------------------------------------------------------------------------------------------
|
||||||
#--- bluetooth ---
|
|
||||||
alias bctl="bluetoothctl" # bluetoothctl
|
alias bctl="bluetoothctl" # bluetoothctl
|
||||||
alias bctlc="bluetoothctl connect" # connect bluetooth device
|
alias bctlc="bluetoothctl connect" # connect bluetooth device
|
||||||
alias bctld="bluetoothctl disconnect" # disconnect bluetooth device
|
alias bctld="bluetoothctl disconnect" # disconnect bluetooth device
|
||||||
alias bctll="bluetoothctl devices" # show bluetooth devices
|
alias bctll="bluetoothctl devices" # show bluetooth devices
|
||||||
alias bctls="bluetoothctl scan on" # scan bluetooth devices
|
alias bctls="bluetoothctl scan on" # scan bluetooth devices
|
||||||
#-----------------
|
#----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
Reference in new issue
Block a user