Change aliases for functions

This commit is contained in:
Augusto Gunsch 2021-08-10 11:10:24 -03:00
parent fc51f4b703
commit dd769c9438
No known key found for this signature in database
GPG Key ID: F7EEFE29825C72DC
1 changed files with 26 additions and 20 deletions

View File

@ -1,5 +1,4 @@
#!/bin/sh #!/bin/sh
shopt -s expand_aliases
set -e set -e
qpushd() { qpushd() {
@ -70,11 +69,18 @@ testif ls /sys/firmware/efi/efivars
readonly DISTRO readonly DISTRO
readonly INIT_SYS readonly INIT_SYS
readonly UEFI readonly UEFI
if [ "$DISTRO" = "arch" ]; then
alias chroot="arch-chroot" right_chroot() {
alias fstabgen="genfstab" [ "$DISTRO" = "arch" ] && arch-chroot $@ || chroot $@
alias basestrap="pacstrap" }
fi
right_fstabgen() {
[ "$DISTRO" = "arch" ] && genfstab $@ || fstabgen $@
}
right_basestrap() {
[ "$DISTRO" = "arch" ] && pacstrap $@ || basestrap $@
}
print_phase() { print_phase() {
echo -e "${BOLD}${YELLOW}[$CUR_PHASE/$MAX_PHASE] $1 phase${NC}${NORM}" echo -e "${BOLD}${YELLOW}[$CUR_PHASE/$MAX_PHASE] $1 phase${NC}${NORM}"
@ -171,13 +177,13 @@ partition() {
install_base() { install_base() {
print_phase "System installation" print_phase "System installation"
echo -n "Installing base system, kernel, bootloader and vi..." echo -n "Installing base system, kernel, bootloader and vi..."
quiet basestrap /mnt base base-devel linux linux-firmware grub vi quiet right_basestrap /mnt base base-devel linux linux-firmware grub vi
echo "done" echo "done"
if [ "$DISTRO" = "artix" ]; then if [ "$DISTRO" = "artix" ]; then
if [ "$INIT_SYS" = "openrc-init" ]; then if [ "$INIT_SYS" = "openrc-init" ]; then
echo -n "Installing openrc..." echo -n "Installing openrc..."
quiet basestrap /mnt openrc elogind-openrc quiet right_basestrap /mnt openrc elogind-openrc
echo "done" echo "done"
else else
echo echo
@ -189,7 +195,7 @@ install_base() {
fi fi
echo -n "Generating fstab..." echo -n "Generating fstab..."
fstabgen -U /mnt >> /mnt/etc/fstab right_fstabgen -U /mnt >> /mnt/etc/fstab
echo "done" echo "done"
} }
@ -198,7 +204,7 @@ set_timezone() {
qpushd /mnt/usr/share/zoneinfo qpushd /mnt/usr/share/zoneinfo
ln -sf "/mnt/usr/share/zoneinfo/$(fzf --layout=reverse --height=20)" /mnt/etc/localtime ln -sf "/mnt/usr/share/zoneinfo/$(fzf --layout=reverse --height=20)" /mnt/etc/localtime
qpopd qpopd
quiet chroot /mnt hwclock --systohc quiet right_chroot /mnt hwclock --systohc
} }
set_locale() { set_locale() {
@ -208,7 +214,7 @@ set_locale() {
echo -n "Configuring locale..." echo -n "Configuring locale..."
cat /mnt/etc/locale.gen | sed "s/^#$LOCALE/$LOCALE/" > /tmp/locale.gen cat /mnt/etc/locale.gen | sed "s/^#$LOCALE/$LOCALE/" > /tmp/locale.gen
mv /tmp/locale.gen /mnt/etc/locale.gen mv /tmp/locale.gen /mnt/etc/locale.gen
quiet chroot /mnt locale-gen quiet right_chroot /mnt locale-gen
echo "export LANG=\"en_US.UTF-8\"" > /mnt/etc/locale.conf echo "export LANG=\"en_US.UTF-8\"" > /mnt/etc/locale.conf
echo "export LC_COLLATE=\"C\"" >> /mnt/etc/locale.conf echo "export LC_COLLATE=\"C\"" >> /mnt/etc/locale.conf
@ -218,24 +224,24 @@ set_locale() {
setup_grub() { setup_grub() {
echo -n "Configuring boot loader..." echo -n "Configuring boot loader..."
if [ $UEFI -eq 1 ]; then if [ $UEFI -eq 1 ]; then
quiet chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot --botloader-id=grub quiet right_chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot --botloader-id=grub
else else
quiet chroot /mnt grub-install "$DRIVE_TARGET" quiet right_chroot /mnt grub-install "$DRIVE_TARGET"
fi fi
quiet chroot grub-mkconfig -o /boot/grub/grub.cfg quiet right_chroot grub-mkconfig -o /boot/grub/grub.cfg
echo "done" echo "done"
} }
setup_users() { setup_users() {
echo "Type root password:" echo "Type root password:"
chroot /mnt passwd -q right_chroot /mnt passwd -q
echo -n "Type your personal username: " echo -n "Type your personal username: "
local user local user
read user read user
chroot /mnt useradd -m "$user" right_chroot /mnt useradd -m "$user"
echo "Type your password:" echo "Type your password:"
chroot /mnt passwd -q "$user" right_chroot /mnt passwd -q "$user"
} }
setup_network() { setup_network() {
@ -252,10 +258,10 @@ setup_network() {
if [ "$DISTRO" = "artix" ]; then if [ "$DISTRO" = "artix" ]; then
if [ "$INIT_SYS" = "openrc-init" ]; then if [ "$INIT_SYS" = "openrc-init" ]; then
echo "hostname=\"$hostname\"" > /mnt/etc/conf.d/hostname echo "hostname=\"$hostname\"" > /mnt/etc/conf.d/hostname
quiet chroot pacman -S connman-openrc quiet right_chroot pacman -S connman-openrc
quiet chroot rc-update add connmand quiet right_chroot rc-update add connmand
fi fi
quiet chroot pacman -S dhcpcd wpa_supplicant quiet right_chroot pacman -S dhcpcd wpa_supplicant
fi fi
echo "done" echo "done"
} }