apply normal bash setup to archboot environment with /root/.bash* files

This commit is contained in:
Tobias Powalowski 2023-02-01 14:46:33 +01:00
parent a435b8447b
commit 7e1357144f
6 changed files with 43 additions and 71 deletions

View file

@ -231,30 +231,12 @@ _auto_nano_syntax() {
_auto_bash(){
if [[ ! -f ${_DESTDIR}/etc/profile.d/custom-bash-prompt.sh ]]; then
_dialog --infobox "Enable custom bash prompt on installed system..." 3 70
! grep -qw 'custom-bash-prompt.sh' "${_DESTDIR}/etc/skel/.bashrc" &&\
echo ". /etc/profile.d/custom-bash-prompt.sh" >> "${_DESTDIR}/etc/skel/.bashrc"
! grep -qw 'custom-bash-prompt.sh' "${_DESTDIR}/root/.bashrc" &&\
echo ". /etc/profile.d/custom-bash-prompt.sh" >> "${_DESTDIR}/root/.bashrc"
cp /etc/profile.d/custom-bash-prompt.sh "${_DESTDIR}"/etc/profile.d/
sleep 2
fi
if [[ ! -f ${_DESTDIR}/etc/profile.d/custom-bash-aliases.sh ]]; then
_dialog --infobox "Enable custom bash aliases on installed system..." 3 70
! grep -qw 'custom-bash-aliases.sh' "${_DESTDIR}/etc/skel/.bashrc" &&\
echo ". /etc/profile.d/custom-bash-aliases.sh" >> "${_DESTDIR}/etc/skel/.bashrc"
! grep -qw 'custom-bash-aliases.sh' "${_DESTDIR}/root/.bashrc" &&\
echo ". /etc/profile.d/custom-bash-aliases.sh" >> "${_DESTDIR}/root/.bashrc"
cp /etc/profile.d/custom-bash-aliases.sh "${_DESTDIR}"/etc/profile.d/
sleep 2
fi
if [[ ! -f ${_DESTDIR}/etc/profile.d/custom-bash-history.sh ]]; then
_dialog --infobox "Enable custom bash history on installed system..." 3 70
! grep -qw 'custom-bash-history.sh' "${_DESTDIR}/etc/skel/.bashrc" &&\
echo ". /etc/profile.d/custom-bash-history.sh" >> "${_DESTDIR}/etc/skel/.bashrc"
! grep -qw 'custom-bash-history.sh' "${_DESTDIR}/root/.bashrc" &&\
echo ". /etc/profile.d/custom-bash-history.sh" >> "${_DESTDIR}/root/.bashrc"
cp /etc/profile.d/custom-bash-history.sh "${_DESTDIR}"/etc/profile.d/
_dialog --infobox "Enable custom bash options on installed system..." 3 70
! grep -qw 'custom-bash-options.sh' "${_DESTDIR}/etc/skel/.bashrc" &&\
echo ". /etc/profile.d/custom-bash-options.sh" >> "${_DESTDIR}/etc/skel/.bashrc"
! grep -qw 'custom-bash-options.sh' "${_DESTDIR}/root/.bashrc" &&\
echo ". /etc/profile.d/custom-bash-options.sh" >> "${_DESTDIR}/root/.bashrc"
cp /etc/profile.d/custom-bash-options.sh "${_DESTDIR}"/etc/profile.d/
sleep 2
fi
}

View file

@ -8,7 +8,7 @@ build ()
add_checked_modules 'virtio|zram|btrfs|libcrc32|zstd|sg|pkcs8_key_parser'
### setting up base structure
map add_dir "/mnt" "/install" "/var/log" "/home" "/var/tmp"
map add_dir "/root /mnt" "/install" "/var/log" "/home" "/var/tmp"
add_symlink /var/run ../run
add_symlink /var/lock ../run/lock
@ -50,7 +50,7 @@ build ()
map add_file "/etc/profile" "/etc/shells"
basic_config="os-release hostname modprobe.d/modprobe.conf"
for i in $basic_config; do
add_file "/usr/share/archboot/base/etc/$i" "/etc/$i"
add_file "/usr/share/archboot/base/etc/${i}" "/etc/${i}"
done
### add bash configuration
@ -60,14 +60,17 @@ build ()
# use color bash prompt
# unlock and delete root password, if not set by user!
# use color grep and ls output
for i in custom-bash-prompt.sh archboot-reset-root-password.sh \
custom-bash-aliases.sh custom-bash-history.sh; do
add_file "/usr/share/archboot/base/etc/profile.d/$i" "/etc/profile.d/$i"
for i in custom-bash-options.sh archboot-reset-root-password.sh; do
add_file "/usr/share/archboot/base/etc/profile.d/${i}" "/etc/profile.d/${i}"
done
echo ". /etc/profile.d/custom-bash-prompt.sh" >> "$BUILDROOT/etc/bash.bashrc"
echo ". /etc/profile.d/custom-bash-aliases.sh" >> "$BUILDROOT/etc/bash.bashrc"
echo ". /etc/profile.d/custom-bash-history.sh" >> "$BUILDROOT/etc/bash.bashrc"
# add default bash setup
for i in .bashrc .bash_profile .bash_logout; do
add_file "/etc/skel/${i}" "$BUILDROOT/root/${i}"
done
# add custom bash options
echo ". /etc/profile.d/custom-bash-options.sh" >> "$BUILDROOT/root/.bashrc"
# add /etc/skel
add_full_dir /etc/skel
### add kmod related config file(s)
add_file "/usr/lib/depmod.d/search.conf"
@ -125,7 +128,7 @@ build ()
map add_file "/usr/lib/libnss_compat.so.2" "/usr/lib/libnsl.so.1"
## fix for systemd >=245 set default.target
# remove initrd-release to allow normal systemd boot without initrd.target
rm -f /tmp/*/root/etc/initrd-release
rm -f $BUILDROOT/etc/initrd-release
add_symlink "/etc/systemd/system/default.target" "/usr/lib/systemd/system/multi-user.target"
# mask systemd-gpt-auto-generator, errors out on initramfs usage
add_symlink "/etc/systemd/system-generators/systemd-gpt-auto-generator" "/dev/null"

View file

@ -1,14 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-only
# created by Tobias Powalowski <tpowa@archlinux.org>
# check on bash
[[ -n "${BASH_VERSION:-}" ]] || return
# Not an interactive shell?
[[ $- == *i* ]] || return
# color output
alias ls='ls --color=auto'
alias grep='grep --color=auto'
# set neovim as default editor
alias vi='nvim'
alias vim='nvim'
alias edit='nvim'

View file

@ -1,9 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-only
# created by Tobias Powalowski <tpowa@archlinux.org>
# check on bash
[[ -n "${BASH_VERSION:-}" ]] || return
# Not an interactive shell?
[[ $- == *i* ]] || return
# keep history clean from dups and spaces
HISTCONTROL="erasedups:ignorespace"

View file

@ -0,0 +1,24 @@
# SPDX-License-Identifier: GPL-2.0-only
# created by Tobias Powalowski <tpowa@archlinux.org>
# check on bash
[[ -n "${BASH_VERSION:-}" ]] || return
# Not an interactive shell?
[[ $- == *i* ]] || return
# keep history clean from dups and spaces
[[ $- == *i* ]] || return
if [[ "${UID}" == 0 ]]; then
# red for root user, host green, print full working dir
PS1='[\e[1;31m\u\e[m@\e[1;32m\h\e[m \w]\$ '
else
# blue for normal user,host green, print full working dir
PS1='[\e[1;34m\u\e[m@\e[1;32m\h\e[m \w]\$ '
fi
HISTCONTROL="erasedups:ignorespace"
# color output
alias grep='grep --color=auto'
# if installed set neovim as default editor
if command -v nvim 2&1>/dev/null; then
alias vi='nvim'
alias vim='nvim'
alias edit='nvim'
fi

View file

@ -1,14 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-only
# created by Tobias Powalowski <tpowa@archlinux.org>
# check on bash
[[ -n "${BASH_VERSION:-}" ]] || return
# Not an interactive shell?
[[ $- == *i* ]] || return
if [[ "${UID}" == 0 ]]; then
# red for root user
PS1='[\e[1;31m\u\e[m@\e[1;32m\h\e[m \w]\$ '
else
# blue for normal user
PS1='[\e[1;34m\u\e[m@\e[1;32m\h\e[m \w]\$ '
fi